GNOME Bugzilla – Bug 552377
String/length parameter pairs should reference each other.
Last modified: 2015-02-07 16:54:24 UTC
Please describe the problem: Often, methods have the form void Foo (gchar *text, int text_len); The association between the two parameters needs annotation so that bindings can perform the proper encoding manipulations for the len parameter. Another, potentially more difficult to annotate, scenario is the scenario where an out string parameter has its length annotated by the return value of a function. I vaguely recall working around that one. I'll see if I can come up with a real example. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Note for this one right now the typelib format only has ArrayTypeBlob with a length index. A few things are needed for this - first we need to come up with an annotation for binding buffers and length together. For arrays this looks currently like: <array,length=3> Maybe we could use: <utf8,length=3> After that the typelib format needs to support this. One random thought is to actually compile these as GI_TYPE_TAG_ARRAY. We then take one of the reserved bits in ArrayTypeBlob to say "this is a utf8". It basically is a special kind of byte[] C-land.
There's a g_file_get_contents() annotation as if it should be working, but it seems to end up in the typelib as "array of strings" not "string" - is this theoretically working now or known still-not-done? (as a side note, g_file_get_contents() probably returns a byte array, not a utf8) <function name="file_get_contents" c:identifier="g_file_get_contents" throws="1"> <return-value transfer-ownership="none"> <type name="boolean" c:type="gboolean"/> </return-value> <parameters> <parameter name="filename" transfer-ownership="none"> <type name="utf8" c:type="gchar*"/> </parameter> <parameter name="contents" direction="out" transfer-ownership="full"> <array c:type="gchar**"> <type name="utf8"/> </array> </parameter> <parameter name="length" direction="out" transfer-ownership="full" allow-none="1"> <type name="size_t" c:type="gsize*"/> </parameter> </parameters> </function>
this has long since been fixed: we can associated array arguments with length ones.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]