/**
* Specifies the class to be registered.
*/
- public weak Class class_reference { get; set; }
+ public weak Class class_reference {
+ get {
+ return (Class) type_symbol;
+ }
+ }
/**
* Creates a new C function to register the specified class at runtime.
* @return newly created class register function
*/
public ClassRegisterFunction (Class cl) {
- class_reference = cl;
- }
-
- public override TypeSymbol get_type_declaration () {
- return class_reference;
+ base (cl);
}
public override string get_type_struct_name () {
}
}
- public override SymbolAccessibility get_accessibility () {
- return class_reference.access;
- }
-
public override string? get_gtype_value_table_init_function_name () {
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
/**
* Specifies the enum to be registered.
*/
- public weak Enum enum_reference { get; set; }
+ public weak Enum enum_reference {
+ get {
+ return (Enum) type_symbol;
+ }
+ }
/**
* Creates a new C function to register the specified enum at runtime.
* @return newly created enum register function
*/
public EnumRegisterFunction (Enum en) {
- enum_reference = en;
- }
-
- public override TypeSymbol get_type_declaration () {
- return enum_reference;
- }
-
- public override SymbolAccessibility get_accessibility () {
- return enum_reference.access;
+ base (en);
}
}
/**
* Specifies the error domain to be registered.
*/
- public weak ErrorDomain error_domain_reference { get; set; }
+ public weak ErrorDomain error_domain_reference {
+ get {
+ return (ErrorDomain) type_symbol;
+ }
+ }
/**
* Creates a new C function to register the specified error domain at runtime.
* @return newly created error domain register function
*/
public ErrorDomainRegisterFunction (ErrorDomain edomain) {
- error_domain_reference = edomain;
- }
-
- public override TypeSymbol get_type_declaration () {
- return error_domain_reference;
- }
-
- public override SymbolAccessibility get_accessibility () {
- return error_domain_reference.access;
+ base (edomain);
}
}
/**
* Specifies the interface to be registered.
*/
- public weak Interface interface_reference { get; set; }
-
- public InterfaceRegisterFunction (Interface iface) {
- interface_reference = iface;
+ public weak Interface interface_reference {
+ get {
+ return (Interface) type_symbol;
+ }
}
- public override TypeSymbol get_type_declaration () {
- return interface_reference;
+ public InterfaceRegisterFunction (Interface iface) {
+ base (iface);
}
public override string get_type_struct_name () {
return "G_TYPE_INTERFACE";
}
- public override SymbolAccessibility get_accessibility () {
- return interface_reference.access;
- }
-
public override void get_type_interface_init_statements (CodeContext context, CCodeBlock block, bool plugin) {
/* register all prerequisites */
foreach (DataType prereq_ref in interface_reference.get_prerequisites ()) {
/**
* Specifies the struct to be registered.
*/
- public weak Struct struct_reference { get; set; }
+ public weak Struct struct_reference {
+ get {
+ return (Struct) type_symbol;
+ }
+ }
/**
* Creates a new C function to register the specified struct at runtime.
* @return newly created struct register function
*/
public StructRegisterFunction (Struct st) {
- struct_reference = st;
- }
-
- public override TypeSymbol get_type_declaration () {
- return struct_reference;
- }
-
- public override SymbolAccessibility get_accessibility () {
- return struct_reference.access;
+ base (st);
}
}
* C function to register a type at runtime.
*/
public abstract class Vala.TypeRegisterFunction {
+ /**
+ * Specifies the enum to be registered.
+ */
+ public weak TypeSymbol type_symbol { get; private set; }
+
CCodeFragment source_declaration_fragment = new CCodeFragment ();
CCodeFragment declaration_fragment = new CCodeFragment ();
CCodeFragment definition_fragment = new CCodeFragment ();
+ protected TypeRegisterFunction (TypeSymbol sym) {
+ type_symbol = sym;
+ }
+
/**
* Constructs the C function from the specified type.
*/
public void init_from_type (CodeContext context, bool plugin, bool declaration_only) {
- var type_symbol = get_type_declaration ();
-
bool fundamental = false;
unowned Class? cl = type_symbol as Class;
if (cl != null && !cl.is_compact && cl.base_class == null) {
fun.modifiers = CCodeModifiers.CONST;
/* Function will not be prototyped anyway */
- if (get_accessibility () == SymbolAccessibility.PRIVATE) {
+ if (type_symbol.access == SymbolAccessibility.PRIVATE) {
// avoid C warning as this function is not always used
fun.modifiers |= CCodeModifiers.STATIC | CCodeModifiers.UNUSED;
- } else if (context.hide_internal && get_accessibility () == SymbolAccessibility.INTERNAL) {
+ } else if (context.hide_internal && type_symbol.access == SymbolAccessibility.INTERNAL) {
// avoid C warning as this function is not always used
fun.modifiers |= CCodeModifiers.INTERNAL | CCodeModifiers.UNUSED;
} else {
definition_fragment.append (fun);
}
- /**
- * Returns the data type to be registered.
- *
- * @return type to be registered
- */
- public abstract TypeSymbol get_type_declaration ();
-
/**
* Returns the name of the type struct in C code.
*
public CCodeFragment get_definition () {
return definition_fragment;
}
-
- /**
- * Returns the accessibility for this type.
- */
- public abstract SymbolAccessibility get_accessibility ();
}