~ubuntu-branches/ubuntu/quantal/vala/quantal

« back to all changes in this revision

Viewing changes to codegen/valagtypemodule.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Terry
  • Date: 2011-01-18 09:51:15 UTC
  • mfrom: (1.5.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20110118095115-r2jr7c63lr0jzj0y
Tags: 0.11.4-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
typedef struct _ValaGTypeModule ValaGTypeModule;
167
167
typedef struct _ValaGTypeModuleClass ValaGTypeModuleClass;
168
168
typedef struct _ValaGTypeModulePrivate ValaGTypeModulePrivate;
 
169
#define _g_free0(var) (var = (g_free (var), NULL))
 
170
#define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
169
171
 
170
172
#define VALA_TYPE_TYPEREGISTER_FUNCTION (vala_typeregister_function_get_type ())
171
173
#define VALA_TYPEREGISTER_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_TYPEREGISTER_FUNCTION, ValaTypeRegisterFunction))
176
178
 
177
179
typedef struct _ValaTypeRegisterFunction ValaTypeRegisterFunction;
178
180
typedef struct _ValaTypeRegisterFunctionClass ValaTypeRegisterFunctionClass;
179
 
#define _g_free0(var) (var = (g_free (var), NULL))
180
 
#define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
181
181
 
182
182
#define VALA_TYPE_CLASS_REGISTER_FUNCTION (vala_class_register_function_get_type ())
183
183
#define VALA_CLASS_REGISTER_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CLASS_REGISTER_FUNCTION, ValaClassRegisterFunction))
294
294
        ValaTypeSymbol* gbytearray_type;
295
295
        ValaTypeSymbol* gptrarray_type;
296
296
        ValaTypeSymbol* gthreadpool_type;
 
297
        ValaDataType* gdestroynotify_type;
297
298
        ValaDataType* gquark_type;
298
299
        ValaStruct* gvalue_type;
299
300
        ValaClass* gvariant_type;
323
324
        ValaCCodeExpression* (*get_dup_func_expression) (ValaCCodeBaseModule* self, ValaDataType* type, ValaSourceReference* source_reference, gboolean is_chainup);
324
325
        gchar* (*append_struct_array_free) (ValaCCodeBaseModule* self, ValaStruct* st);
325
326
        ValaCCodeExpression* (*destroy_value) (ValaCCodeBaseModule* self, ValaTargetValue* value, gboolean is_macro_definition);
326
 
        void (*append_local_free) (ValaCCodeBaseModule* self, ValaSymbol* sym, gboolean stop_at_loop);
 
327
        void (*append_local_free) (ValaCCodeBaseModule* self, ValaSymbol* sym, gboolean stop_at_loop, ValaCodeNode* stop_at);
327
328
        gchar* (*get_delegate_target_cname) (ValaCCodeBaseModule* self, const gchar* delegate_cname);
328
329
        ValaCCodeExpression* (*get_delegate_target_cexpression) (ValaCCodeBaseModule* self, ValaExpression* delegate_expr, ValaCCodeExpression** delegate_target_destroy_notify);
329
330
        ValaCCodeExpression* (*get_delegate_target_cvalue) (ValaCCodeBaseModule* self, ValaTargetValue* value);
334
335
        void (*generate_interface_declaration) (ValaCCodeBaseModule* self, ValaInterface* iface, ValaCCodeFile* decl_space);
335
336
        void (*generate_method_declaration) (ValaCCodeBaseModule* self, ValaMethod* m, ValaCCodeFile* decl_space);
336
337
        void (*generate_error_domain_declaration) (ValaCCodeBaseModule* self, ValaErrorDomain* edomain, ValaCCodeFile* decl_space);
337
 
        ValaCCodeExpression* (*deserialize_expression) (ValaCCodeBaseModule* self, ValaDataType* type, ValaCCodeExpression* variant_expr, ValaCCodeExpression* expr);
 
338
        ValaCCodeExpression* (*deserialize_expression) (ValaCCodeBaseModule* self, ValaDataType* type, ValaCCodeExpression* variant_expr, ValaCCodeExpression* expr, ValaCCodeExpression* error_expr, gboolean* may_fail);
338
339
        ValaCCodeExpression* (*serialize_expression) (ValaCCodeBaseModule* self, ValaDataType* type, ValaCCodeExpression* expr);
339
340
        ValaCCodeExpression* (*get_implicit_cast_expression) (ValaCCodeBaseModule* self, ValaCCodeExpression* source_cexpr, ValaDataType* expression_type, ValaDataType* target_type, ValaExpression* expr);
340
341
        gboolean (*is_gobject_property) (ValaCCodeBaseModule* self, ValaProperty* prop);
343
344
        gboolean (*method_has_wrapper) (ValaCCodeBaseModule* self, ValaMethod* method);
344
345
        ValaCCodeFunctionCall* (*get_param_spec) (ValaCCodeBaseModule* self, ValaProperty* prop);
345
346
        ValaCCodeFunctionCall* (*get_signal_creation) (ValaCCodeBaseModule* self, ValaSignal* sig, ValaTypeSymbol* type);
346
 
        void (*register_dbus_info) (ValaCCodeBaseModule* self, ValaObjectTypeSymbol* bindable);
 
347
        void (*register_dbus_info) (ValaCCodeBaseModule* self, ValaCCodeBlock* block, ValaObjectTypeSymbol* bindable);
347
348
        gchar* (*get_dynamic_property_getter_cname) (ValaCCodeBaseModule* self, ValaDynamicProperty* node);
348
349
        gchar* (*get_dynamic_property_setter_cname) (ValaCCodeBaseModule* self, ValaDynamicProperty* node);
349
350
        gchar* (*get_dynamic_signal_cname) (ValaCCodeBaseModule* self, ValaDynamicSignal* node);
454
455
        ValaGErrorModuleClass parent_class;
455
456
        void (*generate_virtual_method_declaration) (ValaGTypeModule* self, ValaMethod* m, ValaCCodeFile* decl_space, ValaCCodeStruct* type_struct);
456
457
        void (*generate_class_init) (ValaGTypeModule* self, ValaClass* cl);
457
 
        ValaTypeRegisterFunction* (*create_interface_register_function) (ValaGTypeModule* self, ValaInterface* iface);
458
458
};
459
459
 
460
460
struct _ValaCCodeBaseModuleEmitContext {
464
464
        ValaSymbol* current_symbol;
465
465
        ValaArrayList* symbol_stack;
466
466
        ValaTryStatement* current_try;
 
467
        ValaCatchClause* current_catch;
467
468
        ValaCCodeFunction* ccode;
468
469
        ValaArrayList* ccode_stack;
469
470
        ValaArrayList* temp_ref_vars;
499
500
GType vala_ccode_delegate_module_get_type (void) G_GNUC_CONST;
500
501
GType vala_gerror_module_get_type (void) G_GNUC_CONST;
501
502
GType vala_gtype_module_get_type (void) G_GNUC_CONST;
502
 
gpointer vala_typeregister_function_ref (gpointer instance);
503
 
void vala_typeregister_function_unref (gpointer instance);
504
 
GParamSpec* vala_param_spec_typeregister_function (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
505
 
void vala_value_set_typeregister_function (GValue* value, gpointer v_object);
506
 
void vala_value_take_typeregister_function (GValue* value, gpointer v_object);
507
 
gpointer vala_value_get_typeregister_function (const GValue* value);
508
 
GType vala_typeregister_function_get_type (void) G_GNUC_CONST;
509
503
enum  {
510
504
        VALA_GTYPE_MODULE_DUMMY_PROPERTY
511
505
};
522
516
ValaCodeContext* vala_ccode_base_module_get_context (ValaCCodeBaseModule* self);
523
517
ValaClassRegisterFunction* vala_class_register_function_new (ValaClass* cl, ValaCodeContext* context);
524
518
ValaClassRegisterFunction* vala_class_register_function_construct (GType object_type, ValaClass* cl, ValaCodeContext* context);
 
519
gpointer vala_typeregister_function_ref (gpointer instance);
 
520
void vala_typeregister_function_unref (gpointer instance);
 
521
GParamSpec* vala_param_spec_typeregister_function (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
 
522
void vala_value_set_typeregister_function (GValue* value, gpointer v_object);
 
523
void vala_value_take_typeregister_function (GValue* value, gpointer v_object);
 
524
gpointer vala_value_get_typeregister_function (const GValue* value);
 
525
GType vala_typeregister_function_get_type (void) G_GNUC_CONST;
525
526
GType vala_class_register_function_get_type (void) G_GNUC_CONST;
526
527
void vala_typeregister_function_init_from_type (ValaTypeRegisterFunction* self, gboolean plugin);
527
528
ValaCCodeFragment* vala_typeregister_function_get_declaration (ValaTypeRegisterFunction* self);
572
573
void vala_gtype_module_generate_class_init (ValaGTypeModule* self, ValaClass* cl);
573
574
static void vala_gtype_module_real_generate_class_init (ValaGTypeModule* self, ValaClass* cl);
574
575
ValaCCodeFunctionCall* vala_ccode_base_module_get_signal_creation (ValaCCodeBaseModule* self, ValaSignal* sig, ValaTypeSymbol* type);
575
 
void vala_ccode_base_module_register_dbus_info (ValaCCodeBaseModule* self, ValaObjectTypeSymbol* bindable);
576
576
static ValaCCodeExpression* vala_gtype_module_cast_method_pointer (ValaGTypeModule* self, ValaMethod* m, ValaCCodeExpression* cfunc, ValaObjectTypeSymbol* base_type);
577
577
void vala_ccode_base_module_generate_method_declaration (ValaCCodeBaseModule* self, ValaMethod* m, ValaCCodeFile* decl_space);
578
578
static ValaCCodeExpression* vala_gtype_module_cast_property_accessor_pointer (ValaGTypeModule* self, ValaPropertyAccessor* acc, ValaCCodeExpression* cfunc, ValaObjectTypeSymbol* base_type);
583
583
static ValaCCodeFunctionCall* vala_gtype_module_real_get_param_spec (ValaCCodeBaseModule* base, ValaProperty* prop);
584
584
ValaCCodeExpression* vala_ccode_base_module_get_ccodenode (ValaCCodeBaseModule* self, ValaExpression* node);
585
585
static void vala_gtype_module_real_generate_interface_declaration (ValaCCodeBaseModule* base, ValaInterface* iface, ValaCCodeFile* decl_space);
586
 
ValaTypeRegisterFunction* vala_gtype_module_create_interface_register_function (ValaGTypeModule* self, ValaInterface* iface);
587
 
static void vala_gtype_module_real_visit_interface (ValaCodeVisitor* base, ValaInterface* iface);
588
 
static void vala_gtype_module_add_interface_base_init_function (ValaGTypeModule* self, ValaInterface* iface);
589
 
static ValaTypeRegisterFunction* vala_gtype_module_real_create_interface_register_function (ValaGTypeModule* self, ValaInterface* iface);
590
586
ValaInterfaceRegisterFunction* vala_interface_register_function_new (ValaInterface* iface, ValaCodeContext* context);
591
587
ValaInterfaceRegisterFunction* vala_interface_register_function_construct (GType object_type, ValaInterface* iface, ValaCodeContext* context);
592
588
GType vala_interface_register_function_get_type (void) G_GNUC_CONST;
 
589
static void vala_gtype_module_real_visit_interface (ValaCodeVisitor* base, ValaInterface* iface);
 
590
static void vala_gtype_module_add_interface_base_init_function (ValaGTypeModule* self, ValaInterface* iface);
593
591
gboolean vala_ccode_base_module_is_gobject_property (ValaCCodeBaseModule* self, ValaProperty* prop);
594
592
ValaCCodeFunctionCall* vala_ccode_base_module_get_param_spec (ValaCCodeBaseModule* self, ValaProperty* prop);
595
593
static void vala_gtype_module_real_visit_struct (ValaCodeVisitor* base, ValaStruct* st);
6622
6620
                        _vala_iterable_unref0 (_sig_list);
6623
6621
                }
6624
6622
        }
6625
 
        vala_ccode_base_module_register_dbus_info ((ValaCCodeBaseModule*) self, (ValaObjectTypeSymbol*) cl);
6626
6623
        vala_ccode_base_module_pop_context ((ValaCCodeBaseModule*) self);
6627
6624
        _vala_ccode_node_unref0 (parent_assignment);
6628
6625
        _vala_ccode_node_unref0 (parent_var_decl);
9397
9394
        ValaCCodeVariableDeclarator* _tmp81_;
9398
9395
        ValaCCodeTypeDefinition* _tmp82_ = NULL;
9399
9396
        ValaCCodeTypeDefinition* _tmp83_;
9400
 
        ValaTypeRegisterFunction* _tmp161_ = NULL;
9401
 
        ValaTypeRegisterFunction* type_fun;
9402
 
        ValaCCodeFragment* _tmp162_ = NULL;
9403
 
        ValaCCodeFragment* _tmp163_;
 
9397
        ValaCodeContext* _tmp161_ = NULL;
 
9398
        ValaInterfaceRegisterFunction* _tmp162_ = NULL;
 
9399
        ValaInterfaceRegisterFunction* type_fun;
 
9400
        ValaCCodeFragment* _tmp163_ = NULL;
 
9401
        ValaCCodeFragment* _tmp164_;
9404
9402
        self = (ValaGTypeModule*) base;
9405
9403
        g_return_if_fail (iface != NULL);
9406
9404
        g_return_if_fail (decl_space != NULL);
9867
9865
                _vala_iterable_unref0 (_prop_list);
9868
9866
        }
9869
9867
        vala_ccode_file_add_type_definition (decl_space, (ValaCCodeNode*) type_struct);
9870
 
        _tmp161_ = vala_gtype_module_create_interface_register_function (self, iface);
9871
 
        type_fun = _tmp161_;
9872
 
        vala_typeregister_function_init_from_type (type_fun, ((ValaCCodeBaseModule*) self)->in_plugin);
9873
 
        _tmp162_ = vala_typeregister_function_get_declaration (type_fun);
9874
 
        _tmp163_ = _tmp162_;
9875
 
        vala_ccode_file_add_type_member_declaration (decl_space, (ValaCCodeNode*) _tmp163_);
9876
 
        _vala_ccode_node_unref0 (_tmp163_);
 
9868
        _tmp161_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
 
9869
        _tmp162_ = vala_interface_register_function_new (iface, _tmp161_);
 
9870
        type_fun = _tmp162_;
 
9871
        vala_typeregister_function_init_from_type ((ValaTypeRegisterFunction*) type_fun, ((ValaCCodeBaseModule*) self)->in_plugin);
 
9872
        _tmp163_ = vala_typeregister_function_get_declaration ((ValaTypeRegisterFunction*) type_fun);
 
9873
        _tmp164_ = _tmp163_;
 
9874
        vala_ccode_file_add_type_member_declaration (decl_space, (ValaCCodeNode*) _tmp164_);
 
9875
        _vala_ccode_node_unref0 (_tmp164_);
9877
9876
        _vala_typeregister_function_unref0 (type_fun);
9878
9877
        _g_free0 (macro);
9879
9878
        _vala_ccode_node_unref0 (type_struct);
9891
9890
        gboolean _tmp11_;
9892
9891
        gboolean _tmp12_;
9893
9892
        ValaComment* _tmp13_ = NULL;
9894
 
        ValaTypeRegisterFunction* _tmp18_ = NULL;
9895
 
        ValaTypeRegisterFunction* type_fun;
9896
 
        ValaCCodeFragment* _tmp19_ = NULL;
9897
 
        ValaCCodeFragment* _tmp20_;
9898
 
        ValaCCodeFragment* _tmp21_ = NULL;
9899
 
        ValaCCodeFragment* _tmp22_;
 
9893
        ValaCodeContext* _tmp18_ = NULL;
 
9894
        ValaInterfaceRegisterFunction* _tmp19_ = NULL;
 
9895
        ValaInterfaceRegisterFunction* type_fun;
 
9896
        ValaCCodeFragment* _tmp20_ = NULL;
 
9897
        ValaCCodeFragment* _tmp21_;
 
9898
        ValaCCodeFragment* _tmp22_ = NULL;
 
9899
        ValaCCodeFragment* _tmp23_;
9900
9900
        self = (ValaGTypeModule*) base;
9901
9901
        g_return_if_fail (iface != NULL);
9902
9902
        _tmp0_ = vala_ccode_base_module_emit_context_new ((ValaSymbol*) iface);
9947
9947
                vala_ccode_file_add_type_member_definition (((ValaCCodeBaseModule*) self)->cfile, (ValaCCodeNode*) _tmp17_);
9948
9948
                _vala_ccode_node_unref0 (_tmp17_);
9949
9949
        }
9950
 
        _tmp18_ = vala_gtype_module_create_interface_register_function (self, iface);
9951
 
        type_fun = _tmp18_;
9952
 
        vala_typeregister_function_init_from_type (type_fun, ((ValaCCodeBaseModule*) self)->in_plugin);
9953
 
        _tmp19_ = vala_typeregister_function_get_source_declaration (type_fun);
9954
 
        _tmp20_ = _tmp19_;
9955
 
        vala_ccode_file_add_type_member_declaration (((ValaCCodeBaseModule*) self)->cfile, (ValaCCodeNode*) _tmp20_);
9956
 
        _vala_ccode_node_unref0 (_tmp20_);
9957
 
        _tmp21_ = vala_typeregister_function_get_definition (type_fun);
9958
 
        _tmp22_ = _tmp21_;
9959
 
        vala_ccode_file_add_type_member_definition (((ValaCCodeBaseModule*) self)->cfile, (ValaCCodeNode*) _tmp22_);
9960
 
        _vala_ccode_node_unref0 (_tmp22_);
 
9950
        _tmp18_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
 
9951
        _tmp19_ = vala_interface_register_function_new (iface, _tmp18_);
 
9952
        type_fun = _tmp19_;
 
9953
        vala_typeregister_function_init_from_type ((ValaTypeRegisterFunction*) type_fun, ((ValaCCodeBaseModule*) self)->in_plugin);
 
9954
        _tmp20_ = vala_typeregister_function_get_source_declaration ((ValaTypeRegisterFunction*) type_fun);
 
9955
        _tmp21_ = _tmp20_;
 
9956
        vala_ccode_file_add_type_member_declaration (((ValaCCodeBaseModule*) self)->cfile, (ValaCCodeNode*) _tmp21_);
 
9957
        _vala_ccode_node_unref0 (_tmp21_);
 
9958
        _tmp22_ = vala_typeregister_function_get_definition ((ValaTypeRegisterFunction*) type_fun);
 
9959
        _tmp23_ = _tmp22_;
 
9960
        vala_ccode_file_add_type_member_definition (((ValaCCodeBaseModule*) self)->cfile, (ValaCCodeNode*) _tmp23_);
 
9961
        _vala_ccode_node_unref0 (_tmp23_);
9961
9962
        vala_ccode_base_module_pop_context ((ValaCCodeBaseModule*) self);
9962
9963
        _vala_typeregister_function_unref0 (type_fun);
9963
9964
}
9964
9965
 
9965
9966
 
9966
 
static ValaTypeRegisterFunction* vala_gtype_module_real_create_interface_register_function (ValaGTypeModule* self, ValaInterface* iface) {
9967
 
        ValaTypeRegisterFunction* result = NULL;
9968
 
        ValaCodeContext* _tmp0_ = NULL;
9969
 
        ValaInterfaceRegisterFunction* _tmp1_ = NULL;
9970
 
        g_return_val_if_fail (self != NULL, NULL);
9971
 
        g_return_val_if_fail (iface != NULL, NULL);
9972
 
        _tmp0_ = vala_ccode_base_module_get_context ((ValaCCodeBaseModule*) self);
9973
 
        _tmp1_ = vala_interface_register_function_new (iface, _tmp0_);
9974
 
        result = (ValaTypeRegisterFunction*) _tmp1_;
9975
 
        return result;
9976
 
}
9977
 
 
9978
 
 
9979
 
ValaTypeRegisterFunction* vala_gtype_module_create_interface_register_function (ValaGTypeModule* self, ValaInterface* iface) {
9980
 
        return VALA_GTYPE_MODULE_GET_CLASS (self)->create_interface_register_function (self, iface);
9981
 
}
9982
 
 
9983
 
 
9984
9967
static gpointer _vala_iterable_ref0 (gpointer self) {
9985
9968
        return self ? vala_iterable_ref (self) : NULL;
9986
9969
}
10266
10249
                }
10267
10250
                _vala_iterable_unref0 (_m_list);
10268
10251
        }
10269
 
        vala_ccode_base_module_register_dbus_info ((ValaCCodeBaseModule*) self, (ValaObjectTypeSymbol*) iface);
10270
10252
        _tmp81_ = vala_ccode_base_module_get_ccode ((ValaCCodeBaseModule*) self);
10271
10253
        vala_ccode_function_close (_tmp81_);
10272
10254
        vala_ccode_base_module_pop_context ((ValaCCodeBaseModule*) self);
10613
10595
        VALA_CCODE_BASE_MODULE_CLASS (klass)->get_param_spec = vala_gtype_module_real_get_param_spec;
10614
10596
        VALA_CCODE_BASE_MODULE_CLASS (klass)->generate_interface_declaration = vala_gtype_module_real_generate_interface_declaration;
10615
10597
        VALA_CODE_VISITOR_CLASS (klass)->visit_interface = vala_gtype_module_real_visit_interface;
10616
 
        VALA_GTYPE_MODULE_CLASS (klass)->create_interface_register_function = vala_gtype_module_real_create_interface_register_function;
10617
10598
        VALA_CODE_VISITOR_CLASS (klass)->visit_struct = vala_gtype_module_real_visit_struct;
10618
10599
        VALA_CODE_VISITOR_CLASS (klass)->visit_enum = vala_gtype_module_real_visit_enum;
10619
10600
        VALA_CODE_VISITOR_CLASS (klass)->visit_method_call = vala_gtype_module_real_visit_method_call;