[beast/win32] Replace printf with g_print, so that our %-sequences work as expected.
- From: Stefan Westerfeld <stw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [beast/win32] Replace printf with g_print, so that our %-sequences work as expected.
- Date: Sat, 29 Aug 2009 14:28:57 +0000 (UTC)
commit 0d87a2c097da032e514ad430073c239ad9778d02
Author: Stefan Westerfeld <stefan space twc de>
Date: Sat Aug 29 14:28:19 2009 +0200
Replace printf with g_print, so that our %-sequences work as expected.
sfi/sfidl-cbase.cc | 450 ++++++++++++++--------------
sfi/sfidl-clientc.cc | 20 +-
sfi/sfidl-clientcxx.cc | 344 +++++++++++-----------
sfi/sfidl-corec.cc | 598 +++++++++++++++++++-------------------
sfi/sfidl-corecxx.cc | 766 ++++++++++++++++++++++++------------------------
sfi/sfidl-hostc.cc | 78 +++---
sfi/sfidl-options.cc | 36 ++--
7 files changed, 1146 insertions(+), 1146 deletions(-)
---
diff --git a/sfi/sfidl-cbase.cc b/sfi/sfidl-cbase.cc
index ea86bbd..a417a6e 100644
--- a/sfi/sfidl-cbase.cc
+++ b/sfi/sfidl-cbase.cc
@@ -507,33 +507,33 @@ void CodeGeneratorCBase::printProcedure (const Method& mdef, bool proto, const S
}
bool first = true;
- printf("%s%s%s (", cTypeRet (mdef.result.type), proto?" ":"\n", mname.c_str());
+ g_print ("%s%s%s (", cTypeRet (mdef.result.type), proto?" ":"\n", mname.c_str());
for(pi = mdef.params.begin(); pi != mdef.params.end(); pi++)
{
if (pi->name == "_object_id") continue; // C++ binding: get _object_id from class
- if(!first) printf(", ");
+ if(!first) g_print (", ");
first = false;
- printf("%s %s", cTypeArg (pi->type), pi->name.c_str());
+ g_print ("%s %s", cTypeArg (pi->type), pi->name.c_str());
}
if (first)
- printf("void");
- printf(")");
+ g_print ("void");
+ g_print (")");
if (proto)
{
- printf(";\n");
+ g_print (";\n");
return;
}
- printf(" {\n");
+ g_print (" {\n");
String vret = createTypeCode (mdef.result.type, MODEL_VCALL_RET);
if (mdef.result.type != "void")
- printf (" %s _retval;\n", vret.c_str());
+ g_print (" %s _retval;\n", vret.c_str());
String rfree = createTypeCode (mdef.result.type, "_retval_conv", MODEL_VCALL_RFREE);
if (rfree != "")
- printf (" %s _retval_conv;\n", cTypeRet (mdef.result.type));
+ g_print (" %s _retval_conv;\n", cTypeRet (mdef.result.type));
map<String, String> cname;
for(pi = mdef.params.begin(); pi != mdef.params.end(); pi++)
@@ -544,27 +544,27 @@ void CodeGeneratorCBase::printProcedure (const Method& mdef, bool proto, const S
cname[pi->name] = pi->name + "__c";
String arg = createTypeCode(pi->type, MODEL_VCALL_CARG);
- printf(" %s %s__c = %s;\n", arg.c_str(), pi->name.c_str(), conv.c_str());
+ g_print (" %s %s__c = %s;\n", arg.c_str(), pi->name.c_str(), conv.c_str());
}
else
cname[pi->name] = pi->name;
}
- printf(" ");
+ g_print (" ");
if (mdef.result.type != "void")
- printf("_retval = ");
+ g_print ("_retval = ");
String vcall = createTypeCode(mdef.result.type, "", MODEL_VCALL);
- printf("%s (\"%s\", ", vcall.c_str(), dname.c_str());
+ g_print ("%s (\"%s\", ", vcall.c_str(), dname.c_str());
for(pi = mdef.params.begin(); pi != mdef.params.end(); pi++)
- printf("%s ", createTypeCode(pi->type, cname[pi->name], MODEL_VCALL_ARG).c_str());
- printf("0);\n");
+ g_print ("%s ", createTypeCode(pi->type, cname[pi->name], MODEL_VCALL_ARG).c_str());
+ g_print ("0);\n");
for(pi = mdef.params.begin(); pi != mdef.params.end(); pi++)
{
String cfree = createTypeCode (pi->type, cname[pi->name], MODEL_VCALL_CFREE);
if (cfree != "")
- printf(" %s;\n", cfree.c_str());
+ g_print (" %s;\n", cfree.c_str());
}
if (mdef.result.type != "void")
@@ -573,16 +573,16 @@ void CodeGeneratorCBase::printProcedure (const Method& mdef, bool proto, const S
if (rfree != "")
{
- printf (" _retval_conv = %s;\n", rconv.c_str());
- printf (" %s;\n", rfree.c_str());
- printf (" return _retval_conv;\n");
+ g_print (" _retval_conv = %s;\n", rconv.c_str());
+ g_print (" %s;\n", rfree.c_str());
+ g_print (" return _retval_conv;\n");
}
else
{
- printf (" return %s;\n", rconv.c_str());
+ g_print (" return %s;\n", rconv.c_str());
}
}
- printf("}\n\n");
+ g_print ("}\n\n");
}
static bool choiceReverseSort(const ChoiceValue& e1, const ChoiceValue& e2)
@@ -616,31 +616,31 @@ void CodeGeneratorCBase::printChoiceConverters()
ci->name = makeLowerName (ci->name, '-');
sort (components.begin(), components.end(), ::choiceReverseSort);
- printf("static const SfiConstants %s_vals[%zd] = {\n",name.c_str(), ei->contents.size());
+ g_print ("static const SfiConstants %s_vals[%zd] = {\n",name.c_str(), ei->contents.size());
for (ci = components.begin(); ci != components.end(); ci++)
{
int value = ci->sequentialValue;
minval = min (value, minval);
maxval = max (value, maxval);
- printf(" { \"%s\", %zd, %d },\n", ci->name.c_str(), ci->name.size(), value);
+ g_print (" { \"%s\", %zd, %d },\n", ci->name.c_str(), ci->name.size(), value);
}
- printf("};\n\n");
+ g_print ("};\n\n");
- printf("const gchar*\n");
- printf("%s_to_choice (%s value)\n", name.c_str(), arg.c_str());
- printf("{\n");
- printf(" g_return_val_if_fail (value >= %d && value <= %d, NULL);\n", minval, maxval);
- printf(" return sfi_constants_get_name (G_N_ELEMENTS (%s_vals), %s_vals, value);\n",
+ g_print ("const gchar*\n");
+ g_print ("%s_to_choice (%s value)\n", name.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" g_return_val_if_fail (value >= %d && value <= %d, NULL);\n", minval, maxval);
+ g_print (" return sfi_constants_get_name (G_N_ELEMENTS (%s_vals), %s_vals, value);\n",
name.c_str(), name.c_str());
- printf("}\n\n");
+ g_print ("}\n\n");
- printf("%s\n", cTypeRet (ei->name));
- printf("%s_from_choice (const gchar *choice)\n", name.c_str());
- printf("{\n");
- printf(" return (%s) (choice ? sfi_constants_get_index (G_N_ELEMENTS (%s_vals), "
+ g_print ("%s\n", cTypeRet (ei->name));
+ g_print ("%s_from_choice (const gchar *choice)\n", name.c_str());
+ g_print ("{\n");
+ g_print (" return (%s) (choice ? sfi_constants_get_index (G_N_ELEMENTS (%s_vals), "
"%s_vals, choice) : 0);\n", cTypeRet (ei->name), name.c_str(), name.c_str());
- printf("}\n");
- printf("\n");
+ g_print ("}\n");
+ g_print ("\n");
}
}
@@ -651,7 +651,7 @@ void CodeGeneratorCBase::printClientRecordPrototypes()
if (parser.fromInclude (ri->name)) continue;
String mname = makeMixedName (ri->name);
- printf("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
+ g_print ("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
}
}
@@ -662,7 +662,7 @@ void CodeGeneratorCBase::printClientSequencePrototypes()
if (parser.fromInclude (si->name)) continue;
String mname = makeMixedName (si->name);
- printf("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
+ g_print ("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
}
}
@@ -674,14 +674,14 @@ void CodeGeneratorCBase::printClientRecordDefinitions()
String mname = makeMixedName (ri->name.c_str());
- printf("struct _%s {\n", mname.c_str());
+ g_print ("struct _%s {\n", mname.c_str());
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
- printf(" %s %s;\n", cTypeField (pi->type), pi->name.c_str());
+ g_print (" %s %s;\n", cTypeField (pi->type), pi->name.c_str());
}
- printf("};\n");
+ g_print ("};\n");
}
- printf("\n");
+ g_print ("\n");
}
void CodeGeneratorCBase::printClientSequenceDefinitions()
@@ -694,10 +694,10 @@ void CodeGeneratorCBase::printClientSequenceDefinitions()
String array = typeArray (si->content.type);
String elements = si->content.name;
- printf("struct _%s {\n", mname.c_str());
- printf(" guint n_%s;\n", elements.c_str ());
- printf(" %s %s;\n", array.c_str(), elements.c_str());
- printf("};\n");
+ g_print ("struct _%s {\n", mname.c_str());
+ g_print (" guint n_%s;\n", elements.c_str ());
+ g_print (" %s %s;\n", array.c_str(), elements.c_str());
+ g_print ("};\n");
}
}
@@ -721,15 +721,15 @@ void CodeGeneratorCBase::printClientRecordMethodPrototypes (PrefixSymbolMode mod
}
else
{
- printf("%s %s_new (void);\n", ret.c_str(), lname.c_str());
- printf("%s %s_copy_shallow (%s rec);\n", ret.c_str(), lname.c_str(), arg.c_str());
- printf("%s %s_from_rec (SfiRec *sfi_rec);\n", ret.c_str(), lname.c_str());
- printf("SfiRec *%s_to_rec (%s rec);\n", lname.c_str(), arg.c_str());
- printf("void %s_free (%s rec);\n", lname.c_str(), arg.c_str());
- printf("\n");
+ g_print ("%s %s_new (void);\n", ret.c_str(), lname.c_str());
+ g_print ("%s %s_copy_shallow (%s rec);\n", ret.c_str(), lname.c_str(), arg.c_str());
+ g_print ("%s %s_from_rec (SfiRec *sfi_rec);\n", ret.c_str(), lname.c_str());
+ g_print ("SfiRec *%s_to_rec (%s rec);\n", lname.c_str(), arg.c_str());
+ g_print ("void %s_free (%s rec);\n", lname.c_str(), arg.c_str());
+ g_print ("\n");
}
}
- printf("\n");
+ g_print ("\n");
}
void CodeGeneratorCBase::printClientSequenceMethodPrototypes (PrefixSymbolMode mode)
@@ -755,14 +755,14 @@ void CodeGeneratorCBase::printClientSequenceMethodPrototypes (PrefixSymbolMode m
}
else
{
- printf("%s %s_new (void);\n", ret.c_str(), lname.c_str());
- printf("void %s_append (%s seq, %s element);\n", lname.c_str(), arg.c_str(), element.c_str());
- printf("%s %s_copy_shallow (%s seq);\n", ret.c_str(), lname.c_str(), arg.c_str());
- printf("%s %s_from_seq (SfiSeq *sfi_seq);\n", ret.c_str(), lname.c_str());
- printf("SfiSeq *%s_to_seq (%s seq);\n", lname.c_str(), arg.c_str());
- printf("void %s_resize (%s seq, guint new_size);\n", lname.c_str(), arg.c_str());
- printf("void %s_free (%s seq);\n", lname.c_str(), arg.c_str());
- printf("\n");
+ g_print ("%s %s_new (void);\n", ret.c_str(), lname.c_str());
+ g_print ("void %s_append (%s seq, %s element);\n", lname.c_str(), arg.c_str(), element.c_str());
+ g_print ("%s %s_copy_shallow (%s seq);\n", ret.c_str(), lname.c_str(), arg.c_str());
+ g_print ("%s %s_from_seq (SfiSeq *sfi_seq);\n", ret.c_str(), lname.c_str());
+ g_print ("SfiSeq *%s_to_seq (%s seq);\n", lname.c_str(), arg.c_str());
+ g_print ("void %s_resize (%s seq, guint new_size);\n", lname.c_str(), arg.c_str());
+ g_print ("void %s_free (%s seq);\n", lname.c_str(), arg.c_str());
+ g_print ("\n");
}
}
}
@@ -780,10 +780,10 @@ void CodeGeneratorCBase::printClientRecordMethodImpl()
String lname = makeLowerName (ri->name.c_str());
String mname = makeMixedName (ri->name.c_str());
- printf("%s\n", ret.c_str());
- printf("%s_new (void)\n", lname.c_str());
- printf("{\n");
- printf(" %s rec = g_new0 (%s, 1);\n", arg.c_str(), mname.c_str());
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_new (void)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" %s rec = g_new0 (%s, 1);\n", arg.c_str(), mname.c_str());
for (pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
/* FIXME(tim): this needs to be much more versatile, so we can e.g. change
@@ -793,93 +793,93 @@ void CodeGeneratorCBase::printClientRecordMethodImpl()
* way we do it in the C++ language binding)
*/
String init = funcNew (pi->type);
- if (init != "") printf(" rec->%s = %s();\n", pi->name.c_str(), init.c_str());
+ if (init != "") g_print (" rec->%s = %s();\n", pi->name.c_str(), init.c_str());
}
- printf(" return rec;\n");
- printf("}\n\n");
-
- printf("%s\n", ret.c_str());
- printf("%s_copy_shallow (%s rec)\n", lname.c_str(), arg.c_str());
- printf("{\n");
- printf(" %s rec_copy;\n", arg.c_str());
- printf(" if (!rec)\n");
- printf(" return NULL;");
- printf("\n");
- printf(" rec_copy = g_new0 (%s, 1);\n", mname.c_str());
+ g_print (" return rec;\n");
+ g_print ("}\n\n");
+
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_copy_shallow (%s rec)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" %s rec_copy;\n", arg.c_str());
+ g_print (" if (!rec)\n");
+ g_print (" return NULL;");
+ g_print ("\n");
+ g_print (" rec_copy = g_new0 (%s, 1);\n", mname.c_str());
for (pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
/* FIXME(tim): this needs to be more versatile, so NULL fields can be special
* cased before copying */
String copy = funcCopy (pi->type);
- printf(" rec_copy->%s = %s (rec->%s);\n", pi->name.c_str(), copy.c_str(),
+ g_print (" rec_copy->%s = %s (rec->%s);\n", pi->name.c_str(), copy.c_str(),
pi->name.c_str());
}
- printf(" return rec_copy;\n");
- printf("}\n\n");
-
- printf("%s\n", ret.c_str());
- printf("%s_from_rec (SfiRec *sfi_rec)\n", lname.c_str());
- printf("{\n");
- printf(" GValue *element;\n");
- printf(" %s rec;\n", arg.c_str());
- printf(" if (!sfi_rec)\n");
- printf(" return NULL;\n");
- printf("\n");
- printf(" rec = g_new0 (%s, 1);\n", mname.c_str());
+ g_print (" return rec_copy;\n");
+ g_print ("}\n\n");
+
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_from_rec (SfiRec *sfi_rec)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" GValue *element;\n");
+ g_print (" %s rec;\n", arg.c_str());
+ g_print (" if (!sfi_rec)\n");
+ g_print (" return NULL;\n");
+ g_print ("\n");
+ g_print (" rec = g_new0 (%s, 1);\n", mname.c_str());
for (pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
String elementFromValue = createTypeCode (pi->type, "element", MODEL_FROM_VALUE);
String init = funcNew (pi->type);
- printf(" element = sfi_rec_get (sfi_rec, \"%s\");\n", pi->name.c_str());
- printf(" if (element)\n");
- printf(" rec->%s = %s;\n", pi->name.c_str(), elementFromValue.c_str());
+ g_print (" element = sfi_rec_get (sfi_rec, \"%s\");\n", pi->name.c_str());
+ g_print (" if (element)\n");
+ g_print (" rec->%s = %s;\n", pi->name.c_str(), elementFromValue.c_str());
if (init != "")
{
- printf(" else\n");
- printf(" rec->%s = %s();\n", pi->name.c_str(), init.c_str());
+ g_print (" else\n");
+ g_print (" rec->%s = %s();\n", pi->name.c_str(), init.c_str());
}
}
- printf(" return rec;\n");
- printf("}\n\n");
-
- printf("SfiRec *\n");
- printf("%s_to_rec (%s rec)\n", lname.c_str(), arg.c_str());
- printf("{\n");
- printf(" SfiRec *sfi_rec;\n");
- printf(" GValue *element;\n");
- printf(" if (!rec)\n");
- printf(" return NULL;\n");
- printf("\n");
- printf(" sfi_rec = sfi_rec_new ();\n");
+ g_print (" return rec;\n");
+ g_print ("}\n\n");
+
+ g_print ("SfiRec *\n");
+ g_print ("%s_to_rec (%s rec)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" SfiRec *sfi_rec;\n");
+ g_print (" GValue *element;\n");
+ g_print (" if (!rec)\n");
+ g_print (" return NULL;\n");
+ g_print ("\n");
+ g_print (" sfi_rec = sfi_rec_new ();\n");
for (pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
String elementToValue = createTypeCode (pi->type, "rec->" + pi->name, MODEL_TO_VALUE);
- printf(" element = %s;\n", elementToValue.c_str());
- printf(" sfi_rec_set (sfi_rec, \"%s\", element);\n", pi->name.c_str());
- printf(" sfi_value_free (element);\n"); // FIXME: couldn't we have take_set
+ g_print (" element = %s;\n", elementToValue.c_str());
+ g_print (" sfi_rec_set (sfi_rec, \"%s\", element);\n", pi->name.c_str());
+ g_print (" sfi_value_free (element);\n"); // FIXME: couldn't we have take_set
}
- printf(" return sfi_rec;\n");
- printf("}\n\n");
+ g_print (" return sfi_rec;\n");
+ g_print ("}\n\n");
- printf("void\n");
- printf("%s_free (%s rec)\n", lname.c_str(), arg.c_str());
- printf("{\n");
- printf(" g_return_if_fail (rec != NULL);\n");
+ g_print ("void\n");
+ g_print ("%s_free (%s rec)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" g_return_if_fail (rec != NULL);\n");
/* FIXME (tim): should free functions generally demand non-NULL structures? */
- printf(" \n");
+ g_print (" \n");
for (pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
/* FIXME (tim): needs to be more verstaile, so NULL fields can be properly special cased */
// FIXME (stw): there _should_ be no NULL fields in some cases (sequences)!
String free = funcFree (pi->type);
- if (free != "") printf(" if (rec->%s) %s (rec->%s);\n",
+ if (free != "") g_print (" if (rec->%s) %s (rec->%s);\n",
pi->name.c_str(), free.c_str(), pi->name.c_str());
}
- printf(" g_free (rec);\n");
- printf("}\n\n");
- printf("\n");
+ g_print (" g_free (rec);\n");
+ g_print ("}\n\n");
+ g_print ("\n");
}
}
@@ -896,79 +896,79 @@ void CodeGeneratorCBase::printClientSequenceMethodImpl()
String lname = makeLowerName (si->name.c_str());
String mname = makeMixedName (si->name.c_str());
- printf("%s\n", ret.c_str());
- printf("%s_new (void)\n", lname.c_str());
- printf("{\n");
- printf(" return g_new0 (%s, 1);\n",mname.c_str());
- printf("}\n\n");
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_new (void)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" return g_new0 (%s, 1);\n",mname.c_str());
+ g_print ("}\n\n");
String elementCopy = funcCopy (si->content.type);
- printf("void\n");
- printf("%s_append (%s seq, %s element)\n", lname.c_str(), arg.c_str(), element.c_str());
- printf("{\n");
- printf(" g_return_if_fail (seq != NULL);\n");
- printf("\n");
- printf(" seq->%s = g_realloc (seq->%s, "
+ g_print ("void\n");
+ g_print ("%s_append (%s seq, %s element)\n", lname.c_str(), arg.c_str(), element.c_str());
+ g_print ("{\n");
+ g_print (" g_return_if_fail (seq != NULL);\n");
+ g_print ("\n");
+ g_print (" seq->%s = g_realloc (seq->%s, "
"(seq->n_%s + 1) * sizeof (seq->%s[0]));\n",
elements.c_str(), elements.c_str(), elements.c_str(), elements.c_str());
- printf(" seq->%s[seq->n_%s++] = %s (element);\n", elements.c_str(), elements.c_str(),
+ g_print (" seq->%s[seq->n_%s++] = %s (element);\n", elements.c_str(), elements.c_str(),
elementCopy.c_str());
- printf("}\n\n");
-
- printf("%s\n", ret.c_str());
- printf("%s_copy_shallow (%s seq)\n", lname.c_str(), arg.c_str());
- printf("{\n");
- printf(" %s seq_copy;\n", arg.c_str ());
- printf(" guint i;\n");
- printf(" if (!seq)\n");
- printf(" return NULL;\n");
- printf("\n");
- printf(" seq_copy = %s_new ();\n", lname.c_str());
- printf(" for (i = 0; i < seq->n_%s; i++)\n", elements.c_str());
- printf(" %s_append (seq_copy, seq->%s[i]);\n", lname.c_str(), elements.c_str());
- printf(" return seq_copy;\n");
- printf("}\n\n");
+ g_print ("}\n\n");
+
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_copy_shallow (%s seq)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" %s seq_copy;\n", arg.c_str ());
+ g_print (" guint i;\n");
+ g_print (" if (!seq)\n");
+ g_print (" return NULL;\n");
+ g_print ("\n");
+ g_print (" seq_copy = %s_new ();\n", lname.c_str());
+ g_print (" for (i = 0; i < seq->n_%s; i++)\n", elements.c_str());
+ g_print (" %s_append (seq_copy, seq->%s[i]);\n", lname.c_str(), elements.c_str());
+ g_print (" return seq_copy;\n");
+ g_print ("}\n\n");
String elementFromValue = createTypeCode (si->content.type, "element", MODEL_FROM_VALUE);
- printf("%s\n", ret.c_str());
- printf("%s_from_seq (SfiSeq *sfi_seq)\n", lname.c_str());
- printf("{\n");
- printf(" %s seq;\n", arg.c_str());
- printf(" guint i, length;\n");
- printf("\n");
- printf(" g_return_val_if_fail (sfi_seq != NULL, NULL);\n");
- printf("\n");
- printf(" length = sfi_seq_length (sfi_seq);\n");
- printf(" seq = g_new0 (%s, 1);\n",mname.c_str());
- printf(" seq->n_%s = length;\n", elements.c_str());
- printf(" seq->%s = g_malloc (seq->n_%s * sizeof (seq->%s[0]));\n\n",
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_from_seq (SfiSeq *sfi_seq)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" %s seq;\n", arg.c_str());
+ g_print (" guint i, length;\n");
+ g_print ("\n");
+ g_print (" g_return_val_if_fail (sfi_seq != NULL, NULL);\n");
+ g_print ("\n");
+ g_print (" length = sfi_seq_length (sfi_seq);\n");
+ g_print (" seq = g_new0 (%s, 1);\n",mname.c_str());
+ g_print (" seq->n_%s = length;\n", elements.c_str());
+ g_print (" seq->%s = g_malloc (seq->n_%s * sizeof (seq->%s[0]));\n\n",
elements.c_str(), elements.c_str(), elements.c_str());
- printf(" for (i = 0; i < length; i++)\n");
- printf(" {\n");
- printf(" GValue *element = sfi_seq_get (sfi_seq, i);\n");
- printf(" seq->%s[i] = %s;\n", elements.c_str(), elementFromValue.c_str());
- printf(" }\n");
- printf(" return seq;\n");
- printf("}\n\n");
+ g_print (" for (i = 0; i < length; i++)\n");
+ g_print (" {\n");
+ g_print (" GValue *element = sfi_seq_get (sfi_seq, i);\n");
+ g_print (" seq->%s[i] = %s;\n", elements.c_str(), elementFromValue.c_str());
+ g_print (" }\n");
+ g_print (" return seq;\n");
+ g_print ("}\n\n");
String elementToValue = createTypeCode (si->content.type, "seq->" + elements + "[i]", MODEL_TO_VALUE);
- printf("SfiSeq *\n");
- printf("%s_to_seq (%s seq)\n", lname.c_str(), arg.c_str());
- printf("{\n");
- printf(" SfiSeq *sfi_seq;\n");
- printf(" guint i;\n");
- printf("\n");
- printf(" g_return_val_if_fail (seq != NULL, NULL);\n");
- printf("\n");
- printf(" sfi_seq = sfi_seq_new ();\n");
- printf(" for (i = 0; i < seq->n_%s; i++)\n", elements.c_str());
- printf(" {\n");
- printf(" GValue *element = %s;\n", elementToValue.c_str());
- printf(" sfi_seq_append (sfi_seq, element);\n");
- printf(" sfi_value_free (element);\n"); // FIXME: couldn't we have take_append
- printf(" }\n");
- printf(" return sfi_seq;\n");
- printf("}\n\n");
+ g_print ("SfiSeq *\n");
+ g_print ("%s_to_seq (%s seq)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" SfiSeq *sfi_seq;\n");
+ g_print (" guint i;\n");
+ g_print ("\n");
+ g_print (" g_return_val_if_fail (seq != NULL, NULL);\n");
+ g_print ("\n");
+ g_print (" sfi_seq = sfi_seq_new ();\n");
+ g_print (" for (i = 0; i < seq->n_%s; i++)\n", elements.c_str());
+ g_print (" {\n");
+ g_print (" GValue *element = %s;\n", elementToValue.c_str());
+ g_print (" sfi_seq_append (sfi_seq, element);\n");
+ g_print (" sfi_value_free (element);\n"); // FIXME: couldn't we have take_append
+ g_print (" }\n");
+ g_print (" return sfi_seq;\n");
+ g_print ("}\n\n");
// FIXME: we should check whether we _really_ need to deal with a seperate free_check
// function here, as it needs to be specialcased everywhere
@@ -978,58 +978,58 @@ void CodeGeneratorCBase::printClientSequenceMethodImpl()
String element_i_free_check = "if (seq->" + elements + "[i]) ";
String element_i_free = funcFree (si->content.type);
String element_i_new = funcNew (si->content.type);
- printf("void\n");
- printf("%s_resize (%s seq, guint new_size)\n", lname.c_str(), arg.c_str());
- printf("{\n");
- printf(" g_return_if_fail (seq != NULL);\n");
- printf("\n");
+ g_print ("void\n");
+ g_print ("%s_resize (%s seq, guint new_size)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" g_return_if_fail (seq != NULL);\n");
+ g_print ("\n");
if (element_i_free != "")
{
- printf(" if (seq->n_%s > new_size)\n", elements.c_str());
- printf(" {\n");
- printf(" guint i;\n");
- printf(" for (i = new_size; i < seq->n_%s; i++)\n", elements.c_str());
- printf(" %s %s (seq->%s[i]);\n", element_i_free_check.c_str(),
+ g_print (" if (seq->n_%s > new_size)\n", elements.c_str());
+ g_print (" {\n");
+ g_print (" guint i;\n");
+ g_print (" for (i = new_size; i < seq->n_%s; i++)\n", elements.c_str());
+ g_print (" %s %s (seq->%s[i]);\n", element_i_free_check.c_str(),
element_i_free.c_str(), elements.c_str());
- printf(" }\n");
+ g_print (" }\n");
}
- printf("\n");
- printf(" seq->%s = g_realloc (seq->%s, new_size * sizeof (seq->%s[0]));\n",
+ g_print ("\n");
+ g_print (" seq->%s = g_realloc (seq->%s, new_size * sizeof (seq->%s[0]));\n",
elements.c_str(), elements.c_str(), elements.c_str());
- printf(" if (new_size > seq->n_%s)\n", elements.c_str());
+ g_print (" if (new_size > seq->n_%s)\n", elements.c_str());
if (element_i_new != "")
{
- printf(" {\n");
- printf(" guint i;\n");
- printf(" for (i = seq->n_%s; i < new_size; i++)\n", elements.c_str());
- printf(" seq->%s[i] = %s();\n", elements.c_str(), element_i_new.c_str());
- printf(" }\n");
+ g_print (" {\n");
+ g_print (" guint i;\n");
+ g_print (" for (i = seq->n_%s; i < new_size; i++)\n", elements.c_str());
+ g_print (" seq->%s[i] = %s();\n", elements.c_str(), element_i_new.c_str());
+ g_print (" }\n");
}
else
{
- printf(" memset (&seq->%s[seq->n_%s], 0, sizeof(seq->%s[0]) * (new_size - seq->n_%s));\n",
+ g_print (" memset (&seq->%s[seq->n_%s], 0, sizeof(seq->%s[0]) * (new_size - seq->n_%s));\n",
elements.c_str(), elements.c_str(), elements.c_str(), elements.c_str());
}
- printf(" seq->n_%s = new_size;\n", elements.c_str());
- printf("}\n\n");
+ g_print (" seq->n_%s = new_size;\n", elements.c_str());
+ g_print ("}\n\n");
- printf("void\n");
- printf("%s_free (%s seq)\n", lname.c_str(), arg.c_str());
- printf("{\n");
+ g_print ("void\n");
+ g_print ("%s_free (%s seq)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
if (element_i_free != "")
- printf(" guint i;\n\n");
- printf(" g_return_if_fail (seq != NULL);\n");
- printf(" \n");
+ g_print (" guint i;\n\n");
+ g_print (" g_return_if_fail (seq != NULL);\n");
+ g_print (" \n");
if (element_i_free != "")
{
- printf(" for (i = 0; i < seq->n_%s; i++)\n", elements.c_str());
- printf(" %s %s (seq->%s[i]);\n", element_i_free_check.c_str(),
+ g_print (" for (i = 0; i < seq->n_%s; i++)\n", elements.c_str());
+ g_print (" %s %s (seq->%s[i]);\n", element_i_free_check.c_str(),
element_i_free.c_str(), elements.c_str());
}
- printf(" g_free (seq->%s);\n", elements.c_str());
- printf(" g_free (seq);\n");
- printf("}\n\n");
- printf("\n");
+ g_print (" g_free (seq->%s);\n", elements.c_str());
+ g_print (" g_free (seq);\n");
+ g_print ("}\n\n");
+ g_print ("\n");
}
}
@@ -1041,16 +1041,16 @@ void CodeGeneratorCBase::printClientChoiceDefinitions()
String mname = makeMixedName (ci->name);
String lname = makeLowerName (ci->name);
- printf("\ntypedef enum {\n");
+ g_print ("\ntypedef enum {\n");
for (vector<ChoiceValue>::const_iterator vi = ci->contents.begin(); vi != ci->contents.end(); vi++)
{
/* don't export server side assigned choice values to the client */
String ename = makeUpperName (vi->name);
- printf(" %s = %d,\n", ename.c_str(), vi->sequentialValue);
+ g_print (" %s = %d,\n", ename.c_str(), vi->sequentialValue);
}
- printf("} %s;\n", mname.c_str());
+ g_print ("} %s;\n", mname.c_str());
}
- printf("\n");
+ g_print ("\n");
}
void CodeGeneratorCBase::printClientChoiceConverterPrototypes (PrefixSymbolMode mode)
@@ -1069,11 +1069,11 @@ void CodeGeneratorCBase::printClientChoiceConverterPrototypes (PrefixSymbolMode
}
else
{
- printf ("const gchar* %s_to_choice (%s value);\n", lname.c_str(), mname.c_str());
- printf ("%s %s_from_choice (const gchar *choice);\n", mname.c_str(), lname.c_str());
+ g_print ("const gchar* %s_to_choice (%s value);\n", lname.c_str(), mname.c_str());
+ g_print ("%s %s_from_choice (const gchar *choice);\n", mname.c_str(), lname.c_str());
}
}
- printf("\n");
+ g_print ("\n");
}
diff --git a/sfi/sfidl-clientc.cc b/sfi/sfidl-clientc.cc
index 8c5eb77..c4d64e5 100644
--- a/sfi/sfidl-clientc.cc
+++ b/sfi/sfidl-clientc.cc
@@ -34,10 +34,10 @@ void CodeGeneratorClientC::printClassMacros()
makeUpperName (NamespaceHelper::nameOf (ci->name));
String mname = makeMixedName (ci->name);
- printf ("#define %s(proxy) bse_proxy_is_a ((proxy), \"%s\")\n",
+ g_print ("#define %s(proxy) bse_proxy_is_a ((proxy), \"%s\")\n",
macro.c_str(), mname.c_str());
}
- printf("\n");
+ g_print("\n");
}
Method CodeGeneratorClientC::methodWithObject (const Class& c, const Method& method)
@@ -121,7 +121,7 @@ CodeGeneratorClientC::addBindingSpecificFiles (const String& binding_specific_fi
filename = directory + String (G_DIR_SEPARATOR_S) + filename;
g_free (directory);
- printf ("/* %s: including binding specific file \"%s\", as requested in %s:%d */\n",
+ g_print ("/* %s: including binding specific file \"%s\", as requested in %s:%d */\n",
options.sfidlName.c_str(), filename.c_str(), pi->filename.c_str(), pi->line);
FILE *f = fopen (filename.c_str(), "r");
if (f)
@@ -134,7 +134,7 @@ CodeGeneratorClientC::addBindingSpecificFiles (const String& binding_specific_fi
}
else
{
- fprintf (stderr, "binding specific file '%s' not found.\n", filename.c_str());
+ g_printerr ("binding specific file '%s' not found.\n", filename.c_str());
exit (1);
}
}
@@ -143,7 +143,7 @@ CodeGeneratorClientC::addBindingSpecificFiles (const String& binding_specific_fi
bool CodeGeneratorClientC::run()
{
- printf("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
+ g_print ("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
if (generateHeader)
{
@@ -159,8 +159,8 @@ bool CodeGeneratorClientC::run()
if (prefix != "")
{
for (vector<String>::const_iterator pi = prefix_symbols.begin(); pi != prefix_symbols.end(); pi++)
- printf("#define %s %s_%s\n", pi->c_str(), prefix.c_str(), pi->c_str());
- printf("\n");
+ g_print ("#define %s %s_%s\n", pi->c_str(), prefix.c_str(), pi->c_str());
+ g_print ("\n");
}
/* generate the header */
@@ -183,7 +183,7 @@ bool CodeGeneratorClientC::run()
if (generateSource)
{
- printf("#include <string.h>\n");
+ g_print ("#include <string.h>\n");
printClientRecordMethodImpl();
printClientSequenceMethodImpl();
@@ -192,7 +192,7 @@ bool CodeGeneratorClientC::run()
addBindingSpecificFiles ("binding_specific_c_source");
}
- printf("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
+ g_print ("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
return true;
}
@@ -223,7 +223,7 @@ void
CodeGeneratorClientC::help ()
{
CodeGeneratorCBase::help();
- fprintf (stderr, " --prefix <prefix> set the prefix for C functions\n");
+ g_printerr (" --prefix <prefix> set the prefix for C functions\n");
}
namespace {
diff --git a/sfi/sfidl-clientcxx.cc b/sfi/sfidl-clientcxx.cc
index 91af050..7bd9d5d 100644
--- a/sfi/sfidl-clientcxx.cc
+++ b/sfi/sfidl-clientcxx.cc
@@ -171,41 +171,41 @@ cUC_NAME (const String &cstr) // FIXME: need mammut renaming function
void
CodeGeneratorClientCxx::printChoicePrototype (NamespaceHelper& nspace)
{
- printf ("\n/* choice prototypes */\n");
+ g_print ("\n/* choice prototypes */\n");
for (vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name))
continue;
nspace.setFromSymbol(ci->name);
String name = nspace.printableForm (ci->name);
- printf ("\n");
- printf ("static inline SfiChoiceValues %s_choice_values();\n", name.c_str());
+ g_print ("\n");
+ g_print ("static inline SfiChoiceValues %s_choice_values();\n", name.c_str());
}
}
void
CodeGeneratorClientCxx::printChoiceImpl (NamespaceHelper& nspace)
{
- printf ("\n/* choice implementations */\n");
+ g_print ("\n/* choice implementations */\n");
for (vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name))
continue;
nspace.setFromSymbol(ci->name);
String name = nspace.printableForm (ci->name);
- printf ("\n");
- printf ("static inline SfiChoiceValues\n");
- printf ("%s_choice_values()\n", name.c_str());
- printf ("{\n");
- printf (" static const SfiChoiceValue values[%zu] = {\n", ci->contents.size());
+ g_print ("\n");
+ g_print ("static inline SfiChoiceValues\n");
+ g_print ("%s_choice_values()\n", name.c_str());
+ g_print ("{\n");
+ g_print (" static const SfiChoiceValue values[%zu] = {\n", ci->contents.size());
for (vector<ChoiceValue>::const_iterator vi = ci->contents.begin(); vi != ci->contents.end(); vi++)
- printf (" { \"%s\", \"%s\" },\n", cUC_NAME (vi->name), vi->label.c_str()); // FIXME: i18n and blurb
- printf (" };\n");
- printf (" static const SfiChoiceValues choice_values = {\n");
- printf (" G_N_ELEMENTS (values), values,\n");
- printf (" };\n");
- printf (" return choice_values;\n");
- printf ("}\n\n");
+ g_print (" { \"%s\", \"%s\" },\n", cUC_NAME (vi->name), vi->label.c_str()); // FIXME: i18n and blurb
+ g_print (" };\n");
+ g_print (" static const SfiChoiceValues choice_values = {\n");
+ g_print (" G_N_ELEMENTS (values), values,\n");
+ g_print (" };\n");
+ g_print (" return choice_values;\n");
+ g_print ("}\n\n");
}
}
@@ -215,7 +215,7 @@ CodeGeneratorClientCxx::printRecSeqForwardDecl (NamespaceHelper& nspace)
vector<Sequence>::const_iterator si;
vector<Record>::const_iterator ri;
- printf ("\n/* record/sequence prototypes */\n");
+ g_print ("\n/* record/sequence prototypes */\n");
/* forward declarations for records */
for (ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
@@ -226,9 +226,9 @@ CodeGeneratorClientCxx::printRecSeqForwardDecl (NamespaceHelper& nspace)
nspace.setFromSymbol(ri->name);
String name = nspace.printableForm (ri->name);
- printf("\n");
- printf("class %s;\n", name.c_str());
- printf("typedef Sfi::RecordHandle<%s> %sHandle;\n", name.c_str(), name.c_str());
+ g_print("\n");
+ g_print("class %s;\n", name.c_str());
+ g_print("typedef Sfi::RecordHandle<%s> %sHandle;\n", name.c_str(), name.c_str());
}
/* forward declarations for sequences */
@@ -239,8 +239,8 @@ CodeGeneratorClientCxx::printRecSeqForwardDecl (NamespaceHelper& nspace)
nspace.setFromSymbol(si->name);
String name = nspace.printableForm (si->name);
- printf("\n");
- printf("class %s;\n", name.c_str());
+ g_print("\n");
+ g_print("class %s;\n", name.c_str());
}
}
@@ -248,7 +248,7 @@ void CodeGeneratorClientCxx::printRecSeqDefinition (NamespaceHelper& nspace)
{
vector<Param>::const_iterator pi;
- printf ("\n/* record/sequence definitions */\n");
+ g_print ("\n/* record/sequence definitions */\n");
/* sequences */
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
@@ -262,17 +262,17 @@ void CodeGeneratorClientCxx::printRecSeqDefinition (NamespaceHelper& nspace)
String name = nspace.printableForm (si->name);
String content = typeField (si->content.type);
- printf ("\n");
- printf ("class %s : public Sfi::Sequence<%s> {\n", name.c_str(), content.c_str());
- printf ("public:\n");
- printf (" static inline %s from_seq (SfiSeq *seq);\n", cTypeRet (si->name));
- printf (" static inline SfiSeq *to_seq (%s seq);\n", cTypeArg (si->name));
- printf (" static inline %s value_get_seq (const GValue *value);\n", cTypeRet (si->name));
- printf (" static inline void value_set_seq (GValue *value, %s self);\n", cTypeArg (si->name));
+ g_print ("\n");
+ g_print ("class %s : public Sfi::Sequence<%s> {\n", name.c_str(), content.c_str());
+ g_print ("public:\n");
+ g_print (" static inline %s from_seq (SfiSeq *seq);\n", cTypeRet (si->name));
+ g_print (" static inline SfiSeq *to_seq (%s seq);\n", cTypeArg (si->name));
+ g_print (" static inline %s value_get_seq (const GValue *value);\n", cTypeRet (si->name));
+ g_print (" static inline void value_set_seq (GValue *value, %s self);\n", cTypeArg (si->name));
/* FIXME: make this private (or delete it) */
- printf (" static inline const char* type_name () { return \"%s\"; }\n", makeMixedName (si->name).c_str());
- printf("};\n");
- printf ("\n");
+ g_print (" static inline const char* type_name () { return \"%s\"; }\n", makeMixedName (si->name).c_str());
+ g_print("};\n");
+ g_print ("\n");
}
/* records */
@@ -284,27 +284,27 @@ void CodeGeneratorClientCxx::printRecSeqDefinition (NamespaceHelper& nspace)
String name = nspace.printableForm (ri->name);
String type_name = makeMixedName (ri->name).c_str();
- printf ("\n");
- printf ("class %s : public ::Sfi::GNewable {\n", name.c_str());
- printf ("public:\n");
+ g_print ("\n");
+ g_print ("class %s : public ::Sfi::GNewable {\n", name.c_str());
+ g_print ("public:\n");
for (pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
- printf (" %s %s;\n", cTypeField (pi->type), pi->name.c_str());
+ g_print (" %s %s;\n", cTypeField (pi->type), pi->name.c_str());
}
- printf (" static inline %s from_rec (SfiRec *rec);\n", cTypeRet(ri->name));
- printf (" static inline SfiRec *to_rec (%s ptr);\n", cTypeArg(ri->name));
- printf (" static inline %s value_get_rec (const GValue *value);\n", cTypeRet(ri->name));
- printf (" static inline void value_set_rec (GValue *value, %s self);\n", cTypeArg (ri->name));
+ g_print (" static inline %s from_rec (SfiRec *rec);\n", cTypeRet(ri->name));
+ g_print (" static inline SfiRec *to_rec (%s ptr);\n", cTypeArg(ri->name));
+ g_print (" static inline %s value_get_rec (const GValue *value);\n", cTypeRet(ri->name));
+ g_print (" static inline void value_set_rec (GValue *value, %s self);\n", cTypeArg (ri->name));
/* FIXME: make this private (or delete it) */
- printf (" static inline const char* type_name () { return \"%s\"; }\n", type_name.c_str());
- printf ("};\n");
- printf ("\n");
+ g_print (" static inline const char* type_name () { return \"%s\"; }\n", type_name.c_str());
+ g_print ("};\n");
+ g_print ("\n");
}
}
void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
{
- printf ("\n/* record/sequence implementations */\n");
+ g_print ("\n/* record/sequence implementations */\n");
/* sequence members */
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
@@ -317,48 +317,48 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
String type_name = makeMixedName (si->name).c_str();
String elementFromValue = createTypeCode (si->content.type, "element", MODEL_FROM_VALUE);
- printf("%s\n", cTypeRet (si->name));
- printf("%s::from_seq (SfiSeq *sfi_seq)\n", nname.c_str());
- printf("{\n");
- printf(" %s seq;\n", cTypeRet (si->name));
- printf(" guint i, length;\n");
- printf("\n");
- printf(" g_return_val_if_fail (sfi_seq != NULL, seq);\n");
- printf("\n");
- printf(" length = sfi_seq_length (sfi_seq);\n");
- printf(" seq.resize (length);\n");
- printf(" for (i = 0; i < length; i++)\n");
- printf(" {\n");
- printf(" GValue *element = sfi_seq_get (sfi_seq, i);\n");
- printf(" seq[i] = %s;\n", elementFromValue.c_str());
- printf(" }\n");
- printf(" return seq;\n");
- printf("}\n\n");
+ g_print("%s\n", cTypeRet (si->name));
+ g_print("%s::from_seq (SfiSeq *sfi_seq)\n", nname.c_str());
+ g_print("{\n");
+ g_print(" %s seq;\n", cTypeRet (si->name));
+ g_print(" guint i, length;\n");
+ g_print("\n");
+ g_print(" g_return_val_if_fail (sfi_seq != NULL, seq);\n");
+ g_print("\n");
+ g_print(" length = sfi_seq_length (sfi_seq);\n");
+ g_print(" seq.resize (length);\n");
+ g_print(" for (i = 0; i < length; i++)\n");
+ g_print(" {\n");
+ g_print(" GValue *element = sfi_seq_get (sfi_seq, i);\n");
+ g_print(" seq[i] = %s;\n", elementFromValue.c_str());
+ g_print(" }\n");
+ g_print(" return seq;\n");
+ g_print("}\n\n");
String elementToValue = createTypeCode (si->content.type, "seq[i]", MODEL_TO_VALUE);
- printf("SfiSeq *\n");
- printf("%s::to_seq (%s seq)\n", nname.c_str(), cTypeArg (si->name));
- printf("{\n");
- printf(" SfiSeq *sfi_seq = sfi_seq_new ();\n");
- printf(" for (guint i = 0; i < seq.length(); i++)\n");
- printf(" {\n");
- printf(" GValue *element = %s;\n", elementToValue.c_str());
- printf(" sfi_seq_append (sfi_seq, element);\n");
- printf(" sfi_value_free (element);\n"); // FIXME: couldn't we have take_append
- printf(" }\n");
- printf(" return sfi_seq;\n");
- printf("}\n\n");
-
- printf ("%s\n", cTypeRet (si->name));
- printf ("%s::value_get_seq (const GValue *value)\n", nname.c_str());
- printf ("{\n");
- printf (" return ::Sfi::cxx_value_get_seq< %s> (value);\n", nname.c_str());
- printf ("}\n\n");
- printf ("void\n");
- printf ("%s::value_set_seq (GValue *value, %s self)\n", nname.c_str(), cTypeArg (si->name));
- printf ("{\n");
- printf (" ::Sfi::cxx_value_set_seq< %s> (value, self);\n", nname.c_str());
- printf ("}\n\n");
+ g_print("SfiSeq *\n");
+ g_print("%s::to_seq (%s seq)\n", nname.c_str(), cTypeArg (si->name));
+ g_print("{\n");
+ g_print(" SfiSeq *sfi_seq = sfi_seq_new ();\n");
+ g_print(" for (guint i = 0; i < seq.length(); i++)\n");
+ g_print(" {\n");
+ g_print(" GValue *element = %s;\n", elementToValue.c_str());
+ g_print(" sfi_seq_append (sfi_seq, element);\n");
+ g_print(" sfi_value_free (element);\n"); // FIXME: couldn't we have take_append
+ g_print(" }\n");
+ g_print(" return sfi_seq;\n");
+ g_print("}\n\n");
+
+ g_print ("%s\n", cTypeRet (si->name));
+ g_print ("%s::value_get_seq (const GValue *value)\n", nname.c_str());
+ g_print ("{\n");
+ g_print (" return ::Sfi::cxx_value_get_seq< %s> (value);\n", nname.c_str());
+ g_print ("}\n\n");
+ g_print ("void\n");
+ g_print ("%s::value_set_seq (GValue *value, %s self)\n", nname.c_str(), cTypeArg (si->name));
+ g_print ("{\n");
+ g_print (" ::Sfi::cxx_value_set_seq< %s> (value, self);\n", nname.c_str());
+ g_print ("}\n\n");
}
/* record members */
@@ -371,56 +371,56 @@ void CodeGeneratorClientCxx::printRecSeqImpl (NamespaceHelper& nspace)
String nname = ri->name;
String type_name = makeMixedName (ri->name).c_str();
- printf("%s\n", cTypeRet (ri->name));
- printf("%s::from_rec (SfiRec *sfi_rec)\n", nname.c_str());
- printf("{\n");
- printf(" GValue *element;\n");
- printf("\n");
- printf(" if (!sfi_rec)\n");
- printf(" return Sfi::INIT_NULL;\n");
- printf("\n");
- printf(" %s rec = Sfi::INIT_DEFAULT;\n", cTypeField (ri->name));
+ g_print("%s\n", cTypeRet (ri->name));
+ g_print("%s::from_rec (SfiRec *sfi_rec)\n", nname.c_str());
+ g_print("{\n");
+ g_print(" GValue *element;\n");
+ g_print("\n");
+ g_print(" if (!sfi_rec)\n");
+ g_print(" return Sfi::INIT_NULL;\n");
+ g_print("\n");
+ g_print(" %s rec = Sfi::INIT_DEFAULT;\n", cTypeField (ri->name));
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
String elementFromValue = createTypeCode (pi->type, "element", MODEL_FROM_VALUE);
- printf(" element = sfi_rec_get (sfi_rec, \"%s\");\n", pi->name.c_str());
- printf(" if (element)\n");
- printf(" rec->%s = %s;\n", pi->name.c_str(), elementFromValue.c_str());
+ g_print(" element = sfi_rec_get (sfi_rec, \"%s\");\n", pi->name.c_str());
+ g_print(" if (element)\n");
+ g_print(" rec->%s = %s;\n", pi->name.c_str(), elementFromValue.c_str());
}
- printf(" return rec;\n");
- printf("}\n\n");
-
- printf("SfiRec *\n");
- printf("%s::to_rec (%s rec)\n", nname.c_str(), cTypeArg (ri->name));
- printf("{\n");
- printf(" SfiRec *sfi_rec;\n");
- printf(" GValue *element;\n");
- printf("\n");
- printf(" if (!rec)\n");
- printf(" return NULL;\n");
- printf("\n");
- printf(" sfi_rec = sfi_rec_new ();\n");
+ g_print(" return rec;\n");
+ g_print("}\n\n");
+
+ g_print("SfiRec *\n");
+ g_print("%s::to_rec (%s rec)\n", nname.c_str(), cTypeArg (ri->name));
+ g_print("{\n");
+ g_print(" SfiRec *sfi_rec;\n");
+ g_print(" GValue *element;\n");
+ g_print("\n");
+ g_print(" if (!rec)\n");
+ g_print(" return NULL;\n");
+ g_print("\n");
+ g_print(" sfi_rec = sfi_rec_new ();\n");
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
String elementToValue = createTypeCode (pi->type, "rec->" + pi->name, MODEL_TO_VALUE);
- printf(" element = %s;\n", elementToValue.c_str());
- printf(" sfi_rec_set (sfi_rec, \"%s\", element);\n", pi->name.c_str());
- printf(" sfi_value_free (element);\n"); // FIXME: couldn't we have take_set
+ g_print(" element = %s;\n", elementToValue.c_str());
+ g_print(" sfi_rec_set (sfi_rec, \"%s\", element);\n", pi->name.c_str());
+ g_print(" sfi_value_free (element);\n"); // FIXME: couldn't we have take_set
}
- printf(" return sfi_rec;\n");
- printf("}\n\n");
-
- printf ("%s\n", cTypeRet(ri->name));
- printf ("%s::value_get_rec (const GValue *value)\n", nname.c_str());
- printf ("{\n");
- printf (" return ::Sfi::cxx_value_get_rec< %s> (value);\n", nname.c_str());
- printf ("}\n\n");
- printf ("void\n");
- printf ("%s::value_set_rec (GValue *value, %s self)\n", nname.c_str(), cTypeArg (ri->name));
- printf ("{\n");
- printf (" ::Sfi::cxx_value_set_rec< %s> (value, self);\n", nname.c_str());
- printf ("}\n\n");
+ g_print(" return sfi_rec;\n");
+ g_print("}\n\n");
+
+ g_print ("%s\n", cTypeRet(ri->name));
+ g_print ("%s::value_get_rec (const GValue *value)\n", nname.c_str());
+ g_print ("{\n");
+ g_print (" return ::Sfi::cxx_value_get_rec< %s> (value);\n", nname.c_str());
+ g_print ("}\n\n");
+ g_print ("void\n");
+ g_print ("%s::value_set_rec (GValue *value, %s self)\n", nname.c_str(), cTypeArg (ri->name));
+ g_print ("{\n");
+ g_print (" ::Sfi::cxx_value_set_rec< %s> (value, self);\n", nname.c_str());
+ g_print ("}\n\n");
}
}
@@ -431,7 +431,7 @@ bool CodeGeneratorClientCxx::run ()
vector<Class>::const_iterator ci;
vector<Method>::const_iterator mi;
- printf("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
+ g_print("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
if (generateHeader)
{
@@ -442,14 +442,14 @@ bool CodeGeneratorClientCxx::run ()
nspace.setFromSymbol (ei->name);
- printf("\nenum %s {\n", nspace.printableForm (ei->name).c_str());
+ g_print("\nenum %s {\n", nspace.printableForm (ei->name).c_str());
for (vector<ChoiceValue>::const_iterator ci = ei->contents.begin(); ci != ei->contents.end(); ci++)
{
/* don't export server side assigned choice values to the client */
String ename = makeUpperName (nspace.printableForm (ci->name));
- printf(" %s = %d,\n", ename.c_str(), ci->sequentialValue);
+ g_print(" %s = %d,\n", ename.c_str(), ci->sequentialValue);
}
- printf("};\n");
+ g_print("};\n");
}
nspace.leaveAll();
@@ -459,11 +459,11 @@ bool CodeGeneratorClientCxx::run ()
String name = nspace.printableForm (ei->name);
String lname = makeLowerName (ei->name);
- printf("const gchar* %s_to_choice (%s value);\n", lname.c_str(), name.c_str());
- printf("%s %s_from_choice (const gchar *choice);\n", name.c_str(), lname.c_str());
+ g_print("const gchar* %s_to_choice (%s value);\n", lname.c_str(), name.c_str());
+ g_print("%s %s_from_choice (const gchar *choice);\n", name.c_str(), lname.c_str());
}
- printf("\n");
+ g_print("\n");
/* prototypes for classes */
for (ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
@@ -472,7 +472,7 @@ bool CodeGeneratorClientCxx::run ()
nspace.setFromSymbol (ci->name);
String name = nspace.printableForm (ci->name);
- printf("class %s;\n", name.c_str());
+ g_print("class %s;\n", name.c_str());
}
printRecSeqForwardDecl (nspace);
@@ -486,29 +486,29 @@ bool CodeGeneratorClientCxx::run ()
String name = nspace.printableForm (ci->name);
String init;
- printf("\n");
+ g_print("\n");
if (ci->inherits == "")
{
- printf("class %s {\n", name.c_str());
- printf("protected:\n");
- printf(" SfiProxy _object_id;\n");
+ g_print("class %s {\n", name.c_str());
+ g_print("protected:\n");
+ g_print(" SfiProxy _object_id;\n");
init = "_object_id";
}
else
{
- printf("class %s : public %s {\n", name.c_str(), ci->inherits.c_str());
+ g_print("class %s : public %s {\n", name.c_str(), ci->inherits.c_str());
init = ci->inherits;
}
- printf("public:\n");
- printf(" %s() : %s (0) {}\n", name.c_str(), init.c_str());
- printf(" %s(SfiProxy p) : %s (p) {}\n", name.c_str(), init.c_str());
- printf(" %s(const %s& other) : %s (other._object_id) {}\n",
+ g_print("public:\n");
+ g_print(" %s() : %s (0) {}\n", name.c_str(), init.c_str());
+ g_print(" %s(SfiProxy p) : %s (p) {}\n", name.c_str(), init.c_str());
+ g_print(" %s(const %s& other) : %s (other._object_id) {}\n",
name.c_str(), name.c_str(), init.c_str());
- printf(" SfiProxy _proxy() const { return _object_id; }\n");
- printf(" operator bool() const { return _object_id != 0; }\n");
+ g_print(" SfiProxy _proxy() const { return _object_id; }\n");
+ g_print(" operator bool() const { return _object_id != 0; }\n");
printMethods(*ci);
printProperties(*ci);
- printf("};\n");
+ g_print("};\n");
}
printRecSeqDefinition (nspace);
printRecSeqImpl (nspace);
@@ -518,7 +518,7 @@ bool CodeGeneratorClientCxx::run ()
{
/* choice utils */
printChoiceConverters();
- printf("\n");
+ g_print("\n");
/* methods */
for (ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
@@ -529,7 +529,7 @@ bool CodeGeneratorClientCxx::run ()
}
}
- printf("\n");
+ g_print("\n");
for (mi = parser.getProcedures().begin(); mi != parser.getProcedures().end(); mi++)
{
if (parser.fromInclude (mi->name)) continue;
@@ -538,9 +538,9 @@ bool CodeGeneratorClientCxx::run ()
nspace.setFromSymbol (mi->name);
printProcedure (*mi, generateHeader);
}
- printf("\n");
+ g_print("\n");
nspace.leaveAll();
- printf("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
+ g_print("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
return 1;
}
@@ -581,7 +581,7 @@ void CodeGeneratorClientCxx::printMethods (const Class& cdef)
for(pi = mi->params.begin(); pi != mi->params.end(); pi++)
md.params.push_back (*pi);
- if (proto) printf (" ");
+ if (proto) g_print (" ");
printProcedure (md, proto, cdef.name);
}
}
@@ -600,32 +600,32 @@ void CodeGeneratorClientCxx::printProperties (const Class& cdef)
String ret = typeRet (pi->type);
if (proto) {
/* property getter */
- printf (" %s %s ();\n", ret.c_str(), getProperty.c_str());
+ g_print (" %s %s ();\n", ret.c_str(), getProperty.c_str());
/* property setter */
- printf (" void %s (%s %s);\n", setProperty.c_str(), cTypeArg (pi->type), newName.c_str());
+ g_print (" void %s (%s %s);\n", setProperty.c_str(), cTypeArg (pi->type), newName.c_str());
}
else {
/* property getter */
- printf ("%s\n", ret.c_str());
- printf ("%s::%s ()\n", cdef.name.c_str(), getProperty.c_str());
- printf ("{\n");
- printf (" const GValue *val;\n");
- printf (" val = sfi_glue_proxy_get_property (_proxy(), \"%s\");\n", propName.c_str());
- printf (" return %s;\n", createTypeCode (pi->type, "val", MODEL_FROM_VALUE).c_str());
- printf ("}\n");
- printf ("\n");
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s::%s ()\n", cdef.name.c_str(), getProperty.c_str());
+ g_print ("{\n");
+ g_print (" const GValue *val;\n");
+ g_print (" val = sfi_glue_proxy_get_property (_proxy(), \"%s\");\n", propName.c_str());
+ g_print (" return %s;\n", createTypeCode (pi->type, "val", MODEL_FROM_VALUE).c_str());
+ g_print ("}\n");
+ g_print ("\n");
/* property setter */
- printf ("void\n");
- printf ("%s::%s (%s %s)\n", cdef.name.c_str(), setProperty.c_str(),
+ g_print ("void\n");
+ g_print ("%s::%s (%s %s)\n", cdef.name.c_str(), setProperty.c_str(),
cTypeArg (pi->type), newName.c_str());
- printf ("{\n");
+ g_print ("{\n");
String to_val = createTypeCode (pi->type, newName, MODEL_TO_VALUE).c_str();
- printf (" GValue *val = %s;\n", to_val.c_str());
- printf (" sfi_glue_proxy_set_property (_proxy(), \"%s\", val);\n", propName.c_str());
- printf (" sfi_value_free (val);\n");
- printf ("}\n");
- printf ("\n");
+ g_print (" GValue *val = %s;\n", to_val.c_str());
+ g_print (" sfi_glue_proxy_set_property (_proxy(), \"%s\", val);\n", propName.c_str());
+ g_print (" sfi_value_free (val);\n");
+ g_print ("}\n");
+ g_print ("\n");
}
}
}
@@ -662,10 +662,10 @@ void
CodeGeneratorClientCxx::help()
{
CodeGeneratorCxxBase::help();
- fprintf (stderr, " --mixed mixed case identifiers (createMidiSynth)\n");
- fprintf (stderr, " --lower lower case identifiers (create_midi_synth)\n");
+ g_printerr (" --mixed mixed case identifiers (createMidiSynth)\n");
+ g_printerr (" --lower lower case identifiers (create_midi_synth)\n");
/*
- fprintf (stderr, " --namespace <namespace> set the namespace to use for the code\n");
+ g_printerr (stderr, " --namespace <namespace> set the namespace to use for the code\n");
*/
}
diff --git a/sfi/sfidl-corec.cc b/sfi/sfidl-corec.cc
index 9a1825c..2e6c845 100644
--- a/sfi/sfidl-corec.cc
+++ b/sfi/sfidl-corec.cc
@@ -68,21 +68,21 @@ class CodeGeneratorCoreC : public CodeGenerator {
printInfoStrings (const String& name,
const Map<String,IString> &infos)
{
- printf ("static const gchar *%s[] = {\n", name.c_str());
+ g_print ("static const gchar *%s[] = {\n", name.c_str());
Map<String,IString>::const_iterator ii;
for (ii = infos.begin(); ii != infos.end(); ii++)
- printf (" \"%s=%s\",\n", ii->first.c_str(), ii->second.c_str());
+ g_print (" \"%s=%s\",\n", ii->first.c_str(), ii->second.c_str());
- printf (" NULL,\n");
- printf ("};\n");
+ g_print (" NULL,\n");
+ g_print ("};\n");
}
void
help()
{
CodeGenerator::help();
- fprintf (stderr, " --init <name> set the name of the init function\n");
+ g_printerr (" --init <name> set the name of the init function\n");
}
OptionVector
getOptions()
@@ -215,220 +215,220 @@ class CodeGeneratorCoreC : public CodeGenerator {
void
generate_enum_type_id_prototypes ()
{
- printf ("\n\n/* enum type ids */\n");
+ g_print ("\n\n/* enum type ids */\n");
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
- printf ("extern GType %s;\n", make_type_id_symbol (ei->name));
+ g_print ("extern GType %s;\n", make_type_id_symbol (ei->name));
}
}
void
generate_enum_type_id_declarations ()
{
- printf ("\n\n/* enum type ids */\n");
+ g_print ("\n\n/* enum type ids */\n");
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
- printf ("GType %s = 0;\n", make_type_id_symbol (ei->name));
+ g_print ("GType %s = 0;\n", make_type_id_symbol (ei->name));
}
}
void
generate_enum_type_id_initializations ()
{
- printf ("\n\n /* enum type ids */\n");
+ g_print ("\n\n /* enum type ids */\n");
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
- printf (" %s = %s;\n", make_type_id_symbol (ei->name), make_TYPE_MACRO (ei->name));
+ g_print (" %s = %s;\n", make_type_id_symbol (ei->name), make_TYPE_MACRO (ei->name));
}
}
void
generate_enum_type_macros ()
{
- printf ("\n\n/* enum type macros */\n");
+ g_print ("\n\n/* enum type macros */\n");
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
- printf ("#define %s\t\t(%s)\n", make_TYPE_MACRO (ei->name), make_type_id_symbol (ei->name));
+ g_print ("#define %s\t\t(%s)\n", make_TYPE_MACRO (ei->name), make_type_id_symbol (ei->name));
}
}
void
generate_enum_definitions ()
{
- printf ("\n\n/* enums */\n");
+ g_print ("\n\n/* enums */\n");
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
String mname = makeMixedName (ei->name);
String lname = makeLowerName (ei->name);
- printf ("\ntypedef enum {\n");
+ g_print ("\ntypedef enum {\n");
for (vector<ChoiceValue>::const_iterator ci = ei->contents.begin(); ci != ei->contents.end(); ci++)
{
/* don't export server side assigned choice values to the client */
gint value = ci->value;
String ename = makeUpperName (ci->name);
- printf (" %s = %d,\n", ename.c_str(), value);
+ g_print (" %s = %d,\n", ename.c_str(), value);
}
- printf ("} %s;\n", mname.c_str());
+ g_print ("} %s;\n", mname.c_str());
}
}
void
generate_enum_value_array ()
{
- printf ("\n\n/* enum values */\n");
+ g_print ("\n\n/* enum values */\n");
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
String name = makeLowerName (ei->name);
- printf ("static const GEnumValue %s_value[%zd] = {\n", name.c_str(), ei->contents.size() + 1); // FIXME: i18n
+ g_print ("static const GEnumValue %s_value[%zd] = {\n", name.c_str(), ei->contents.size() + 1); // FIXME: i18n
for (vector<ChoiceValue>::const_iterator ci = ei->contents.begin(); ci != ei->contents.end(); ci++)
{
String ename = makeUpperName (ci->name);
- printf (" { %d, \"%s\", \"%s\" },\n", ci->value, ename.c_str(), ci->label.c_str());
+ g_print (" { %d, \"%s\", \"%s\" },\n", ci->value, ename.c_str(), ci->label.c_str());
}
- printf (" { 0, NULL, NULL }\n");
- printf ("};\n");
+ g_print (" { 0, NULL, NULL }\n");
+ g_print ("};\n");
}
}
void
generate_enum_method_prototypes ()
{
- printf ("\n\n/* enum functions */\n");
+ g_print ("\n\n/* enum functions */\n");
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
- printf ("SfiChoiceValues %s_get_values (void);\n", makeLowerName (ei->name).c_str());
+ g_print ("SfiChoiceValues %s_get_values (void);\n", makeLowerName (ei->name).c_str());
}
}
void
generate_enum_method_implementations ()
{
int enumCount = 0;
- printf ("\n\n/* enum functions */\n");
+ g_print ("\n\n/* enum functions */\n");
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
{
if (parser.fromInclude (ei->name))
continue;
String name = makeLowerName (ei->name);
- printf ("SfiChoiceValues\n");
- printf ("%s_get_values (void)\n", makeLowerName (ei->name).c_str());
- printf ("{\n");
- printf (" static SfiChoiceValue values[%zu];\n", ei->contents.size());
- printf (" static const SfiChoiceValues choice_values = {\n");
- printf (" G_N_ELEMENTS (values), values,\n");
- printf (" };\n");
- printf (" if (!values[0].choice_ident)\n {\n");
+ g_print ("SfiChoiceValues\n");
+ g_print ("%s_get_values (void)\n", makeLowerName (ei->name).c_str());
+ g_print ("{\n");
+ g_print (" static SfiChoiceValue values[%zu];\n", ei->contents.size());
+ g_print (" static const SfiChoiceValues choice_values = {\n");
+ g_print (" G_N_ELEMENTS (values), values,\n");
+ g_print (" };\n");
+ g_print (" if (!values[0].choice_ident)\n {\n");
int i = 0;
for (vector<ChoiceValue>::const_iterator vi = ei->contents.begin(); vi != ei->contents.end(); i++, vi++)
{
- printf (" values[%u].choice_ident = \"%s\";\n", i, makeUpperName (vi->name).c_str());
- printf (" values[%u].choice_label = %s;\n", i, vi->label.escaped().c_str());
- printf (" values[%u].choice_blurb = %s;\n", i, vi->blurb.escaped().c_str());
+ g_print (" values[%u].choice_ident = \"%s\";\n", i, makeUpperName (vi->name).c_str());
+ g_print (" values[%u].choice_label = %s;\n", i, vi->label.escaped().c_str());
+ g_print (" values[%u].choice_blurb = %s;\n", i, vi->blurb.escaped().c_str());
}
- printf (" }\n");
- printf (" return choice_values;\n");
- printf ("}\n");
+ g_print (" }\n");
+ g_print (" return choice_values;\n");
+ g_print ("}\n");
- printf ("GType %s = 0;\n", make_TYPE_MACRO (ei->name));
- printf ("\n");
+ g_print ("GType %s = 0;\n", make_TYPE_MACRO (ei->name));
+ g_print ("\n");
enumCount++;
}
if (enumCount)
{
- printf ("static void\n");
- printf ("choice2enum (const GValue *src_value,\n");
- printf (" GValue *dest_value)\n");
- printf ("{\n");
- printf (" sfi_value_choice2enum (src_value, dest_value, NULL);\n");
- printf ("}\n");
+ g_print ("static void\n");
+ g_print ("choice2enum (const GValue *src_value,\n");
+ g_print (" GValue *dest_value)\n");
+ g_print ("{\n");
+ g_print (" sfi_value_choice2enum (src_value, dest_value, NULL);\n");
+ g_print ("}\n");
}
}
void
generate_record_prototypes ()
{
- printf ("\n\n/* record typedefs */\n");
+ g_print ("\n\n/* record typedefs */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
continue;
String mname = makeMixedName (ri->name);
- printf ("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
+ g_print ("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
}
}
void
generate_record_definitions ()
{
- printf ("\n\n/* records */\n");
+ g_print ("\n\n/* records */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
String mname = makeMixedName (ri->name.c_str());
- printf ("struct _%s {\n", mname.c_str());
+ g_print ("struct _%s {\n", mname.c_str());
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
- printf (" %s %s;\n", TypeField (pi->type), pi->name.c_str());
+ g_print (" %s %s;\n", TypeField (pi->type), pi->name.c_str());
}
- printf ("};\n");
+ g_print ("};\n");
}
}
void
generate_record_type_id_prototypes ()
{
- printf ("\n\n/* record type ids */\n");
+ g_print ("\n\n/* record type ids */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
continue;
- printf ("extern GType %s;\n", make_type_id_symbol (ri->name));
+ g_print ("extern GType %s;\n", make_type_id_symbol (ri->name));
}
}
void
generate_record_type_id_declarations ()
{
- printf ("\n\n/* record type ids */\n");
+ g_print ("\n\n/* record type ids */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
continue;
- printf ("GType %s = 0;\n", make_type_id_symbol (ri->name));
+ g_print ("GType %s = 0;\n", make_type_id_symbol (ri->name));
}
}
void
generate_record_type_id_initializations ()
{
- printf ("\n\n /* record type ids */\n");
+ g_print ("\n\n /* record type ids */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
continue;
- printf (" %s = %s;\n", make_type_id_symbol (ri->name), make_TYPE_MACRO (ri->name));
+ g_print (" %s = %s;\n", make_type_id_symbol (ri->name), make_TYPE_MACRO (ri->name));
}
}
void
generate_record_type_macros ()
{
- printf ("\n\n/* record type macros */\n");
+ g_print ("\n\n/* record type macros */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
continue;
- printf ("#define %s\t\t(%s)\n", make_TYPE_MACRO (ri->name), make_type_id_symbol (ri->name));
+ g_print ("#define %s\t\t(%s)\n", make_TYPE_MACRO (ri->name), make_type_id_symbol (ri->name));
}
}
void
generate_record_method_prototypes ()
{
- printf ("\n\n/* record functions */\n");
+ g_print ("\n\n/* record functions */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name)) continue;
@@ -437,19 +437,19 @@ class CodeGeneratorCoreC : public CodeGenerator {
String arg = TypeArg (ri->name);
String lname = makeLowerName (ri->name.c_str());
- printf ("SfiRecFields %s_get_fields (void);\n", lname.c_str());
- printf ("%s %s_new (void);\n", ret.c_str(), lname.c_str());
- printf ("%s %s_copy_shallow (%s rec);\n", ret.c_str(), lname.c_str(), arg.c_str());
- printf ("%s %s_from_rec (SfiRec *sfi_rec);\n", ret.c_str(), lname.c_str());
- printf ("SfiRec *%s_to_rec (%s rec);\n", lname.c_str(), arg.c_str());
- printf ("void %s_free (%s rec);\n", lname.c_str(), arg.c_str());
- printf ("\n");
+ g_print ("SfiRecFields %s_get_fields (void);\n", lname.c_str());
+ g_print ("%s %s_new (void);\n", ret.c_str(), lname.c_str());
+ g_print ("%s %s_copy_shallow (%s rec);\n", ret.c_str(), lname.c_str(), arg.c_str());
+ g_print ("%s %s_from_rec (SfiRec *sfi_rec);\n", ret.c_str(), lname.c_str());
+ g_print ("SfiRec *%s_to_rec (%s rec);\n", lname.c_str(), arg.c_str());
+ g_print ("void %s_free (%s rec);\n", lname.c_str(), arg.c_str());
+ g_print ("\n");
}
}
void
generate_record_hack_cast_implementations ()
{
- printf ("\n\n/* record functions */\n");
+ g_print ("\n\n/* record functions */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
@@ -457,22 +457,22 @@ class CodeGeneratorCoreC : public CodeGenerator {
String ret = TypeRet (ri->name);
const gchar *type = make_fqtn (ri->name);
- printf ("static inline %s\n", ret.c_str());
- printf ("hack_cast (%s *cxxstruct)\n", type);
- printf ("{\n");
- printf (" return reinterpret_cast<%s> (cxxstruct);\n", ret.c_str());
- printf ("}\n");
- printf ("static inline %s*\n", type);
- printf ("hack_cast (%s cstruct)\n", ret.c_str());
- printf ("{\n");
- printf (" return reinterpret_cast< %s*> (cstruct);\n", type);
- printf ("}\n");
+ g_print ("static inline %s\n", ret.c_str());
+ g_print ("hack_cast (%s *cxxstruct)\n", type);
+ g_print ("{\n");
+ g_print (" return reinterpret_cast<%s> (cxxstruct);\n", ret.c_str());
+ g_print ("}\n");
+ g_print ("static inline %s*\n", type);
+ g_print ("hack_cast (%s cstruct)\n", ret.c_str());
+ g_print ("{\n");
+ g_print (" return reinterpret_cast< %s*> (cstruct);\n", type);
+ g_print ("}\n");
}
}
void
generate_record_method_implementations ()
{
- printf ("\n\n/* record functions */\n");
+ g_print ("\n\n/* record functions */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
@@ -484,55 +484,55 @@ class CodeGeneratorCoreC : public CodeGenerator {
const gchar *type = make_fqtn (ri->name);
- printf ("SfiRecFields\n");
- printf ("%s_get_fields (void)\n", lname.c_str());
- printf ("{\n");
- printf (" return %s::get_fields ();\n", type);
- printf ("}\n");
+ g_print ("SfiRecFields\n");
+ g_print ("%s_get_fields (void)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" return %s::get_fields ();\n", type);
+ g_print ("}\n");
- printf ("%s\n", ret.c_str());
- printf ("%s_new (void)\n", lname.c_str());
- printf ("{\n");
- printf (" %sHandle rh (Sfi::INIT_DEFAULT); \n", type);
- printf (" return hack_cast (rh.steal());\n");
- printf ("}\n");
-
- printf ("%s\n", ret.c_str());
- printf ("%s_copy_shallow (%s cstruct)\n", lname.c_str(), arg.c_str());
- printf ("{\n");
- printf (" %sHandle rh;\n", type);
- printf (" rh.set_boxed (hack_cast (cstruct));\n");
- printf (" return hack_cast (rh.steal());\n");
- printf ("}\n");
-
- printf ("%s\n", ret.c_str());
- printf ("%s_from_rec (SfiRec *rec)\n", lname.c_str());
- printf ("{\n");
- printf (" %sHandle rh = %s::from_rec (rec);\n", type, type);
- printf (" return hack_cast (rh.steal());\n");
- printf ("}\n");
-
- printf ("SfiRec*\n");
- printf ("%s_to_rec (%s cstruct)\n", lname.c_str(), arg.c_str());
- printf ("{\n");
- printf (" %sHandle rh;\n", type);
- printf (" rh.set_boxed (hack_cast (cstruct));\n");
- printf (" return %s::to_rec (rh);\n", type);
- printf ("}\n");
-
- printf ("void\n");
- printf ("%s_free (%s cstruct)\n", lname.c_str(), arg.c_str());
- printf ("{\n");
- printf (" %sHandle rh;\n", type);
- printf (" rh.take (hack_cast (cstruct));\n");
- printf ("}\n");
- printf ("\n");
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_new (void)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" %sHandle rh (Sfi::INIT_DEFAULT); \n", type);
+ g_print (" return hack_cast (rh.steal());\n");
+ g_print ("}\n");
+
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_copy_shallow (%s cstruct)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" %sHandle rh;\n", type);
+ g_print (" rh.set_boxed (hack_cast (cstruct));\n");
+ g_print (" return hack_cast (rh.steal());\n");
+ g_print ("}\n");
+
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_from_rec (SfiRec *rec)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" %sHandle rh = %s::from_rec (rec);\n", type, type);
+ g_print (" return hack_cast (rh.steal());\n");
+ g_print ("}\n");
+
+ g_print ("SfiRec*\n");
+ g_print ("%s_to_rec (%s cstruct)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" %sHandle rh;\n", type);
+ g_print (" rh.set_boxed (hack_cast (cstruct));\n");
+ g_print (" return %s::to_rec (rh);\n", type);
+ g_print ("}\n");
+
+ g_print ("void\n");
+ g_print ("%s_free (%s cstruct)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" %sHandle rh;\n", type);
+ g_print (" rh.take (hack_cast (cstruct));\n");
+ g_print ("}\n");
+ g_print ("\n");
}
}
void
generate_record_converter_implementations ()
{
- printf ("\n\n/* record converters */\n");
+ g_print ("\n\n/* record converters */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
@@ -540,53 +540,53 @@ class CodeGeneratorCoreC : public CodeGenerator {
String name = makeLowerName (ri->name);
- printf ("static GParamSpec *%s_field[%zd];\n", name.c_str(), ri->contents.size());
- printf ("SfiRecFields %s_fields = { %zd, %s_field };\n", name.c_str(), ri->contents.size(), name.c_str());
+ g_print ("static GParamSpec *%s_field[%zd];\n", name.c_str(), ri->contents.size());
+ g_print ("SfiRecFields %s_fields = { %zd, %s_field };\n", name.c_str(), ri->contents.size(), name.c_str());
String mname = makeMixedName (ri->name);
- printf ("static void\n");
- printf ("%s_boxed2rec (const GValue *src_value, GValue *dest_value)\n", name.c_str());
- printf ("{\n");
- printf (" gpointer boxed = g_value_get_boxed (src_value);\n");
- printf (" sfi_value_take_rec (dest_value, boxed ? %s_to_rec (boxed) : NULL);\n", name.c_str());
- printf ("}\n");
-
- printf ("static void\n");
- printf ("%s_rec2boxed (const GValue *src_value, GValue *dest_value)\n", name.c_str());
- printf ("{\n");
- printf (" SfiRec *rec = sfi_value_get_rec (src_value);\n");
- printf (" g_value_take_boxed (dest_value,\n");
- printf (" rec ? %s_from_rec (rec) : NULL);\n", name.c_str());
- printf ("}\n");
+ g_print ("static void\n");
+ g_print ("%s_boxed2rec (const GValue *src_value, GValue *dest_value)\n", name.c_str());
+ g_print ("{\n");
+ g_print (" gpointer boxed = g_value_get_boxed (src_value);\n");
+ g_print (" sfi_value_take_rec (dest_value, boxed ? %s_to_rec (boxed) : NULL);\n", name.c_str());
+ g_print ("}\n");
+
+ g_print ("static void\n");
+ g_print ("%s_rec2boxed (const GValue *src_value, GValue *dest_value)\n", name.c_str());
+ g_print ("{\n");
+ g_print (" SfiRec *rec = sfi_value_get_rec (src_value);\n");
+ g_print (" g_value_take_boxed (dest_value,\n");
+ g_print (" rec ? %s_from_rec (rec) : NULL);\n", name.c_str());
+ g_print ("}\n");
printInfoStrings (name + "_info_strings", ri->infos);
- printf ("static SfiBoxedRecordInfo %s_boxed_info = {\n", name.c_str());
- printf (" \"%s\",\n", mname.c_str());
- printf (" { %zd, %s_field },\n", ri->contents.size(), name.c_str());
- printf (" %s_boxed2rec,\n", name.c_str());
- printf (" %s_rec2boxed,\n", name.c_str());
- printf (" %s_info_strings\n", name.c_str());
- printf ("};\n");
- printf ("GType %s = 0;\n", make_TYPE_MACRO (ri->name));
+ g_print ("static SfiBoxedRecordInfo %s_boxed_info = {\n", name.c_str());
+ g_print (" \"%s\",\n", mname.c_str());
+ g_print (" { %zd, %s_field },\n", ri->contents.size(), name.c_str());
+ g_print (" %s_boxed2rec,\n", name.c_str());
+ g_print (" %s_rec2boxed,\n", name.c_str());
+ g_print (" %s_info_strings\n", name.c_str());
+ g_print ("};\n");
+ g_print ("GType %s = 0;\n", make_TYPE_MACRO (ri->name));
}
}
void
generate_sequence_prototypes ()
{
- printf ("\n\n/* sequence typedefs */\n");
+ g_print ("\n\n/* sequence typedefs */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
continue;
String mname = makeMixedName (si->name);
- printf ("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
+ g_print ("typedef struct _%s %s;\n", mname.c_str(), mname.c_str());
}
}
void
generate_sequence_definitions ()
{
- printf ("\n\n/* sequences */\n");
+ g_print ("\n\n/* sequences */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
@@ -595,60 +595,60 @@ class CodeGeneratorCoreC : public CodeGenerator {
String array = String (TypeField (si->content.type)) + "*";
String elements = si->content.name;
- printf ("struct _%s {\n", mname.c_str());
- printf (" guint n_%s;\n", elements.c_str ());
- printf (" %s %s;\n", array.c_str(), elements.c_str());
- printf ("};\n");
+ g_print ("struct _%s {\n", mname.c_str());
+ g_print (" guint n_%s;\n", elements.c_str ());
+ g_print (" %s %s;\n", array.c_str(), elements.c_str());
+ g_print ("};\n");
}
}
void
generate_sequence_type_id_prototypes ()
{
- printf ("\n\n/* sequence type ids */\n");
+ g_print ("\n\n/* sequence type ids */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
continue;
- printf ("extern GType %s;\n", make_type_id_symbol (si->name));
+ g_print ("extern GType %s;\n", make_type_id_symbol (si->name));
}
}
void
generate_sequence_type_id_declarations ()
{
- printf ("\n\n/* sequence type ids */\n");
+ g_print ("\n\n/* sequence type ids */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
continue;
- printf ("GType %s = 0;\n", make_type_id_symbol (si->name));
+ g_print ("GType %s = 0;\n", make_type_id_symbol (si->name));
}
}
void
generate_sequence_type_id_initializations ()
{
- printf ("\n\n /* sequence type ids */\n");
+ g_print ("\n\n /* sequence type ids */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
continue;
- printf (" %s = %s;\n", make_type_id_symbol (si->name), make_TYPE_MACRO (si->name));
+ g_print (" %s = %s;\n", make_type_id_symbol (si->name), make_TYPE_MACRO (si->name));
}
}
void
generate_sequence_type_macros ()
{
- printf ("\n\n/* sequence type macros */\n");
+ g_print ("\n\n/* sequence type macros */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
continue;
- printf ("#define %s\t\t(%s)\n", make_TYPE_MACRO (si->name), make_type_id_symbol (si->name));
+ g_print ("#define %s\t\t(%s)\n", make_TYPE_MACRO (si->name), make_type_id_symbol (si->name));
}
}
void
generate_sequence_method_prototypes ()
{
- printf ("\n\n/* sequence functions */\n");
+ g_print ("\n\n/* sequence functions */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
@@ -658,21 +658,21 @@ class CodeGeneratorCoreC : public CodeGenerator {
String element = TypeArg (si->content.type);
String lname = makeLowerName (si->name.c_str());
- printf ("GParamSpec* %s_get_element (void);\n", lname.c_str());
- printf ("%s %s_new (void);\n", ret.c_str(), lname.c_str());
- printf ("void %s_append (%s seq, %s element);\n", lname.c_str(), arg.c_str(), element.c_str());
- printf ("%s %s_copy_shallow (%s seq);\n", ret.c_str(), lname.c_str(), arg.c_str());
- printf ("%s %s_from_seq (SfiSeq *sfi_seq);\n", ret.c_str(), lname.c_str());
- printf ("SfiSeq *%s_to_seq (%s seq);\n", lname.c_str(), arg.c_str());
- printf ("void %s_resize (%s seq, guint new_size);\n", lname.c_str(), arg.c_str());
- printf ("void %s_free (%s seq);\n", lname.c_str(), arg.c_str());
- printf ("\n");
+ g_print ("GParamSpec* %s_get_element (void);\n", lname.c_str());
+ g_print ("%s %s_new (void);\n", ret.c_str(), lname.c_str());
+ g_print ("void %s_append (%s seq, %s element);\n", lname.c_str(), arg.c_str(), element.c_str());
+ g_print ("%s %s_copy_shallow (%s seq);\n", ret.c_str(), lname.c_str(), arg.c_str());
+ g_print ("%s %s_from_seq (SfiSeq *sfi_seq);\n", ret.c_str(), lname.c_str());
+ g_print ("SfiSeq *%s_to_seq (%s seq);\n", lname.c_str(), arg.c_str());
+ g_print ("void %s_resize (%s seq, guint new_size);\n", lname.c_str(), arg.c_str());
+ g_print ("void %s_free (%s seq);\n", lname.c_str(), arg.c_str());
+ g_print ("\n");
}
}
void
generate_sequence_hack_cast_implementations ()
{
- printf ("\n\n/* sequence C <-> C++ casts */\n");
+ g_print ("\n\n/* sequence C <-> C++ casts */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
@@ -683,22 +683,22 @@ class CodeGeneratorCoreC : public CodeGenerator {
/* the cast functions take an extra unused sequence argument, to distinguish
* two sequences A and B which both have the same CSeq type (e.g. SfiInt and SfiNote).
*/
- printf ("static inline %s\n", ret.c_str());
- printf ("hack_cast (const %s &unused, %s::CSeq *cxxseq)\n", type, type);
- printf ("{\n");
- printf (" return reinterpret_cast<%s> (cxxseq);\n", ret.c_str());
- printf ("}\n");
- printf ("static inline %s::CSeq*\n", type);
- printf ("hack_cast (%s cseq)\n", ret.c_str());
- printf ("{\n");
- printf (" return reinterpret_cast< %s::CSeq*> (cseq);\n", type);
- printf ("}\n");
+ g_print ("static inline %s\n", ret.c_str());
+ g_print ("hack_cast (const %s &unused, %s::CSeq *cxxseq)\n", type, type);
+ g_print ("{\n");
+ g_print (" return reinterpret_cast<%s> (cxxseq);\n", ret.c_str());
+ g_print ("}\n");
+ g_print ("static inline %s::CSeq*\n", type);
+ g_print ("hack_cast (%s cseq)\n", ret.c_str());
+ g_print ("{\n");
+ g_print (" return reinterpret_cast< %s::CSeq*> (cseq);\n", type);
+ g_print ("}\n");
}
}
void
generate_sequence_method_implementations ()
{
- printf ("\n\n/* sequence functions */\n");
+ g_print ("\n\n/* sequence functions */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
@@ -711,120 +711,120 @@ class CodeGeneratorCoreC : public CodeGenerator {
const gchar *type = make_fqtn (si->name);
- printf ("GParamSpec*\n");
- printf ("%s_get_element (void)\n", lname.c_str());
- printf ("{\n");
- printf (" return %s::get_element ();\n", type);
- printf ("}\n");
+ g_print ("GParamSpec*\n");
+ g_print ("%s_get_element (void)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" return %s::get_element ();\n", type);
+ g_print ("}\n");
- printf ("%s\n", ret.c_str());
- printf ("%s_new (void)\n", lname.c_str());
- printf ("{\n");
- printf (" %s sh (0);\n", type);
- printf (" return hack_cast (sh, sh.steal());\n");
- printf ("}\n");
-
- printf ("void\n");
- printf ("%s_append (%s cseq, %s element)\n", lname.c_str(), arg.c_str(), element.c_str());
- printf ("{\n");
- printf (" g_return_if_fail (cseq != NULL);\n");
- printf (" %s sh (0);\n", type);
- printf (" sh.take (hack_cast (cseq));\n");
- printf (" sh += %s;\n", cxx_handle (si->content.type, "element"));
- printf (" sh.steal(); /* prevent cseq deletion */\n");
- printf ("}\n");
-
- printf ("%s\n", ret.c_str());
- printf ("%s_copy_shallow (%s cseq)\n", lname.c_str(), arg.c_str());
- printf ("{\n");
- printf (" %s sh (0);\n", type);
- printf (" sh.set_boxed (hack_cast (cseq));\n");
- printf (" return hack_cast (sh, sh.steal());\n");
- printf ("}\n");
-
- printf ("%s\n", ret.c_str());
- printf ("%s_from_seq (SfiSeq *seq)\n", lname.c_str());
- printf ("{\n");
- printf (" %s sh = %s::from_seq (seq);\n", type, type);
- printf (" return hack_cast (sh, sh.steal());\n");
- printf ("}\n");
-
- printf ("SfiSeq*\n");
- printf ("%s_to_seq (%s cseq)\n", lname.c_str(), arg.c_str());
- printf ("{\n");
- printf (" %s sh (0);\n", type);
- printf (" sh.take (hack_cast (cseq));\n");
- printf (" SfiSeq *seq = %s::to_seq (sh);\n", type);
- printf (" sh.steal(); /* prevent cseq deletion */\n");
- printf (" return seq;\n");
- printf ("}\n");
-
- printf ("void\n");
- printf ("%s_resize (%s cseq, guint n)\n", lname.c_str(), arg.c_str());
- printf ("{\n");
- printf (" g_return_if_fail (cseq != NULL);\n");
- printf (" %s sh (0);\n", type);
- printf (" sh.take (hack_cast (cseq));\n");
- printf (" sh.resize (n);\n");
- printf (" sh.steal(); /* prevent cseq deletion */\n");
- printf ("}\n");
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_new (void)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" %s sh (0);\n", type);
+ g_print (" return hack_cast (sh, sh.steal());\n");
+ g_print ("}\n");
+
+ g_print ("void\n");
+ g_print ("%s_append (%s cseq, %s element)\n", lname.c_str(), arg.c_str(), element.c_str());
+ g_print ("{\n");
+ g_print (" g_return_if_fail (cseq != NULL);\n");
+ g_print (" %s sh (0);\n", type);
+ g_print (" sh.take (hack_cast (cseq));\n");
+ g_print (" sh += %s;\n", cxx_handle (si->content.type, "element"));
+ g_print (" sh.steal(); /* prevent cseq deletion */\n");
+ g_print ("}\n");
+
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_copy_shallow (%s cseq)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" %s sh (0);\n", type);
+ g_print (" sh.set_boxed (hack_cast (cseq));\n");
+ g_print (" return hack_cast (sh, sh.steal());\n");
+ g_print ("}\n");
+
+ g_print ("%s\n", ret.c_str());
+ g_print ("%s_from_seq (SfiSeq *seq)\n", lname.c_str());
+ g_print ("{\n");
+ g_print (" %s sh = %s::from_seq (seq);\n", type, type);
+ g_print (" return hack_cast (sh, sh.steal());\n");
+ g_print ("}\n");
+
+ g_print ("SfiSeq*\n");
+ g_print ("%s_to_seq (%s cseq)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" %s sh (0);\n", type);
+ g_print (" sh.take (hack_cast (cseq));\n");
+ g_print (" SfiSeq *seq = %s::to_seq (sh);\n", type);
+ g_print (" sh.steal(); /* prevent cseq deletion */\n");
+ g_print (" return seq;\n");
+ g_print ("}\n");
+
+ g_print ("void\n");
+ g_print ("%s_resize (%s cseq, guint n)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" g_return_if_fail (cseq != NULL);\n");
+ g_print (" %s sh (0);\n", type);
+ g_print (" sh.take (hack_cast (cseq));\n");
+ g_print (" sh.resize (n);\n");
+ g_print (" sh.steal(); /* prevent cseq deletion */\n");
+ g_print ("}\n");
- printf ("void\n");
- printf ("%s_free (%s cseq)\n", lname.c_str(), arg.c_str());
- printf ("{\n");
- printf (" %s sh (0);\n", type);
- printf (" sh.take (hack_cast (cseq));\n");
- printf ("}\n");
- printf ("\n");
+ g_print ("void\n");
+ g_print ("%s_free (%s cseq)\n", lname.c_str(), arg.c_str());
+ g_print ("{\n");
+ g_print (" %s sh (0);\n", type);
+ g_print (" sh.take (hack_cast (cseq));\n");
+ g_print ("}\n");
+ g_print ("\n");
}
}
void
generate_sequence_converter_implementations ()
{
- printf ("\n\n/* sequence converters */\n");
+ g_print ("\n\n/* sequence converters */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name)) continue;
String name = makeLowerName (si->name);
- printf ("static GParamSpec *%s_content;\n", name.c_str());
+ g_print ("static GParamSpec *%s_content;\n", name.c_str());
String mname = makeMixedName (si->name);
- printf ("static void\n");
- printf ("%s_boxed2seq (const GValue *src_value, GValue *dest_value)\n", name.c_str());
- printf ("{\n");
- printf (" gpointer boxed = g_value_get_boxed (src_value);\n");
- printf (" sfi_value_take_seq (dest_value, boxed ? %s_to_seq (boxed) : NULL);\n", name.c_str());
- printf ("}\n");
-
- printf ("static void\n");
- printf ("%s_seq2boxed (const GValue *src_value, GValue *dest_value)\n", name.c_str());
- printf ("{\n");
- printf (" SfiSeq *seq = sfi_value_get_seq (src_value);\n");
- printf (" g_value_take_boxed (dest_value,\n");
- printf (" seq ? %s_from_seq (seq) : NULL);\n", name.c_str());
- printf ("}\n");
+ g_print ("static void\n");
+ g_print ("%s_boxed2seq (const GValue *src_value, GValue *dest_value)\n", name.c_str());
+ g_print ("{\n");
+ g_print (" gpointer boxed = g_value_get_boxed (src_value);\n");
+ g_print (" sfi_value_take_seq (dest_value, boxed ? %s_to_seq (boxed) : NULL);\n", name.c_str());
+ g_print ("}\n");
+
+ g_print ("static void\n");
+ g_print ("%s_seq2boxed (const GValue *src_value, GValue *dest_value)\n", name.c_str());
+ g_print ("{\n");
+ g_print (" SfiSeq *seq = sfi_value_get_seq (src_value);\n");
+ g_print (" g_value_take_boxed (dest_value,\n");
+ g_print (" seq ? %s_from_seq (seq) : NULL);\n", name.c_str());
+ g_print ("}\n");
printInfoStrings (name + "_info_strings", si->infos);
- printf ("static SfiBoxedSequenceInfo %s_boxed_info = {\n", name.c_str());
- printf (" \"%s\",\n", mname.c_str());
- printf (" NULL, /* %s_content */\n", name.c_str());
- printf (" %s_boxed2seq,\n", name.c_str());
- printf (" %s_seq2boxed,\n", name.c_str());
- printf (" %s_info_strings\n", name.c_str());
- printf ("};\n");
- printf ("GType %s = 0;\n", make_TYPE_MACRO (si->name));
+ g_print ("static SfiBoxedSequenceInfo %s_boxed_info = {\n", name.c_str());
+ g_print (" \"%s\",\n", mname.c_str());
+ g_print (" NULL, /* %s_content */\n", name.c_str());
+ g_print (" %s_boxed2seq,\n", name.c_str());
+ g_print (" %s_seq2boxed,\n", name.c_str());
+ g_print (" %s_info_strings\n", name.c_str());
+ g_print ("};\n");
+ g_print ("GType %s = 0;\n", make_TYPE_MACRO (si->name));
}
}
void
generate_init_function ()
{
bool first = true;
- printf ("\n\n/* type initialization function */\n");
- printf ("static void\n%s (void)\n", generateInitFunction.c_str());
- printf ("{\n");
+ g_print ("\n\n/* type initialization function */\n");
+ g_print ("static void\n%s (void)\n", generateInitFunction.c_str());
+ g_print ("{\n");
/*
* It is important to follow the declaration order of the idl file here, as for
@@ -841,7 +841,7 @@ class CodeGeneratorCoreC : public CodeGenerator {
if (parser.isRecord (*ti) || parser.isSequence (*ti))
{
if (!first)
- printf ("\n");
+ g_print ("\n");
first = false;
}
if (parser.isRecord (*ti))
@@ -854,8 +854,8 @@ class CodeGeneratorCoreC : public CodeGenerator {
for (vector<Param>::const_iterator pi = rdef.contents.begin(); pi != rdef.contents.end(); pi++, f++)
{
if (generateIdlLineNumbers)
- printf ("#line %u \"%s\"\n", pi->line, parser.fileName().c_str());
- printf (" %s_field[%d] = %s;\n", name.c_str(), f, construct_pspec (*pi).c_str());
+ g_print ("#line %u \"%s\"\n", pi->line, parser.fileName().c_str());
+ g_print (" %s_field[%d] = %s;\n", name.c_str(), f, construct_pspec (*pi).c_str());
}
}
if (parser.isSequence (*ti))
@@ -865,8 +865,8 @@ class CodeGeneratorCoreC : public CodeGenerator {
String name = makeLowerName (sdef.name);
if (generateIdlLineNumbers)
- printf ("#line %u \"%s\"\n", sdef.content.line, parser.fileName().c_str());
- printf (" %s_content = %s;\n", name.c_str(), construct_pspec (sdef.content).c_str());
+ g_print ("#line %u \"%s\"\n", sdef.content.line, parser.fileName().c_str());
+ g_print (" %s_content = %s;\n", name.c_str(), construct_pspec (sdef.content).c_str());
}
}
for (vector<Choice>::const_iterator ei = parser.getChoices().begin(); ei != parser.getChoices().end(); ei++)
@@ -877,11 +877,11 @@ class CodeGeneratorCoreC : public CodeGenerator {
String name = makeLowerName(ei->name);
String mname = makeMixedName(ei->name);
- printf (" %s = g_enum_register_static (\"%s\", %s_value);\n", gname.c_str(),
+ g_print (" %s = g_enum_register_static (\"%s\", %s_value);\n", gname.c_str(),
mname.c_str(), name.c_str());
- printf (" g_value_register_transform_func (SFI_TYPE_CHOICE, %s, choice2enum);\n",
+ g_print (" g_value_register_transform_func (SFI_TYPE_CHOICE, %s, choice2enum);\n",
gname.c_str());
- printf (" g_value_register_transform_func (%s, SFI_TYPE_CHOICE,"
+ g_print (" g_value_register_transform_func (%s, SFI_TYPE_CHOICE,"
" sfi_value_enum2choice);\n", gname.c_str());
}
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
@@ -891,9 +891,9 @@ class CodeGeneratorCoreC : public CodeGenerator {
String gname = make_TYPE_MACRO (ri->name);
String name = makeLowerName(ri->name);
- printf (" %s = sfi_boxed_make_record (&%s_boxed_info,\n", gname.c_str(), name.c_str());
- printf (" (GBoxedCopyFunc) %s_copy_shallow,\n", name.c_str());
- printf (" (GBoxedFreeFunc) %s_free);\n", name.c_str());
+ g_print (" %s = sfi_boxed_make_record (&%s_boxed_info,\n", gname.c_str(), name.c_str());
+ g_print (" (GBoxedCopyFunc) %s_copy_shallow,\n", name.c_str());
+ g_print (" (GBoxedFreeFunc) %s_free);\n", name.c_str());
}
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
@@ -902,12 +902,12 @@ class CodeGeneratorCoreC : public CodeGenerator {
String gname = make_TYPE_MACRO (si->name);
String name = makeLowerName(si->name);
- printf (" %s_boxed_info.element = %s_content;\n", name.c_str(), name.c_str());
- printf (" %s = sfi_boxed_make_sequence (&%s_boxed_info,\n", gname.c_str(), name.c_str());
- printf (" (GBoxedCopyFunc) %s_copy_shallow,\n", name.c_str());
- printf (" (GBoxedFreeFunc) %s_free);\n", name.c_str());
+ g_print (" %s_boxed_info.element = %s_content;\n", name.c_str(), name.c_str());
+ g_print (" %s = sfi_boxed_make_sequence (&%s_boxed_info,\n", gname.c_str(), name.c_str());
+ g_print (" (GBoxedCopyFunc) %s_copy_shallow,\n", name.c_str());
+ g_print (" (GBoxedFreeFunc) %s_free);\n", name.c_str());
}
- printf ("}\n");
+ g_print ("}\n");
}
public:
@@ -919,9 +919,9 @@ public:
bool
run ()
{
- printf ("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
+ g_print ("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
if (generateSource)
- printf ("#include <string.h>\n");
+ g_print ("#include <string.h>\n");
if (generateHeader)
{
@@ -936,11 +936,11 @@ public:
generate_enum_type_id_prototypes ();
generate_record_type_id_prototypes ();
generate_sequence_type_id_prototypes ();
- printf ("\n#ifndef __cplusplus\n");
+ g_print ("\n#ifndef __cplusplus\n");
generate_enum_type_macros ();
generate_record_type_macros ();
generate_sequence_type_macros ();
- printf ("\n#endif\n");
+ g_print ("\n#endif\n");
}
if (generateSource)
@@ -959,16 +959,16 @@ public:
// printChoiceConverters ();
if (generateInitFunction != "")
{ // generate_init_function();
- printf ("\n\n/* type initialization function */\n");
- printf ("static void\n%s (void)\n{\n", generateInitFunction.c_str());
+ g_print ("\n\n/* type initialization function */\n");
+ g_print ("static void\n%s (void)\n{\n", generateInitFunction.c_str());
generate_enum_type_id_initializations ();
generate_record_type_id_initializations ();
generate_sequence_type_id_initializations ();
- printf ("}\n");
+ g_print ("}\n");
}
}
- printf ("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
+ g_print ("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
return true;
}
};
diff --git a/sfi/sfidl-corecxx.cc b/sfi/sfidl-corecxx.cc
index a61b6b1..23d282e 100644
--- a/sfi/sfidl-corecxx.cc
+++ b/sfi/sfidl-corecxx.cc
@@ -480,57 +480,57 @@ public:
void
generate_choice_prototypes (NamespaceHelper& nspace)
{
- printf ("\n\n/* choice prototypes */\n");
+ g_print ("\n\n/* choice prototypes */\n");
for (vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name))
continue;
nspace.setFromSymbol(ci->name);
const char *name = nspace.printable_form (ci->name);
- printf ("static SfiChoiceValues %s_choice_values();\n", name);
+ g_print ("static SfiChoiceValues %s_choice_values();\n", name);
}
}
void
generate_choice_implementations (NamespaceHelper& nspace)
{
- printf ("\n\n/* choice implementations */\n");
+ g_print ("\n\n/* choice implementations */\n");
for (vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name))
continue;
nspace.setFromSymbol(ci->name);
const char *name = nspace.printable_form (ci->name);
- printf ("static SfiChoiceValues\n");
- printf ("%s_choice_values()\n", name);
- printf ("{\n");
- printf (" static SfiChoiceValue values[%zu];\n", ci->contents.size());
- printf (" static const SfiChoiceValues choice_values = {\n");
- printf (" G_N_ELEMENTS (values), values,\n");
- printf (" };\n");
- printf (" if (!values[0].choice_ident)\n {\n");
+ g_print ("static SfiChoiceValues\n");
+ g_print ("%s_choice_values()\n", name);
+ g_print ("{\n");
+ g_print (" static SfiChoiceValue values[%zu];\n", ci->contents.size());
+ g_print (" static const SfiChoiceValues choice_values = {\n");
+ g_print (" G_N_ELEMENTS (values), values,\n");
+ g_print (" };\n");
+ g_print (" if (!values[0].choice_ident)\n {\n");
int i = 0;
for (vector<ChoiceValue>::const_iterator vi = ci->contents.begin(); vi != ci->contents.end(); i++, vi++)
{
- printf (" values[%u].choice_ident = \"%s\";\n", i, make_FULL_UPPER (vi->name));
- printf (" values[%u].choice_label = %s;\n", i, vi->label.escaped().c_str());
- printf (" values[%u].choice_blurb = %s;\n", i, vi->blurb.escaped().c_str());
+ g_print (" values[%u].choice_ident = \"%s\";\n", i, make_FULL_UPPER (vi->name));
+ g_print (" values[%u].choice_label = %s;\n", i, vi->label.escaped().c_str());
+ g_print (" values[%u].choice_blurb = %s;\n", i, vi->blurb.escaped().c_str());
}
- printf (" }\n");
- printf (" return choice_values;\n");
- printf ("}\n\n");
+ g_print (" }\n");
+ g_print (" return choice_values;\n");
+ g_print ("}\n\n");
}
}
void
generate_enum_prototypes (NamespaceHelper& nspace)
{
- printf ("\n\n/* enum prototypes */\n");
+ g_print ("\n\n/* enum prototypes */\n");
for (vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name))
continue;
nspace.setFromSymbol(ci->name);
// const char *name = nspace.printable_form (ci->name);
- printf ("#define %s\t\tBSE_CXX_DECLARED_ENUM_TYPE (%s, %s)\n",
+ g_print ("#define %s\t\tBSE_CXX_DECLARED_ENUM_TYPE (%s, %s)\n",
make_TYPE_NAME (ci->name),
nspace.namespaceOf (ci->name).c_str(),
pure_TypeName (ci->name));
@@ -540,41 +540,41 @@ public:
void
generate_enum_definitions (NamespaceHelper& nspace)
{
- printf ("\n\n/* enum definitions */\n");
+ g_print ("\n\n/* enum definitions */\n");
for (vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name))
continue;
nspace.setFromSymbol(ci->name);
const char *name = nspace.printable_form (ci->name);
- printf ("enum %s {\n", name);
+ g_print ("enum %s {\n", name);
for (vector<ChoiceValue>::const_iterator vi = ci->contents.begin(); vi != ci->contents.end(); vi++)
- printf (" %s = %d,\n", pure_UPPER (vi->name), vi->value);
- printf ("};\n");
+ g_print (" %s = %d,\n", pure_UPPER (vi->name), vi->value);
+ g_print ("};\n");
}
}
void
generate_enum_declarations (NamespaceHelper& nspace)
{
- printf ("\n\n/* enum declarations */\n");
+ g_print ("\n\n/* enum declarations */\n");
for (vector<Choice>::const_iterator ci = parser.getChoices().begin(); ci != parser.getChoices().end(); ci++)
{
if (parser.fromInclude (ci->name))
continue;
nspace.setFromSymbol(ci->name);
// const char *name = nspace.printable_form (ci->name);
- printf ("BSE_CXX_DECLARE_ENUM (%s, \"%s\", %zu,\n",
+ g_print ("BSE_CXX_DECLARE_ENUM (%s, \"%s\", %zu,\n",
pure_TypeName (ci->name), make_PrefixedTypeName (ci->name), ci->contents.size());
for (vector<ChoiceValue>::const_iterator vi = ci->contents.begin(); vi != ci->contents.end(); vi++)
- printf (" *v++ = ::Bse::EnumValue (%s, \"%s\", %s );\n",
+ g_print (" *v++ = ::Bse::EnumValue (%s, \"%s\", %s );\n",
pure_UPPER (vi->name), make_FULL_UPPER (vi->name), vi->label.escaped().c_str());
- printf (");\n");
+ g_print (");\n");
}
}
void
generate_record_prototypes (NamespaceHelper& nspace)
{
- printf ("\n\n/* record prototypes */\n");
+ g_print ("\n\n/* record prototypes */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
@@ -583,9 +583,9 @@ public:
nspace.setFromSymbol(ri->name);
const char *name = nspace.printable_form (ri->name);
- printf ("class %s;\n", pure_TypeName (ri->name));
- printf ("typedef Sfi::RecordHandle<%s> %sHandle;\n", name, name);
- printf ("#define %s\t\tBSE_CXX_DECLARED_RECORD_TYPE (%s, %s)\n",
+ g_print ("class %s;\n", pure_TypeName (ri->name));
+ g_print ("typedef Sfi::RecordHandle<%s> %sHandle;\n", name, name);
+ g_print ("#define %s\t\tBSE_CXX_DECLARED_RECORD_TYPE (%s, %s)\n",
make_TYPE_NAME (ri->name),
nspace.namespaceOf (ri->name).c_str(),
pure_TypeName (ri->name));
@@ -595,51 +595,51 @@ public:
void
generate_record_definitions (NamespaceHelper& nspace)
{
- printf ("\n\n/* record definitions */\n");
+ g_print ("\n\n/* record definitions */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
continue;
nspace.setFromSymbol(ri->name);
- printf ("class %s : public ::Sfi::GNewable {\n", pure_TypeName (ri->name));
- printf ("public:\n");
+ g_print ("class %s : public ::Sfi::GNewable {\n", pure_TypeName (ri->name));
+ g_print ("public:\n");
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
- printf (" %s %s;\n", TypeField (pi->type), pi->name.c_str());
+ g_print (" %s %s;\n", TypeField (pi->type), pi->name.c_str());
}
- printf (" static inline %s from_rec (SfiRec *rec);\n", TypeRet (ri->name));
- printf (" static inline SfiRec *to_rec (%s ptr);\n", TypeArg (ri->name));
- printf (" static inline %s value_get_boxed (const GValue *value);\n", TypeRet (ri->name));
- printf (" static inline void value_set_boxed (GValue *value, %s self);\n", TypeArg (ri->name));
- printf (" static inline const char* options () { return %s; }\n", ri->infos.get("options").escaped().c_str());
- printf (" static inline const char* blurb () { return %s; }\n", ri->infos.get("blurb").escaped().c_str());
- printf (" static inline const char* authors () { return %s; }\n", ri->infos.get("authors").escaped().c_str());
- printf (" static inline const char* license () { return %s; }\n", ri->infos.get("license").escaped().c_str());
- printf (" static inline const char* type_name () { return \"%s\"; }\n", make_PrefixedTypeName (ri->name));
- printf (" static inline SfiRecFields get_fields ();\n");
- printf ("};\n");
- printf ("\n");
+ g_print (" static inline %s from_rec (SfiRec *rec);\n", TypeRet (ri->name));
+ g_print (" static inline SfiRec *to_rec (%s ptr);\n", TypeArg (ri->name));
+ g_print (" static inline %s value_get_boxed (const GValue *value);\n", TypeRet (ri->name));
+ g_print (" static inline void value_set_boxed (GValue *value, %s self);\n", TypeArg (ri->name));
+ g_print (" static inline const char* options () { return %s; }\n", ri->infos.get("options").escaped().c_str());
+ g_print (" static inline const char* blurb () { return %s; }\n", ri->infos.get("blurb").escaped().c_str());
+ g_print (" static inline const char* authors () { return %s; }\n", ri->infos.get("authors").escaped().c_str());
+ g_print (" static inline const char* license () { return %s; }\n", ri->infos.get("license").escaped().c_str());
+ g_print (" static inline const char* type_name () { return \"%s\"; }\n", make_PrefixedTypeName (ri->name));
+ g_print (" static inline SfiRecFields get_fields ();\n");
+ g_print ("};\n");
+ g_print ("\n");
}
}
void
generate_record_declarations (NamespaceHelper& nspace)
{
- printf ("\n\n/* record type declarations */\n");
+ g_print ("\n\n/* record type declarations */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
continue;
nspace.setFromSymbol(ri->name);
- printf ("BSE_CXX_DECLARE_RECORD (%s);\n", pure_TypeName (ri->name));
- printf ("\n");
+ g_print ("BSE_CXX_DECLARE_RECORD (%s);\n", pure_TypeName (ri->name));
+ g_print ("\n");
}
}
void
generate_record_implementations (NamespaceHelper& nspace)
{
- printf ("\n\n/* record implementations */\n");
+ g_print ("\n\n/* record implementations */\n");
for (vector<Record>::const_iterator ri = parser.getRecords().begin(); ri != parser.getRecords().end(); ri++)
{
if (parser.fromInclude (ri->name))
@@ -647,86 +647,86 @@ public:
nspace.setFromSymbol(ri->name);
const char *nname = nspace.printable_form (ri->name);
- printf ("%s\n", TypeRet (ri->name));
- printf ("%s::from_rec (SfiRec *sfi_rec)\n", nname);
- printf ("{\n");
- printf (" GValue *element;\n");
- printf ("\n");
- printf (" if (!sfi_rec)\n");
- printf (" return Sfi::INIT_NULL;\n");
- printf ("\n");
- printf (" %s rec = Sfi::INIT_DEFAULT;\n", TypeField (ri->name));
+ g_print ("%s\n", TypeRet (ri->name));
+ g_print ("%s::from_rec (SfiRec *sfi_rec)\n", nname);
+ g_print ("{\n");
+ g_print (" GValue *element;\n");
+ g_print ("\n");
+ g_print (" if (!sfi_rec)\n");
+ g_print (" return Sfi::INIT_NULL;\n");
+ g_print ("\n");
+ g_print (" %s rec = Sfi::INIT_DEFAULT;\n", TypeField (ri->name));
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
- printf (" element = sfi_rec_get (sfi_rec, \"%s\");\n", pi->name.c_str());
- printf (" if (element)\n");
- printf (" rec->%s = %s (element);\n", pi->name.c_str(), func_value_get_param (pi->type));
+ g_print (" element = sfi_rec_get (sfi_rec, \"%s\");\n", pi->name.c_str());
+ g_print (" if (element)\n");
+ g_print (" rec->%s = %s (element);\n", pi->name.c_str(), func_value_get_param (pi->type));
}
- printf (" return rec;\n");
- printf ("}\n\n");
+ g_print (" return rec;\n");
+ g_print ("}\n\n");
- printf ("SfiRec *\n");
- printf ("%s::to_rec (%s rec)\n", nname, TypeArg (ri->name));
- printf ("{\n");
- printf (" SfiRec *sfi_rec;\n");
- printf (" GValue *element;\n");
- printf ("\n");
- printf (" if (!rec)\n");
- printf (" return NULL;\n");
- printf ("\n");
- printf (" sfi_rec = sfi_rec_new ();\n");
+ g_print ("SfiRec *\n");
+ g_print ("%s::to_rec (%s rec)\n", nname, TypeArg (ri->name));
+ g_print ("{\n");
+ g_print (" SfiRec *sfi_rec;\n");
+ g_print (" GValue *element;\n");
+ g_print ("\n");
+ g_print (" if (!rec)\n");
+ g_print (" return NULL;\n");
+ g_print ("\n");
+ g_print (" sfi_rec = sfi_rec_new ();\n");
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
- printf (" element = sfi_rec_forced_get (sfi_rec, \"%s\", %s);\n",
+ g_print (" element = sfi_rec_forced_get (sfi_rec, \"%s\", %s);\n",
pi->name.c_str(), make_SFI_TYPE_NAME (pi->type));
- printf (" %s (element, rec->%s);\n", func_value_set_param (pi->type), pi->name.c_str());
+ g_print (" %s (element, rec->%s);\n", func_value_set_param (pi->type), pi->name.c_str());
}
- printf (" return sfi_rec;\n");
- printf ("}\n\n");
+ g_print (" return sfi_rec;\n");
+ g_print ("}\n\n");
- printf ("%s\n", TypeRet (ri->name));
- printf ("%s::value_get_boxed (const GValue *value)\n", nname);
- printf ("{\n");
- printf (" return %s::value_get_boxed (value);\n", TypeRet (ri->name));
- printf ("}\n\n");
- printf ("void\n");
- printf ("%s::value_set_boxed (GValue *value, %s self)\n", nname, TypeArg (ri->name));
- printf ("{\n");
- printf (" %s::value_set_boxed (value, self);\n", TypeRet (ri->name));
- printf ("}\n\n");
+ g_print ("%s\n", TypeRet (ri->name));
+ g_print ("%s::value_get_boxed (const GValue *value)\n", nname);
+ g_print ("{\n");
+ g_print (" return %s::value_get_boxed (value);\n", TypeRet (ri->name));
+ g_print ("}\n\n");
+ g_print ("void\n");
+ g_print ("%s::value_set_boxed (GValue *value, %s self)\n", nname, TypeArg (ri->name));
+ g_print ("{\n");
+ g_print (" %s::value_set_boxed (value, self);\n", TypeRet (ri->name));
+ g_print ("}\n\n");
- printf ("SfiRecFields\n");
- printf ("%s::get_fields()\n", nname);
- printf ("{\n");
- printf (" static SfiRecFields rfields = { 0, NULL };\n");
- printf (" if (!rfields.n_fields)\n");
- printf (" {\n");
- printf (" static GParamSpec *fields[%zu + 1];\n", ri->contents.size());
- printf (" rfields.n_fields = %zu;\n", ri->contents.size());
+ g_print ("SfiRecFields\n");
+ g_print ("%s::get_fields()\n", nname);
+ g_print ("{\n");
+ g_print (" static SfiRecFields rfields = { 0, NULL };\n");
+ g_print (" if (!rfields.n_fields)\n");
+ g_print (" {\n");
+ g_print (" static GParamSpec *fields[%zu + 1];\n", ri->contents.size());
+ g_print (" rfields.n_fields = %zu;\n", ri->contents.size());
guint j = 0;
for (vector<Param>::const_iterator pi = ri->contents.begin(); pi != ri->contents.end(); pi++)
{
- // printf ("#line %u \"%s\"\n", pi->line, parser.fileName().c_str());
- printf (" fields[%u] = %s;\n", j++, untyped_pspec_constructor (*pi).c_str());
+ // g_print ("#line %u \"%s\"\n", pi->line, parser.fileName().c_str());
+ g_print (" fields[%u] = %s;\n", j++, untyped_pspec_constructor (*pi).c_str());
}
- printf (" rfields.fields = fields;\n");
- printf (" }\n");
- printf (" return rfields;\n");
- printf ("}\n");
+ g_print (" rfields.fields = fields;\n");
+ g_print (" }\n");
+ g_print (" return rfields;\n");
+ g_print ("}\n");
}
}
void
generate_sequence_prototypes (NamespaceHelper& nspace)
{
- printf ("\n\n/* sequence prototypes */\n");
+ g_print ("\n\n/* sequence prototypes */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
continue;
nspace.setFromSymbol(si->name);
- printf ("class %s;\n", pure_TypeName (si->name));
- printf ("#define %s\t\tBSE_CXX_DECLARED_SEQUENCE_TYPE (%s, %s)\n",
+ g_print ("class %s;\n", pure_TypeName (si->name));
+ g_print ("#define %s\t\tBSE_CXX_DECLARED_SEQUENCE_TYPE (%s, %s)\n",
make_TYPE_NAME (si->name),
nspace.namespaceOf (si->name).c_str(),
pure_TypeName (si->name));
@@ -736,48 +736,48 @@ public:
void
generate_sequence_definitions (NamespaceHelper& nspace)
{
- printf ("\n\n/* sequence definitions */\n");
+ g_print ("\n\n/* sequence definitions */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
continue;
nspace.setFromSymbol(si->name);
- printf ("class %s : public Sfi::Sequence< %s > {\n", pure_TypeName (si->name), TypeField (si->content.type));
- printf ("public:\n");
- printf (" %s (unsigned int n = 0) : Sfi::Sequence< %s > (n) {}\n", pure_TypeName (si->name), TypeField (si->content.type));
- printf (" static inline %s from_seq (SfiSeq *seq);\n", TypeRet (si->name));
- printf (" static inline SfiSeq *to_seq (%s seq);\n", TypeArg (si->name));
- printf (" static inline %s value_get_boxed (const GValue *value);\n", TypeRet (si->name));
- printf (" static inline void value_set_boxed (GValue *value, %s self);\n", TypeArg (si->name));
- printf (" static inline const char* options () { return %s; }\n", si->infos.get("options").escaped().c_str());
- printf (" static inline const char* blurb () { return %s; }\n", si->infos.get("blurb").escaped().c_str());
- printf (" static inline const char* authors () { return %s; }\n", si->infos.get("authors").escaped().c_str());
- printf (" static inline const char* license () { return %s; }\n", si->infos.get("license").escaped().c_str());
- printf (" static inline const char* type_name () { return \"%s\"; }\n", make_PrefixedTypeName (si->name));
- printf (" static inline GParamSpec* get_element ();\n");
- printf ("};\n");
- printf ("\n");
+ g_print ("class %s : public Sfi::Sequence< %s > {\n", pure_TypeName (si->name), TypeField (si->content.type));
+ g_print ("public:\n");
+ g_print (" %s (unsigned int n = 0) : Sfi::Sequence< %s > (n) {}\n", pure_TypeName (si->name), TypeField (si->content.type));
+ g_print (" static inline %s from_seq (SfiSeq *seq);\n", TypeRet (si->name));
+ g_print (" static inline SfiSeq *to_seq (%s seq);\n", TypeArg (si->name));
+ g_print (" static inline %s value_get_boxed (const GValue *value);\n", TypeRet (si->name));
+ g_print (" static inline void value_set_boxed (GValue *value, %s self);\n", TypeArg (si->name));
+ g_print (" static inline const char* options () { return %s; }\n", si->infos.get("options").escaped().c_str());
+ g_print (" static inline const char* blurb () { return %s; }\n", si->infos.get("blurb").escaped().c_str());
+ g_print (" static inline const char* authors () { return %s; }\n", si->infos.get("authors").escaped().c_str());
+ g_print (" static inline const char* license () { return %s; }\n", si->infos.get("license").escaped().c_str());
+ g_print (" static inline const char* type_name () { return \"%s\"; }\n", make_PrefixedTypeName (si->name));
+ g_print (" static inline GParamSpec* get_element ();\n");
+ g_print ("};\n");
+ g_print ("\n");
}
}
void
generate_sequence_declarations (NamespaceHelper& nspace)
{
- printf ("\n\n/* sequence type declarations */\n");
+ g_print ("\n\n/* sequence type declarations */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
continue;
nspace.setFromSymbol(si->name);
- printf ("BSE_CXX_DECLARE_SEQUENCE (%s);\n", pure_TypeName (si->name));
- printf ("\n");
+ g_print ("BSE_CXX_DECLARE_SEQUENCE (%s);\n", pure_TypeName (si->name));
+ g_print ("\n");
}
}
void
generate_sequence_implementations (NamespaceHelper& nspace)
{
- printf ("\n\n/* sequence implementations */\n");
+ g_print ("\n\n/* sequence implementations */\n");
for (vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
if (parser.fromInclude (si->name))
@@ -785,75 +785,75 @@ public:
nspace.setFromSymbol(si->name);
const char *nname = nspace.printable_form (si->name);
- printf ("%s\n", TypeRet (si->name));
- printf ("%s::from_seq (SfiSeq *sfi_seq)\n", nname);
- printf ("{\n");
- printf (" %s cseq;\n", TypeRet (si->name));
- printf (" guint i, length;\n");
- printf ("\n");
- printf (" if (!sfi_seq)\n");
- printf (" return cseq;\n");
- printf ("\n");
- printf (" length = sfi_seq_length (sfi_seq);\n");
- printf (" cseq.resize (length);\n");
- printf (" for (i = 0; i < length; i++)\n");
- printf (" {\n");
- printf (" GValue *element = sfi_seq_get (sfi_seq, i);\n");
- printf (" cseq[i] = %s (element);\n", func_value_get_param (si->content.type));
- printf (" }\n");
- printf (" return cseq;\n");
- printf ("}\n\n");
+ g_print ("%s\n", TypeRet (si->name));
+ g_print ("%s::from_seq (SfiSeq *sfi_seq)\n", nname);
+ g_print ("{\n");
+ g_print (" %s cseq;\n", TypeRet (si->name));
+ g_print (" guint i, length;\n");
+ g_print ("\n");
+ g_print (" if (!sfi_seq)\n");
+ g_print (" return cseq;\n");
+ g_print ("\n");
+ g_print (" length = sfi_seq_length (sfi_seq);\n");
+ g_print (" cseq.resize (length);\n");
+ g_print (" for (i = 0; i < length; i++)\n");
+ g_print (" {\n");
+ g_print (" GValue *element = sfi_seq_get (sfi_seq, i);\n");
+ g_print (" cseq[i] = %s (element);\n", func_value_get_param (si->content.type));
+ g_print (" }\n");
+ g_print (" return cseq;\n");
+ g_print ("}\n\n");
- printf ("SfiSeq *\n");
- printf ("%s::to_seq (%s cseq)\n", nname, TypeArg (si->name));
- printf ("{\n");
- printf (" SfiSeq *sfi_seq = sfi_seq_new ();\n");
- printf (" for (guint i = 0; i < cseq.length(); i++)\n");
- printf (" {\n");
- printf (" GValue *element = sfi_seq_append_empty (sfi_seq, %s);\n", make_SFI_TYPE_NAME (si->content.type));
- printf (" %s (element, cseq[i]);\n", func_value_set_param (si->content.type));
- printf (" }\n");
- printf (" return sfi_seq;\n");
- printf ("}\n\n");
+ g_print ("SfiSeq *\n");
+ g_print ("%s::to_seq (%s cseq)\n", nname, TypeArg (si->name));
+ g_print ("{\n");
+ g_print (" SfiSeq *sfi_seq = sfi_seq_new ();\n");
+ g_print (" for (guint i = 0; i < cseq.length(); i++)\n");
+ g_print (" {\n");
+ g_print (" GValue *element = sfi_seq_append_empty (sfi_seq, %s);\n", make_SFI_TYPE_NAME (si->content.type));
+ g_print (" %s (element, cseq[i]);\n", func_value_set_param (si->content.type));
+ g_print (" }\n");
+ g_print (" return sfi_seq;\n");
+ g_print ("}\n\n");
- printf ("%s\n", TypeRet (si->name));
- printf ("%s::value_get_boxed (const GValue *value)\n", nname);
- printf ("{\n");
- printf (" return ::Sfi::cxx_value_get_boxed_sequence< %s> (value);\n", nname);
- printf ("}\n\n");
- printf ("void\n");
- printf ("%s::value_set_boxed (GValue *value, %s self)\n", nname, TypeArg (si->name));
- printf ("{\n");
- printf (" ::Sfi::cxx_value_set_boxed_sequence< %s> (value, self);\n", nname);
- printf ("}\n\n");
+ g_print ("%s\n", TypeRet (si->name));
+ g_print ("%s::value_get_boxed (const GValue *value)\n", nname);
+ g_print ("{\n");
+ g_print (" return ::Sfi::cxx_value_get_boxed_sequence< %s> (value);\n", nname);
+ g_print ("}\n\n");
+ g_print ("void\n");
+ g_print ("%s::value_set_boxed (GValue *value, %s self)\n", nname, TypeArg (si->name));
+ g_print ("{\n");
+ g_print (" ::Sfi::cxx_value_set_boxed_sequence< %s> (value, self);\n", nname);
+ g_print ("}\n\n");
- printf ("GParamSpec*\n");
- printf ("%s::get_element()\n", nname);
- printf ("{\n");
- printf (" static GParamSpec *element = NULL;\n");
- printf (" if (!element)\n");
- // printf ("#line %u \"%s\"\n", si->content.line, parser.fileName().c_str());
- printf (" element = %s;\n", untyped_pspec_constructor (si->content).c_str());
- printf (" return element;\n");
- printf ("}\n\n");
+ g_print ("GParamSpec*\n");
+ g_print ("%s::get_element()\n", nname);
+ g_print ("{\n");
+ g_print (" static GParamSpec *element = NULL;\n");
+ g_print (" if (!element)\n");
+ // g_print ("#line %u \"%s\"\n", si->content.line, parser.fileName().c_str());
+ g_print (" element = %s;\n", untyped_pspec_constructor (si->content).c_str());
+ g_print (" return element;\n");
+ g_print ("}\n\n");
}
}
void
generate_class_prototypes (NamespaceHelper& nspace)
{
- printf ("\n\n/* class prototypes */\n");
+ g_print ("\n\n/* class prototypes */\n");
for (vector<Class>::const_iterator ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
if (parser.fromInclude (ci->name))
continue;
nspace.setFromSymbol(ci->name);
- printf ("class %sBase;\n", pure_TypeName (ci->name));
- printf ("class %s;\n", pure_TypeName (ci->name));
- printf ("#define %s\t\tBSE_CXX_DECLARED_CLASS_TYPE (%s, %s)\n",
+ g_print ("class %sBase;\n", pure_TypeName (ci->name));
+ g_print ("class %s;\n", pure_TypeName (ci->name));
+ g_print ("#define %s\t\tBSE_CXX_DECLARED_CLASS_TYPE (%s, %s)\n",
make_TYPE_NAME (ci->name),
nspace.namespaceOf (ci->name).c_str(),
pure_TypeName (ci->name));
- printf ("#define %s(o) (::Bse::CxxBase::instance_is_a (o, %s))\n",
+ g_print ("#define %s(o) (::Bse::CxxBase::instance_is_a (o, %s))\n",
make_IS_NAME (ci->name), make_TYPE_NAME (ci->name));
push_type ("EFFECT", pure_TypeName (ci->name));
}
@@ -870,7 +870,7 @@ public:
void
generate_class_definitions (NamespaceHelper& nspace)
{
- printf ("\n\n/* class definitions */\n");
+ g_print ("\n\n/* class definitions */\n");
for (vector<Class>::const_iterator ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
if (parser.fromInclude (ci->name))
@@ -884,8 +884,8 @@ public:
vector<String> destroy_jobs;
/* skeleton class declaration + type macro */
- printf ("BSE_CXX_DECLARE_CLASS (%s);\n", pure_TypeName (ci->name));
- printf ("class %s : public %s {\n", ctNameBase, make_fqtn (ci->inherits));
+ g_print ("BSE_CXX_DECLARE_CLASS (%s);\n", pure_TypeName (ci->name));
+ g_print ("class %s : public %s {\n", ctNameBase, make_fqtn (ci->inherits));
/* class Info strings */
/* pixstream(), this is a bit of a hack, we make it a template rather than
@@ -895,236 +895,236 @@ public:
String pstream = "NULL";
if (icon != "")
{
- printf (" template<bool> static inline const unsigned char* inlined_pixstream();\n");
+ g_print (" template<bool> static inline const unsigned char* inlined_pixstream();\n");
images.push_back (Image (include_relative (icon, ci->file),
String ("template<bool> const unsigned char*\n") +
make_fqtn (ci->name) + "Base" +
"::inlined_pixstream()"));
pstream = "inlined_pixstream<true>()";
}
- printf ("public:\n");
- printf (" static inline const unsigned char* pixstream () { return %s; }\n", pstream.c_str());
- printf (" static void class_init (::Bse::CxxBaseClass *klass);\n");
- printf (" static inline const char* options () { return %s; }\n", ci->infos.get("options").escaped().c_str());
- printf (" static inline const char* category () { static const char *c = NULL;\n");
- printf (" return c ? c : c = sfi_category_concat (\"/Modules\", %s); }\n",
+ g_print ("public:\n");
+ g_print (" static inline const unsigned char* pixstream () { return %s; }\n", pstream.c_str());
+ g_print (" static void class_init (::Bse::CxxBaseClass *klass);\n");
+ g_print (" static inline const char* options () { return %s; }\n", ci->infos.get("options").escaped().c_str());
+ g_print (" static inline const char* category () { static const char *c = NULL;\n");
+ g_print (" return c ? c : c = sfi_category_concat (\"/Modules\", %s); }\n",
ci->infos.get("category").escaped(" ").c_str()); // untranslated
- printf (" static inline const char* i18n_category () { static const char *c = NULL;\n");
- printf (" return c ? c : c = sfi_category_concat (\"/Modules\", %s); }\n",
+ g_print (" static inline const char* i18n_category () { static const char *c = NULL;\n");
+ g_print (" return c ? c : c = sfi_category_concat (\"/Modules\", %s); }\n",
ci->infos.get("category").escaped().c_str()); // translated
- printf (" static inline const char* blurb () { return %s; }\n", ci->infos.get("blurb").escaped().c_str());
- printf (" static inline const char* authors () { return %s; }\n", ci->infos.get("authors").escaped().c_str());
- printf (" static inline const char* license () { return %s; }\n", ci->infos.get("license").escaped().c_str());
- printf (" static inline const char* type_name () { return \"%s\"; }\n", make_PrefixedTypeName (ci->name));
+ g_print (" static inline const char* blurb () { return %s; }\n", ci->infos.get("blurb").escaped().c_str());
+ g_print (" static inline const char* authors () { return %s; }\n", ci->infos.get("authors").escaped().c_str());
+ g_print (" static inline const char* license () { return %s; }\n", ci->infos.get("license").escaped().c_str());
+ g_print (" static inline const char* type_name () { return \"%s\"; }\n", make_PrefixedTypeName (ci->name));
/* i/j/o channel names */
if (ci->istreams.size())
{
- printf ("public:\n");
- printf (" enum {\n");
+ g_print ("public:\n");
+ g_print (" enum {\n");
for (vector<Stream>::const_iterator si = ci->istreams.begin(); si != ci->istreams.end(); si++)
- printf (" ICHANNEL_%s,\n", pure_UPPER (si->ident));
- printf (" N_ICHANNELS\n };\n");
+ g_print (" ICHANNEL_%s,\n", pure_UPPER (si->ident));
+ g_print (" N_ICHANNELS\n };\n");
}
if (ci->jstreams.size())
{
- printf ("public:\n");
- printf (" enum {\n");
+ g_print ("public:\n");
+ g_print (" enum {\n");
for (vector<Stream>::const_iterator si = ci->jstreams.begin(); si != ci->jstreams.end(); si++)
- printf (" JCHANNEL_%s,\n", pure_UPPER (si->ident));
- printf (" N_JCHANNELS\n };\n");
+ g_print (" JCHANNEL_%s,\n", pure_UPPER (si->ident));
+ g_print (" N_JCHANNELS\n };\n");
}
if (ci->ostreams.size())
{
- printf ("public:\n");
- printf (" enum {\n");
+ g_print ("public:\n");
+ g_print (" enum {\n");
for (vector<Stream>::const_iterator si = ci->ostreams.begin(); si != ci->ostreams.end(); si++)
- printf (" OCHANNEL_%s,\n", pure_UPPER (si->ident));
- printf (" N_OCHANNELS\n };\n");
+ g_print (" OCHANNEL_%s,\n", pure_UPPER (si->ident));
+ g_print (" N_OCHANNELS\n };\n");
}
/* property IDs */
- printf ("protected:\n enum %s {\n", ctPropertyID);
+ g_print ("protected:\n enum %s {\n", ctPropertyID);
if (ci->properties.begin() != ci->properties.end())
{
vector<Param>::const_iterator pi = ci->properties.begin();
- printf (" PROP_%s = 1,\n", pure_UPPER (pi->name));
+ g_print (" PROP_%s = 1,\n", pure_UPPER (pi->name));
for (pi++; pi != ci->properties.end(); pi++)
- printf (" PROP_%s,\n", pure_UPPER (pi->name));
+ g_print (" PROP_%s,\n", pure_UPPER (pi->name));
}
- printf (" };\n");
+ g_print (" };\n");
/* "Properties" structure for synthesis modules */
if (ci->istreams.size() + ci->jstreams.size() + ci->ostreams.size())
{
- printf ("public:\n");
- printf (" /* \"transport\" structure to configure synthesis modules from properties */\n");
- printf (" struct %s {\n", ctProperties);
- printf (" typedef %s IDType;\n", ctPropertyID);
+ g_print ("public:\n");
+ g_print (" /* \"transport\" structure to configure synthesis modules from properties */\n");
+ g_print (" struct %s {\n", ctProperties);
+ g_print (" typedef %s IDType;\n", ctPropertyID);
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
- printf (" %s %s;\n", TypeField (pi->type), pi->name.c_str());
- printf (" explicit %s (%s *p) ", ctProperties, ctNameBase);
+ g_print (" %s %s;\n", TypeField (pi->type), pi->name.c_str());
+ g_print (" explicit %s (%s *p) ", ctProperties, ctNameBase);
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
- printf ("%c\n %s (p->%s)", pi == ci->properties.begin() ? ':' : ',', pi->name.c_str(), pi->name.c_str());
- printf ("\n {\n");
- printf (" }\n");
- printf (" };\n");
+ g_print ("%c\n %s (p->%s)", pi == ci->properties.begin() ? ':' : ',', pi->name.c_str(), pi->name.c_str());
+ g_print ("\n {\n");
+ g_print (" }\n");
+ g_print (" };\n");
}
/* auto-update type */
- printf ("protected:\n");
- printf (" typedef %s AutoUpdateCategory;\n", class_has_automation_properties (*ci) ? "::Bse::SynthesisModule::NeedAutoUpdateTag" : "void");
+ g_print ("protected:\n");
+ g_print (" typedef %s AutoUpdateCategory;\n", class_has_automation_properties (*ci) ? "::Bse::SynthesisModule::NeedAutoUpdateTag" : "void");
/* property fields */
- printf ("protected:\n");
+ g_print ("protected:\n");
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
{
- printf (" %s %s;\n", TypeField (pi->type), pi->name.c_str());
+ g_print (" %s %s;\n", TypeField (pi->type), pi->name.c_str());
if (g_option_check (pi->literal_options.c_str(), "automate"))
- printf (" guint64 last__%s;\n", pi->name.c_str());
+ g_print (" guint64 last__%s;\n", pi->name.c_str());
}
/* get_property() */
- printf ("public:\n");
- printf (" void get_property (%s prop_id, ::Bse::Value &value, GParamSpec *pspec)\n", ctPropertyID);
- printf (" {\n");
- printf (" switch (prop_id) {\n");
+ g_print ("public:\n");
+ g_print (" void get_property (%s prop_id, ::Bse::Value &value, GParamSpec *pspec)\n", ctPropertyID);
+ g_print (" {\n");
+ g_print (" switch (prop_id) {\n");
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
{
- printf (" case PROP_%s:\n", pure_UPPER (pi->name));
- printf (" %s (&value, %s);\n", func_value_set_param (pi->type), pi->name.c_str());
- printf (" break;\n");
+ g_print (" case PROP_%s:\n", pure_UPPER (pi->name));
+ g_print (" %s (&value, %s);\n", func_value_set_param (pi->type), pi->name.c_str());
+ g_print (" break;\n");
}
- printf (" };\n");
- printf (" }\n");
+ g_print (" };\n");
+ g_print (" }\n");
/* set_property() */
- printf (" void set_property (%s prop_id, const ::Bse::Value &value, GParamSpec *pspec)\n", ctPropertyID);
- printf (" {\n");
- printf (" switch (prop_id) {\n");
+ g_print (" void set_property (%s prop_id, const ::Bse::Value &value, GParamSpec *pspec)\n", ctPropertyID);
+ g_print (" {\n");
+ g_print (" switch (prop_id) {\n");
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
{
- printf (" case PROP_%s:\n", pure_UPPER (pi->name));
- printf (" %s = %s (&value);\n", pi->name.c_str(), func_value_get_param (pi->type));
- printf (" break;\n");
+ g_print (" case PROP_%s:\n", pure_UPPER (pi->name));
+ g_print (" %s = %s (&value);\n", pi->name.c_str(), func_value_get_param (pi->type));
+ g_print (" break;\n");
}
- printf (" };\n");
- printf (" property_changed (%s (prop_id));\n", ctPropertyID);
- printf (" update_modules();\n");
+ g_print (" };\n");
+ g_print (" property_changed (%s (prop_id));\n", ctPropertyID);
+ g_print (" update_modules();\n");
/* reset triggers */
- printf (" switch (prop_id) {\n");
+ g_print (" switch (prop_id) {\n");
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
{
if (pi->pspec != "Trigger")
continue;
- printf (" case PROP_%s:\n", pure_UPPER (pi->name));
- printf (" %s = FALSE;\n", pi->name.c_str());
- printf (" break;\n");
+ g_print (" case PROP_%s:\n", pure_UPPER (pi->name));
+ g_print (" %s = FALSE;\n", pi->name.c_str());
+ g_print (" break;\n");
}
- printf (" default: ;\n");
- printf (" };\n");
- printf (" }\n");
+ g_print (" default: ;\n");
+ g_print (" };\n");
+ g_print (" }\n");
/* editable_property() */
- printf (" virtual bool editable_property (%s prop_id, GParamSpec *pspec)\n", ctPropertyID);
- printf (" {\n");
- printf (" return true;\n");
- printf (" }\n");
+ g_print (" virtual bool editable_property (%s prop_id, GParamSpec *pspec)\n", ctPropertyID);
+ g_print (" {\n");
+ g_print (" return true;\n");
+ g_print (" }\n");
/* get_candidates() */
- printf (" virtual void get_candidates (%s prop_id, ::Bse::PropertyCandidatesHandle &pch, GParamSpec *pspec)\n", ctPropertyID);
- printf (" {\n");
- printf (" }\n");
+ g_print (" virtual void get_candidates (%s prop_id, ::Bse::PropertyCandidatesHandle &pch, GParamSpec *pspec)\n", ctPropertyID);
+ g_print (" {\n");
+ g_print (" }\n");
/* property_updated() */
- printf (" void property_updated (%s prop_id, guint64 tick_stamp, double prop_value, GParamSpec *pspec)\n", ctPropertyID);
- printf (" {\n");
- printf (" bool seen_change = false;\n");
- printf (" switch (prop_id) {\n");
+ g_print (" void property_updated (%s prop_id, guint64 tick_stamp, double prop_value, GParamSpec *pspec)\n", ctPropertyID);
+ g_print (" {\n");
+ g_print (" bool seen_change = false;\n");
+ g_print (" switch (prop_id) {\n");
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
{
if (!g_option_check (pi->literal_options.c_str(), "automate"))
continue;
- printf (" case PROP_%s:\n", pure_UPPER (pi->name));
- printf (" if (tick_stamp >= ::std::max (last__%s, module_update_tick_stamp()))\n", pi->name.c_str());
- printf (" {\n");
- printf (" seen_change = true;\n");
- printf (" %s = prop_value;\n", pi->name.c_str());
- printf (" }\n");
- printf (" last__%s = tick_stamp;\n", pi->name.c_str());
- printf (" break;\n");
+ g_print (" case PROP_%s:\n", pure_UPPER (pi->name));
+ g_print (" if (tick_stamp >= ::std::max (last__%s, module_update_tick_stamp()))\n", pi->name.c_str());
+ g_print (" {\n");
+ g_print (" seen_change = true;\n");
+ g_print (" %s = prop_value;\n", pi->name.c_str());
+ g_print (" }\n");
+ g_print (" last__%s = tick_stamp;\n", pi->name.c_str());
+ g_print (" break;\n");
}
- printf (" default: ;\n");
- printf (" };\n");
- printf (" if (seen_change &&\n");
- printf (" property_changed (%s (prop_id)))\n", ctPropertyID);
- printf (" update_modules();\n");
- printf (" }\n");
+ g_print (" default: ;\n");
+ g_print (" };\n");
+ g_print (" if (seen_change &&\n");
+ g_print (" property_changed (%s (prop_id)))\n", ctPropertyID);
+ g_print (" update_modules();\n");
+ g_print (" }\n");
/* static data */
- printf ("private:\n");
- printf (" static struct StaticData {\n");
- printf (" int dummy;\n");
+ g_print ("private:\n");
+ g_print (" static struct StaticData {\n");
+ g_print (" int dummy;\n");
for (vector<Method>::const_iterator si = ci->signals.begin(); si != ci->signals.end(); si++)
{
const gchar *sig_name = canonify_name (si->name, '_');
- printf (" guint signal_%s;\n", sig_name);
+ g_print (" guint signal_%s;\n", sig_name);
}
- printf (" } static_data;\n");
+ g_print (" } static_data;\n");
/* property-changed hooking */
- printf ("protected:\n");
- printf (" virtual bool property_changed (%s) { return false; }\n", ctPropertyID);
+ g_print ("protected:\n");
+ g_print (" virtual bool property_changed (%s) { return false; }\n", ctPropertyID);
/* methods */
for (vector<Method>::const_iterator mi = ci->methods.begin(); mi != ci->methods.end(); mi++)
procs.push_back (&(*mi));
/* destructor */
- printf (" virtual ~%s ()\n", ctNameBase);
- printf (" {\n");
+ g_print (" virtual ~%s ()\n", ctNameBase);
+ g_print (" {\n");
/* property deletion */
for (vector<String>::const_iterator vi = destroy_jobs.begin(); vi != destroy_jobs.end(); vi++)
- printf (" %s;\n", vi->c_str());
- printf (" }\n");
+ g_print (" %s;\n", vi->c_str());
+ g_print (" }\n");
/* signal emission methods */
- printf ("public:\n");
+ g_print ("public:\n");
for (vector<Method>::const_iterator si = ci->signals.begin(); si != ci->signals.end(); si++)
{
const gchar *sig_name = canonify_name (si->name, '_');
- printf (" void emit_%s (", sig_name);
+ g_print (" void emit_%s (", sig_name);
for (vector<Param>::const_iterator ai = si->params.begin(); ai != si->params.end(); ai++)
{
if (ai != si->params.begin())
- printf (", ");
- printf ("%s %s", TypeArg (ai->type), ai->name.c_str());
+ g_print (", ");
+ g_print ("%s %s", TypeArg (ai->type), ai->name.c_str());
}
- printf (")\n");
- printf (" {\n");
- printf (" GValue args[1 + %zu];\n", si->params.size());
- printf (" args[0].g_type = 0, g_value_init (args + 0, %s);\n", make_TYPE_NAME (ci->name));
- printf (" g_value_set_object (args + 0, gobject());\n");
+ g_print (")\n");
+ g_print (" {\n");
+ g_print (" GValue args[1 + %zu];\n", si->params.size());
+ g_print (" args[0].g_type = 0, g_value_init (args + 0, %s);\n", make_TYPE_NAME (ci->name));
+ g_print (" g_value_set_object (args + 0, gobject());\n");
guint i = 1;
for (vector<Param>::const_iterator ai = si->params.begin(); ai != si->params.end(); ai++, i++)
{
- printf (" args[%u].g_type = 0, g_value_init (args + %u, %s);\n", i, i, make_TYPE_NAME (ai->type));
- printf (" %s (args + %u, %s);\n", func_value_set_param (ai->type), i, ai->name.c_str());
+ g_print (" args[%u].g_type = 0, g_value_init (args + %u, %s);\n", i, i, make_TYPE_NAME (ai->type));
+ g_print (" %s (args + %u, %s);\n", func_value_set_param (ai->type), i, ai->name.c_str());
}
- printf (" g_signal_emitv (args, static_data.signal_%s, 0, NULL);\n", sig_name);
+ g_print (" g_signal_emitv (args, static_data.signal_%s, 0, NULL);\n", sig_name);
for (i = 0; i <= si->params.size(); i++)
- printf (" g_value_unset (args + %u);\n", i);
- printf (" }\n");
+ g_print (" g_value_unset (args + %u);\n", i);
+ g_print (" }\n");
}
/* done */
- printf ("};\n"); /* finish: class ... { }; */
+ g_print ("};\n"); /* finish: class ... { }; */
}
}
void
generate_class_implementations (NamespaceHelper& nspace)
{
- printf ("\n\n/* class implementations */\n");
+ g_print ("\n\n/* class implementations */\n");
for (vector<Class>::const_iterator ci = parser.getClasses().begin(); ci != parser.getClasses().end(); ci++)
{
if (parser.fromInclude (ci->name))
@@ -1137,45 +1137,45 @@ public:
vector<String> destroy_jobs;
/* class_init */
- printf ("void\n");
- printf ("%sBase::class_init (::Bse::CxxBaseClass *klass)\n", nname);
- printf ("{\n");
- printf (" klass->set_accessors (::Bse::cxx_get_property_trampoline<%s, %s>,\n", ctNameBase, ctPropertyID);
- printf (" ::Bse::cxx_set_property_trampoline<%s, %s>,\n", ctNameBase, ctPropertyID);
- printf (" ::Bse::cxx_editable_property_trampoline<%s, %s>,\n", ctNameBase, ctPropertyID);
- printf (" ::Bse::cxx_get_candidates_trampoline<%s, %s>,\n", ctNameBase, ctPropertyID);
+ g_print ("void\n");
+ g_print ("%sBase::class_init (::Bse::CxxBaseClass *klass)\n", nname);
+ g_print ("{\n");
+ g_print (" klass->set_accessors (::Bse::cxx_get_property_trampoline<%s, %s>,\n", ctNameBase, ctPropertyID);
+ g_print (" ::Bse::cxx_set_property_trampoline<%s, %s>,\n", ctNameBase, ctPropertyID);
+ g_print (" ::Bse::cxx_editable_property_trampoline<%s, %s>,\n", ctNameBase, ctPropertyID);
+ g_print (" ::Bse::cxx_get_candidates_trampoline<%s, %s>,\n", ctNameBase, ctPropertyID);
if (class_has_automation_properties (*ci))
- printf (" ::Bse::cxx_property_updated_trampoline<%s, %s>);\n", ctNameBase, ctPropertyID);
+ g_print (" ::Bse::cxx_property_updated_trampoline<%s, %s>);\n", ctNameBase, ctPropertyID);
else
- printf (" NULL);\n");
+ g_print (" NULL);\n");
for (vector<Param>::const_iterator pi = ci->properties.begin(); pi != ci->properties.end(); pi++)
- printf (" klass->add_param (PROP_%s, %s);\n", pure_UPPER (pi->name), typed_pspec_constructor (*pi).c_str());
+ g_print (" klass->add_param (PROP_%s, %s);\n", pure_UPPER (pi->name), typed_pspec_constructor (*pi).c_str());
for (vector<Stream>::const_iterator si = ci->istreams.begin(); si != ci->istreams.end(); si++)
- printf (" klass->add_ichannel (%s, %s, %s, ICHANNEL_%s);\n",
+ g_print (" klass->add_ichannel (%s, %s, %s, ICHANNEL_%s);\n",
intern_escape (si->ident), si->label.escaped().c_str(), si->blurb.escaped().c_str(), pure_UPPER (si->ident));
for (vector<Stream>::const_iterator si = ci->jstreams.begin(); si != ci->jstreams.end(); si++)
- printf (" klass->add_jchannel (%s, %s, %s, JCHANNEL_%s);\n",
+ g_print (" klass->add_jchannel (%s, %s, %s, JCHANNEL_%s);\n",
intern_escape (si->ident), si->label.escaped().c_str(), si->blurb.escaped().c_str(), pure_UPPER (si->ident));
for (vector<Stream>::const_iterator si = ci->ostreams.begin(); si != ci->ostreams.end(); si++)
- printf (" klass->add_ochannel (%s, %s, %s, OCHANNEL_%s);\n",
+ g_print (" klass->add_ochannel (%s, %s, %s, OCHANNEL_%s);\n",
intern_escape (si->ident), si->label.escaped().c_str(), si->blurb.escaped().c_str(), pure_UPPER (si->ident));
for (vector<Method>::const_iterator si = ci->signals.begin(); si != ci->signals.end(); si++)
{
const gchar *sig_name = canonify_name (si->name, '_');
const gchar *sig_string = canonify_name (si->name);
- printf (" static_data.signal_%s =\n klass->add_signal (\"%s\", (GSignalFlags) 0, %zu",
+ g_print (" static_data.signal_%s =\n klass->add_signal (\"%s\", (GSignalFlags) 0, %zu",
sig_name, sig_string, si->params.size());
for (vector<Param>::const_iterator ai = si->params.begin(); ai != si->params.end(); ai++)
- printf (",\n %s", make_TYPE_NAME (ai->type));
- printf (");\n");
+ g_print (",\n %s", make_TYPE_NAME (ai->type));
+ g_print (");\n");
}
- printf ("}\n");
+ g_print ("}\n");
}
}
void
generate_procedure_prototypes (NamespaceHelper& nspace)
{
- printf ("\n\n/* procedure prototypes */\n");
+ g_print ("\n\n/* procedure prototypes */\n");
for (vector<const Method*>::const_iterator ppi = procs.begin(); ppi != procs.end(); ppi++)
{
const Method *mi = *ppi;
@@ -1183,20 +1183,20 @@ public:
continue;
nspace.setFromSymbol(mi->name);
- printf ("namespace Procedure {\n");
- printf ("class %s;\n", pure_lower (mi->name));
- printf ("#define %s\t\tBSE_CXX_DECLARED_PROC_TYPE (%s, %s)\n",
+ g_print ("namespace Procedure {\n");
+ g_print ("class %s;\n", pure_lower (mi->name));
+ g_print ("#define %s\t\tBSE_CXX_DECLARED_PROC_TYPE (%s, %s)\n",
make_TYPE_NAME (mi->name),
nspace.namespaceOf (mi->name).c_str(),
pure_lower (mi->name));
- printf ("} // Procedure\n\n");
+ g_print ("} // Procedure\n\n");
push_type ("PROCEDURE", pure_lower (mi->name));
}
}
void
generate_procedure_implementations (NamespaceHelper &nspace)
{
- printf ("\n\n/* procedure implementations */\n");
+ g_print ("\n\n/* procedure implementations */\n");
for (vector<const Method*>::const_iterator ppi = procs.begin(); ppi != procs.end(); ppi++)
{
const Method *mi = *ppi;
@@ -1206,9 +1206,9 @@ public:
const char *name = nspace.printable_form (mi->name);
const Map<String, IString> &infos = mi->infos;
bool is_void = mi->result.type == "void";
- printf ("namespace Procedure {\n");
- printf ("BSE_CXX_DECLARE_PROC (%s);\n", pure_lower (mi->name));
- printf ("class %s {\n", pure_lower (mi->name));
+ g_print ("namespace Procedure {\n");
+ g_print ("BSE_CXX_DECLARE_PROC (%s);\n", pure_lower (mi->name));
+ g_print ("class %s {\n", pure_lower (mi->name));
/* class Info strings */
/* pixstream(), this is a bit of a hack, we make it a template rather than
@@ -1218,88 +1218,88 @@ public:
String pstream = "NULL";
if (icon != "")
{
- printf (" template<bool> static inline const unsigned char* inlined_pixstream();\n");
+ g_print (" template<bool> static inline const unsigned char* inlined_pixstream();\n");
images.push_back (Image (include_relative (icon, mi->file),
String ("template<bool> const unsigned char*\n") +
make_full_lower (mi->name) +
"::inlined_pixstream()"));
pstream = "inlined_pixstream<true>()";
}
- printf ("public:\n");
- printf (" static inline const unsigned char* pixstream () { return %s; }\n", pstream.c_str());
- printf (" static inline const char* options () { return %s; }\n", infos.get("options").escaped().c_str());
- printf (" static inline const char* category () { static const char *c = NULL;\n");
- printf (" return c ? c : c = sfi_category_concat (\"/Proc\", %s); }\n",
+ g_print ("public:\n");
+ g_print (" static inline const unsigned char* pixstream () { return %s; }\n", pstream.c_str());
+ g_print (" static inline const char* options () { return %s; }\n", infos.get("options").escaped().c_str());
+ g_print (" static inline const char* category () { static const char *c = NULL;\n");
+ g_print (" return c ? c : c = sfi_category_concat (\"/Proc\", %s); }\n",
infos.get("category").escaped(" ").c_str()); // untranslated
- printf (" static inline const char* i18n_category () { static const char *c = NULL;\n");
- printf (" return c ? c : c = sfi_category_concat (\"/Proc\", %s); }\n",
+ g_print (" static inline const char* i18n_category () { static const char *c = NULL;\n");
+ g_print (" return c ? c : c = sfi_category_concat (\"/Proc\", %s); }\n",
infos.get("category").escaped().c_str()); // translated
- printf (" static inline const char* blurb () { return %s; }\n", infos.get("blurb").escaped().c_str());
- printf (" static inline const char* authors () { return %s; }\n", infos.get("authors").escaped().c_str());
- printf (" static inline const char* license () { return %s; }\n", infos.get("license").escaped().c_str());
- printf (" static inline const char* type_name () { return \"%s\"; }\n", make_scheme_name (mi->name));
+ g_print (" static inline const char* blurb () { return %s; }\n", infos.get("blurb").escaped().c_str());
+ g_print (" static inline const char* authors () { return %s; }\n", infos.get("authors").escaped().c_str());
+ g_print (" static inline const char* license () { return %s; }\n", infos.get("license").escaped().c_str());
+ g_print (" static inline const char* type_name () { return \"%s\"; }\n", make_scheme_name (mi->name));
/* return type */
- printf (" static %s exec (", TypeRet (mi->result.type));
+ g_print (" static %s exec (", TypeRet (mi->result.type));
/* args */
for (vector<Param>::const_iterator ai = mi->params.begin(); ai != mi->params.end(); ai++)
{
if (ai != mi->params.begin())
- printf (", ");
- printf ("%s %s", TypeArg (ai->type), ai->name.c_str());
+ g_print (", ");
+ g_print ("%s %s", TypeArg (ai->type), ai->name.c_str());
}
- printf (");\n");
+ g_print (");\n");
/* marshal */
- printf (" static BseErrorType marshal (BseProcedureClass *procedure,\n"
+ g_print (" static BseErrorType marshal (BseProcedureClass *procedure,\n"
" const GValue *in_values,\n"
" GValue *out_values)\n");
- printf (" {\n");
- printf (" try {\n");
+ g_print (" {\n");
+ g_print (" try {\n");
if (!is_void)
- printf (" %s __return_value =\n", TypeRet (mi->result.type));
- printf (" exec (\n");
+ g_print (" %s __return_value =\n", TypeRet (mi->result.type));
+ g_print (" exec (\n");
int i = 0;
for (vector<Param>::const_iterator pi = mi->params.begin(); pi != mi->params.end(); pi++)
- printf (" %s (in_values + %u)%c\n",
+ g_print (" %s (in_values + %u)%c\n",
func_value_get_param (pi->type), i++,
&(*pi) == &(mi->params.back()) ? ' ' : ',');
- printf (" );\n");
+ g_print (" );\n");
if (!is_void)
- printf (" %s (out_values, __return_value);\n", func_value_set_param (mi->result.type));
- printf (" } catch (std::exception &e) {\n");
- printf (" sfi_diag (\"%%s: %%s\", \"%s\", e.what());\n", name);
- printf (" return BSE_ERROR_PROC_EXECUTION;\n");
- printf (" } catch (...) {\n");
- printf (" sfi_diag (\"%%s: %%s\", \"%s\", \"uncaught exception\");\n", name);
- printf (" return BSE_ERROR_PROC_EXECUTION;\n");
- printf (" }\n");
- printf (" return BSE_ERROR_NONE;\n");
- printf (" }\n");
+ g_print (" %s (out_values, __return_value);\n", func_value_set_param (mi->result.type));
+ g_print (" } catch (std::exception &e) {\n");
+ g_print (" sfi_diag (\"%%s: %%s\", \"%s\", e.what());\n", name);
+ g_print (" return BSE_ERROR_PROC_EXECUTION;\n");
+ g_print (" } catch (...) {\n");
+ g_print (" sfi_diag (\"%%s: %%s\", \"%s\", \"uncaught exception\");\n", name);
+ g_print (" return BSE_ERROR_PROC_EXECUTION;\n");
+ g_print (" }\n");
+ g_print (" return BSE_ERROR_NONE;\n");
+ g_print (" }\n");
/* init */
- printf (" static void init (BseProcedureClass *proc,\n"
+ g_print (" static void init (BseProcedureClass *proc,\n"
" GParamSpec **in_pspecs,\n"
" GParamSpec **out_pspecs)\n");
- printf (" {\n");
+ g_print (" {\n");
for (vector<Param>::const_iterator ai = mi->params.begin(); ai != mi->params.end(); ai++)
- printf (" *(in_pspecs++) = %s;\n", typed_pspec_constructor (*ai).c_str());
+ g_print (" *(in_pspecs++) = %s;\n", typed_pspec_constructor (*ai).c_str());
if (!is_void)
- printf (" *(out_pspecs++) = %s;\n", typed_pspec_constructor (mi->result).c_str());
- printf (" }\n");
+ g_print (" *(out_pspecs++) = %s;\n", typed_pspec_constructor (mi->result).c_str());
+ g_print (" }\n");
/* done */
- printf ("};\n"); /* finish: class ... { }; */
- printf ("} // Procedure\n\n");
+ g_print ("};\n"); /* finish: class ... { }; */
+ g_print ("} // Procedure\n\n");
}
}
bool
run ()
{
- printf ("\n/*-------- begin %s generated code --------*/\n\n\n", Options::the()->sfidlName.c_str());
+ g_print ("\n/*-------- begin %s generated code --------*/\n\n\n", Options::the()->sfidlName.c_str());
/* standard includes */
- printf ("\n#include <bse/bsecxxplugin.hh>\n");
+ g_print ("\n#include <bse/bsecxxplugin.hh>\n");
/* reset auxillary structures */
images.resize (0);
@@ -1341,25 +1341,25 @@ public:
generate_procedure_implementations (nsh); /* adds to images */
/* alltypes macro */
- printf ("\n\n/* %s type registrations */\n", alltypes_macro.c_str());
+ g_print ("\n\n/* %s type registrations */\n", alltypes_macro.c_str());
if (alltypes_macro != "" && alltypes.size())
{
- printf ("#define BSE_CXX_REGISTER_ALL_TYPES_FROM_%s() \\\n", UPPER_CASE (alltypes_macro));
+ g_print ("#define BSE_CXX_REGISTER_ALL_TYPES_FROM_%s() \\\n", UPPER_CASE (alltypes_macro));
for (vector<String>::const_iterator si = alltypes.begin(); si != alltypes.end(); si++)
- printf (" BSE_CXX_REGISTER_%s; \\\n", si->c_str());
- printf (" /* %s type registrations done */\n", alltypes_macro.c_str());
+ g_print (" BSE_CXX_REGISTER_%s; \\\n", si->c_str());
+ g_print (" /* %s type registrations done */\n", alltypes_macro.c_str());
}
/* close namespace state */
nsh.leaveAll();
- // printf ("\nnamespace ... {\n"); // FIXME: do images need a namespace?
+ // g_print ("\nnamespace ... {\n"); // FIXME: do images need a namespace?
/* image method implementations */
for (vector<Image>::const_iterator ii = images.begin(); ii != images.end(); ii++)
{
- printf ("%s\n", ii->method.c_str());
- printf ("{\n");
+ g_print ("%s\n", ii->method.c_str());
+ g_print ("{\n");
gint estatus = 0;
GError *error = NULL;
gchar *out, *err = NULL;
@@ -1376,16 +1376,16 @@ public:
}
g_clear_error (&error);
g_free (err);
- printf (" %s\n", out);
+ g_print (" %s\n", out);
g_free (out);
- printf (" return local_pixstream;\n");
- printf ("}\n");
+ g_print (" return local_pixstream;\n");
+ g_print ("}\n");
}
- // printf ("\n}; // ...\n"); // FIXME: do images need a namespace?
+ // g_print ("\n}; // ...\n"); // FIXME: do images need a namespace?
/* done */
- printf ("\n/*-------- end %s generated code --------*/\n\n\n", Options::the()->sfidlName.c_str());
+ g_print ("\n/*-------- end %s generated code --------*/\n\n\n", Options::the()->sfidlName.c_str());
return true;
}
};
diff --git a/sfi/sfidl-hostc.cc b/sfi/sfidl-hostc.cc
index 4c4ec78..63734d1 100644
--- a/sfi/sfidl-hostc.cc
+++ b/sfi/sfidl-hostc.cc
@@ -39,9 +39,9 @@ void CodeGeneratorHostC::printRecordFieldDeclarations()
{
if (parser.fromInclude (ri->name)) continue;
- printf("extern SfiRecFields %s_fields;\n",makeLowerName (ri->name).c_str());
+ g_print("extern SfiRecFields %s_fields;\n",makeLowerName (ri->name).c_str());
}
- printf("\n");
+ g_print("\n");
}
void CodeGeneratorHostC::printInitFunction (const String& initFunction)
@@ -55,9 +55,9 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
String name = makeLowerName (ri->name);
- printf("static GParamSpec *%s_field[%zd];\n", name.c_str(), ri->contents.size());
- printf("SfiRecFields %s_fields = { %zd, %s_field };\n", name.c_str(), ri->contents.size(), name.c_str());
- printf("\n");
+ g_print("static GParamSpec *%s_field[%zd];\n", name.c_str(), ri->contents.size());
+ g_print("SfiRecFields %s_fields = { %zd, %s_field };\n", name.c_str(), ri->contents.size(), name.c_str());
+ g_print("\n");
}
for(vector<Sequence>::const_iterator si = parser.getSequences().begin(); si != parser.getSequences().end(); si++)
{
@@ -65,16 +65,16 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
String name = makeLowerName (si->name);
- printf("static GParamSpec *%s_content;\n", name.c_str());
- printf("\n");
+ g_print("static GParamSpec *%s_content;\n", name.c_str());
+ g_print("\n");
}
/*
* the init function itself
*/
bool first = true;
- printf("static void\n%s (void)\n", initFunction.c_str());
- printf("{\n");
+ g_print("static void\n%s (void)\n", initFunction.c_str());
+ g_print("{\n");
/*
* It is important to follow the declaration order of the idl file here, as for
@@ -90,7 +90,7 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
if (parser.isRecord (*ti) || parser.isSequence (*ti))
{
- if(!first) printf("\n");
+ if(!first) g_print("\n");
first = false;
}
if (parser.isRecord (*ti))
@@ -102,8 +102,8 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
for (vector<Param>::const_iterator pi = rdef.contents.begin(); pi != rdef.contents.end(); pi++, f++)
{
- printf("#line %u \"%s\"\n", pi->line, parser.fileName().c_str());
- printf(" %s_field[%d] = %s;\n", name.c_str(), f, makeParamSpec (*pi).c_str());
+ g_print("#line %u \"%s\"\n", pi->line, parser.fileName().c_str());
+ g_print(" %s_field[%d] = %s;\n", name.c_str(), f, makeParamSpec (*pi).c_str());
}
}
if (parser.isSequence (*ti))
@@ -112,11 +112,11 @@ void CodeGeneratorHostC::printInitFunction (const String& initFunction)
String name = makeLowerName (sdef.name);
- printf("#line %u \"%s\"\n", sdef.content.line, parser.fileName().c_str());
- printf(" %s_content = %s;\n", name.c_str(), makeParamSpec (sdef.content).c_str());
+ g_print("#line %u \"%s\"\n", sdef.content.line, parser.fileName().c_str());
+ g_print(" %s_content = %s;\n", name.c_str(), makeParamSpec (sdef.content).c_str());
}
}
- printf("}\n");
+ g_print("}\n");
}
void CodeGeneratorHostC::printChoiceMethodPrototypes (PrefixSymbolMode mode)
@@ -128,7 +128,7 @@ void CodeGeneratorHostC::printChoiceMethodPrototypes (PrefixSymbolMode mode)
if (mode == generatePrefixSymbols)
prefix_symbols.push_back (makeLowerName (ei->name) + "_get_values");
else
- printf("SfiChoiceValues %s_get_values (void);\n", makeLowerName (ei->name).c_str());
+ g_print("SfiChoiceValues %s_get_values (void);\n", makeLowerName (ei->name).c_str());
}
}
@@ -142,26 +142,26 @@ void CodeGeneratorHostC::printChoiceMethodImpl()
String name = makeLowerName (ei->name);
- printf ("SfiChoiceValues\n");
- printf ("%s_get_values (void)\n", makeLowerName (ei->name).c_str());
- printf ("{\n");
- printf (" static SfiChoiceValue values[%zu];\n", ei->contents.size());
- printf (" static const SfiChoiceValues choice_values = {\n");
- printf (" G_N_ELEMENTS (values), values,\n");
- printf (" };\n");
- printf (" if (!values[0].choice_ident)\n");
- printf (" {\n");
+ g_print ("SfiChoiceValues\n");
+ g_print ("%s_get_values (void)\n", makeLowerName (ei->name).c_str());
+ g_print ("{\n");
+ g_print (" static SfiChoiceValue values[%zu];\n", ei->contents.size());
+ g_print (" static const SfiChoiceValues choice_values = {\n");
+ g_print (" G_N_ELEMENTS (values), values,\n");
+ g_print (" };\n");
+ g_print (" if (!values[0].choice_ident)\n");
+ g_print (" {\n");
int i = 0;
for (vector<ChoiceValue>::const_iterator vi = ei->contents.begin(); vi != ei->contents.end(); i++, vi++)
{
- printf (" values[%u].choice_ident = \"%s\";\n", i, makeUpperName (vi->name).c_str());
- printf (" values[%u].choice_label = %s;\n", i, vi->label.escaped().c_str());
- printf (" values[%u].choice_blurb = %s;\n", i, vi->blurb.escaped().c_str());
+ g_print (" values[%u].choice_ident = \"%s\";\n", i, makeUpperName (vi->name).c_str());
+ g_print (" values[%u].choice_label = %s;\n", i, vi->label.escaped().c_str());
+ g_print (" values[%u].choice_blurb = %s;\n", i, vi->blurb.escaped().c_str());
}
- printf (" }\n");
- printf (" return choice_values;\n");
- printf ("}\n");
- printf("\n");
+ g_print (" }\n");
+ g_print (" return choice_values;\n");
+ g_print ("}\n");
+ g_print("\n");
enumCount++;
}
@@ -169,7 +169,7 @@ void CodeGeneratorHostC::printChoiceMethodImpl()
bool CodeGeneratorHostC::run ()
{
- printf("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
+ g_print("\n/*-------- begin %s generated code --------*/\n\n\n", options.sfidlName.c_str());
if (generateHeader)
{
@@ -185,8 +185,8 @@ bool CodeGeneratorHostC::run ()
if (prefix != "")
{
for (vector<String>::const_iterator pi = prefix_symbols.begin(); pi != prefix_symbols.end(); pi++)
- printf("#define %s %s_%s\n", pi->c_str(), prefix.c_str(), pi->c_str());
- printf("\n");
+ g_print("#define %s %s_%s\n", pi->c_str(), prefix.c_str(), pi->c_str());
+ g_print("\n");
}
/* generate the header */
@@ -208,7 +208,7 @@ bool CodeGeneratorHostC::run ()
if (generateSource)
{
- printf("#include <string.h>\n");
+ g_print("#include <string.h>\n");
printClientRecordMethodImpl();
printClientSequenceMethodImpl();
@@ -219,7 +219,7 @@ bool CodeGeneratorHostC::run ()
printInitFunction (generateInitFunction);
}
- printf("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
+ g_print("\n/*-------- end %s generated code --------*/\n\n\n", options.sfidlName.c_str());
return true;
}
@@ -255,8 +255,8 @@ void
CodeGeneratorHostC::help()
{
CodeGeneratorCBase::help();
- fprintf (stderr, " --prefix <prefix> set the prefix for C functions\n");
- fprintf (stderr, " --init <name> set the name of the init function\n");
+ g_printerr (" --prefix <prefix> set the prefix for C functions\n");
+ g_printerr (" --init <name> set the name of the init function\n");
}
namespace {
diff --git a/sfi/sfidl-options.cc b/sfi/sfidl-options.cc
index 344f3f5..3ba1423 100644
--- a/sfi/sfidl-options.cc
+++ b/sfi/sfidl-options.cc
@@ -206,18 +206,18 @@ bool Options::parse (int *argc_p, char **argv_p[], const Parser& parser)
for (std::vector<String>::const_iterator ii = includePath.begin(); ii != includePath.end(); ii++)
{
if (!first)
- printf (":");
+ g_print (":");
else
first = false;
- printf ("%s", ii->c_str());
+ g_print ("%s", ii->c_str());
}
- printf ("\n");
+ g_print ("\n");
return true;
}
if (printVersion)
{
- printf ("%s %s\n", SFIDL_PRG_NAME, SFIDL_VERSION);
+ g_print ("%s %s\n", SFIDL_PRG_NAME, SFIDL_VERSION);
return true;
}
@@ -228,27 +228,27 @@ void Options::printUsage ()
{
list<Factory *> factories = Factory::listFactories();
- fprintf (stderr, "usage: %s <binding> [ <options> ] <idlfile>\n", sfidlName.c_str());
- fprintf (stderr, "\n");
- fprintf (stderr, "general options:\n");
- fprintf (stderr, " -I <directory> add this directory to the include path\n");
- fprintf (stderr, " --print-include-path print include path\n");
- fprintf (stderr, " --nostdinc don't use standard include path\n");
- fprintf (stderr, "\n");
- fprintf (stderr, " --help help for %s\n", sfidlName.c_str());
- fprintf (stderr, " --help <binding> help for a specific binding\n");
- fprintf (stderr, " --version print version\n");
- fprintf (stderr, "\n");
+ g_printerr ("usage: %s <binding> [ <options> ] <idlfile>\n", sfidlName.c_str());
+ g_printerr ("\n");
+ g_printerr ("general options:\n");
+ g_printerr (" -I <directory> add this directory to the include path\n");
+ g_printerr (" --print-include-path print include path\n");
+ g_printerr (" --nostdinc don't use standard include path\n");
+ g_printerr ("\n");
+ g_printerr (" --help help for %s\n", sfidlName.c_str());
+ g_printerr (" --help <binding> help for a specific binding\n");
+ g_printerr (" --version print version\n");
+ g_printerr ("\n");
if (!codeGenerator)
{
- fprintf (stderr, "language bindings:\n");
+ g_printerr ("language bindings:\n");
for (list<Factory *>::const_iterator fi = factories.begin(); fi != factories.end(); fi++)
- fprintf (stderr, " %-28s%s\n", (*fi)->option().c_str(), (*fi)->description().c_str());
+ g_printerr (" %-28s%s\n", (*fi)->option().c_str(), (*fi)->description().c_str());
}
else
{
- fprintf (stderr, "options for %s:\n", codeGeneratorName.c_str());
+ g_printerr ("options for %s:\n", codeGeneratorName.c_str());
codeGenerator->help();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]