[Vala] Vala on win32
- From: Hans Breuer <hans breuer org>
- To: vala paldo org
- Subject: [Vala] Vala on win32
- Date: Sun, 06 May 2007 22:58:51 +0200
Hi,
recently I stumbled over Vala and immediately liked the concept. As a long
term win32 gtk+ developer the first thing I've done was to port Vala to
win32 following the pattern from:
http://svn.gnome.org/viewcvs/glib/trunk/README.win32?revision=5294&view=markup
Given that the Vala compiler is written in Vala but the generated C source
was not compilable as is with msvc, I needed a combination of modifying
generated sources and regeneration on linux.
Is the following patch acceptable?
* vapi/glib-2.0.vala : instead of strtoll() map to g_ascii_strtoll() to for
increased portability
* gobject/valacodegenerator.vala : avoid empty struct declaration which is
a gccism
* gobject/valacodegeneratorclass.vala gobject/valacodegeneratormethod.vala
vala/valatyperegisterfunction.vala : don't use of 'cdecl' as variable name,
it's a keyword to specify the calling convention with windoze compilers
* vala/parser.y : declare variables at the beginning of blocks as required
for c89
There are much more issues with the use of c99 and the msvc compiler, but
I've written a Python script to deal with them.
Thanks,
Hans
-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it. -- Dilbert
Index: gobject/valacodegenerator.vala
===================================================================
--- gobject/valacodegenerator.vala (revision 306)
+++ gobject/valacodegenerator.vala (working copy)
@@ -291,18 +291,18 @@
public override void visit_constant (Constant! c) {
if (c.symbol.parent_symbol.node is DataType) {
var t = (DataType) c.symbol.parent_symbol.node;
- var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
+ var c_decl = new CCodeDeclaration (c.type_reference.get_const_cname ());
var arr = "";
if (c.type_reference.data_type is Array) {
arr = "[]";
}
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("%s%s".printf
(c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode));
- cdecl.modifiers = CCodeModifiers.STATIC;
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer ("%s%s".printf
(c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode));
+ c_decl.modifiers = CCodeModifiers.STATIC;
if (c.access != MemberAccessibility.PRIVATE) {
- header_type_member_declaration.append (cdecl);
+ header_type_member_declaration.append (c_decl);
} else {
- source_type_member_declaration.append (cdecl);
+ source_type_member_declaration.append (c_decl);
}
}
}
@@ -323,14 +323,14 @@
} else {
if (f.symbol.parent_symbol.node is DataType) {
var t = (DataType) f.symbol.parent_symbol.node;
- var cdecl = new CCodeDeclaration (f.type_reference.get_cname ());
+ var c_decl = new CCodeDeclaration (f.type_reference.get_cname ());
var var_decl = new CCodeVariableDeclarator (f.get_cname ());
if (f.initializer != null) {
var_decl.initializer = (CCodeExpression)
f.initializer.ccodenode;
}
- cdecl.add_declarator (var_decl);
- cdecl.modifiers = CCodeModifiers.STATIC;
- source_type_member_declaration.append (cdecl);
+ c_decl.add_declarator (var_decl);
+ c_decl.modifiers = CCodeModifiers.STATIC;
+ source_type_member_declaration.append (c_decl);
}
}
}
@@ -508,17 +508,17 @@
var cblock = new CCodeBlock ();
- var cdecl = new CCodeDeclaration ("GObject *");
- cdecl.add_declarator (new CCodeVariableDeclarator ("obj"));
- cblock.add_statement (cdecl);
+ var c_decl = new CCodeDeclaration ("GObject *");
+ c_decl.add_declarator (new CCodeVariableDeclarator ("obj"));
+ cblock.add_statement (c_decl);
- cdecl = new CCodeDeclaration ("%sClass *".printf (cl.get_cname ()));
- cdecl.add_declarator (new CCodeVariableDeclarator ("klass"));
- cblock.add_statement (cdecl);
+ c_decl = new CCodeDeclaration ("%sClass *".printf (cl.get_cname ()));
+ c_decl.add_declarator (new CCodeVariableDeclarator ("klass"));
+ cblock.add_statement (c_decl);
- cdecl = new CCodeDeclaration ("GObjectClass *");
- cdecl.add_declarator (new CCodeVariableDeclarator ("parent_class"));
- cblock.add_statement (cdecl);
+ c_decl = new CCodeDeclaration ("GObjectClass *");
+ c_decl.add_declarator (new CCodeVariableDeclarator ("parent_class"));
+ cblock.add_statement (c_decl);
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_peek"));
@@ -544,10 +544,10 @@
ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_upper_case_cname (null)));
ccall.add_argument (new CCodeIdentifier ("obj"));
- cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
+ c_decl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
- cblock.add_statement (cdecl);
+ cblock.add_statement (c_decl);
cblock.add_statement (c.body.ccodenode);
@@ -574,11 +574,11 @@
ccall.add_argument (new CCodeConstant ("__params_it - __params"));
ccall.add_argument (new CCodeConstant ("__params"));
- var cdecl = new CCodeVariableDeclarator ("self");
- cdecl.initializer = ccall;
+ var c_decl = new CCodeVariableDeclarator ("self");
+ c_decl.initializer = ccall;
var cdeclaration = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
- cdeclaration.add_declarator (cdecl);
+ cdeclaration.add_declarator (c_decl);
b.add_statement (cdeclaration);
}
@@ -640,11 +640,11 @@
var cfrag = new CCodeFragment ();
foreach (VariableDeclarator decl in stmt.declaration.get_variable_declarators ()) {
- var cdecl = new CCodeDeclaration (decl.type_reference.get_cname (false,
!decl.type_reference.takes_ownership));
+ var c_decl = new CCodeDeclaration (decl.type_reference.get_cname (false,
!decl.type_reference.takes_ownership));
- cdecl.add_declarator ((CCodeVariableDeclarator) decl.ccodenode);
+ c_decl.add_declarator ((CCodeVariableDeclarator) decl.ccodenode);
- cfrag.append (cdecl);
+ cfrag.append (c_decl);
/* try to initialize uninitialized variables */
if (decl.initializer == null && decl.type_reference.data_type is Struct) {
@@ -897,16 +897,16 @@
private void append_temp_decl (CCodeFragment! cfrag, List<VariableDeclarator> temp_vars) {
foreach (VariableDeclarator decl in temp_vars) {
- var cdecl = new CCodeDeclaration (decl.type_reference.get_cname (true,
!decl.type_reference.takes_ownership));
+ var c_decl = new CCodeDeclaration (decl.type_reference.get_cname (true,
!decl.type_reference.takes_ownership));
var vardecl = new CCodeVariableDeclarator (decl.name);
- cdecl.add_declarator (vardecl);
+ c_decl.add_declarator (vardecl);
if (decl.type_reference.data_type != null &&
decl.type_reference.data_type.is_reference_type ()) {
vardecl.initializer = new CCodeConstant ("NULL");
}
- cfrag.append (cdecl);
+ cfrag.append (c_decl);
}
}
@@ -1100,9 +1100,9 @@
var cbody = new CCodeBlock ();
- var cdecl = new CCodeDeclaration (stmt.type_reference.get_cname ());
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer
(stmt.variable_name, new CCodeIdentifier ("*%s".printf (it_name))));
- cbody.add_statement (cdecl);
+ var c_decl = new CCodeDeclaration (stmt.type_reference.get_cname ());
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer
(stmt.variable_name, new CCodeIdentifier ("*%s".printf (it_name))));
+ cbody.add_statement (c_decl);
cbody.add_statement (stmt.body.ccodenode);
@@ -1124,9 +1124,9 @@
var cbody = new CCodeBlock ();
- var cdecl = new CCodeDeclaration (stmt.type_reference.get_cname ());
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer
(stmt.variable_name, new CCodeElementAccess (new CCodeIdentifier (collection_backup.name), new
CCodeIdentifier (it_name))));
- cbody.add_statement (cdecl);
+ var c_decl = new CCodeDeclaration (stmt.type_reference.get_cname ());
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer
(stmt.variable_name, new CCodeElementAccess (new CCodeIdentifier (collection_backup.name), new
CCodeIdentifier (it_name))));
+ cbody.add_statement (c_decl);
cbody.add_statement (stmt.body.ccodenode);
@@ -1177,9 +1177,9 @@
}
}
- var cdecl = new CCodeDeclaration (stmt.type_reference.get_cname ());
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer
(stmt.variable_name, element_expr));
- cbody.add_statement (cdecl);
+ var c_decl = new CCodeDeclaration (stmt.type_reference.get_cname ());
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer
(stmt.variable_name, element_expr));
+ cbody.add_statement (c_decl);
cbody.add_statement (stmt.body.ccodenode);
Index: gobject/valacodegeneratorclass.vala
===================================================================
--- gobject/valacodegeneratorclass.vala (revision 306)
+++ gobject/valacodegeneratorclass.vala (working copy)
@@ -78,9 +78,12 @@
}
header_type_definition.append (instance_struct);
header_type_definition.append (type_struct);
- source_type_member_declaration.append (instance_priv_struct);
- macro = "(G_TYPE_INSTANCE_GET_PRIVATE ((o), %s, %sPrivate))".printf (cl.get_upper_case_cname
("TYPE_"), cl.get_cname ());
- source_type_member_declaration.append (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf
(cl.get_upper_case_cname (null)), macro));
+ /* only add the *Private struct if it is not empty, i.e. we actually have private data */
+ if (cl.has_private_fields) {
+ source_type_member_declaration.append (instance_priv_struct);
+ macro = "(G_TYPE_INSTANCE_GET_PRIVATE ((o), %s, %sPrivate))".printf
(cl.get_upper_case_cname ("TYPE_"), cl.get_cname ());
+ source_type_member_declaration.append (new CCodeMacroReplacement
("%s_GET_PRIVATE(o)".printf (cl.get_upper_case_cname (null)), macro));
+ }
source_type_member_declaration.append (prop_enum);
}
@@ -310,20 +313,20 @@
var ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_upper_case_cname (null)));
ccall.add_argument (new CCodeIdentifier ("obj"));
- var cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
+ var c_decl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
- cblock.add_statement (cdecl);
+ cblock.add_statement (c_decl);
cblock.add_statement (instance_dispose_fragment);
- cdecl = new CCodeDeclaration ("%sClass *".printf (cl.get_cname ()));
- cdecl.add_declarator (new CCodeVariableDeclarator ("klass"));
- cblock.add_statement (cdecl);
+ c_decl = new CCodeDeclaration ("%sClass *".printf (cl.get_cname ()));
+ c_decl.add_declarator (new CCodeVariableDeclarator ("klass"));
+ cblock.add_statement (c_decl);
- cdecl = new CCodeDeclaration ("GObjectClass *");
- cdecl.add_declarator (new CCodeVariableDeclarator ("parent_class"));
- cblock.add_statement (cdecl);
+ c_decl = new CCodeDeclaration ("GObjectClass *");
+ c_decl.add_declarator (new CCodeVariableDeclarator ("parent_class"));
+ cblock.add_statement (c_decl);
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_peek"));
@@ -386,9 +389,9 @@
var ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_upper_case_cname (null)));
ccall.add_argument (new CCodeIdentifier ("object"));
- var cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
- block.add_statement (cdecl);
+ var c_decl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
+ block.add_statement (c_decl);
var cswitch = new CCodeSwitchStatement (new CCodeIdentifier ("property_id"));
var props = cl.get_properties ();
@@ -434,9 +437,9 @@
var ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_upper_case_cname (null)));
ccall.add_argument (new CCodeIdentifier ("object"));
- var cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
- block.add_statement (cdecl);
+ var c_decl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
+ block.add_statement (c_decl);
var cswitch = new CCodeSwitchStatement (new CCodeIdentifier ("property_id"));
var props = cl.get_properties ();
Index: gobject/valacodegeneratormethod.vala
===================================================================
--- gobject/valacodegeneratormethod.vala (revision 306)
+++ gobject/valacodegeneratormethod.vala (working copy)
@@ -216,10 +216,10 @@
var ccall = new CCodeFunctionCall (new CCodeIdentifier
(cl.get_upper_case_cname (null)));
ccall.add_argument (new CCodeIdentifier ("base"));
- var cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname
()));
- cdecl.add_declarator (new
CCodeVariableDeclarator.with_initializer ("self", ccall));
+ var c_decl = new CCodeDeclaration ("%s *".printf
(cl.get_cname ()));
+ c_decl.add_declarator (new
CCodeVariableDeclarator.with_initializer ("self", ccall));
- cinit.append (cdecl);
+ cinit.append (c_decl);
} else if (m.instance) {
cinit.append (create_method_type_check_statement (m, cl,
true, "self"));
}
@@ -249,13 +249,13 @@
cparamsinit.add_argument (new CCodeIdentifier ("GParameter"));
cparamsinit.add_argument (new CCodeConstant
(n_params.to_string ()));
- var cdecl = new CCodeDeclaration ("GParameter *");
- cdecl.add_declarator (new
CCodeVariableDeclarator.with_initializer ("__params", cparamsinit));
- cinit.append (cdecl);
+ var c_decl = new CCodeDeclaration ("GParameter *");
+ c_decl.add_declarator (new
CCodeVariableDeclarator.with_initializer ("__params", cparamsinit));
+ cinit.append (c_decl);
- cdecl = new CCodeDeclaration ("GParameter *");
- cdecl.add_declarator (new
CCodeVariableDeclarator.with_initializer ("__params_it", new CCodeIdentifier ("__params")));
- cinit.append (cdecl);
+ c_decl = new CCodeDeclaration ("GParameter *");
+ c_decl.add_declarator (new
CCodeVariableDeclarator.with_initializer ("__params_it", new CCodeIdentifier ("__params")));
+ cinit.append (c_decl);
/* destroy func properties for generic types */
foreach (TypeParameter type_param in
current_class.get_type_parameters ()) {
@@ -290,12 +290,12 @@
}
} else {
var st = (Struct) m.symbol.parent_symbol.node;
- var cdecl = new CCodeDeclaration (st.get_cname () + "*");
+ var c_decl = new CCodeDeclaration (st.get_cname () + "*");
var ccall = new CCodeFunctionCall (new CCodeIdentifier
("g_new0"));
ccall.add_argument (new CCodeConstant (st.get_cname ()));
ccall.add_argument (new CCodeConstant ("1"));
- cdecl.add_declarator (new
CCodeVariableDeclarator.with_initializer ("self", ccall));
- cinit.append (cdecl);
+ c_decl.add_declarator (new
CCodeVariableDeclarator.with_initializer ("self", ccall));
+ cinit.append (c_decl);
}
}
Index: vala/parser.y
===================================================================
--- vala/parser.y (revision 306)
+++ vala/parser.y (working copy)
@@ -1575,6 +1575,8 @@
: comment IF open_parens expression CLOSE_PARENS embedded_statement
{
ValaBlock *true_block;
+ ValaSourceReference *src;
+
if (VALA_IS_BLOCK ($6)) {
true_block = VALA_BLOCK ($6);
} else {
@@ -1583,7 +1585,7 @@
g_object_unref ($6);
}
- ValaSourceReference *src = src_com(@4, $1);
+ src = src_com(@4, $1);
$$ = VALA_STATEMENT (vala_if_statement_new ($4, true_block, NULL, src));
g_object_unref (src);
g_object_unref ($4);
@@ -1592,6 +1594,9 @@
| comment IF open_parens expression CLOSE_PARENS embedded_statement ELSE embedded_statement
{
ValaBlock *true_block;
+ ValaBlock *false_block;
+ ValaSourceReference *src;
+
if (VALA_IS_BLOCK ($6)) {
true_block = VALA_BLOCK ($6);
} else {
@@ -1600,7 +1605,6 @@
g_object_unref ($6);
}
- ValaBlock *false_block;
if (VALA_IS_BLOCK ($8)) {
false_block = VALA_BLOCK ($8);
} else {
@@ -1609,7 +1613,7 @@
g_object_unref ($8);
}
- ValaSourceReference *src = src_com(@4, $1);
+ src = src_com(@4, $1);
$$ = VALA_STATEMENT (vala_if_statement_new ($4, true_block, false_block, src));
g_object_unref (src);
g_object_unref ($4);
@@ -1666,11 +1670,11 @@
switch_section
: comment switch_labels statement_list
{
+ GList *l;
ValaSourceReference *src = src_com(@2, $1);
$$ = vala_switch_section_new (src);
g_object_unref (src);
- GList *l;
for (l = $2; l != NULL; l = l->next) {
vala_switch_section_add_label ($$, l->data);
g_object_unref (l->data);
@@ -1743,6 +1747,7 @@
for_statement
: FOR OPEN_PARENS opt_statement_expression_list SEMICOLON opt_expression SEMICOLON
opt_statement_expression_list CLOSE_PARENS embedded_statement
{
+ GList *l;
ValaSourceReference *src = src(@1);
$$ = VALA_STATEMENT (vala_for_statement_new ($5, $9, src));
if ($5 != NULL) {
@@ -1751,7 +1756,6 @@
g_object_unref ($9);
g_object_unref (src);
- GList *l;
if ($3 != NULL) {
for (l = $3; l != NULL; l = l->next) {
vala_for_statement_add_initializer (VALA_FOR_STATEMENT ($$), l->data);
@@ -1769,6 +1773,11 @@
}
| FOR OPEN_PARENS local_variable_declaration SEMICOLON opt_expression SEMICOLON
opt_statement_expression_list CLOSE_PARENS embedded_statement
{
+ GList *l;
+ GList* decls;
+
+ ValaDeclarationStatement *decl_statement;
+
ValaSourceReference *src = src(@1);
ValaBlock *block = vala_block_new (src);
@@ -1779,9 +1788,8 @@
}
g_object_unref ($9);
- GList *l;
- GList* decls = vala_local_variable_declaration_get_variable_declarators ($3);
+ decls = vala_local_variable_declaration_get_variable_declarators ($3);
for (l = decls; l != NULL; l = l->next) {
ValaVariableDeclarator *decl = l->data;
ValaExpression *init = vala_variable_declarator_get_initializer (decl);
@@ -1799,7 +1807,7 @@
}
g_list_free (decls);
- ValaDeclarationStatement *decl_statement = vala_declaration_statement_new ($3, src);
+ decl_statement = vala_declaration_statement_new ($3, src);
g_object_unref ($3);
g_object_unref (src);
vala_block_add_statement (block, VALA_STATEMENT (decl_statement));
@@ -1903,6 +1911,7 @@
try_statement
: TRY block catch_clauses opt_finally_clause
{
+ GList *l;
ValaSourceReference *src = src(@1);
$$ = VALA_STATEMENT (vala_try_statement_new (VALA_BLOCK ($2), VALA_BLOCK ($4), src));
g_object_unref ($2);
@@ -1911,7 +1920,6 @@
}
g_object_unref (src);
- GList *l;
for (l = $3; l != NULL; l = l->next) {
vala_try_statement_add_catch_clause (VALA_TRY_STATEMENT ($$), l->data);
g_object_unref (l->data);
@@ -2218,6 +2226,9 @@
class_declaration
: comment opt_attributes opt_access_modifier opt_modifiers CLASS identifier opt_name_specifier
opt_type_parameter_list opt_class_base
{
+ GList *l;
+ ValaSourceReference *src;
+
char *name = $6;
if ($7 != NULL) {
@@ -2233,8 +2244,7 @@
name = $7;
}
- GList *l;
- ValaSourceReference *src = src_com(@6, $1);
+ src = src_com(@6, $1);
current_class = vala_class_new (name, src);
g_free (name);
g_object_unref (src);
@@ -2448,12 +2458,14 @@
field_declaration
: comment opt_attributes opt_access_modifier opt_modifiers type variable_declarator SEMICOLON
{
+ ValaSourceReference *src;
+
if (!vala_type_reference_get_is_weak ($5)) {
vala_type_reference_set_takes_ownership ($5, TRUE);
}
vala_type_reference_set_is_ref ($5, FALSE);
- ValaSourceReference *src = src_com(@5, $1);
+ src = src_com(@5, $1);
$$ = vala_field_new (vala_variable_declarator_get_name ($6), $5,
vala_variable_declarator_get_initializer ($6), src);
g_object_unref (src);
if ($3 != 0) {
@@ -2564,12 +2576,13 @@
: comment opt_attributes opt_access_modifier opt_modifiers type identifier OPEN_PARENS
opt_formal_parameter_list CLOSE_PARENS opt_throws_declaration
{
GList *l;
+ ValaSourceReference *src;
if (!vala_type_reference_get_is_weak ($5)) {
vala_type_reference_set_transfers_ownership ($5, TRUE);
}
- ValaSourceReference *src = src_com(@6, $1);
+ src = src_com(@6, $1);
$$ = vala_method_new ($6, $5, src);
g_object_unref (src);
if ($3 != 0) {
@@ -2682,12 +2695,14 @@
fixed_parameter
: opt_attributes opt_construct type identifier
{
+ ValaSourceReference *src;
+
if (vala_type_reference_get_is_ref ($3) && vala_type_reference_get_is_out ($3)) {
vala_type_reference_set_takes_ownership ($3, TRUE);
vala_type_reference_set_is_ref ($3, FALSE);
}
- ValaSourceReference *src = src(@3);
+ src = src(@3);
$$ = vala_formal_parameter_new ($4, $3, src);
g_object_unref (src);
vala_formal_parameter_set_construct_parameter ($$, $2);
@@ -2696,12 +2711,14 @@
}
| opt_attributes opt_construct type identifier ASSIGN expression
{
+ ValaSourceReference *src;
+
if (vala_type_reference_get_is_ref ($3) && vala_type_reference_get_is_out ($3)) {
vala_type_reference_set_takes_ownership ($3, TRUE);
vala_type_reference_set_is_ref ($3, FALSE);
}
- ValaSourceReference *src = src(@3);
+ src = src(@3);
$$ = vala_formal_parameter_new ($4, $3, src);
g_object_unref (src);
vala_formal_parameter_set_default_expression ($$, $6);
@@ -2730,11 +2747,13 @@
property_declaration
: comment opt_attributes opt_access_modifier opt_modifiers type identifier OPEN_BRACE
get_accessor_declaration opt_set_accessor_declaration CLOSE_BRACE
{
+ ValaSourceReference *src;
+
if (!vala_type_reference_get_is_weak ($5)) {
vala_type_reference_set_takes_ownership ($5, TRUE);
}
- ValaSourceReference *src = src_com(@5, $1);
+ src = src_com(@5, $1);
$$ = vala_property_new ($6, $5, $8, $9, src);
g_object_unref (src);
@@ -2759,11 +2778,13 @@
}
| comment opt_attributes opt_access_modifier opt_modifiers type identifier OPEN_BRACE
set_accessor_declaration CLOSE_BRACE
{
+ ValaSourceReference *src;
+
if (!vala_type_reference_get_is_weak ($5)) {
vala_type_reference_set_takes_ownership ($5, TRUE);
}
- ValaSourceReference *src = src_com(@5, $1);
+ src = src_com(@5, $1);
$$ = vala_property_new ($6, $5, NULL, $8, src);
g_object_unref (src);
@@ -2901,6 +2922,9 @@
struct_header
: comment opt_attributes opt_access_modifier STRUCT identifier opt_name_specifier
opt_type_parameter_list opt_class_base
{
+ GList *l;
+ ValaSourceReference *src;
+
char *name = $5;
if ($6 != NULL) {
@@ -2916,8 +2940,7 @@
name = $6;
}
- GList *l;
- ValaSourceReference *src = src_com(@5, $1);
+ src = src_com(@5, $1);
$$ = vala_struct_new (name, src);
g_free (name);
g_object_unref (src);
@@ -2974,6 +2997,7 @@
interface_declaration
: comment opt_attributes opt_access_modifier opt_modifiers INTERFACE identifier opt_name_specifier
opt_type_parameter_list opt_class_base
{
+ ValaSourceReference *src;
char *name = $6;
if ($7 != NULL) {
@@ -2989,7 +3013,7 @@
name = $7;
}
- ValaSourceReference *src = src_com(@6, $1);
+ src = src_com(@6, $1);
current_interface = vala_interface_new (name, src);
g_free (name);
g_object_unref (src);
@@ -3068,6 +3092,9 @@
enum_declaration
: comment opt_attributes opt_access_modifier ENUM identifier opt_name_specifier enum_body
{
+ GList *l;
+ ValaSourceReference *src;
+
char *name = $5;
if ($6 != NULL) {
@@ -3083,8 +3110,7 @@
name = $6;
}
- GList *l;
- ValaSourceReference *src = src_com(@5, $1);
+ src = src_com(@5, $1);
$$ = vala_enum_new (name, src);
g_free (name);
g_object_unref (src);
@@ -3144,6 +3170,8 @@
flags_declaration
: comment opt_attributes opt_access_modifier FLAGS identifier opt_name_specifier flags_body
{
+ ValaSourceReference *src;
+
char *name = $5;
if ($6 != NULL) {
@@ -3159,21 +3187,10 @@
name = $6;
}
- GList *l;
- ValaSourceReference *src = src_com(@5, $1);
+ src = src_com(@5, $1);
$$ = vala_flags_new (name, src);
g_free (name);
g_object_unref (src);
-
- VALA_CODE_NODE($$)->attributes = $2;
-
- if ($3 != 0) {
- VALA_DATA_TYPE($$)->access = $3;
- }
- for (l = $7; l != NULL; l = l->next) {
- vala_flags_add_value ($$, l->data);
- g_object_unref (l->data);
- }
}
;
@@ -3220,6 +3237,7 @@
callback_declaration
: comment opt_attributes opt_access_modifier CALLBACK type identifier opt_name_specifier
opt_type_parameter_list OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS SEMICOLON
{
+ ValaSourceReference *src;
GList *l;
char *name = $6;
@@ -3236,7 +3254,7 @@
name = $7;
}
- ValaSourceReference *src = src_com(@6, $1);
+ src = src_com(@6, $1);
$$ = vala_callback_new (name, $5, src);
g_free (name);
g_object_unref ($5);
Index: vala/valatyperegisterfunction.vala
===================================================================
--- vala/valatyperegisterfunction.vala (revision 306)
+++ vala/valatyperegisterfunction.vala (working copy)
@@ -37,13 +37,13 @@
string type_id_name = "%s_type_id".printf (get_type_declaration ().get_lower_case_cname
(null));
var type_block = new CCodeBlock ();
- var cdecl = new CCodeDeclaration ("GType");
- cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer (type_id_name, new
CCodeConstant ("0")));
- cdecl.modifiers = CCodeModifiers.STATIC;
+ var c_decl = new CCodeDeclaration ("GType");
+ c_decl.add_declarator (new CCodeVariableDeclarator.with_initializer (type_id_name, new
CCodeConstant ("0")));
+ c_decl.modifiers = CCodeModifiers.STATIC;
if (!plugin) {
- type_block.add_statement (cdecl);
+ type_block.add_statement (c_decl);
} else {
- definition_fragment.append (cdecl);
+ definition_fragment.append (c_decl);
}
CCodeFunction fun;
Index: vapi/glib-2.0.vala
===================================================================
--- vapi/glib-2.0.vala (revision 306)
+++ vapi/glib-2.0.vala (working copy)
@@ -491,7 +491,7 @@
[CCode (cname = "atoi")]
public int to_int ();
- [CCode (cname = "strtoll")]
+ [CCode (cname = "g_ascii_strtoll")]
public int64 to_int64 (out string endptr = null, int _base = 0);
[CCode (cname = "strlen")]
public long size ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]