You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/06/25 14:39:47 UTC
[lucy-commits] svn commit: r1139539 - in /incubator/lucy/trunk/clownfish/src:
CFCBindAliases.c CFCBindFunction.c CFCBindMethod.c
Author: marvin
Date: Sat Jun 25 12:39:46 2011
New Revision: 1139539
URL: http://svn.apache.org/viewvc?rev=1139539&view=rev
Log:
Restore C++ and MSVC compatibility. Add some casts, rename vars away
from "template", give stub functions valid return values.
Modified:
incubator/lucy/trunk/clownfish/src/CFCBindAliases.c
incubator/lucy/trunk/clownfish/src/CFCBindFunction.c
incubator/lucy/trunk/clownfish/src/CFCBindMethod.c
Modified: incubator/lucy/trunk/clownfish/src/CFCBindAliases.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindAliases.c?rev=1139539&r1=1139538&r2=1139539&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindAliases.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCBindAliases.c Sat Jun 25 12:39:46 2011
@@ -119,7 +119,7 @@ CFCBindAliases_c_aliases(void) {
size += strlen(aliases[i].to);
size += sizeof("#define %s %s\n");
}
- char *content = MALLOCATE(size);
+ char *content = (char*)MALLOCATE(size);
content[0] = '\0';
strcat(content, "#ifndef CFISH_C_ALIASES\n#define CFISH_C_ALIASES\n\n");
Modified: incubator/lucy/trunk/clownfish/src/CFCBindFunction.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindFunction.c?rev=1139539&r1=1139538&r2=1139539&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindFunction.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCBindFunction.c Sat Jun 25 12:39:46 2011
@@ -38,7 +38,7 @@ CFCBindFunc_func_declaration(CFCFunction
+ strlen(param_list_str)
+ 20
+ strlen("\0");
- char *buf = MALLOCATE(size);
+ char *buf = (char*)MALLOCATE(size);
sprintf(buf, "%s%s\n%s(%s);", inline_prop, ret_type_str, full_func_sym,
param_list_str);
return buf;
Modified: incubator/lucy/trunk/clownfish/src/CFCBindMethod.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindMethod.c?rev=1139539&r1=1139538&r2=1139539&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindMethod.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCBindMethod.c Sat Jun 25 12:39:46 2011
@@ -214,16 +214,16 @@ CFCBindMeth_callback_obj_def(CFCMethod *
unsigned macro_sym_len = strlen(macro_sym);
const char *full_override_sym = CFCMethod_full_override_sym(method);
const char *full_callback_sym = CFCMethod_full_callback_sym(method);
- char template[] =
+ char pattern[] =
"cfish_Callback %s = {\"%s\", %u, (cfish_method_t)%s, %s};\n";
- size_t size = sizeof(template)
+ size_t size = sizeof(pattern)
+ macro_sym_len
+ strlen(full_override_sym)
+ strlen(full_callback_sym)
+ strlen(offset)
+ 30;
char *def = (char*)MALLOCATE(size);
- sprintf(def, template, full_callback_sym, macro_sym, macro_sym_len,
+ sprintf(def, pattern, full_callback_sym, macro_sym, macro_sym_len,
full_override_sym, offset);
return def;
}
@@ -252,7 +252,7 @@ S_maybe_unreachable(CFCType *return_type
}
else {
const char *ret_type_str = CFCType_to_c(return_type);
- return_statement = MALLOCATE(strlen(ret_type_str) + 60);
+ return_statement = (char*)MALLOCATE(strlen(ret_type_str) + 60);
sprintf(return_statement, "\n CHY_UNREACHABLE_RETURN(%s);",
ret_type_str);
}
@@ -275,13 +275,13 @@ CFCBindMeth_abstract_method_def(CFCMetho
char *unused = S_build_unused_vars(param_vars + 1);
char *return_statement = S_maybe_unreachable(return_type);
- char template[] =
+ char pattern[] =
"%s\n"
"%s(%s) {\n"
" cfish_CharBuf *klass = self ? Cfish_Obj_Get_Class_Name((cfish_Obj*)self) : %s->name;%s\n"
" CFISH_THROW(CFISH_ERR, \"Abstract method '%s' not defined by %%o\", klass);%s\n"
"}\n";
- size_t needed = sizeof(template)
+ size_t needed = sizeof(pattern)
+ strlen(ret_type_str)
+ strlen(full_func_sym)
+ strlen(params)
@@ -291,7 +291,7 @@ CFCBindMeth_abstract_method_def(CFCMetho
+ strlen(return_statement)
+ 50;
char *abstract_def = (char*)MALLOCATE(needed);
- sprintf(abstract_def, template, ret_type_str, full_func_sym, params,
+ sprintf(abstract_def, pattern, ret_type_str, full_func_sym, params,
vtable_var, unused, macro_sym, return_statement);
FREEMEM(unused);
@@ -406,15 +406,17 @@ S_invalid_callback_def(CFCMethod *method
// Thwart compiler warnings.
CFCType *return_type = CFCMethod_get_return_type(method);
+ const char *ret_type_str = CFCType_to_c(return_type);
char *unused = S_build_unused_vars(param_vars);
char *unreachable = S_maybe_unreachable(return_type);
char pattern[] =
- "void\n"
+ "%s\n"
"%s(%s) {%s\n"
" CFISH_THROW(CFISH_ERR, \"Can't override %s via binding\");%s\n"
"}\n";
size_t size = sizeof(pattern)
+ + strlen(ret_type_str)
+ strlen(override_sym)
+ strlen(params)
+ strlen(unused)
@@ -422,7 +424,7 @@ S_invalid_callback_def(CFCMethod *method
+ strlen(unreachable)
+ 20;
char *callback_def = (char*)MALLOCATE(size);
- sprintf(callback_def, pattern, override_sym, params, unused,
+ sprintf(callback_def, pattern, ret_type_str, override_sym, params, unused,
full_method_sym, unreachable);
FREEMEM(unused);