vala r1694 - in trunk: . ccode gobject
- From: jaredm svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1694 - in trunk: . ccode gobject
- Date: Thu, 10 Jul 2008 16:05:11 +0000 (UTC)
Author: jaredm
Date: Thu Jul 10 16:05:10 2008
New Revision: 1694
URL: http://svn.gnome.org/viewvc/vala?rev=1694&view=rev
Log:
2008-07-10 Jared Moore <jaredm svn gnome org>
* ccode/valaccodedeclaration.vala:
* ccode/valaccodemodifiers.vala:
Added support for 'volatile' modifier in C code.
* gobject/valatyperegisterfunction.vala:
Make *_get_type functions thread safe, fixes bug 540705.
Added:
trunk/ (props changed)
- copied from r1690, /trunk/
Modified:
trunk/ChangeLog
trunk/ccode/valaccodedeclaration.vala
trunk/ccode/valaccodemodifiers.vala
trunk/gobject/valatyperegisterfunction.vala
Modified: trunk/ccode/valaccodedeclaration.vala
==============================================================================
--- /trunk/ccode/valaccodedeclaration.vala (original)
+++ trunk/ccode/valaccodedeclaration.vala Thu Jul 10 16:05:10 2008
@@ -59,6 +59,9 @@
if ((modifiers & CCodeModifiers.STATIC) != 0) {
writer.write_string ("static ");
}
+ if ((modifiers & CCodeModifiers.VOLATILE) != 0) {
+ writer.write_string ("volatile ");
+ }
if ((modifiers & CCodeModifiers.EXTERN) != 0 && !has_initializer ()) {
writer.write_string ("extern ");
}
Modified: trunk/ccode/valaccodemodifiers.vala
==============================================================================
--- /trunk/ccode/valaccodemodifiers.vala (original)
+++ trunk/ccode/valaccodemodifiers.vala Thu Jul 10 16:05:10 2008
@@ -29,5 +29,6 @@
STATIC = 1 << 0,
REGISTER = 1 << 1,
EXTERN = 1 << 2,
- INLINE = 1 << 3
+ INLINE = 1 << 3,
+ VOLATILE = 1 << 4
}
Modified: trunk/gobject/valatyperegisterfunction.vala
==============================================================================
--- /trunk/gobject/valatyperegisterfunction.vala (original)
+++ trunk/gobject/valatyperegisterfunction.vala Thu Jul 10 16:05:10 2008
@@ -45,7 +45,7 @@
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;
+ cdecl.modifiers = CCodeModifiers.STATIC | CCodeModifiers.VOLATILE;
if (!plugin) {
type_block.add_statement (cdecl);
} else {
@@ -110,14 +110,26 @@
reg_call.add_argument (new CCodeIdentifier ("&g_define_type_fundamental_info"));
}
reg_call.add_argument (new CCodeConstant (get_type_flags ()));
- type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier (type_id_name), reg_call)));
+
+ string temp_type_id_name = "%s_type_id_temp".printf (get_type_declaration ().get_lower_case_cname (null));
+ if (!plugin) {
+ var temp_decl = new CCodeDeclaration ("GType");
+ temp_decl.add_declarator (new CCodeVariableDeclarator.with_initializer (temp_type_id_name, reg_call));
+ type_init.add_statement (temp_decl);
+ } else {
+ type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier (type_id_name), reg_call)));
+ }
type_init.add_statement (get_type_interface_init_statements ());
if (!plugin) {
- var cond = new CCodeFunctionCall (new CCodeIdentifier ("G_UNLIKELY"));
- cond.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeIdentifier (type_id_name), new CCodeConstant ("0")));
- var cif = new CCodeIfStatement (cond, type_init);
+ var enter = new CCodeFunctionCall (new CCodeIdentifier ("g_once_init_enter"));
+ enter.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (type_id_name)));
+ var leave = new CCodeFunctionCall (new CCodeIdentifier ("g_once_init_leave"));
+ leave.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (type_id_name)));
+ leave.add_argument (new CCodeIdentifier (temp_type_id_name));
+ type_init.add_statement (new CCodeExpressionStatement (leave));
+ var cif = new CCodeIfStatement (enter, type_init);
type_block.add_statement (cif);
} else {
type_block = type_init;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]