*/
public string type_name { get; set; }
- /**
- * The declaration modifier.
- */
- public CCodeModifiers modifiers { get; set; }
-
private List<CCodeDeclarator> declarators = new ArrayList<CCodeDeclarator> ();
public CCodeDeclaration (string type_name) {
*/
public string name { get; set; }
- /**
- * The function modifiers.
- */
- public CCodeModifiers modifiers { get; set; }
-
/**
* The function return type.
*/
public string return_type { get; set; }
- public string attributes { get; set; }
-
public bool is_declaration { get; set; }
/**
public CCodeFunction copy () {
var func = new CCodeFunction (name, return_type);
func.modifiers = modifiers;
- func.attributes = attributes;
/* no deep copy for lists available yet
* func.parameters = parameters.copy ();
writer.write_string (" G_GNUC_FORMAT(%d)".printf (format_arg_index + 1));
}
- if (attributes != null) {
- writer.write_string (" ");
- writer.write_string (attributes);
+ if (CCodeModifiers.CONST in modifiers) {
+ writer.write_string (" G_GNUC_CONST");
+ }
+ if (CCodeModifiers.UNUSED in modifiers) {
+ writer.write_string (" G_GNUC_UNUSED");
+ }
+
+ if (CCodeModifiers.CONSTRUCTOR in modifiers) {
+ writer.write_string (" __attribute__((constructor))");
+ } else if (CCodeModifiers.DESTRUCTOR in modifiers) {
+ writer.write_string (" __attribute__((destructor))");
}
writer.write_string (";");
VOLATILE = 1 << 4,
DEPRECATED = 1 << 5,
THREAD_LOCAL = 1 << 6,
- INTERNAL = 1 << 7
+ INTERNAL = 1 << 7,
+ CONST = 1 << 8,
+ UNUSED = 1 << 9,
+ CONSTRUCTOR = 1 << 10,
+ DESTRUCTOR = 1 << 11
}
*/
public CCodeLineDirective line { get; set; }
+ /**
+ * The modifiers for this code node which will be handled as needed
+ * in every subclass.
+ */
+ public CCodeModifiers modifiers { get; set; }
+
/**
* Writes this code node and all children with the specified C code
* writer.
var fun_name = "%s_get_type".printf (get_ccode_lower_case_name (en, null));
var regfun = new CCodeFunction (fun_name, "GType");
- regfun.attributes = "G_GNUC_CONST";
+ regfun.modifiers = CCodeModifiers.CONST;
if (en.is_private_symbol ()) {
- regfun.modifiers = CCodeModifiers.STATIC;
// avoid C warning as this function is not always used
- regfun.attributes += " G_GNUC_UNUSED";
+ regfun.modifiers |= CCodeModifiers.STATIC | CCodeModifiers.UNUSED;
} else if (context.hide_internal && en.is_internal_symbol ()) {
- regfun.modifiers = CCodeModifiers.INTERNAL;
+ regfun.modifiers |= CCodeModifiers.INTERNAL;
}
decl_space.add_function_declaration (regfun);
cfile.add_type_member_declaration (timer_decl);
var constructor = new CCodeFunction (prefix + "_init");
- constructor.modifiers = CCodeModifiers.STATIC;
- constructor.attributes = "__attribute__((constructor))";
+ constructor.modifiers = CCodeModifiers.STATIC | CCodeModifiers.CONSTRUCTOR;
cfile.add_function_declaration (constructor);
push_function (constructor);
var destructor = new CCodeFunction (prefix + "_exit");
- destructor.modifiers = CCodeModifiers.STATIC;
- destructor.attributes = "__attribute__((destructor))";
+ destructor.modifiers = CCodeModifiers.STATIC | CCodeModifiers.DESTRUCTOR;
cfile.add_function_declaration (destructor);
push_function (destructor);
// declare proxy_get_type function
var proxy_get_type = new CCodeFunction (get_type_name, "GType");
- proxy_get_type.attributes = "G_GNUC_CONST";
+ proxy_get_type.modifiers = CCodeModifiers.CONST;
decl_space.add_function_declaration (proxy_get_type);
if (in_plugin) {
function.add_parameter (new CCodeParameter ("flags", "GParamFlags"));
if (cl.is_private_symbol ()) {
- function.modifiers = CCodeModifiers.STATIC;
// avoid C warning as this function is not always used
- function.attributes = "G_GNUC_UNUSED";
+ function.modifiers = CCodeModifiers.STATIC | CCodeModifiers.UNUSED;
} else if (context.hide_internal && cl.is_internal_symbol ()) {
function.modifiers = CCodeModifiers.INTERNAL;
}
function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
if (cl.is_private_symbol ()) {
- function.modifiers = CCodeModifiers.STATIC;
// avoid C warning as this function is not always used
- function.attributes = "G_GNUC_UNUSED";
+ function.modifiers = CCodeModifiers.STATIC | CCodeModifiers.UNUSED;
} else if (context.hide_internal && cl.is_internal_symbol ()) {
- function.modifiers = CCodeModifiers.INTERNAL;
// avoid C warning as this function is not always used
- function.attributes = "G_GNUC_UNUSED";
+ function.modifiers = CCodeModifiers.INTERNAL | CCodeModifiers.UNUSED;
}
decl_space.add_function_declaration (function);
function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
if (cl.is_private_symbol ()) {
- function.modifiers = CCodeModifiers.STATIC;
// avoid C warning as this function is not always used
- function.attributes = "G_GNUC_UNUSED";
+ function.modifiers = CCodeModifiers.STATIC | CCodeModifiers.UNUSED;
} else if (context.hide_internal && cl.is_internal_symbol ()) {
function.modifiers = CCodeModifiers.INTERNAL;
}
function.add_parameter (new CCodeParameter ("value", "const GValue*"));
if (cl.is_private_symbol ()) {
- function.modifiers = CCodeModifiers.STATIC;
// avoid C warning as this function is not always used
- function.attributes = "G_GNUC_UNUSED";
+ function.modifiers = CCodeModifiers.STATIC | CCodeModifiers.UNUSED;
} else if (context.hide_internal && cl.is_internal_symbol ()) {
- function.modifiers = CCodeModifiers.INTERNAL;
// avoid C warning as this function is not always used
- function.attributes = "G_GNUC_UNUSED";
+ function.modifiers = CCodeModifiers.INTERNAL | CCodeModifiers.UNUSED;
}
decl_space.add_function_declaration (function);
CCodeFunction fun;
if (!plugin) {
fun = new CCodeFunction ("%s_get_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
- fun.attributes = "G_GNUC_CONST";
+ fun.modifiers = CCodeModifiers.CONST;
/* Function will not be prototyped anyway */
if (get_accessibility () == SymbolAccessibility.PRIVATE) {
- fun.modifiers = CCodeModifiers.STATIC;
// avoid C warning as this function is not always used
- fun.attributes += " G_GNUC_UNUSED";
+ fun.modifiers |= CCodeModifiers.STATIC | CCodeModifiers.UNUSED;
} else if (context.hide_internal && get_accessibility () == SymbolAccessibility.INTERNAL) {
- fun.modifiers = CCodeModifiers.INTERNAL;
// avoid C warning as this function is not always used
- fun.attributes += " G_GNUC_UNUSED";
+ fun.modifiers |= CCodeModifiers.INTERNAL | CCodeModifiers.UNUSED;
}
} else {
fun = new CCodeFunction ("%s_register_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
fun.add_parameter (new CCodeParameter ("module", "GTypeModule *"));
var get_fun = new CCodeFunction ("%s_get_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
- get_fun.attributes = "G_GNUC_CONST";
+ get_fun.modifiers = CCodeModifiers.CONST;
get_fun.is_declaration = true;
declaration_fragment.append (get_fun.copy ());