return get_ccode_attribute(node).const_name;
}
- public static string get_ccode_type_name (Interface iface) {
- return get_ccode_attribute(iface).type_name;
+ public static string get_ccode_type_name (ObjectTypeSymbol sym) {
+ return get_ccode_attribute (sym).type_name;
}
public static string get_ccode_type_cast_function (ObjectTypeSymbol sym) {
_type_name = ccode.get_string ("type_cname");
}
if (_type_name == null) {
- _type_name = "%sIface".printf (get_ccode_name (sym));
+ if (sym is Class) {
+ _type_name = "%sClass".printf (get_ccode_name (sym));
+ } else if (sym is Interface) {
+ _type_name = "%sIface".printf (get_ccode_name (sym));
+ } else {
+ Report.error (sym.source_reference, "`CCode.type_cname' not supported");
+ _type_name = "";
+ }
}
}
return _type_name;
return new CCodeInvalidExpression ();
}
- public virtual CCodeExpression get_signal_creation (Signal sig, TypeSymbol type) {
+ public virtual CCodeExpression get_signal_creation (Signal sig, ObjectTypeSymbol type) {
return new CCodeInvalidExpression ();
}
}
public override string get_type_struct_name () {
- return "%sClass".printf (get_ccode_name (class_reference));
+ return get_ccode_type_name (class_reference);
}
public override string get_base_init_func_name () {
user_marshal_set.add (signature);
}
- public override CCodeExpression get_signal_creation (Signal sig, TypeSymbol type) {
+ public override CCodeExpression get_signal_creation (Signal sig, ObjectTypeSymbol type) {
CCodeFunctionCall csignew;
if (sig.default_handler == null || sig.is_virtual) {
csignew = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_new"));
csignew.add_argument (new CCodeConstant ("0"));
} else if (sig.is_virtual) {
var struct_offset = new CCodeFunctionCall (new CCodeIdentifier ("G_STRUCT_OFFSET"));
- if (type is Class) {
- struct_offset.add_argument (new CCodeIdentifier ("%sClass".printf (get_ccode_name (type))));
- } else {
- // interface
- struct_offset.add_argument (new CCodeIdentifier (get_ccode_type_name ((Interface) type)));
- }
+ struct_offset.add_argument (new CCodeIdentifier (get_ccode_type_name (type)));
struct_offset.add_argument (new CCodeIdentifier (get_ccode_vfunc_name (sig.default_handler)));
csignew.add_argument (struct_offset);
} else {
}
if (is_gtypeinstance) {
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%sClass".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("%sClass".printf (get_ccode_name (cl)))));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_type_name (cl)), new CCodeVariableDeclarator (get_ccode_type_name (cl))));
var type_fun = new ClassRegisterFunction (cl);
type_fun.init_from_type (context, in_plugin, true);
bool is_fundamental = is_gtypeinstance && cl.base_class == null;
var instance_struct = new CCodeStruct ("_%s".printf (get_ccode_name (cl)));
- var type_struct = new CCodeStruct ("_%sClass".printf (get_ccode_name (cl)));
+ var type_struct = new CCodeStruct ("_%s".printf (get_ccode_type_name (cl)));
if (cl.base_class != null) {
instance_struct.add_field (get_ccode_name (cl.base_class), "parent_instance");
if (is_fundamental) {
type_struct.add_field ("GTypeClass", "parent_class");
} else {
- type_struct.add_field ("%sClass".printf (get_ccode_name (cl.base_class)), "parent_class");
+ type_struct.add_field (get_ccode_type_name (cl.base_class), "parent_class");
}
if (is_fundamental) {