Merged trunk up to revision 12551

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12552 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-03-24 05:46:05 +00:00
commit 93499e12af
160 changed files with 3204 additions and 1238 deletions

View file

@ -22,6 +22,21 @@ char cvsroot_allegrocl_cxx[] = "$Id$";
// #define ALLEGROCL_TYPE_DEBUG
// #define ALLEGROCL_CLASS_DEBUG
static const char *usage = (char *) "\
Allegro CL Options (available with -allegrocl)\n\
-identifier-converter <type or funcname> - \n\
Specifies the type of conversion to do on C identifiers to convert\n\
them to symbols. There are two built-in converters: 'null' and\n\
'lispify'. The default is 'null'. If you supply a name other\n\
than one of the built-ins, then a function by that name will be\n\
called to convert identifiers to symbols.\n\
-[no]cwrap - Turn on or turn off generation of an intermediate C file when\n\
creating a C interface. By default this is only done for C++ code.\n\
-isolate - Define all SWIG helper functions in a package unique to this\n\
module. Avoids redefinition warnings when loading multiple\n\
SWIGged modules into the same running Allegro CL image.\n\
";
static File *f_cl = 0;
String *f_clhead = NewString("");
String *f_clwrap = NewString("(swig-in-package ())\n\n");
@ -1587,21 +1602,7 @@ void ALLEGROCL::main(int argc, char *argv[]) {
}
if (!strcmp(argv[i], "-help")) {
fprintf(stdout, "Allegro CL Options (available with -allegrocl)\n");
fprintf(stdout,
" -identifier-converter <type or funcname>\n"
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
"\tthem to symbols. There are two built-in converters: 'null' and\n"
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
"\tthan one of the built-ins, then a function by that name will be\n"
"\tcalled to convert identifiers to symbols.\n"
"\n"
" -[no]cwrap\n"
"\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n"
" -isolate\n"
"Define all SWIG helper functions in a package unique to this module. Avoids redefinition warnings when loading multiple SWIGged modules\n"
"into the same running Allegro CL image.\n");
Printf(stdout, "%s\n", usage);
}
}
@ -2499,11 +2500,8 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
Delete(parsed);
int isPtrReturn = 0;
if (cl_t) {
lclass = lookup_defined_foreign_ltype(cl_t);
isPtrReturn = 1;
}
int ff_foreign_ptr = 0;
@ -2522,17 +2520,8 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
Replaceall(wrap->code, "$out_fftype", out_ffitype);
if (deref_out_ffitype)
Replaceall(wrap->code, "$*out_fftype", deref_out_ffitype);
// if(Replaceall(wrap->code,"$lclass", lclass) && !isPtrReturn) {
// Swig_warning(WARN_LANG_RETURN_TYPE,Getfile(n), Getline(n),
// "While Wrapping %s, replaced a $lclass reference when return type is non-pointer %s!\n",
// Getattr(n,"name"), cl_t);
// }
Replaceall(wrap->code, "$body", NewStringf("(swig-ff-call%s)", wrap->locals));
// Replaceall(wrap->code,"$body",
// (!Strcmp(result_type,"void") ?
// NewStringf("(swig-ff-call%s)", wrap->locals) :
// NewStringf("(push (swig-ff-call%s) ACL_result)", wrap->locals)));
String *ldestructor = Copy(lclass);
if (ff_foreign_ptr)
Replaceall(ldestructor, ldestructor, "cl::identity");
@ -2869,23 +2858,13 @@ int ALLEGROCL::globalvariableHandler(Node *n) {
// String *name = Getattr(n, "name");
SwigType *type = Getattr(n, "type");
SwigType *ctype;
SwigType *rtype = SwigType_typedef_resolve_all(type);
int pointer_added = 0;
if (SwigType_isclass(rtype)) {
SwigType_add_pointer(type);
SwigType_add_pointer(rtype);
pointer_added = 1;
}
ctype = SwigType_str(type, 0);
// EXPORT <SwigType_str> <mangled_name>;
// <SwigType_str> <mangled_name> = <name>;
// Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name,
// ctype, mangled_name, (pointer_added ? "&" : ""), name);
Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n",
Getattr(n, "sym:name"), Getattr(n, "sym:name"), ((SwigType_isconst(type)) ? ":constant" : ":variable"));
@ -3230,3 +3209,4 @@ int ALLEGROCL::templateDeclaration(Node *n) {
return SWIG_OK;
}

View file

@ -386,10 +386,6 @@ class Allocate:public Dispatcher {
}
Node *c = firstChild(cls);
String *kind = Getattr(cls, "kind");
int mode = PUBLIC;
if (kind && (Strcmp(kind, "class") == 0))
mode = PRIVATE;
while (c) {
if (Getattr(c, "error") || GetFlag(c, "feature:ignore")) {
@ -457,13 +453,6 @@ class Allocate:public Dispatcher {
}
}
if (Strcmp(nodeType(c), "access") == 0) {
kind = Getattr(c, "kind");
if (Strcmp(kind, "public") == 0)
mode = PUBLIC;
else
mode = PRIVATE;
}
c = nextSibling(c);
}
/* Look for methods in base classes */

View file

@ -20,6 +20,19 @@ char cvsroot_cffi_cxx[] = "$Id$";
//#define CFFI_DEBUG
//#define CFFI_WRAP_DEBUG
static const char *usage = (char *) "\
CFFI Options (available with -cffi)\n\
-generate-typedef - Use defctype to generate shortcuts according to the\n\
typedefs in the input.\n\
-[no]cwrap - Turn on or turn off generation of an intermediate C\n\
file when creating a C interface. By default this is\n\
only done for C++ code.\n\
-[no]swig-lisp - Turn on or off generation of code for helper lisp\n\
macro, functions, etc. which SWIG uses while\n\
generating wrappers. These macros, functions may still\n\
be used by generated wrapper code.\n\
";
class CFFI:public Language {
public:
String *f_cl;
@ -80,17 +93,7 @@ void CFFI::main(int argc, char *argv[]) {
CWrap = false;
for (i = 1; i < argc; i++) {
if (!Strcmp(argv[i], "-help")) {
Printf(stdout, "cffi Options (available with -cffi)\n");
Printf(stdout,
" -generate-typedef\n"
"\tIf this option is given then defctype will be used to generate\n"
"\tshortcuts according to the typedefs in the input.\n"
" -[no]cwrap\n"
"\tTurn on or turn off generation of an intermediate C file when\n"
"\tcreating a C interface. By default this is only done for C++ code.\n"
" -[no]swig-lisp\n"
"\tTurns on or off generation of code for helper lisp macro, functions,\n"
"\tetc. which SWIG uses while generating wrappers. These macros, functions\n" "\tmay still be used by generated wrapper code.\n");
Printf(stdout, "%s\n", usage);
} else if (!strcmp(argv[i], "-cwrap")) {
CWrap = true;
Swig_mark_arg(i);

View file

@ -17,17 +17,17 @@ char cvsroot_chicken_cxx[] = "$Id$";
#include <ctype.h>
static const char *chicken_usage = (char *) "\
static const char *usage = (char *) "\
\
CHICKEN Options (available with -chicken)\n\
-proxy - Export TinyCLOS class definitions\n\
-closprefix <prefix> - Prepend <prefix> to all clos identifiers\n\
-useclassprefix - Prepend the class name to all clos identifiers\n\
-unhideprimitive - Unhide the primitive: symbols\n\
-nounit - Do not (declare (unit ...)) in scheme file\n\
-noclosuses - Do not (declare (uses ...)) in scheme file\n\
-nocollection - Do not register pointers with chicken garbage\n\
collector and export destructors\n\
-nounit - Do not (declare (unit ...)) in scheme file\n\
-proxy - Export TinyCLOS class definitions\n\
-unhideprimitive - Unhide the primitive: symbols\n\
-useclassprefix - Prepend the class name to all clos identifiers\n\
\n";
static char *module = 0;
@ -137,7 +137,7 @@ void CHICKEN::main(int argc, char *argv[]) {
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(chicken_usage, stdout);
fputs(usage, stdout);
SWIG_exit(0);
} else if (strcmp(argv[i], "-proxy") == 0) {
clos = 1;
@ -684,9 +684,6 @@ int CHICKEN::variableWrapper(Node *n) {
String *overname = 0;
String *scmname;
int num_required;
int num_arguments;
scmname = NewString(iname);
Replaceall(scmname, "_", "-");
@ -705,10 +702,6 @@ int CHICKEN::variableWrapper(Node *n) {
emit_attach_parmmaps(l, f);
Setattr(n, "wrap:parms", l);
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
// evaluation function names
Append(wname, Swig_name_wrapper(iname));
if (overname) {
@ -845,9 +838,6 @@ int CHICKEN::constantWrapper(Node *n) {
String *rvalue;
SwigType *nctype;
int num_required;
int num_arguments;
scmname = NewString(iname);
Replaceall(scmname, "_", "-");
@ -903,10 +893,6 @@ int CHICKEN::constantWrapper(Node *n) {
emit_attach_parmmaps(l, f);
Setattr(n, "wrap:parms", l);
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
// evaluation function names
// Check for interrupts
@ -1382,12 +1368,10 @@ void CHICKEN::dispatchFunction(Node *n) {
SortList(flist, compareTypeLists);
String *clos_name;
int construct = 0;
if (have_constructor && !has_constructor_args) {
has_constructor_args = 1;
constructor_dispatch = NewStringf("%s@SWIG@new@dispatch", short_class_name);
clos_name = Copy(constructor_dispatch);
construct = 1;
Printf(clos_methods, "(declare (hide %s))\n", clos_name);
} else if (in_class)
clos_name = NewString(member_name);

View file

@ -15,6 +15,15 @@ char cvsroot_clisp_cxx[] = "$Id$";
#include "swigmod.h"
static const char *usage = (char *) "\
CLISP Options (available with -clisp)\n\
-extern-all - Create clisp definitions for all the functions and\n\
global variables otherwise only definitions for\n\
externed functions and variables are created.\n\
-generate-typedef - Use def-c-type to generate shortcuts according to the\n\
typedefs in the input.\n\
";
class CLISP:public Language {
public:
File *f_cl;
@ -48,15 +57,7 @@ void CLISP::main(int argc, char *argv[]) {
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-help")) {
Printf(stdout, "clisp Options (available with -clisp)\n");
Printf(stdout,
" -extern-all\n"
"\t If this option is given then clisp definitions for all the functions\n"
"and global variables will be created otherwise only definitions for \n"
"externed functions and variables are created.\n"
" -generate-typedef\n"
"\t If this option is given then def-c-type will be used to generate shortcuts\n"
"according to the typedefs in the input.\n");
Printf(stdout, "%s\n", usage);
} else if ((Strcmp(argv[i], "-extern-all") == 0)) {
extern_all_flag = 1;
Swig_mark_arg(i);
@ -293,16 +294,18 @@ int CLISP::classDeclaration(Node *n) {
}
String *temp = Copy(Getattr(c, "decl"));
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
String *lisp_type = get_ffi_type(n, temp);
Delete(temp);
if (temp) {
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
String *lisp_type = get_ffi_type(n, temp);
Delete(temp);
String *slot_name = Getattr(c, "sym:name");
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
String *slot_name = Getattr(c, "sym:name");
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
Append(entries, NewStringf("%s-%s", name, slot_name));
Append(entries, NewStringf("%s-%s", name, slot_name));
Delete(lisp_type);
Delete(lisp_type);
}
}
Printf(f_cl, ")\n");

View file

@ -646,7 +646,6 @@ public:
UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *decl, String *overloaded_name) {
UpcallData *udata;
String *imclass_methodidx;
String *class_methodidx;
Hash *new_udata;
String *key = NewStringf("%s|%s", imclass_method, decl);
@ -659,7 +658,6 @@ public:
return Getattr(udata, "methodoff");
}
imclass_methodidx = NewStringf("%d", n_dmethods);
class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod);
n_dmethods++;
@ -668,10 +666,6 @@ public:
Setattr(dmethods_table, key, new_udata);
Setattr(new_udata, "method", Copy(class_method));
// TODO: remove fdesc
// Setattr(new_udata, "fdesc", Copy(class_desc));
// Setattr(new_udata, "imclass_method", Copy(imclass_method));
// Setattr(new_udata, "imclass_methodidx", imclass_methodidx);
Setattr(new_udata, "class_methodidx", class_methodidx);
Setattr(new_udata, "decl", Copy(decl));
Setattr(new_udata, "overname", Copy(overloaded_name));
@ -736,7 +730,6 @@ public:
String *body = NewString("");
String *im_outattributes = 0;
int num_arguments = 0;
int num_required = 0;
bool is_void_return;
String *overloaded_name = getOverloadedName(n);
@ -815,7 +808,6 @@ public:
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
int gencomma = 0;
// Now walk the function parameter list and generate code to get arguments
@ -2707,7 +2699,6 @@ public:
String *return_type = NewString("");
String *function_code = NewString("");
int num_arguments = 0;
int num_required = 0;
String *overloaded_name = getOverloadedName(n);
String *func_name = NULL;
bool setter_flag = false;
@ -2767,7 +2758,6 @@ public:
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag);
int gencomma = 0;
@ -4020,7 +4010,6 @@ public:
int classDirectorDestructor(Node *n) {
Node *current_class = getCurrentClass();
String *full_classname = Getattr(current_class, "name");
String *classname = Swig_class_name(current_class);
Wrapper *w = NewWrapper();
@ -4032,22 +4021,11 @@ public:
Printf(w->def, "SwigDirector_%s::~SwigDirector_%s() {\n", classname, classname);
}
/* Ensure that correct directordisconnect typemap's method name is called
* here: */
const String *disconn_tm = NULL;
Node *disconn_attr = NewHash();
String *disconn_methodname = NULL;
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
Printv(w->code, "}\n", NIL);
Wrapper_print(w, f_directors);
DelWrapper(w);
Delete(disconn_attr);
Delete(classname);
return SWIG_OK;
}
@ -4172,5 +4150,5 @@ C# Options (available with -csharp)\n\
-namespace <nm> - Generate wrappers into C# namespace <nm>\n\
-noproxy - Generate the low-level functional interface instead\n\
of proxy classes\n\
-oldvarnames - old intermediary method names for variable wrappers\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
\n";

File diff suppressed because it is too large Load diff

View file

@ -402,7 +402,6 @@ String *emit_action(Node *n) {
String *tm;
String *action;
String *wrap;
SwigType *rt;
ParmList *catchlist = Getattr(n, "catchlist");
/* Look for fragments */
@ -440,9 +439,6 @@ String *emit_action(Node *n) {
action = Getattr(n, "wrap:action");
assert(action != 0);
/* Get the return type */
rt = Getattr(n, "type");
/* Emit contract code (if any) */
if (Swig_contract_mode_get()) {
/* Preassertion */

View file

@ -12,7 +12,6 @@ char cvsroot_go_cxx[] = "$Id";
#include "swigmod.h"
#include "cparse.h"
#include <ctype.h>
#include <string>
class GO:public Language {
static const char *const usage;
@ -573,7 +572,7 @@ private:
result = NewString("void");
r1 = result;
} else {
if (!is_public(n)) {
if (!checkFunctionVisibility(n, NULL)) {
return SWIG_OK;
}
@ -647,7 +646,7 @@ private:
}
/* ----------------------------------------------------------------------
* staticmemberfunctionHandler
* staticmemberfunctionHandler()
*
* For some reason the language code removes the "storage" attribute
* for a static function before calling functionWrapper, which means
@ -746,7 +745,7 @@ private:
receiver = NULL;
}
bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && is_public(n));
bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && checkFunctionVisibility(n, NULL));
bool needs_wrapper = (gccgo_flag || receiver || is_constructor || is_destructor || parm_count > required_count);
@ -1087,9 +1086,9 @@ private:
// A slice has a pointer, a length, and a capacity. The
// length and capacity are always 4 bytes.
Append(orig, "(SWIG_PARM_SIZE + 8)");
} else if (Strcmp(go, "float") == 0 || Strcmp(go, "float64") == 0) {
} else if (Strcmp(go, "float64") == 0) {
Append(orig, "8");
} else if (Strcmp(go, "complex") == 0 || Strcmp(go, "complex64") == 0) {
} else if (Strcmp(go, "complex64") == 0) {
Append(orig, "8");
} else if (Strcmp(go, "complex128") == 0) {
Append(orig, "16");
@ -1398,7 +1397,6 @@ private:
}
Printv(current, Getattr(parms, "lname"), NULL);
String *last = NULL;
int vc = 0;
for (Iterator bi = First(base); bi.item; bi = Next(bi)) {
Printf(actioncode, " %s *swig_b%d = (%s *)%s;\n", bi.item, vc, bi.item, current);
@ -1406,7 +1404,6 @@ private:
current = NewString("");
Printf(current, "swig_b%d", vc);
++vc;
last = bi.item;
}
String *code = Copy(Getattr(n, "wrap:action"));
@ -2772,8 +2769,6 @@ private:
* ------------------------------------------------------------ */
int classDirectorMethod(Node *n, Node *parent, String *super) {
(void) super;
bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
@ -2800,7 +2795,7 @@ private:
Setattr(class_methods, name, NewString(""));
if (!Getattr(n, "sym:overloaded")) {
int r = oneClassDirectorMethod(n, parent);
int r = oneClassDirectorMethod(n, parent, super);
if (r != SWIG_OK) {
return r;
}
@ -2811,7 +2806,7 @@ private:
// function in one class hides a function of the same name in a
// parent class.
for (Node *on = Getattr(n, "sym:overloaded"); on; on = Getattr(on, "sym:nextSibling")) {
int r = oneClassDirectorMethod(on, parent);
int r = oneClassDirectorMethod(on, parent, super);
if (r != SWIG_OK) {
return r;
}
@ -2861,7 +2856,11 @@ private:
* Emit a method for a director class.
* ------------------------------------------------------------ */
int oneClassDirectorMethod(Node *n, Node *parent) {
int oneClassDirectorMethod(Node *n, Node *parent, String *super) {
if (!checkFunctionVisibility(n, parent)) {
return SWIG_OK;
}
bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
@ -3104,24 +3103,13 @@ private:
if (SwigType_type(result) != T_VOID) {
Printv(f_c_directors_h, "return ", NULL);
}
Printv(f_c_directors_h, Getattr(parent, "classtype"), "::", Getattr(n, "name"), "(", NULL);
p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
if (i > 0) {
Printv(f_c_directors_h, ", ", NULL);
}
String *pn = Getattr(p, "name");
assert(pn);
Printv(f_c_directors_h, pn, NULL);
p = nextParm(p);
}
String *super_call = Swig_method_call(super, parms);
Printv(f_c_directors_h, super_call, ";\n", NULL);
Delete(super_call);
Printv(f_c_directors_h, ");\n", NULL);
Printv(f_c_directors_h, " }\n", NULL);
// Define the C++ function that the Go function calls.
SwigType *first_type = NULL;
@ -3802,7 +3790,8 @@ private:
int nak = emit_num_arguments(pk);
if ((nrk >= num_required && nrk <= num_arguments)
|| (nak >= num_required && nak <= num_arguments)
|| (nrk <= num_required && nak >= num_arguments)) {
|| (nrk <= num_required && nak >= num_arguments)
|| (varargs && nrk >= num_required)) {
Append(coll, nk);
}
}
@ -3992,7 +3981,6 @@ private:
Delete(coll);
}
Printv(f_go_wrappers, "fail:\n", NULL);
Printv(f_go_wrappers, "\tpanic(\"No match for overloaded function call\")\n", NULL);
Printv(f_go_wrappers, "}\n\n", NULL);
@ -4002,6 +3990,32 @@ private:
return SWIG_OK;
}
/* ----------------------------------------------------------------------
* checkFunctionVisibility()
*
* Return true if we should write out a function based on its
* visibility, false otherwise.
* ---------------------------------------------------------------------- */
bool checkFunctionVisibility(Node *n, Node *parent) {
// Write out a public function.
if (is_public(n))
return true;
// Don't write out a private function.
if (is_private(n))
return false;
// Write a protected function for a director class in
// dirprot_mode.
if (parent == NULL) {
return false;
}
if (dirprot_mode() && Swig_directorclass(parent))
return true;
// Otherwise don't write out a protected function.
return false;
}
/* ----------------------------------------------------------------------
* exportedName()
*
@ -4402,6 +4416,8 @@ private:
SwigType_del_qualifier(r);
ret = goTypeWithInfo(n, r, p_is_interface);
Delete(r);
} else if (SwigType_isvarargs(t)) {
ret = NewString("[]interface{}");
}
Delete(t);
@ -4513,9 +4529,22 @@ private:
bool is_slice = Strncmp(gt, "[]", 2) == 0;
bool is_function = Strcmp(gt, "_swig_fnptr") == 0;
bool is_member = Strcmp(gt, "_swig_memberptr") == 0;
bool is_complex = Strcmp(gt, "complex") == 0;
bool is_complex64 = Strcmp(gt, "complex64") == 0;
bool is_complex128 = Strcmp(gt, "complex128") == 0;
bool is_char = false;
bool is_short = false;
bool is_int = false;
bool is_long = false;
bool is_float = false;
bool is_double = false;
if ((n != NULL && Getattr(n, "tmap:gotype") != NULL) || hasGoTypemap(type)) {
is_char = Strcmp(gt, "int8") == 0 || Strcmp(gt, "uint8") == 0 || Strcmp(gt, "byte") == 0;
is_short = Strcmp(gt, "int16") == 0 || Strcmp(gt, "uint16") == 0;
is_int = Strcmp(gt, "int") == 0 || Strcmp(gt, "int32") == 0 || Strcmp(gt, "uint32") == 0;
is_long = Strcmp(gt, "int64") == 0 || Strcmp(gt, "uint64") == 0;
is_float = Strcmp(gt, "float32") == 0;
is_double = Strcmp(gt, "float64") == 0;
}
Delete(gt);
String *ret;
@ -4531,7 +4560,7 @@ private:
ret = NewString("void *");
Append(ret, name);
return ret;
} else if (is_complex || is_complex64) {
} else if (is_complex64) {
ret = NewString("_Complex float ");
} else if (is_complex128) {
ret = NewString("_Complex double ");
@ -4571,7 +4600,21 @@ private:
}
}
Delete(t);
return SwigType_lstr(type, name);
if (is_char) {
ret = NewString("char ");
} else if (is_short) {
ret = NewString("short ");
} else if (is_int) {
ret = NewString("int ");
} else if (is_long) {
ret = NewString("long long ");
} else if (is_float) {
ret = NewString("float ");
} else if (is_double) {
ret = NewString("double ");
} else {
return SwigType_lstr(type, name);
}
}
if (SwigType_isreference(type)) {
@ -4738,9 +4781,9 @@ extern "C" Language *swig_go(void) {
// Usage message.
const char * const GO::usage = (char *) "\
Go Options (available with -go)\n\
-package <name> - Set name of the Go package to <name>\n\
-gccgo - Generate code for gccgo rather than 6g/8g\n\
-go-prefix <p> - Like gccgo -fgo-prefix option\n\
-soname <name> - Set shared library holding C/C++ code to <name>\n\
-longsize <s> - Set size of C/C++ long type--32 or 64 bits\n\
-package <name> - Set name of the Go package to <name>\n\
-soname <name> - Set shared library holding C/C++ code to <name>\n\
\n";

View file

@ -18,19 +18,15 @@ char cvsroot_guile_cxx[] = "$Id$";
#include <ctype.h>
// Note string broken in half for compilers that can't handle long strings
static const char *guile_usage = (char *) "\
static const char *usage = (char *) "\
Guile Options (available with -guile)\n\
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
-package <name> - Set the path of the module to <name>\n\
(default NULL)\n\
-emitsetters - Emit procedures-with-setters for variables\n\
and structure slots.\n\
-onlysetters - Don't emit traditional getter and setter\n\
procedures for structure slots,\n\
only emit procedures-with-setters.\n\
-procdoc <file> - Output procedure documentation to <file>\n\
-procdocformat <format> - Output procedure documentation in <format>;\n\
one of `guile-1.4', `plain', `texinfo'\n\
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
-exportprimitive - Add the (export ...) code from scmstub into the\n\
GOOPS file.\n\
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
-linkage <lstyle> - Use linkage protocol <lstyle> (default `simple')\n\
Use `module' for native Guile module linking\n\
(requires Guile >= 1.5.0). Use `passive' for\n\
@ -38,18 +34,23 @@ Guile Options (available with -guile)\n\
`ltdlmod' for Guile's old dynamic module\n\
convention (Guile <= 1.4), or `hobbit' for hobbit\n\
modules.\n\
-scmstub - Output Scheme file with module declaration and\n\
exports; only with `passive' and `simple' linkage\n\
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
-onlysetters - Don't emit traditional getter and setter\n\
procedures for structure slots,\n\
only emit procedures-with-setters.\n\
-package <name> - Set the path of the module to <name>\n\
(default NULL)\n\
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
-procdoc <file> - Output procedure documentation to <file>\n\
-procdocformat <format> - Output procedure documentation in <format>;\n\
one of `guile-1.4', `plain', `texinfo'\n\
-proxy - Export GOOPS class definitions\n\
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
-primsuffix <suffix> - Name appended to primitive module when exporting\n\
GOOPS classes. (default = \"primitive\")\n\
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
-scmstub - Output Scheme file with module declaration and\n\
exports; only with `passive' and `simple' linkage\n\
-useclassprefix - Prepend the class name to all goops identifiers\n\
-exportprimitive - Add the (export ...) code from scmstub into the\n\
GOOPS file.\n";
\n";
static File *f_begin = 0;
static File *f_runtime = 0;
@ -135,7 +136,7 @@ public:
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(guile_usage, stdout);
fputs(usage, stdout);
SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-prefix") == 0) {
if (argv[i + 1]) {

View file

@ -808,7 +808,6 @@ public:
String *outarg = NewString("");
String *body = NewString("");
int num_arguments = 0;
int num_required = 0;
int gencomma = 0;
bool is_void_return;
String *overloaded_name = getOverloadedName(n);
@ -885,9 +884,7 @@ public:
Printf(imclass_class_code, " public final static native %s %s(", im_return_type, overloaded_name);
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
// Now walk the function parameter list and generate code to get arguments
for (i = 0, p = l; i < num_arguments; i++) {
@ -2619,7 +2616,6 @@ public:
String *return_type = NewString("");
String *function_code = NewString("");
int num_arguments = 0;
int num_required = 0;
String *overloaded_name = getOverloadedName(n);
String *func_name = NULL;
bool setter_flag = false;
@ -2667,7 +2663,6 @@ public:
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag);
int gencomma = 0;
@ -4227,11 +4222,10 @@ public:
/* Ensure that correct directordisconnect typemap's method name is called
* here: */
const String *disconn_tm = NULL;
Node *disconn_attr = NewHash();
String *disconn_methodname = NULL;
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
Printv(w->code, " swig_disconnect_director_self(\"", disconn_methodname, "\");\n", "}\n", NIL);
@ -4394,6 +4388,6 @@ Java Options (available with -java)\n\
-nopgcpp - Suppress premature garbage collection prevention parameter\n\
-noproxy - Generate the low-level functional interface instead\n\
of proxy classes\n\
-oldvarnames - old intermediary method names for variable wrappers\n\
-package <name> - set name of the Java package to <name>\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
-package <name> - Set name of the Java package to <name>\n\
\n";

View file

@ -82,8 +82,9 @@ void display_mapping(DOH *d) {
(though for now I have not bothered)
NEW LANGUAGE NOTE:END ************************************************/
static const char *usage = (char *) "\
Lua Options (available with -lua)\n\
(coming soon.)\n\n";
Lua Options (available with -lua)\n\
[no additional options]\n\
\n";
@ -170,7 +171,7 @@ public:
for (int i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) { // usage flags
fputs(usage, stderr);
fputs(usage, stdout);
}
}
}

View file

@ -1192,7 +1192,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
}
if (dump_typedef) {
SwigType_print_scope(0);
SwigType_print_scope();
}
if (dump_symtabs) {

View file

@ -3975,10 +3975,10 @@ extern "C" Language *swig_modula3(void) {
const char *MODULA3::usage = (char *) "\
Modula 3 Options (available with -modula3)\n\
-generateconst <file> - generate code for computing numeric values of constants\n\
-generaterename <file> - generate suggestions for %rename\n\
-generatetypemap <file> - generate templates for some basic typemaps\n\
-oldvarnames - old intermediary method names for variable wrappers\n\
-generateconst <file> - Generate code for computing numeric values of constants\n\
-generaterename <file> - Generate suggestions for %rename\n\
-generatetypemap <file> - Generate templates for some basic typemaps\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
\n";
/*

View file

@ -19,12 +19,12 @@ char cvsroot_mzscheme_cxx[] = "$Id$";
static const char *usage = (char *) "\
Mzscheme Options (available with -mzscheme)\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
-declaremodule - Create extension that declares a module\n\
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
scheme_module_name functions\n\
-dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
them\n\
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
scheme_module_name functions\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
";
static String *fieldnames_tab = 0;
@ -240,7 +240,6 @@ public:
String *outarg = NewString("");
String *build = NewString("");
String *tm;
int argout_set = 0;
int i = 0;
int numargs;
int numreq;
@ -381,7 +380,6 @@ public:
Replaceall(tm, "$input", Getattr(p, "emit:input"));
Printv(outarg, tm, "\n", NIL);
p = Getattr(p, "tmap:argout:next");
argout_set = 1;
} else {
p = nextSibling(p);
}

View file

@ -17,11 +17,13 @@ char cvsroot_ocaml_cxx[] = "$Id$";
#include <ctype.h>
static const char *usage = (char *)
("Ocaml Options (available with -ocaml)\n"
"-prefix <name> - Set a prefix <name> to be prepended to all names\n"
"-where - Emit library location\n"
"-suffix <name> - Change .cxx to something else\n" "-oldvarnames - old intermediary method names for variable wrappers\n" "\n");
static const char *usage = (char *) "\
Ocaml Options (available with -ocaml)\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
-suffix <name> - Change .cxx to something else\n\
-where - Emit library location\n\
\n";
static int classmode = 0;
static int in_constructor = 0, in_destructor = 0, in_copyconst = 0;
@ -443,7 +445,6 @@ public:
String *outarg = NewString("");
String *build = NewString("");
String *tm;
int argout_set = 0;
int i = 0;
int numargs;
int numreq;
@ -606,7 +607,6 @@ public:
Replaceall(tm, "$ntype", normalizeTemplatedClassName(Getattr(p, "type")));
Printv(outarg, tm, "\n", NIL);
p = Getattr(p, "tmap:argout:next");
argout_set = 1;
} else {
p = nextSibling(p);
}
@ -879,9 +879,8 @@ public:
* ------------------------------------------------------------ */
virtual int staticmemberfunctionHandler(Node *n) {
int rv;
static_member_function = 1;
rv = Language::staticmemberfunctionHandler(n);
Language::staticmemberfunctionHandler(n);
static_member_function = 0;
return SWIG_OK;
}

View file

@ -18,7 +18,7 @@ char cvsroot_octave_cxx[] = "$Id$";
static const char *usage = (char *) "\
Octave Options (available with -octave)\n\
[no additional options]\n\
\n";
\n";
class OCTAVE:public Language {
@ -64,7 +64,7 @@ public:
for (int i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stderr);
fputs(usage, stdout);
}
}
}
@ -359,13 +359,11 @@ public:
String *name = 0;
String *type = 0;
String *value = 0;
String *ptype = 0;
String *pdoc = Getattr(p, "tmap:doc");
if (pdoc) {
name = Getattr(p, "tmap:doc:name");
type = Getattr(p, "tmap:doc:type");
value = Getattr(p, "tmap:doc:value");
ptype = Getattr(p, "tmap:doc:pytype");
}
name = name ? name : Getattr(p, "name");
@ -1243,7 +1241,6 @@ public:
// build argument list and type conversion string
idx = 0;
p = l;
int use_parse = 0;
while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
@ -1266,7 +1263,6 @@ public:
Printf(wrap_args, "args.append(tmpv);\n");
Putc('O', parse_args);
} else {
use_parse = 1;
Append(parse_args, parse);
Replaceall(tm, "$input", pname);
Replaceall(tm, "$owner", "0");

View file

@ -231,11 +231,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
}
nodes[j].error = 1;
@ -248,11 +249,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
}
nodes[j].error = 1;
@ -270,11 +272,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
}
@ -386,16 +389,11 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
int num_arguments = emit_num_arguments(pi);
if (num_arguments > *maxargs)
*maxargs = num_arguments;
int varargs = emit_isvarargs(pi);
if (!varargs) {
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
Printf(f, "SWIG_TypeRank _ranki = 0;\n");
Printf(f, "SWIG_TypeRank _rankm = 0;\n");
@ -565,16 +563,11 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *
int num_arguments = emit_num_arguments(pi);
if (num_arguments > *maxargs)
*maxargs = num_arguments;
int varargs = emit_isvarargs(pi);
if (!varargs) {
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
/* create a list with the wrappers that collide with the
@ -732,16 +725,11 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
}
if (num_arguments > *maxargs)
*maxargs = num_arguments;
int varargs = emit_isvarargs(pi);
if (!varargs) {
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
if (num_required == num_arguments) {
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
} else {
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
}
if (num_arguments) {

View file

@ -21,14 +21,15 @@ static int treduce = SWIG_cparse_template_reduce(0);
static const char *usage = (char *) "\
Perl5 Options (available with -perl5)\n\
-static - Omit code related to dynamic loading\n\
-nopm - Do not generate the .pm file\n\
-proxy - Create proxy classes\n\
-noproxy - Don't create proxy classes\n\
-compat - Compatibility mode\n\
-const - Wrap constants as constants and not variables (implies -proxy)\n\
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-cppcast - Enable C++ casting operators\n\
-compat - Compatibility mode\n\n";
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-nopm - Do not generate the .pm file\n\
-noproxy - Don't create proxy classes\n\
-proxy - Create proxy classes\n\
-static - Omit code related to dynamic loading\n\
\n";
static int compat = 0;

View file

@ -46,7 +46,7 @@ char cvsroot_php_cxx[] = "$Id$";
static const char *usage = (char *) "\
PHP Options (available with -php)\n\
-cppext - cpp file extension (default to .cpp)\n\
-cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
-noproxy - Don't generate proxy classes.\n\
-prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
\n";
@ -250,7 +250,6 @@ public:
virtual int top(Node *n) {
String *filen;
String *s_type;
/* Check if directors are enabled for this module. */
Node *mod = Getattr(n, "module");
@ -283,7 +282,6 @@ public:
r_shutdown = NewString("/* rshutdown section */\n");
s_header = NewString("/* header section */\n");
s_wrappers = NewString("/* wrapper section */\n");
s_type = NewStringEmpty();
/* subsections of the init section */
s_vinit = NewString("/* vinit subsection */\n");
s_vdecl = NewString("/* vdecl subsection */\n");
@ -391,6 +389,12 @@ public:
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module);
Printf(s_header, "#endif\n\n");
Printf(s_header, "// Allow the user to workaround a PHP bug on some platforms/architectures by\n");
Printf(s_header, "// compiling with -DSWIG_ZEND_ERROR_NORETURN=zend_error\n");
Printf(s_header, "#ifndef SWIG_ZEND_ERROR_NORETURN\n");
Printf(s_header, "# define SWIG_ZEND_ERROR_NORETURN zend_error_noreturn\n");
Printf(s_header, "#endif\n\n");
Printf(s_header, "static void %s_init_globals(zend_%s_globals *globals ) {\n", module, module);
Printf(s_header, " globals->error_msg = default_error_msg;\n");
Printf(s_header, " globals->error_code = default_error_code;\n");
@ -976,7 +980,11 @@ public:
/* Error handling code */
Printf(f->code, "fail:\n");
Printv(f->code, cleanup, NIL);
Printv(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
* using zend_error() here shouldn't generate a warning, so just use that.
* At worst this may result in slightly less good code.
*/
Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
Printf(f->code, "}\n");
@ -1069,6 +1077,8 @@ public:
Hash *ret_types = NewHash();
Setattr(ret_types, d, d);
bool non_void_return = (Cmp(d, "void") != 0);
if (overloaded) {
// Look at all the overloaded versions of this method in turn to
// decide if it's really an overloaded method, or just one where some
@ -1085,6 +1095,7 @@ public:
assert(constructor);
} else if (!Getattr(ret_types, d2)) {
Setattr(ret_types, d2, d2);
non_void_return = non_void_return || (Cmp(d2, "void") != 0);
}
ParmList *l2 = Getattr(o, "wrap:parms");
@ -1496,7 +1507,7 @@ public:
while (last_handled_i < i) {
Printf(prepare, "case %d: ", ++last_handled_i);
}
if (Cmp(d, "void") != 0) {
if (non_void_return) {
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
Append(prepare, "$r=");
} else {
@ -1518,7 +1529,7 @@ public:
Printf(prepare, "\t\t");
if (had_a_case)
Printf(prepare, "default: ");
if (Cmp(d, "void") != 0) {
if (non_void_return) {
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
Append(prepare, "$r=");
} else {
@ -1664,7 +1675,7 @@ public:
}
}
Printf(output, "%s", prepare);
} else if (Cmp(d, "void") == 0 && !hasargout) {
} else if (!non_void_return && !hasargout) {
if (Cmp(invoke, "$r") != 0)
Printf(output, "\t\t%s;\n", invoke);
} else if (is_class(d)) {
@ -1718,7 +1729,6 @@ public:
while (i.item) {
SwigType *ret_type = i.item;
i = Next(i);
Printf(output, "\t\t");
String *mangled = NewString("_p");
Printf(mangled, "%s", SwigType_manglestr(ret_type));
Node *class_node = Getattr(zend_types, mangled);
@ -1729,7 +1739,13 @@ public:
Delete(mangled);
mangled = NewString(SwigType_manglestr(ret_type));
class_node = Getattr(zend_types, mangled);
if (!class_node) {
// Return type isn't an object, so will be handled by the
// !is_resource() check before the switch.
continue;
}
}
Printf(output, "\t\t");
if (i.item) {
Printf(output, "case '%s': ", mangled);
} else {
@ -2290,7 +2306,11 @@ done:
Append(f->code, "return;\n");
Append(f->code, "fail:\n");
Append(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
* using zend_error() here shouldn't generate a warning, so just use that.
* At worst this may result in slightly less good code.
*/
Append(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
Printf(f->code, "}\n");
Wrapper_print(f, s_wrappers);
@ -2503,7 +2523,6 @@ done:
/* build argument list and type conversion string */
idx = 0;
p = l;
int use_parse = 0;
while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
@ -2530,7 +2549,6 @@ done:
Printv(wrap_args, tm, "\n", NIL);
Putc('O', parse_args);
} else {
use_parse = 1;
Append(parse_args, parse);
Replaceall(tm, "$input", pname);
Replaceall(tm, "$owner", "0");
@ -2665,7 +2683,15 @@ done:
}
Append(w->code, "fail:\n");
Append(w->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
if (!is_void) {
Append(w->code, "SWIG_ZEND_ERROR_NORETURN(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
} else {
/* This could be zend_error_noreturn(), but that's buggy in PHP ~5.3 and
* using zend_error() here shouldn't generate a warning, so just use that.
* At worst this may result in slightly less good code.
*/
Append(w->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
}
Append(w->code, "}\n");
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method

View file

@ -37,7 +37,7 @@ char cvsroot_pike_cxx[] = "$Id$";
static const char *usage = (char *) "\
Pike Options (available with -pike)\n\
[None]\n\
[no additional options]\n\
\n";
class PIKE:public Language {

View file

@ -883,9 +883,9 @@ public:
* But don't sure wether this would broken old Python?
*/
Printv(f_shadow,
// "import types\n",
// "import types\n",
"try:\n",
// " _object = types.ObjectType\n",
// " _object = types.ObjectType\n",
" _object = object\n", " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n",
// "del types\n",
"\n\n", NIL);
@ -1344,13 +1344,11 @@ public:
String *name = 0;
String *type = 0;
String *value = 0;
String *ptype = 0;
String *pdoc = Getattr(p, "tmap:doc");
if (pdoc) {
name = Getattr(p, "tmap:doc:name");
type = Getattr(p, "tmap:doc:type");
value = Getattr(p, "tmap:doc:value");
ptype = Getattr(p, "tmap:doc:pytype");
}
name = name ? name : Getattr(p, "name");
@ -1566,7 +1564,7 @@ public:
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
return NewString("False");
if (Strcmp(v, "NULL") == 0)
return NewString("None");
return SwigType_ispointer(t) ? NewString("None") : NewString("0");
}
return 0;
}
@ -3062,13 +3060,13 @@ public:
Printf(f_directors_h, "\n\n");
Printf(f_directors_h, "/* Internal Director utilities */\n");
Printf(f_directors_h, "public:\n");
Printf(f_directors_h, " bool swig_get_inner(const char* protected_method_name) const {\n");
Printf(f_directors_h, " std::map<std::string, bool>::const_iterator iv = swig_inner.find(protected_method_name);\n");
Printf(f_directors_h, " bool swig_get_inner(const char* swig_protected_method_name) const {\n");
Printf(f_directors_h, " std::map<std::string, bool>::const_iterator iv = swig_inner.find(swig_protected_method_name);\n");
Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n");
Printf(f_directors_h, " }\n\n");
Printf(f_directors_h, " void swig_set_inner(const char* protected_method_name, bool val) const\n");
Printf(f_directors_h, " { swig_inner[protected_method_name] = val;}\n\n");
Printf(f_directors_h, " void swig_set_inner(const char* swig_protected_method_name, bool val) const\n");
Printf(f_directors_h, " { swig_inner[swig_protected_method_name] = val;}\n\n");
Printf(f_directors_h, "private:\n");
Printf(f_directors_h, " mutable std::map<std::string, bool> swig_inner;\n");
@ -3793,8 +3791,8 @@ public:
List *shadow_list = Getattr(n, "shadow_methods");
for (int i = 0; i < Len(shadow_list); ++i) {
String *symname = Getitem(shadow_list, i);
Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module,
Swig_name_member(NSPACE_TODO, class_name, symname), class_name);
Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname),
class_name);
}
}
Printf(f_shadow_file, "%s_swigregister = %s.%s_swigregister\n", class_name, module, class_name);
@ -4091,7 +4089,6 @@ public:
String *rclassname = Swig_class_name(getCurrentClass());
assert(rclassname);
String *parms = make_pyParmList(n, true, false, allow_kwargs);
/* Pass 'self' only if using director */
String *callParms = make_pyParmList(n, false, true, allow_kwargs);

View file

@ -15,8 +15,6 @@ char cvsroot_r_cxx[] = "$Id$";
#include "swigmod.h"
#define UNUSED(a) (void)a
static const double DEFAULT_NUMBER = .0000123456712312312323;
static const int MAX_OVERLOAD_ARGS = 5;
@ -215,12 +213,15 @@ R Options (available with -r)\n\
-copystruct - Emit R code to copy C structs (on by default)\n\
-cppcast - Enable C++ casting operators (default) \n\
-debug - Output debug\n\
-dll <name> - Name of the DLL (without the .dll or .so suffix). Default is the module name.\n\
-dll <name> - Name of the DLL (without the .dll or .so suffix).\n\
Default is the module name.\n\
-gc - Aggressive garbage collection\n\
-memoryprof - Add memory profile\n\
-namespace - Output NAMESPACE file\n\
-no-init-code - Turn off the generation of the R_init_<pkgname> code (registration information still generated)\n\
-package <name> - Package name for the PACKAGE argument of the R .Call() invocations. Default is the module name.\n\
-no-init-code - Turn off the generation of the R_init_<pkgname> code\n\
(registration information still generated)\n\
-package <name> - Package name for the PACKAGE argument of the R .Call()\n\
invocations. Default is the module name.\n\
";
@ -265,12 +266,9 @@ static void replaceRClass(String *tm, SwigType *type) {
Delete(tmp); Delete(tmp_base); Delete(tmp_ref);
}
static double getNumber(String *value, String *type) {
UNUSED(type);
static double getNumber(String *value) {
double d = DEFAULT_NUMBER;
if(Char(value)) {
// Printf(stderr, "getNumber %s %s\n", Char(value), type);
if(sscanf(Char(value), "%lf", &d) != 1)
return(DEFAULT_NUMBER);
}
@ -300,7 +298,7 @@ public:
Printf(stderr, "<memberfunctionHandler> %s %s\n",
Getattr(n, "name"),
Getattr(n, "type"));
member_name = Getattr(n, "name");
member_name = Getattr(n, "sym:name");
processing_class_member_function = 1;
int status = Language::memberfunctionHandler(n);
processing_class_member_function = 0;
@ -1013,7 +1011,6 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
int R::OutputMemberReferenceMethod(String *className, int isSet,
List *el, File *out) {
int numMems = Len(el), j;
int has_getitem = 0, has_setitem = 0, has_str = 0;
int varaccessor = 0;
if (numMems == 0)
return SWIG_OK;
@ -1033,9 +1030,6 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
if (Getattr(itemList, item))
continue;
Setattr(itemList, item, "1");
if (!Strcmp(item, "__getitem__")) has_getitem = 1;
if (!Strcmp(item, "__setitem__")) has_setitem = 1;
if (!Strcmp(item, "__str__")) has_str = 1;
String *dup = Getitem(el, j + 1);
char *ptr = Char(dup);
@ -1209,10 +1203,9 @@ int R::enumDeclaration(Node *n) {
// const char *tag = Char(nodeType(c));
// if (Strcmp(tag,"cdecl") == 0) {
name = Getattr(c, "name");
String *type = Getattr(c, "type");
String *val = Getattr(c, "enumvalue");
if(val && Char(val)) {
int inval = (int) getNumber(val, type);
int inval = (int) getNumber(val);
if(inval == DEFAULT_NUMBER)
value++;
else
@ -1735,8 +1728,7 @@ int R::functionWrapper(Node *n) {
}
int i;
int nargs, num_required, varargs;
UNUSED(varargs);
int nargs;
String *wname = Swig_name_wrapper(iname);
Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST);
@ -1785,8 +1777,6 @@ int R::functionWrapper(Node *n) {
Setattr(n,"wrap:parms",l);
nargs = emit_num_arguments(l);
num_required = emit_num_required(l);
varargs = emit_isvarargs(l);
Wrapper_add_local(f, "r_nprotect", "unsigned int r_nprotect = 0");
Wrapper_add_localv(f, "r_ans", "SEXP", "r_ans = R_NilValue", NIL);
@ -2131,11 +2121,6 @@ int R::functionWrapper(Node *n) {
Would like to be able to do this so that we can potentialy insert
*/
if(processing_member_access_function || processing_class_member_function) {
String *tmp;
if(member_name)
tmp = member_name;
else
tmp = Getattr(n, "memberfunctionHandler:name");
addAccessor(member_name, sfun, iname);
}

View file

@ -131,16 +131,17 @@ enum autodoc_t {
AUTODOC_SETTER
};
static const char *usage = "\
static const char *usage = (char *) "\
Ruby Options (available with -ruby)\n\
-globalmodule - Wrap everything into the global module\n\
-minherit - Attempt to support multiple inheritance\n\
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-cppcast - Enable C++ casting operators (default)\n\
-autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\
-cppcast - Enable C++ casting operators (default)\n\
-globalmodule - Wrap everything into the global module\n\
-initname <name>- Set entry function to Init_<name> (used by `require')\n\
-minherit - Attempt to support multiple inheritance\n\
-noautorename - Disable renaming of classes and methods (default)\n\
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
-initname <name> - Set entry function to Init_<name> (used by `require')\n";
";
#define RCLASS(hash, name) (RClass*)(Getattr(hash, name) ? Data(Getattr(hash, name)) : 0)
@ -321,13 +322,11 @@ private:
String *name = 0;
String *type = 0;
String *value = 0;
String *ptype = 0;
String *pdoc = Getattr(p, "tmap:doc");
if (pdoc) {
name = Getattr(p, "tmap:doc:name");
type = Getattr(p, "tmap:doc:type");
value = Getattr(p, "tmap:doc:value");
ptype = Getattr(p, "tmap:doc:pytype");
}
name = name ? name : Getattr(p, "name");
@ -1607,9 +1606,7 @@ public:
virtual int functionWrapper(Node *n) {
String *nodeType;
bool constructor;
bool destructor;
String *storage;
String *symname = Copy(Getattr(n, "sym:name"));
SwigType *t = Getattr(n, "type");
@ -1624,9 +1621,7 @@ public:
return SWIG_NOWRAP;
nodeType = Getattr(n, "nodeType");
constructor = (!Cmp(nodeType, "constructor"));
destructor = (!Cmp(nodeType, "destructor"));
storage = Getattr(n, "storage");
/* If the C++ class constructor is overloaded, we only want to
* write out the "new" singleton method once since it is always

View file

@ -1062,11 +1062,11 @@ class TypePass:private Dispatcher {
* which is hacked. */
if (Getattr(n, "sym:overloaded"))
{
#ifdef DEBUG_OVERLOADED
show_overloaded(n);
#endif
int cnt = 0;
#ifdef DEBUG_OVERLOADED
Node *debugnode = n;
show_overloaded(n);
#endif
if (!firstChild(n)) {
// Remove from overloaded list ('using' node does not actually end up adding in any methods)
Node *ps = Getattr(n, "sym:previousSibling");
@ -1113,14 +1113,16 @@ show_overloaded(n);
Setattr(ns, "sym:previousSibling", pp);
Setattr(pp, "sym:nextSibling", ns);
}
#ifdef DEBUG_OVERLOADED
debugnode = firstoverloaded;
#endif
}
Delattr(n, "sym:previousSibling");
Delattr(n, "sym:nextSibling");
Delattr(n, "sym:overloaded");
Delattr(n, "sym:overname");
#ifdef DEBUG_OVERLOADED
show_overloaded(debugnode);
show_overloaded(debugnode);
#endif
clean_overloaded(n); // Needed?
}

View file

@ -17,6 +17,17 @@ char cvsroot_uffi_cxx[] = "$Id$";
#include "swigmod.h"
static const char *usage = (char *) "\
UFFI Options (available with -uffi)\n\
-identifier-converter <type or funcname> - \n\
Specifies the type of conversion to do on C identifiers\n\
to convert them to symbols. There are two built-in\n\
converters: 'null' and 'lispify'. The default is\n\
'null'. If you supply a name other than one of the\n\
built-ins, then a function by that name will be\n\
called to convert identifiers to symbols.\n\
";
class UFFI:public Language {
public:
@ -222,14 +233,7 @@ void UFFI::main(int argc, char *argv[]) {
}
if (!strcmp(argv[i], "-help")) {
fprintf(stdout, "UFFI Options (available with -uffi)\n");
fprintf(stdout,
" -identifier-converter <type or funcname>\n"
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
"\tthem to symbols. There are two built-in converters: 'null' and\n"
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
"\tthan one of the built-ins, then a function by that name will be\n"
"\tcalled to convert identifiers to symbols.\n");
Printf(stdout, "%s\n", usage);
}
}
}
@ -274,7 +278,8 @@ int UFFI::functionWrapper(Node *n) {
String *funcname = Getattr(n, "sym:name");
ParmList *pl = Getattr(n, "parms");
Parm *p;
int argnum = 0, first = 1, varargs = 0;
int argnum = 0, first = 1;
// int varargs = 0;
//Language::functionWrapper(n);
@ -287,7 +292,7 @@ int UFFI::functionWrapper(Node *n) {
Printf(f_cl, ":void");
} else if (any_varargs(pl)) {
Printf(f_cl, "#| varargs |#");
varargs = 1;
// varargs = 1;
} else {
for (p = pl; p; p = nextSibling(p), argnum++) {
String *argname = Getattr(p, "name");