[vala] codegen: Use builder API for regex init function
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Use builder API for regex init function
- Date: Sun, 10 Oct 2010 16:39:27 +0000 (UTC)
commit 074717dae750526cc4d92c771bae0d5cefa25a18
Author: Jürg Billeter <j bitron ch>
Date: Sun Oct 10 11:57:12 2010 +0200
codegen: Use builder API for regex init function
codegen/valaccodebasemodule.vala | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 9b01ab5..2d1aa31 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3409,28 +3409,30 @@ public class Vala.CCodeBaseModule : CodeGenerator {
fun.add_parameter (new CCodeFormalParameter ("re", "GRegex**"));
fun.add_parameter (new CCodeFormalParameter ("pattern", "const gchar *"));
fun.add_parameter (new CCodeFormalParameter ("match_options", "GRegexMatchFlags"));
- fun.block = new CCodeBlock ();
+
+ push_function (fun);
var once_enter_call = new CCodeFunctionCall (new CCodeIdentifier ("g_once_init_enter"));
once_enter_call.add_argument (new CCodeConstant ("(volatile gsize*) re"));
-
- var if_block = new CCodeBlock ();
+ ccode.open_if (once_enter_call);
var regex_new_call = new CCodeFunctionCall (new CCodeIdentifier ("g_regex_new"));
regex_new_call.add_argument (new CCodeConstant ("pattern"));
regex_new_call.add_argument (new CCodeConstant ("match_options"));
regex_new_call.add_argument (new CCodeConstant ("0"));
regex_new_call.add_argument (new CCodeConstant ("NULL"));
- if_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("GRegex* val"), regex_new_call)));
+ ccode.add_expression (new CCodeAssignment (new CCodeIdentifier ("GRegex* val"), regex_new_call));
var once_leave_call = new CCodeFunctionCall (new CCodeIdentifier ("g_once_init_leave"));
once_leave_call.add_argument (new CCodeConstant ("(volatile gsize*) re"));
once_leave_call.add_argument (new CCodeConstant ("(gsize) val"));
- if_block.add_statement (new CCodeExpressionStatement (once_leave_call));
+ ccode.add_expression (once_leave_call);
+
+ ccode.close ();
+
+ ccode.add_return (new CCodeIdentifier ("*re"));
- var if_stat = new CCodeIfStatement (once_enter_call, if_block);
- fun.block.add_statement (if_stat);
- fun.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("*re")));
+ pop_function ();
cfile.add_function (fun);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]