var temp_value = create_temp_value (expr.value_type, false, expr);
ccode.add_assignment (get_cvalue_ (temp_value), creation_expr);
expr.target_value = temp_value;
+
+ if (context.gobject_tracing) {
+ // GObject creation tracing enabled
+
+ var cl = expr.type_reference.data_type as Class;
+ if (cl != null && cl.is_subtype_of (gobject_type)) {
+ // creating GObject
+
+ // instance can be NULL in error cases
+ ccode.open_if (get_cvalue_ (expr.target_value));
+
+ var set_data_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_set_data"));
+ set_data_call.add_argument (new CCodeCastExpression (get_cvalue_ (expr.target_value), "GObject *"));
+ set_data_call.add_argument (new CCodeConstant ("\"vala-creation-function\""));
+
+ string func_name = "";
+ if (current_method != null) {
+ func_name = current_method.get_full_name ();
+ } else if (current_property_accessor != null) {
+ func_name = current_property_accessor.get_full_name ();
+ }
+
+ set_data_call.add_argument (new CCodeConstant ("\"%s\"".printf (func_name)));
+
+ ccode.add_expression (set_data_call);
+
+ ccode.close ();
+ }
+ }
}
((GLibValue) expr.target_value).lvalue = true;
static bool deprecated;
static bool experimental;
static bool experimental_non_null;
+ static bool gobject_tracing;
static bool disable_warnings;
static string cc_command;
[CCode (array_length = false, array_null_terminated = true)]
{ "disable-warnings", 0, 0, OptionArg.NONE, ref disable_warnings, "Disable warnings", null },
{ "fatal-warnings", 0, 0, OptionArg.NONE, ref fatal_warnings, "Treat warnings as fatal", null },
{ "enable-experimental-non-null", 0, 0, OptionArg.NONE, ref experimental_non_null, "Enable experimental enhancements for non-null types", null },
+ { "enable-gobject-tracing", 0, 0, OptionArg.NONE, ref gobject_tracing, "Enable GObject creation tracing", null },
{ "cc", 0, 0, OptionArg.STRING, ref cc_command, "Use COMMAND as C compiler command", "COMMAND" },
{ "Xcc", 'X', 0, OptionArg.STRING_ARRAY, ref cc_options, "Pass OPTION to the C compiler", "OPTION..." },
{ "dump-tree", 0, 0, OptionArg.FILENAME, ref dump_tree, "Write code tree to FILE", "FILE" },
context.deprecated = deprecated;
context.experimental = experimental;
context.experimental_non_null = experimental_non_null;
+ context.gobject_tracing = gobject_tracing;
context.report.enable_warnings = !disable_warnings;
context.report.set_verbose_errors (!quiet_mode);
context.verbose_mode = verbose_mode;