Lot's of minor bug fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@718 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
597c3f8ebe
commit
e8fe852d9f
7 changed files with 94 additions and 14 deletions
|
|
@ -12,6 +12,9 @@
|
|||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* DB: I had to take some features related to package naming out of this to
|
||||
get the new type system to work. These need to be put back in at some point. */
|
||||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
#include "mod11.h"
|
||||
|
|
@ -20,6 +23,7 @@ static char cvsroot[] = "$Header$";
|
|||
static char *usage = (char*)"\
|
||||
Perl5 Options (available with -perl5)\n\
|
||||
-module name - Set module name\n\
|
||||
-interface name - Set interface name\n\
|
||||
-package name - Set package prefix\n\
|
||||
-static - Omit code related to dynamic loading.\n\
|
||||
-shadow - Create shadow classes.\n\
|
||||
|
|
@ -32,6 +36,7 @@ static int compat = 0;
|
|||
static int export_all = 0;
|
||||
static String *package = 0;
|
||||
static String *module = 0;
|
||||
static String *interface = 0;
|
||||
static String *cmodule = 0;
|
||||
static String *vinit = 0;
|
||||
static FILE *f_pm = 0;
|
||||
|
|
@ -95,6 +100,15 @@ PERL5::parse_args(int argc, char *argv[]) {
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if(strcmp(argv[i],"-interface") == 0) {
|
||||
if (argv[i+1]) {
|
||||
interface = NewString(argv[i+1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i+1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i],"-module") == 0) {
|
||||
if (argv[i+1]) {
|
||||
module = NewString(argv[i+1]);
|
||||
|
|
@ -212,7 +226,7 @@ PERL5::initialize()
|
|||
|
||||
if (blessed) {
|
||||
realpackage = package;
|
||||
package = NewStringf("%sc",package);
|
||||
package = interface ? interface : NewStringf("%sc",package);
|
||||
} else {
|
||||
realpackage = NewString(package);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ static char cvsroot[] = "$Header$";
|
|||
static String *const_code = 0;
|
||||
static String *shadow_methods = 0;
|
||||
static String *module = 0;
|
||||
static String *interface = 0;
|
||||
static String *global_name = 0;
|
||||
static int shadow = 0;
|
||||
static int have_defarg = 0;
|
||||
|
|
@ -38,6 +39,7 @@ static char *usage = (char *)"\
|
|||
Python Options (available with -python)\n\
|
||||
-globals name - Set name used to access C global variable ('cvar' by default).\n\
|
||||
-module name - Set module name\n\
|
||||
-interface name - Set the lib name\n\
|
||||
-keyword - Use keyword arguments\n\
|
||||
-noopt - No optimized shadows (pre 1.5.2)\n\
|
||||
-opt - Optimized shadow classes (1.5.2 or later)\n\
|
||||
|
|
@ -71,6 +73,18 @@ PYTHON::parse_args(int argc, char *argv[]) {
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
|
||||
/* Added edz@bsn.com */
|
||||
} else if(strcmp(argv[i],"-interface") == 0) {
|
||||
if (argv[i+1]) {
|
||||
interface = NewString(argv[i+1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i+1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
/* end added */
|
||||
} else if (strcmp(argv[i],"-globals") == 0) {
|
||||
if (argv[i+1]) {
|
||||
global_name = NewString(argv[i+1]);
|
||||
|
|
@ -190,14 +204,22 @@ PYTHON::initialize(void) {
|
|||
}
|
||||
/* If shadow classing is enabled, we're going to change the module name to "modulec" */
|
||||
if (shadow) {
|
||||
|
||||
sprintf(filen,"%s%s.py", output_dir, Char(module));
|
||||
// If we don't have an interface then change the module name X to Xc
|
||||
if (! interface)
|
||||
Append(module,"c");
|
||||
if ((f_shadow = fopen(filen,"w")) == 0) {
|
||||
Printf(stderr,"Unable to open %s\n", filen);
|
||||
SWIG_exit(0);
|
||||
}
|
||||
Printf(f_shadow,"# This file was created automatically by SWIG.\n");
|
||||
Printf(f_shadow,"import %s\n", module);
|
||||
Printf(f_shadow,"import %s\n", interface ? interface : module);
|
||||
|
||||
// Include some information in the code
|
||||
Printf(f_header,"\n/*-----------------------------------------------\n @(target):= %s.so\n\
|
||||
------------------------------------------------*/\n", interface ? interface : module);
|
||||
|
||||
if (!noopt)
|
||||
Printf(f_shadow,"import new\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ TCL8::parse() {
|
|||
if (NoInclude) {
|
||||
Printf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
||||
}
|
||||
if (Swig_insert_file("common.swg",f_runtime) == -1) {
|
||||
/* if (Swig_insert_file("common.swg",f_runtime) == -1) {
|
||||
Printf(stderr,"SWIG : Fatal error. Unable to locate 'common.swg' in SWIG library.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
|
|
@ -124,6 +124,7 @@ TCL8::parse() {
|
|||
Printf(stderr,"SWIG : Fatal error. Unable to locate 'swigtcl8.swg' in SWIG library.\n");
|
||||
SWIG_exit(1);
|
||||
}
|
||||
*/
|
||||
yyparse();
|
||||
}
|
||||
|
||||
|
|
@ -543,12 +544,14 @@ TCL8::link_variable(char *name, char *iname, SwigType *t) {
|
|||
Printv(set->def, "static char *_swig_", SwigType_manglestr(t), "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
|
||||
Printv(get->def, "static char *_swig_", SwigType_manglestr(t), "_get(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
SwigType_add_pointer(t);
|
||||
Wrapper_add_localv(get,"addr",SwigType_lstr(t,0),"addr",0);
|
||||
Wrapper_add_localv(set,"addr",SwigType_lstr(t,0),"addr",0);
|
||||
Printv(set->code, "addr = (", SwigType_lstr(t,0), ") clientData;\n", 0);
|
||||
Printv(get->code, "addr = (", SwigType_lstr(t,0), ") clientData;\n", 0);
|
||||
SwigType_del_pointer(t);
|
||||
SwigType *lt = Swig_clocal_type(t);
|
||||
SwigType_add_pointer(lt);
|
||||
Wrapper_add_localv(get,"addr",SwigType_lstr(lt,"addr"),0);
|
||||
Wrapper_add_localv(set,"addr",SwigType_lstr(lt,"addr"),0);
|
||||
Printv(set->code, "addr = (", SwigType_lstr(lt,0), ") clientData;\n", 0);
|
||||
Printv(get->code, "addr = (", SwigType_lstr(lt,0), ") clientData;\n", 0);
|
||||
SwigType_del_pointer(lt);
|
||||
Delete(lt);
|
||||
Wrapper_add_local(set, "value", "char *value");
|
||||
Wrapper_add_local(get, "value", "Tcl_Obj *value");
|
||||
|
||||
|
|
|
|||
|
|
@ -402,6 +402,10 @@ public:
|
|||
|
||||
t = Copy(type);
|
||||
update_local_type(t);
|
||||
/* Check to see if it's read-only */
|
||||
if (SwigType_isarray(t) || SwigType_isconst(t))
|
||||
Status = Status | STAT_READONLY;
|
||||
|
||||
if (!is_static) {
|
||||
lang->cpp_variable(name,iname,t);
|
||||
} else {
|
||||
|
|
@ -1923,6 +1927,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
if (!classrename) classrename = classname;
|
||||
strcpy(iname, Char(Swig_name_set(Swig_name_member(classrename, mrename))));
|
||||
|
||||
|
||||
// Now check to see if we have already wrapped a variable like this.
|
||||
|
||||
strcpy(key,cname);
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ static int freeze = 0;
|
|||
static String *lang_config = 0;
|
||||
|
||||
/* This function sets the name of the configuration file */
|
||||
|
||||
void SWIG_config_file(const String_or_char *filename) {
|
||||
lang_config = NewString(filename);
|
||||
}
|
||||
|
|
@ -229,6 +230,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-c") == 0) {
|
||||
NoInclude=1;
|
||||
Preprocessor_define((DOH *) "SWIG_NOINCLUDE 1", 0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-make_default") == 0) {
|
||||
GenerateDefault = 1;
|
||||
|
|
|
|||
|
|
@ -475,9 +475,9 @@ static void dump_nested(char *parent) {
|
|||
};
|
||||
|
||||
%token <id> ID
|
||||
%token <id> HBLOCK WRAPPER POUND RUNTIME
|
||||
%token <id> HBLOCK WRAPPER POUND RUNTIME HEADER
|
||||
%token <id> STRING
|
||||
%token <loc> INCLUDE IMPORT WEXTERN SWIGMACRO
|
||||
%token <loc> INCLUDE IMPORT WEXTERN SWIGMACRO INSERT
|
||||
%token <id> NUM_INT NUM_FLOAT CHARCONST NUM_UNSIGNED NUM_LONG NUM_ULONG
|
||||
%token <ivalue> TYPEDEF
|
||||
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_TYPEDEF TYPE_RAW
|
||||
|
|
@ -841,13 +841,19 @@ statement : INCLUDE STRING LBRACE {
|
|||
|
||||
| HBLOCK {
|
||||
if (!WrapExtern) {
|
||||
init_language();
|
||||
$1[strlen($1) - 1] = 0;
|
||||
// Printf(f_header,"#line %d \"%s\"\n", start_line, input_file);
|
||||
Printf(f_header, "%s\n", $1);
|
||||
}
|
||||
}
|
||||
|
||||
| HEADER HBLOCK {
|
||||
if (!WrapExtern) {
|
||||
$2[strlen($1) - 2] = 0;
|
||||
Printf(f_header, "%s\n", $2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Super-secret undocumented for people who really know what's going on feature */
|
||||
|
||||
| WRAPPER HBLOCK {
|
||||
|
|
@ -875,6 +881,28 @@ statement : INCLUDE STRING LBRACE {
|
|||
}
|
||||
}
|
||||
|
||||
| INSERT LPAREN ID RPAREN STRING {
|
||||
if (!WrapExtern) {
|
||||
File *f = 0;
|
||||
if (strcmp($3,"headers") == 0) {
|
||||
f = f_header;
|
||||
} else if (strcmp($3,"runtime") == 0) {
|
||||
f = f_runtime;
|
||||
} else if (strcmp($3,"wrappers") == 0) {
|
||||
f = f_wrappers;
|
||||
} else if (strcmp($3,"init") == 0) {
|
||||
f = f_init;
|
||||
}
|
||||
if (!f) {
|
||||
Printf(stderr,"%s:%d: Unknown target '%s' for %%insert directive.\n", input_file, line_number, $3);
|
||||
} else {
|
||||
if (Swig_insert_file($5,f) < 0) {
|
||||
Printf(stderr,"%s:%d: Couldn't find '%s'. Possible installation problem.\n", input_file, line_number, $5);
|
||||
SWIG_exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Inline block */
|
||||
| INLINE HBLOCK {
|
||||
if (!WrapExtern) {
|
||||
|
|
@ -2383,7 +2411,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
if (Active_type) Delete(Active_type);
|
||||
Active_type = Copy($1);
|
||||
add_pointers($1, $2.is_pointer + 1);
|
||||
add_pointers($1, $2.is_pointer);
|
||||
if ($2.is_reference) SwigType_add_reference($1);
|
||||
SwigType_push($1,ArrayString);
|
||||
iname = make_name($2.id);
|
||||
|
|
@ -3310,3 +3338,7 @@ void yyerror (char *) {
|
|||
// error_recover();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1007,9 +1007,9 @@ extern "C" int yylex(void) {
|
|||
|
||||
// Misc keywords
|
||||
|
||||
if (strcmp(yytext,"static") == 0) return(STATIC);
|
||||
if (strcmp(yytext,"extern") == 0) return(EXTERN);
|
||||
if (strcmp(yytext,"const") == 0) return(CONST);
|
||||
if (strcmp(yytext,"static") == 0) return(STATIC);
|
||||
if (strcmp(yytext,"struct") == 0) return(STRUCT);
|
||||
if (strcmp(yytext,"union") == 0) return(UNION);
|
||||
if (strcmp(yytext,"enum") == 0) return(ENUM);
|
||||
|
|
@ -1031,6 +1031,8 @@ extern "C" int yylex(void) {
|
|||
if (strcmp(yytext,"%init") == 0) return(INIT);
|
||||
if (strcmp(yytext,"%wrapper") == 0) return(WRAPPER);
|
||||
if (strcmp(yytext,"%runtime") == 0) return(RUNTIME);
|
||||
if (strcmp(yytext,"%header") == 0) return(HEADER);
|
||||
if (strcmp(yytext,"%insert") == 0) return(INSERT);
|
||||
if (strcmp(yytext,"%readonly") == 0) return(READONLY);
|
||||
if (strcmp(yytext,"%readwrite") == 0) return(READWRITE);
|
||||
if (strcmp(yytext,"%name") == 0) return(NAME);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue