~ubuntu-branches/ubuntu/vivid/vala/vivid

« back to all changes in this revision

Viewing changes to vala/valanamespace.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-07-28 07:58:01 UTC
  • mfrom: (1.5.5 upstream) (7.3.14 experimental)
  • Revision ID: james.westby@ubuntu.com-20100728075801-18u9cg5hv5oety6m
Tags: 0.9.4-1
New upstream development release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
typedef struct _ValaSymbol ValaSymbol;
92
92
typedef struct _ValaSymbolClass ValaSymbolClass;
93
93
 
 
94
#define VALA_TYPE_VARIABLE (vala_variable_get_type ())
 
95
#define VALA_VARIABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_VARIABLE, ValaVariable))
 
96
#define VALA_VARIABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_VARIABLE, ValaVariableClass))
 
97
#define VALA_IS_VARIABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_VARIABLE))
 
98
#define VALA_IS_VARIABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_VARIABLE))
 
99
#define VALA_VARIABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_VARIABLE, ValaVariableClass))
 
100
 
 
101
typedef struct _ValaVariable ValaVariable;
 
102
typedef struct _ValaVariableClass ValaVariableClass;
 
103
 
94
104
#define VALA_TYPE_LOCAL_VARIABLE (vala_local_variable_get_type ())
95
105
#define VALA_LOCAL_VARIABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_LOCAL_VARIABLE, ValaLocalVariable))
96
106
#define VALA_LOCAL_VARIABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_LOCAL_VARIABLE, ValaLocalVariableClass))
203
213
typedef struct _ValaDelegate ValaDelegate;
204
214
typedef struct _ValaDelegateClass ValaDelegateClass;
205
215
 
206
 
#define VALA_TYPE_MEMBER (vala_member_get_type ())
207
 
#define VALA_MEMBER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_MEMBER, ValaMember))
208
 
#define VALA_MEMBER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_MEMBER, ValaMemberClass))
209
 
#define VALA_IS_MEMBER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_MEMBER))
210
 
#define VALA_IS_MEMBER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_MEMBER))
211
 
#define VALA_MEMBER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_MEMBER, ValaMemberClass))
212
 
 
213
 
typedef struct _ValaMember ValaMember;
214
 
typedef struct _ValaMemberClass ValaMemberClass;
215
 
 
216
216
#define VALA_TYPE_CONSTANT (vala_constant_get_type ())
217
217
#define VALA_CONSTANT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CONSTANT, ValaConstant))
218
218
#define VALA_CONSTANT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CONSTANT, ValaConstantClass))
392
392
        ValaList* comments;
393
393
        ValaList* cprefixes;
394
394
        char* lower_case_cprefix;
395
 
        ValaList* cheader_filenames;
396
395
        ValaList* namespaces;
397
396
        ValaList* using_directives;
398
397
};
437
436
GType vala_data_type_get_type (void) G_GNUC_CONST;
438
437
GType vala_expression_get_type (void) G_GNUC_CONST;
439
438
GType vala_symbol_get_type (void) G_GNUC_CONST;
 
439
GType vala_variable_get_type (void) G_GNUC_CONST;
440
440
GType vala_local_variable_get_type (void) G_GNUC_CONST;
441
441
GType vala_attribute_get_type (void) G_GNUC_CONST;
442
442
GType vala_namespace_get_type (void) G_GNUC_CONST;
448
448
GType vala_enum_get_type (void) G_GNUC_CONST;
449
449
GType vala_error_domain_get_type (void) G_GNUC_CONST;
450
450
GType vala_delegate_get_type (void) G_GNUC_CONST;
451
 
GType vala_member_get_type (void) G_GNUC_CONST;
452
451
GType vala_constant_get_type (void) G_GNUC_CONST;
453
452
GType vala_field_get_type (void) G_GNUC_CONST;
454
453
GType vala_method_get_type (void) G_GNUC_CONST;
471
470
void vala_value_take_source_reference (GValue* value, gpointer v_object);
472
471
gpointer vala_value_get_source_reference (const GValue* value);
473
472
GType vala_source_reference_get_type (void) G_GNUC_CONST;
474
 
ValaSymbol* vala_symbol_construct (GType object_type, const char* name, ValaSourceReference* source_reference);
 
473
ValaSymbol* vala_symbol_construct (GType object_type, const char* name, ValaSourceReference* source_reference, ValaComment* comment);
475
474
GType vala_symbol_accessibility_get_type (void) G_GNUC_CONST;
476
475
void vala_symbol_set_access (ValaSymbol* self, ValaSymbolAccessibility value);
477
476
ValaNamespace* vala_namespace_new (const char* name, ValaSourceReference* source_reference);
554
553
char* vala_symbol_camel_case_to_lower_case (const char* camel_case);
555
554
static char* vala_namespace_real_get_lower_case_cprefix (ValaSymbol* base);
556
555
void vala_namespace_set_lower_case_cprefix (ValaNamespace* self, const char* cprefix);
557
 
static ValaList* vala_namespace_real_get_cheader_filenames (ValaSymbol* base);
558
 
void vala_namespace_set_cheader_filename (ValaNamespace* self, const char* cheader_filename);
559
 
void vala_namespace_add_cheader_filename (ValaNamespace* self, const char* cheader_filename);
560
556
gboolean vala_attribute_has_argument (ValaAttribute* self, const char* name);
561
557
char* vala_attribute_get_string (ValaAttribute* self, const char* name);
 
558
void vala_symbol_add_cheader_filename (ValaSymbol* self, const char* filename);
562
559
gpointer vala_source_file_ref (gpointer instance);
563
560
void vala_source_file_unref (gpointer instance);
564
561
GParamSpec* vala_param_spec_source_file (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
585
582
 
586
583
 
587
584
 
 
585
/**
 
586
 * Creates a new namespace.
 
587
 *
 
588
 * @param name             namespace name
 
589
 * @param source_reference reference to source code
 
590
 * @return                 newly created namespace
 
591
 */
588
592
ValaNamespace* vala_namespace_construct (GType object_type, const char* name, ValaSourceReference* source_reference) {
589
593
        ValaNamespace* self;
590
 
        self = (ValaNamespace*) vala_symbol_construct (object_type, name, source_reference);
 
594
        self = (ValaNamespace*) vala_symbol_construct (object_type, name, source_reference, NULL);
591
595
        vala_symbol_set_access ((ValaSymbol*) self, VALA_SYMBOL_ACCESSIBILITY_PUBLIC);
592
596
        return self;
593
597
}
598
602
}
599
603
 
600
604
 
 
605
/**
 
606
 * Adds a new using directive with the specified namespace.
 
607
 *
 
608
 * @param ns reference to namespace
 
609
 */
601
610
void vala_namespace_add_using_directive (ValaNamespace* self, ValaUsingDirective* ns) {
602
611
        g_return_if_fail (self != NULL);
603
612
        g_return_if_fail (ns != NULL);
617
626
}
618
627
 
619
628
 
 
629
/**
 
630
 * Returns a copy of the list of namespaces.
 
631
 *
 
632
 * @return comment list
 
633
 */
620
634
ValaList* vala_namespace_get_comments (ValaNamespace* self) {
621
635
        ValaList* result = NULL;
622
636
        g_return_val_if_fail (self != NULL, NULL);
625
639
}
626
640
 
627
641
 
 
642
/**
 
643
 * Adds the specified namespace to this source file.
 
644
 *
 
645
 * @param ns a namespace
 
646
 */
628
647
void vala_namespace_add_namespace (ValaNamespace* self, ValaNamespace* ns) {
629
648
        ValaSymbol* _tmp0_;
630
649
        gboolean _tmp1_;
840
859
}
841
860
 
842
861
 
 
862
/**
 
863
 * Returns a copy of the list of namespaces.
 
864
 *
 
865
 * @return namespace list
 
866
 */
843
867
ValaList* vala_namespace_get_namespaces (ValaNamespace* self) {
844
868
        ValaList* result = NULL;
845
869
        g_return_val_if_fail (self != NULL, NULL);
848
872
}
849
873
 
850
874
 
 
875
/**
 
876
 * Adds the specified class to this namespace.
 
877
 *
 
878
 * @param cl a class
 
879
 */
851
880
void vala_namespace_add_class (ValaNamespace* self, ValaClass* cl) {
852
881
        g_return_if_fail (self != NULL);
853
882
        g_return_if_fail (cl != NULL);
859
888
}
860
889
 
861
890
 
 
891
/**
 
892
 * Adds the specified interface to this namespace.
 
893
 *
 
894
 * @param iface an interface
 
895
 */
862
896
void vala_namespace_add_interface (ValaNamespace* self, ValaInterface* iface) {
863
897
        g_return_if_fail (self != NULL);
864
898
        g_return_if_fail (iface != NULL);
870
904
}
871
905
 
872
906
 
 
907
/**
 
908
 * Adds the specified struct to this namespace.
 
909
 *
 
910
 * @param st a struct
 
911
 */
873
912
void vala_namespace_add_struct (ValaNamespace* self, ValaStruct* st) {
874
913
        g_return_if_fail (self != NULL);
875
914
        g_return_if_fail (st != NULL);
881
920
}
882
921
 
883
922
 
 
923
/**
 
924
 * Removes the specified struct from this namespace.
 
925
 *
 
926
 * @param st a struct
 
927
 */
884
928
void vala_namespace_remove_struct (ValaNamespace* self, ValaStruct* st) {
885
929
        g_return_if_fail (self != NULL);
886
930
        g_return_if_fail (st != NULL);
889
933
}
890
934
 
891
935
 
 
936
/**
 
937
 * Adds the specified enum to this namespace.
 
938
 *
 
939
 * @param en an enum
 
940
 */
892
941
void vala_namespace_add_enum (ValaNamespace* self, ValaEnum* en) {
893
942
        g_return_if_fail (self != NULL);
894
943
        g_return_if_fail (en != NULL);
900
949
}
901
950
 
902
951
 
 
952
/**
 
953
 * Adds the specified error domain to this namespace.
 
954
 *
 
955
 * @param edomain an error domain
 
956
 */
903
957
void vala_namespace_add_error_domain (ValaNamespace* self, ValaErrorDomain* edomain) {
904
958
        g_return_if_fail (self != NULL);
905
959
        g_return_if_fail (edomain != NULL);
911
965
}
912
966
 
913
967
 
 
968
/**
 
969
 * Adds the specified delegate to this namespace.
 
970
 *
 
971
 * @param d a delegate
 
972
 */
914
973
void vala_namespace_add_delegate (ValaNamespace* self, ValaDelegate* d) {
915
974
        g_return_if_fail (self != NULL);
916
975
        g_return_if_fail (d != NULL);
922
981
}
923
982
 
924
983
 
 
984
/**
 
985
 * Returns a copy of the list of structs.
 
986
 *
 
987
 * @return struct list
 
988
 */
925
989
ValaList* vala_namespace_get_structs (ValaNamespace* self) {
926
990
        ValaList* result = NULL;
927
991
        g_return_val_if_fail (self != NULL, NULL);
930
994
}
931
995
 
932
996
 
 
997
/**
 
998
 * Returns a copy of the list of classes.
 
999
 *
 
1000
 * @return class list
 
1001
 */
933
1002
ValaList* vala_namespace_get_classes (ValaNamespace* self) {
934
1003
        ValaList* result = NULL;
935
1004
        g_return_val_if_fail (self != NULL, NULL);
938
1007
}
939
1008
 
940
1009
 
 
1010
/**
 
1011
 * Returns a copy of the list of interfaces.
 
1012
 *
 
1013
 * @return interface list
 
1014
 */
941
1015
ValaList* vala_namespace_get_interfaces (ValaNamespace* self) {
942
1016
        ValaList* result = NULL;
943
1017
        g_return_val_if_fail (self != NULL, NULL);
946
1020
}
947
1021
 
948
1022
 
 
1023
/**
 
1024
 * Returns a copy of the list of enums.
 
1025
 *
 
1026
 * @return enum list
 
1027
 */
949
1028
ValaList* vala_namespace_get_enums (ValaNamespace* self) {
950
1029
        ValaList* result = NULL;
951
1030
        g_return_val_if_fail (self != NULL, NULL);
954
1033
}
955
1034
 
956
1035
 
 
1036
/**
 
1037
 * Returns a copy of the list of error domains.
 
1038
 *
 
1039
 * @return error domain list
 
1040
 */
957
1041
ValaList* vala_namespace_get_error_domains (ValaNamespace* self) {
958
1042
        ValaList* result = NULL;
959
1043
        g_return_val_if_fail (self != NULL, NULL);
962
1046
}
963
1047
 
964
1048
 
 
1049
/**
 
1050
 * Returns a copy of the list of fields.
 
1051
 *
 
1052
 * @return field list
 
1053
 */
965
1054
ValaList* vala_namespace_get_fields (ValaNamespace* self) {
966
1055
        ValaList* result = NULL;
967
1056
        g_return_val_if_fail (self != NULL, NULL);
970
1059
}
971
1060
 
972
1061
 
 
1062
/**
 
1063
 * Returns a copy of the list of constants.
 
1064
 *
 
1065
 * @return constant list
 
1066
 */
973
1067
ValaList* vala_namespace_get_constants (ValaNamespace* self) {
974
1068
        ValaList* result = NULL;
975
1069
        g_return_val_if_fail (self != NULL, NULL);
978
1072
}
979
1073
 
980
1074
 
 
1075
/**
 
1076
 * Returns a copy of the list of delegates.
 
1077
 *
 
1078
 * @return delegate list
 
1079
 */
981
1080
ValaList* vala_namespace_get_delegates (ValaNamespace* self) {
982
1081
        ValaList* result = NULL;
983
1082
        g_return_val_if_fail (self != NULL, NULL);
986
1085
}
987
1086
 
988
1087
 
 
1088
/**
 
1089
 * Returns a copy of the list of methods.
 
1090
 *
 
1091
 * @return method list
 
1092
 */
989
1093
ValaList* vala_namespace_get_methods (ValaNamespace* self) {
990
1094
        ValaList* result = NULL;
991
1095
        g_return_val_if_fail (self != NULL, NULL);
994
1098
}
995
1099
 
996
1100
 
 
1101
/**
 
1102
 * Adds the specified constant to this namespace.
 
1103
 *
 
1104
 * @param constant a constant
 
1105
 */
997
1106
void vala_namespace_add_constant (ValaNamespace* self, ValaConstant* constant) {
998
1107
        g_return_if_fail (self != NULL);
999
1108
        g_return_if_fail (constant != NULL);
1005
1114
}
1006
1115
 
1007
1116
 
 
1117
/**
 
1118
 * Adds the specified field to this namespace.
 
1119
 *
 
1120
 * @param f a field
 
1121
 */
1008
1122
void vala_namespace_add_field (ValaNamespace* self, ValaField* f) {
1009
1123
        g_return_if_fail (self != NULL);
1010
1124
        g_return_if_fail (f != NULL);
1027
1141
}
1028
1142
 
1029
1143
 
 
1144
/**
 
1145
 * Adds the specified method to this namespace.
 
1146
 *
 
1147
 * @param m a method
 
1148
 */
1030
1149
void vala_namespace_add_method (ValaNamespace* self, ValaMethod* m) {
1031
1150
        gboolean _tmp0_ = FALSE;
1032
1151
        g_return_if_fail (self != NULL);
1293
1412
}
1294
1413
 
1295
1414
 
 
1415
/**
 
1416
 * Adds a camel case string to be prepended to the name of members of
 
1417
 * this namespace when used in C code.
 
1418
 *
 
1419
 * @param cprefixes the camel case prefixes used in C code
 
1420
 */
1296
1421
void vala_namespace_add_cprefix (ValaNamespace* self, const char* cprefix) {
1297
1422
        g_return_if_fail (self != NULL);
1298
1423
        g_return_if_fail (cprefix != NULL);
1300
1425
}
1301
1426
 
1302
1427
 
 
1428
/**
 
1429
 * Returns the lower case string to be prepended to the name of members
 
1430
 * of this namespace when used in C code.
 
1431
 *
 
1432
 * @return the lower case prefix to be used in C code
 
1433
 */
1303
1434
static char* vala_namespace_real_get_lower_case_cprefix (ValaSymbol* base) {
1304
1435
        ValaNamespace * self;
1305
1436
        char* result = NULL;
1330
1461
}
1331
1462
 
1332
1463
 
 
1464
/**
 
1465
 * Sets the lower case string to be prepended to the name of members of
 
1466
 * this namespace when used in C code.
 
1467
 *
 
1468
 * @param cprefix the lower case prefix to be used in C code
 
1469
 */
1333
1470
void vala_namespace_set_lower_case_cprefix (ValaNamespace* self, const char* cprefix) {
1334
1471
        char* _tmp0_;
1335
1472
        g_return_if_fail (self != NULL);
1338
1475
}
1339
1476
 
1340
1477
 
1341
 
static ValaList* vala_namespace_real_get_cheader_filenames (ValaSymbol* base) {
1342
 
        ValaNamespace * self;
1343
 
        ValaList* result = NULL;
1344
 
        self = (ValaNamespace*) base;
1345
 
        result = _vala_collection_object_ref0 (self->priv->cheader_filenames);
1346
 
        return result;
1347
 
}
1348
 
 
1349
 
 
1350
 
void vala_namespace_set_cheader_filename (ValaNamespace* self, const char* cheader_filename) {
1351
 
        ValaList* _tmp0_;
1352
 
        g_return_if_fail (self != NULL);
1353
 
        g_return_if_fail (cheader_filename != NULL);
1354
 
        self->priv->cheader_filenames = (_tmp0_ = (ValaList*) vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, g_direct_equal), _vala_collection_object_unref0 (self->priv->cheader_filenames), _tmp0_);
1355
 
        vala_collection_add ((ValaCollection*) self->priv->cheader_filenames, cheader_filename);
1356
 
}
1357
 
 
1358
 
 
1359
 
void vala_namespace_add_cheader_filename (ValaNamespace* self, const char* cheader_filename) {
1360
 
        g_return_if_fail (self != NULL);
1361
 
        g_return_if_fail (cheader_filename != NULL);
1362
 
        vala_collection_add ((ValaCollection*) self->priv->cheader_filenames, cheader_filename);
1363
 
}
1364
 
 
1365
 
 
1366
1478
static void vala_namespace_process_ccode_attribute (ValaNamespace* self, ValaAttribute* a) {
1367
1479
        g_return_if_fail (self != NULL);
1368
1480
        g_return_if_fail (a != NULL);
1411
1523
                                char* filename;
1412
1524
                                filename = g_strdup (filename_collection[filename_it]);
1413
1525
                                {
1414
 
                                        vala_collection_add ((ValaCollection*) self->priv->cheader_filenames, filename);
 
1526
                                        vala_symbol_add_cheader_filename ((ValaSymbol*) self, filename);
1415
1527
                                        _g_free0 (filename);
1416
1528
                                }
1417
1529
                        }
1437
1549
}
1438
1550
 
1439
1551
 
 
1552
/**
 
1553
 * Process all associated attributes.
 
1554
 */
1440
1555
void vala_namespace_process_attributes (ValaNamespace* self) {
1441
1556
        g_return_if_fail (self != NULL);
1442
1557
        {
1495
1610
        VALA_CODE_NODE_CLASS (klass)->accept_children = vala_namespace_real_accept_children;
1496
1611
        VALA_SYMBOL_CLASS (klass)->get_cprefix = vala_namespace_real_get_cprefix;
1497
1612
        VALA_SYMBOL_CLASS (klass)->get_lower_case_cprefix = vala_namespace_real_get_lower_case_cprefix;
1498
 
        VALA_SYMBOL_CLASS (klass)->get_cheader_filenames = vala_namespace_real_get_cheader_filenames;
1499
1613
        VALA_CODE_NODE_CLASS (klass)->check = vala_namespace_real_check;
1500
1614
}
1501
1615
 
1513
1627
        self->priv->methods = (ValaList*) vala_array_list_new (VALA_TYPE_METHOD, (GBoxedCopyFunc) vala_code_node_ref, vala_code_node_unref, g_direct_equal);
1514
1628
        self->priv->comments = (ValaList*) vala_array_list_new (VALA_TYPE_COMMENT, (GBoxedCopyFunc) vala_comment_ref, vala_comment_unref, g_direct_equal);
1515
1629
        self->priv->cprefixes = (ValaList*) vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, g_direct_equal);
1516
 
        self->priv->cheader_filenames = (ValaList*) vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, g_direct_equal);
1517
1630
        self->priv->namespaces = (ValaList*) vala_array_list_new (VALA_TYPE_NAMESPACE, (GBoxedCopyFunc) vala_code_node_ref, vala_code_node_unref, g_direct_equal);
1518
1631
        self->priv->using_directives = (ValaList*) vala_array_list_new (VALA_TYPE_USING_DIRECTIVE, (GBoxedCopyFunc) vala_code_node_ref, vala_code_node_unref, g_direct_equal);
1519
1632
}
1534
1647
        _vala_collection_object_unref0 (self->priv->comments);
1535
1648
        _vala_collection_object_unref0 (self->priv->cprefixes);
1536
1649
        _g_free0 (self->priv->lower_case_cprefix);
1537
 
        _vala_collection_object_unref0 (self->priv->cheader_filenames);
1538
1650
        _vala_collection_object_unref0 (self->priv->namespaces);
1539
1651
        _vala_collection_object_unref0 (self->priv->using_directives);
1540
1652
        VALA_CODE_NODE_CLASS (vala_namespace_parent_class)->finalize (obj);
1541
1653
}
1542
1654
 
1543
1655
 
 
1656
/**
 
1657
 * Represents a namespace declaration in the source code.
 
1658
 */
1544
1659
GType vala_namespace_get_type (void) {
1545
1660
        static volatile gsize vala_namespace_type_id__volatile = 0;
1546
1661
        if (g_once_init_enter (&vala_namespace_type_id__volatile)) {