gir/class.test \
gir/constant.test \
gir/delegate-alias-without-target.test \
+ gir/delegate-anonymous.test \
gir/delegate-array-length-type.test \
gir/delegate-closure-destroy-index-conflict.test \
gir/delegate-error-pos.test \
--- /dev/null
+GIR
+
+Input:
+
+<record name="Foo" c:type="TestFoo">
+ <field name="bar_callback">
+ <callback name="bar_callback" throws="1">
+ <return-value transfer-ownership="none">
+ <type name="gpointer" c:type="gpointer"/>
+ </return-value>
+ <parameters>
+ <parameter name="func"
+ transfer-ownership="none"
+ closure="1">
+ <type name="GLib.SourceFunc" c:type="GSourceFunc"/>
+ </parameter>
+ <parameter name="user_data"
+ transfer-ownership="none"
+ nullable="1"
+ allow-none="1">
+ <type name="gpointer" c:type="gpointer"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
+</record>
+
+Output:
+
+[CCode (cheader_filename = "test.h", has_type_id = false)]
+public struct Foo {
+ public weak Test.FooBarCallbackFunc bar_callback;
+}
+[CCode (cheader_filename = "test.h", has_target = false, has_typedef = false)]
+public delegate void* FooBarCallbackFunc (GLib.SourceFunc func) throws GLib.Error;
var d = ((DelegateType) field.variable_type).delegate_symbol;
parser.process_virtual_method_field (this, d, parent.gtype_struct_for);
merged = true;
+ } else if (field.variable_type is DelegateType) {
+ // anonymous delegate
+ var d = ((DelegateType) field.variable_type).delegate_symbol;
+ if (this.lookup (d.name).parent == this) {
+ d.set_attribute_bool ("CCode", "has_typedef", false);
+ if (d.has_target && !metadata.has_argument (ArgumentType.DELEGATE_TARGET)) {
+ field.set_attribute_bool ("CCode", "delegate_target", false);
+ }
+ d.name = "%s%sFunc".printf (parent.symbol.name, Symbol.lower_case_to_camel_case (d.name));
+ get_parent_namespace (this).add_delegate (d);
+ }
} else if (field.variable_type is ArrayType) {
Node array_length;
if (metadata.has_argument (ArgumentType.ARRAY_LENGTH_FIELD)) {
return sym is ObjectTypeSymbol || sym is Struct || sym is Namespace || sym is ErrorDomain || sym is Enum;
}
+ static unowned Namespace get_parent_namespace (Node node) {
+ unowned Node? n = node.parent;
+ while (n != null) {
+ if (n.symbol is Namespace) {
+ return (Namespace) n.symbol;
+ }
+ n = n.parent;
+ }
+ assert_not_reached ();
+ }
+
UnresolvedSymbol? parse_symbol_from_string (string symbol_string, SourceReference? source_reference = null) {
UnresolvedSymbol? sym = null;
foreach (unowned string s in symbol_string.split (".")) {