Completely new type implementation. Almost everything broken. Typemaps sort of work. Tcl is the only working language module. More changes to follow over the next few days.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@651 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
84f5185008
commit
fa2942e77c
31 changed files with 2167 additions and 2097 deletions
|
|
@ -13,8 +13,8 @@ AR = @AR@
|
|||
RANLIB = @RANLIB@
|
||||
|
||||
TARGET = libmodules11.a
|
||||
OBJS = swigmain.o tcl8.o perl5.o python.o guile.o java.o mzscheme.o ruby.o
|
||||
SRCS = swigmain.cxx tcl8.cxx perl5.cxx python.cxx guile.cxx java.cxx mzscheme.cxx ruby.cxx
|
||||
OBJS = swigmain.o tcl8.o #perl5.o python.o guile.o java.o mzscheme.o ruby.o
|
||||
SRCS = swigmain.cxx tcl8.cxx #perl5.cxx python.cxx guile.cxx java.cxx mzscheme.cxx ruby.cxx
|
||||
INCLUDE = -I$(srcdir)/../Include \
|
||||
-I$(srcdir)/../SWIG1.1 \
|
||||
-I$(srcdir)/../DOH/Include \
|
||||
|
|
|
|||
|
|
@ -34,22 +34,22 @@ private:
|
|||
GUILE_LSTYLE_LTDLMOD, // "native" guile?
|
||||
GUILE_LSTYLE_HOBBIT // use (hobbit4d link)
|
||||
} linkage;
|
||||
void get_pointer(char *iname, int parm, DataType *t,
|
||||
void get_pointer(char *iname, int parm, SwigType *t,
|
||||
Wrapper *f, DOHString_or_char *proc_name,
|
||||
int num_scheme_parm);
|
||||
void usage_var(char *, DataType *, DOHString *usage);
|
||||
void usage_func(char *, DataType *, ParmList *, DOHString *usage);
|
||||
void usage_returns(char *, DataType *, ParmList *, DOHString *usage);
|
||||
void usage_const(char *, DataType *, char *, DOHString *usage);
|
||||
void usage_var(char *, SwigType *, DOHString *usage);
|
||||
void usage_func(char *, SwigType *, ParmList *, DOHString *usage);
|
||||
void usage_returns(char *, SwigType *, ParmList *, DOHString *usage);
|
||||
void usage_const(char *, SwigType *, char *, DOHString *usage);
|
||||
void emit_linkage(char *module_name);
|
||||
|
||||
public :
|
||||
GUILE ();
|
||||
void parse_args (int, char *argv[]);
|
||||
void parse ();
|
||||
void create_function (char *, char *, DataType *, ParmList *);
|
||||
void link_variable (char *, char *, DataType *);
|
||||
void declare_const (char *, char *, DataType *, char *);
|
||||
void create_function (char *, char *, SwigType *, ParmList *);
|
||||
void link_variable (char *, char *, SwigType *);
|
||||
void declare_const (char *, char *, SwigType *, char *);
|
||||
void initialize ();
|
||||
void headers (void);
|
||||
void close (void);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ public :
|
|||
|
||||
void parse_args(int, char *argv[]);
|
||||
void parse();
|
||||
void add_native(char *, char *, DataType *, ParmList *);
|
||||
void create_function(char *, char *, DataType *, ParmList *);
|
||||
void link_variable(char *, char *, DataType *);
|
||||
void declare_const(char *, char *, DataType *, char *);
|
||||
void add_native(char *, char *, SwigType *, ParmList *);
|
||||
void create_function(char *, char *, SwigType *, ParmList *);
|
||||
void link_variable(char *, char *, SwigType *);
|
||||
void declare_const(char *, char *, SwigType *, char *);
|
||||
void initialize(void);
|
||||
void headers(void);
|
||||
void close(void);
|
||||
|
|
@ -22,28 +22,28 @@ public :
|
|||
void create_command(char *, char *);
|
||||
|
||||
void pragma(char *lang, char *code, char *value);
|
||||
void add_typedef(DataType *t, char *name);
|
||||
void add_typedef(SwigType *t, char *name);
|
||||
void cpp_open_class(char *classname, char *rename, char *ctype, int strip);
|
||||
void cpp_close_class();
|
||||
void cpp_member_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
void cpp_static_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
void cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
void cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
void cpp_constructor(char *name, char *iname, ParmList *l);
|
||||
void cpp_destructor(char *name, char *newname);
|
||||
void cpp_class_decl(char *name, char *rename, char *type);
|
||||
void cpp_inherit(char **baseclass, int);
|
||||
void cpp_variable(char *name, char *iname, DataType *t);
|
||||
void cpp_static_var(char *, char *, class DataType *);
|
||||
void cpp_declare_const(char *name, char *iname, DataType *type, char *value);
|
||||
void cpp_variable(char *name, char *iname, SwigType *t);
|
||||
void cpp_static_var(char *, char *, SwigType *);
|
||||
void cpp_declare_const(char *name, char *iname, SwigType *type, char *value);
|
||||
|
||||
/* Java Module methods */
|
||||
void emit_classdef();
|
||||
void emit_shadow_classdef();
|
||||
char *JNICALL(DOHString_or_char *func);
|
||||
char *SwigTcToJniType(DataType *t, int ret);
|
||||
char *SwigTcToJavaType(DataType *t, int ret, int inShadow);
|
||||
char *SwigTcToJniScalarType(DataType *t);
|
||||
char *JavaTypeFromTypemap(char *op, char *lang, DataType *t, char *pname);
|
||||
char *SwigTcToJniType(SwigType *t, int ret);
|
||||
char *SwigTcToJavaType(SwigType *t, int ret, int inShadow);
|
||||
char *SwigTcToJniScalarType(SwigType *t);
|
||||
char *JavaTypeFromTypemap(char *op, char *lang, SwigType *t, char *pname);
|
||||
char *makeValidJniName(char *name);
|
||||
char *JavaMethodSignature(DataType *t, int ret, int inShadow);
|
||||
char *JavaMethodSignature(SwigType *t, int ret, int inShadow);
|
||||
void writeRegisterNatives();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,18 +26,18 @@
|
|||
class MZSCHEME : public Language
|
||||
{
|
||||
private:
|
||||
void get_pointer(DOHString_or_char *name, int parm, DataType *t, Wrapper *f);
|
||||
void usage_var(char *, DataType *, DOHString *usage);
|
||||
void usage_func(char *, DataType *, ParmList *, DOHString *usage);
|
||||
void usage_returns(char *, DataType *, ParmList *, DOHString *usage);
|
||||
void usage_const(char *, DataType *, char *, DOHString *usage);
|
||||
void get_pointer(DOHString_or_char *name, int parm, SwigType *t, Wrapper *f);
|
||||
void usage_var(char *, SwigType *, DOHString *usage);
|
||||
void usage_func(char *, SwigType *, ParmList *, DOHString *usage);
|
||||
void usage_returns(char *, SwigType *, ParmList *, DOHString *usage);
|
||||
void usage_const(char *, SwigType *, char *, DOHString *usage);
|
||||
|
||||
public :
|
||||
void parse_args (int, char *argv[]);
|
||||
void parse ();
|
||||
void create_function (char *, char *, DataType *, ParmList *);
|
||||
void link_variable (char *, char *, DataType *);
|
||||
void declare_const (char *, char *, DataType *, char *);
|
||||
void create_function (char *, char *, SwigType *, ParmList *);
|
||||
void link_variable (char *, char *, SwigType *);
|
||||
void declare_const (char *, char *, SwigType *, char *);
|
||||
void initialize ();
|
||||
void headers (void);
|
||||
void close (void);
|
||||
|
|
|
|||
|
|
@ -22,38 +22,38 @@
|
|||
class PERL5 : public Language {
|
||||
private:
|
||||
void get_pointer(char *iname, char *srcname, char *src, char *dest,
|
||||
DataType *t, DOHString *f, char *ret);
|
||||
char *usage_var(char *, DataType *);
|
||||
char *usage_func(char *, DataType *, ParmList *);
|
||||
char *usage_const(char *, DataType *, char *);
|
||||
SwigType *t, DOHString *f, char *ret);
|
||||
char *usage_var(char *, SwigType *);
|
||||
char *usage_func(char *, SwigType *, ParmList *);
|
||||
char *usage_const(char *, SwigType *, char *);
|
||||
|
||||
public :
|
||||
virtual void parse_args(int, char *argv[]);
|
||||
virtual void parse();
|
||||
virtual void create_function(char *, char *, DataType *, ParmList *);
|
||||
virtual void link_variable(char *, char *, DataType *);
|
||||
virtual void declare_const(char *, char *, DataType *, char *);
|
||||
virtual void create_function(char *, char *, SwigType *, ParmList *);
|
||||
virtual void link_variable(char *, char *, SwigType *);
|
||||
virtual void declare_const(char *, char *, SwigType *, char *);
|
||||
virtual void initialize(void);
|
||||
virtual void headers(void);
|
||||
virtual void close(void);
|
||||
virtual void set_module(char *, char **);
|
||||
virtual void set_init(char *);
|
||||
virtual void add_native(char *, char *, DataType *, ParmList *);
|
||||
virtual void add_native(char *, char *, SwigType *, ParmList *);
|
||||
virtual void create_command(char *, char *);
|
||||
|
||||
// Support for blessed perl thingies....
|
||||
|
||||
virtual void cpp_open_class(char *classname, char *rename, char *ctype, int strip);
|
||||
virtual void cpp_close_class();
|
||||
virtual void cpp_member_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void cpp_static_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void cpp_variable(char *name, char *iname, DataType *t);
|
||||
virtual void cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void cpp_variable(char *name, char *iname, SwigType *t);
|
||||
virtual void cpp_constructor(char *name, char *iname, ParmList *l);
|
||||
virtual void cpp_destructor(char *name, char *newname);
|
||||
virtual void cpp_inherit(char **baseclass, int mode = INHERIT_ALL);
|
||||
virtual void cpp_declare_const(char *name, char *iname, DataType *type, char *value);
|
||||
virtual void cpp_declare_const(char *name, char *iname, SwigType *type, char *value);
|
||||
virtual void cpp_class_decl(char *, char *, char *);
|
||||
virtual void add_typedef(DataType *t, char *name);
|
||||
virtual void add_typedef(SwigType *t, char *name);
|
||||
virtual void pragma(char *, char *, char *);
|
||||
virtual void import(char *filename);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@
|
|||
|
||||
class PYTHON : public Language {
|
||||
protected:
|
||||
void get_pointer(char *iname, char *srcname, char *src, char *dest, DataType *t, DOHString *f, char *ret);
|
||||
void get_pointer(char *iname, char *srcname, char *src, char *dest, SwigType *t, DOHString *f, char *ret);
|
||||
|
||||
void add_method(char *name, char *function, int kw);
|
||||
void print_methods();
|
||||
char *usage_var(char *, DataType *);
|
||||
char *usage_func(char *, DataType *, ParmList *);
|
||||
char *usage_const(char *, DataType *, char *);
|
||||
char *usage_var(char *, SwigType *);
|
||||
char *usage_func(char *, SwigType *, ParmList *);
|
||||
char *usage_const(char *, SwigType *, char *);
|
||||
|
||||
virtual void initialize_cmodule();
|
||||
virtual void close_cmodule();
|
||||
|
|
@ -43,33 +43,33 @@ public :
|
|||
// Don't change any of this
|
||||
virtual void parse_args(int, char *argv[]);
|
||||
virtual void parse();
|
||||
virtual void create_function(char *, char *, DataType *, ParmList *);
|
||||
virtual void link_variable(char *, char *, DataType *);
|
||||
virtual void declare_const(char *, char *, DataType *, char *);
|
||||
virtual void create_function(char *, char *, SwigType *, ParmList *);
|
||||
virtual void link_variable(char *, char *, SwigType *);
|
||||
virtual void declare_const(char *, char *, SwigType *, char *);
|
||||
virtual void initialize(void);
|
||||
virtual void headers(void);
|
||||
virtual void close(void);
|
||||
virtual void set_module(char *, char **);
|
||||
virtual void set_init(char *);
|
||||
virtual void add_native(char *, char *, DataType *, ParmList *);
|
||||
virtual void add_native(char *, char *, SwigType *, ParmList *);
|
||||
virtual void create_command(char *, char *);
|
||||
virtual void import(char *);
|
||||
|
||||
// C++ extensions---for creating shadow classes
|
||||
|
||||
virtual void cpp_member_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void cpp_constructor(char *name, char *iname, ParmList *l);
|
||||
virtual void cpp_destructor(char *name, char *newname);
|
||||
virtual void cpp_open_class(char *classname, char *rname, char *ctype, int strip);
|
||||
virtual void cpp_close_class();
|
||||
virtual void cpp_cleanup();
|
||||
virtual void cpp_inherit(char **baseclass, int mode = INHERIT_ALL);
|
||||
virtual void cpp_variable(char *name, char *iname, DataType *t);
|
||||
virtual void cpp_declare_const(char *name, char *iname, DataType *type, char *value);
|
||||
virtual void cpp_variable(char *name, char *iname, SwigType *t);
|
||||
virtual void cpp_declare_const(char *name, char *iname, SwigType *type, char *value);
|
||||
virtual void cpp_class_decl(char *, char *,char *);
|
||||
virtual void pragma(char *, char *, char *);
|
||||
virtual void cpp_pragma(Pragma *);
|
||||
virtual void add_typedef(DataType *t, char *name);
|
||||
virtual void add_typedef(SwigType *t, char *name);
|
||||
};
|
||||
|
||||
#define PYSHADOW_MEMBER 0x2
|
||||
|
|
|
|||
|
|
@ -82,17 +82,17 @@ class RUBY : public Language {
|
|||
private:
|
||||
virtual char *make_wrapper_name(char *cname);
|
||||
virtual char *validate_const_name(char *name);
|
||||
virtual char *ruby_typemap_lookup(char *, DataType *, char *, char *, char *, Wrapper * = 0);
|
||||
virtual int to_VALUE(DataType *, char *, DOHString *, int = 0);
|
||||
virtual int from_VALUE(DataType *, char *, DOHString *);
|
||||
virtual char *ruby_typemap_lookup(char *, SwigType *, char *, char *, char *, Wrapper * = 0);
|
||||
virtual int to_VALUE(SwigType *, char *, DOHString *, int = 0);
|
||||
virtual int from_VALUE(SwigType *, char *, DOHString *);
|
||||
public:
|
||||
RUBY();
|
||||
// Virtual functions required by the SWIG parser
|
||||
virtual void parse_args(int, char *argv[]);
|
||||
virtual void parse();
|
||||
virtual void create_function(char *, char *, DataType *, ParmList *);
|
||||
virtual void link_variable(char *, char *, DataType *);
|
||||
virtual void declare_const(char *, char *, DataType *, char *);
|
||||
virtual void create_function(char *, char *, SwigType *, ParmList *);
|
||||
virtual void link_variable(char *, char *, SwigType *);
|
||||
virtual void declare_const(char *, char *, SwigType *, char *);
|
||||
virtual void initialize(void);
|
||||
virtual void headers(void);
|
||||
virtual void close(void);
|
||||
|
|
@ -100,16 +100,16 @@ class RUBY : public Language {
|
|||
virtual void create_command(char *, char *, int);
|
||||
|
||||
// C++ language extensions.
|
||||
virtual void cpp_member_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void cpp_constructor(char *name, char *iname, ParmList *l);
|
||||
virtual void cpp_destructor(char *name, char *newname);
|
||||
virtual void cpp_open_class(char *classname, char *rname, char *ctype, int strip);
|
||||
virtual void cpp_close_class();
|
||||
virtual void cpp_inherit(char **baseclass, int mode = INHERIT_ALL);
|
||||
virtual void cpp_variable(char *name, char *iname, DataType *t);
|
||||
virtual void cpp_static_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void cpp_declare_const(char *name, char *iname, DataType *type, char *value);
|
||||
virtual void cpp_static_var(char *name, char *iname, DataType *t);
|
||||
virtual void cpp_variable(char *name, char *iname, SwigType *t);
|
||||
virtual void cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void cpp_declare_const(char *name, char *iname, SwigType *type, char *value);
|
||||
virtual void cpp_static_var(char *name, char *iname, SwigType *t);
|
||||
|
||||
// Declaration of a class, but not a full definition
|
||||
virtual void cpp_class_decl(char *, char *, char *);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ static char cvsroot[] = "$Header$";
|
|||
#include "swigconfig.h"
|
||||
#include "mod11.h"
|
||||
#include "tcl8.h"
|
||||
|
||||
#ifdef OLD
|
||||
#include "perl5.h"
|
||||
#include "java.h"
|
||||
#include "python.h"
|
||||
|
|
@ -34,6 +36,8 @@ static char cvsroot[] = "$Header$";
|
|||
#include "mzscheme.h"
|
||||
#include "ruby.h"
|
||||
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef SWIG_LANG
|
||||
|
|
@ -74,6 +78,7 @@ int main(int argc, char **argv) {
|
|||
} else if (strcmp(argv[i],"-tcl8") == 0) {
|
||||
dl = new TCL8;
|
||||
Swig_mark_arg(i);
|
||||
#ifdef OLD
|
||||
} else if (strcmp(argv[i],"-perl5") == 0) {
|
||||
dl = new PERL5;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -92,6 +97,7 @@ int main(int argc, char **argv) {
|
|||
} else if (strcmp(argv[i],"-ruby") == 0) {
|
||||
dl = new RUBY;
|
||||
Swig_mark_arg(i);
|
||||
#endif
|
||||
} else if (strcmp(argv[i],"-help") == 0) {
|
||||
fputs(usage,stderr);
|
||||
Swig_mark_arg(i);
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ Tcl 8.0 Options (available with -tcl)\n\
|
|||
|
||||
static char *ns_name = 0;
|
||||
|
||||
static DOHString *mod_init = 0;
|
||||
static DOHString *mod_extern = 0;
|
||||
static DOHString *cmd_info = 0;
|
||||
static DOHString *var_info = 0;
|
||||
static DOHString *methods = 0;
|
||||
static DOHString *attributes = 0;
|
||||
static String *mod_init = 0;
|
||||
static String *mod_extern = 0;
|
||||
static String *cmd_info = 0;
|
||||
static String *var_info = 0;
|
||||
static String *methods = 0;
|
||||
static String *attributes = 0;
|
||||
|
||||
/* Various parameters */
|
||||
|
||||
|
|
@ -62,9 +62,9 @@ static char *class_name = 0;
|
|||
static char *class_type = 0;
|
||||
static char *real_classname = 0;
|
||||
static char *base_class = 0;
|
||||
static DOHHash *hash = 0;
|
||||
static DOHHash *repeatcmd = 0;
|
||||
static DOHHash *setget = 0;
|
||||
static Hash *hash = 0;
|
||||
static Hash *repeatcmd = 0;
|
||||
static Hash *setget = 0;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// TCL8::parse_args(int argc, char *argv[])
|
||||
|
|
@ -398,7 +398,9 @@ void TCL8::close(void)
|
|||
|
||||
// Dump the pointer equivalency table
|
||||
|
||||
emit_type_table(f_runtime);
|
||||
// emit_type_table(f_runtime);
|
||||
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
|
||||
// emit_ptr_equivalence(f_init);
|
||||
|
||||
|
|
@ -411,28 +413,28 @@ void TCL8::close(void)
|
|||
|
||||
// ----------------------------------------------------------------------
|
||||
// TCL8::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
||||
// DataType *t, String &f, char *ret)
|
||||
// SwigType *t, String &f, char *ret)
|
||||
//
|
||||
// iname = name of function or variable
|
||||
// srcname = name of source
|
||||
// src = source variable in wrapper code
|
||||
// dest = destination variable in wrapper code
|
||||
// t = Datatype
|
||||
// t = SwigType
|
||||
// f = String where output is going to go
|
||||
// ret = Return action
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TCL8::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
||||
DataType *t, DOHString *f, char *ret) {
|
||||
SwigType *t, String *f, char *ret) {
|
||||
|
||||
// Pointers are read as hex-strings with encoded type information
|
||||
|
||||
DataType_remember(t);
|
||||
SwigType_remember(t);
|
||||
Printv(f, tab4, "if ((SWIG_ConvertPtr(interp,", src, ",(void **) &", dest, ",",0);
|
||||
|
||||
if (DataType_type(t) == T_VOID) Printf(f, "0)) == TCL_ERROR) { return TCL_ERROR; }\n");
|
||||
if (SwigType_type(t) == T_VOID) Printf(f, "0)) == TCL_ERROR) { return TCL_ERROR; }\n");
|
||||
else
|
||||
Printv(f, "SWIGTYPE", DataType_manglestr(t), ")) == TCL_ERROR) { return TCL_ERROR; }\n", 0);
|
||||
Printv(f, "SWIGTYPE", SwigType_manglestr(t), ")) == TCL_ERROR) { return TCL_ERROR; }\n", 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -443,33 +445,33 @@ void TCL8::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
|||
|
||||
void TCL8::create_command(char *cname, char *iname) {
|
||||
|
||||
char *wname = Swig_name_wrapper(cname);
|
||||
String *wname = Swig_name_wrapper(cname);
|
||||
|
||||
Printv(cmd_info, tab4, "{ SWIG_prefix \"", iname, "\", ", wname, ", NULL},\n", 0);
|
||||
|
||||
// Add interpreter name to repeatcmd hash table. This hash is used in C++ code
|
||||
// generation to try and find repeated wrapper functions.
|
||||
|
||||
Setattr(repeatcmd,iname,wname);
|
||||
Setattr(repeatcmd,iname,Char(wname));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||
// TCL8::create_function(char *name, char *iname, SwigType *d, ParmList *l)
|
||||
//
|
||||
// Create a function declaration and register it with the interpreter.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||
void TCL8::create_function(char *name, char *iname, SwigType *d, ParmList *l)
|
||||
{
|
||||
Parm *p;
|
||||
int pcount,i,j;
|
||||
char *wname;
|
||||
char wname[256];
|
||||
char *usage = 0, *tm;
|
||||
char source[64];
|
||||
char target[64];
|
||||
char argnum[32];
|
||||
Wrapper *f;
|
||||
DOHString *incode, *cleanup, *outarg, *argstr, *args;
|
||||
String *incode, *cleanup, *outarg, *argstr, *args;
|
||||
int numopt= 0;
|
||||
|
||||
f = NewWrapper();
|
||||
|
|
@ -481,7 +483,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Make a wrapper name for this function
|
||||
|
||||
wname = Swig_name_wrapper(iname);
|
||||
strcpy(wname, Char(Swig_name_wrapper(iname)));
|
||||
|
||||
// Now write the wrapper function itself....this is pretty ugly
|
||||
|
||||
|
|
@ -507,12 +509,11 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
j = 0;
|
||||
p = l;
|
||||
while (p != 0) {
|
||||
DataType *pt = Gettype(p);
|
||||
char *pn = Getname(p);
|
||||
|
||||
SwigType *pt = Gettype(p);
|
||||
String *pn = Getname(p);
|
||||
// Produce string representations of the source and target arguments
|
||||
sprintf(source,"objv[%d]",j+1);
|
||||
sprintf(target,"%s", Getlname(p));
|
||||
sprintf(target,"%s", Char(Getlname(p)));
|
||||
sprintf(argnum,"%d",j+1);
|
||||
|
||||
// See if this argument is being ignored
|
||||
|
|
@ -532,7 +533,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
} else {
|
||||
// Extract a parameter by value.
|
||||
|
||||
switch(DataType_type(pt)) {
|
||||
switch(SwigType_type(pt)) {
|
||||
// Signed Integers
|
||||
case T_INT:
|
||||
case T_UINT:
|
||||
|
|
@ -590,11 +591,11 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// User defined. This is an error.
|
||||
|
||||
case T_USER:
|
||||
DataType_add_pointer(pt);
|
||||
DataType_remember(pt);
|
||||
SwigType_add_pointer(pt);
|
||||
SwigType_remember(pt);
|
||||
Putc('p',argstr);
|
||||
Printv(args, ",&", target, ", SWIGTYPE", DataType_manglestr(pt), 0);
|
||||
DataType_del_pointer(pt);
|
||||
Printv(args, ",&", target, ", SWIGTYPE", SwigType_manglestr(pt), 0);
|
||||
SwigType_del_pointer(pt);
|
||||
break;
|
||||
|
||||
case T_STRING:
|
||||
|
|
@ -603,16 +604,16 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
break;
|
||||
|
||||
case T_POINTER: case T_ARRAY: case T_REFERENCE:
|
||||
DataType_remember(pt);
|
||||
SwigType_remember(pt);
|
||||
Putc('p',argstr);
|
||||
Printv(args, ",&", target, ", SWIGTYPE", DataType_manglestr(pt), 0);
|
||||
Printv(args, ",&", target, ", SWIGTYPE", SwigType_manglestr(pt), 0);
|
||||
break;
|
||||
|
||||
// Unsupported data type
|
||||
|
||||
default :
|
||||
Printf(stderr,"%s : Line %d: Unable to use type %s as a function argument.\n",
|
||||
input_file, line_number, DataType_str(pt,0));
|
||||
input_file, line_number, SwigType_str(pt,0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -620,7 +621,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Check to see if there was any sort of a constaint typemap
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"tcl8",pt,pn,source,target))) {
|
||||
if ((tm = typemap_lookup((char*)"check",(char*)"tcl8",pt,pn,source,target,0))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(incode,"%s\n", tm);
|
||||
Replace(incode,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
|
|
@ -628,14 +629,14 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// Check if there was any cleanup code (save it for later)
|
||||
if ((tm = typemap_lookup((char*)"freearg",(char*)"tcl8",pt,pn,target,(char*)"tcl_result"))) {
|
||||
if ((tm = typemap_lookup((char*)"freearg",(char*)"tcl8",pt,pn,target,(char*)"tcl_result",0))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(cleanup,"%s\n", tm);
|
||||
Replace(cleanup,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
Replace(cleanup,"$arg",source,DOH_REPLACE_ANY);
|
||||
}
|
||||
// Look for output arguments
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"tcl8",pt,pn,target,(char*)"tcl_result"))) {
|
||||
if ((tm = typemap_lookup((char*)"argout",(char*)"tcl8",pt,pn,target,(char*)"tcl_result",0))) {
|
||||
Printf(outarg,"%s\n", tm);
|
||||
Replace(outarg,"$argnum",argnum, DOH_REPLACE_ANY);
|
||||
Replace(outarg,"$arg",source, DOH_REPLACE_ANY);
|
||||
|
|
@ -656,11 +657,11 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Return value if necessary
|
||||
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"tcl8",d,name,(char*)"result",(char*)"tcl_result"))) {
|
||||
if ((tm = typemap_lookup((char*)"out",(char*)"tcl8",d,name,(char*)"result",(char*)"tcl_result",0))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code,"%s\n", tm);
|
||||
} else {
|
||||
switch(DataType_type(d)) {
|
||||
switch(SwigType_type(d)) {
|
||||
case T_BOOL:
|
||||
case T_INT:
|
||||
case T_SHORT:
|
||||
|
|
@ -690,12 +691,12 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Okay. We're returning malloced memory at this point.
|
||||
// Probably dangerous, but who said safety was a good thing?
|
||||
|
||||
DataType_add_pointer(d);
|
||||
DataType_remember(d);
|
||||
SwigType_add_pointer(d);
|
||||
SwigType_remember(d);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) result,SWIGTYPE",
|
||||
DataType_manglestr(d), "));\n", 0);
|
||||
SwigType_manglestr(d), "));\n", 0);
|
||||
|
||||
DataType_del_pointer(d);
|
||||
SwigType_del_pointer(d);
|
||||
break;
|
||||
|
||||
case T_STRING:
|
||||
|
|
@ -703,9 +704,9 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(result,-1));\n",0);
|
||||
break;
|
||||
case T_POINTER: case T_REFERENCE: case T_ARRAY:
|
||||
DataType_remember(d);
|
||||
SwigType_remember(d);
|
||||
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) result,SWIGTYPE",
|
||||
DataType_manglestr(d), "));\n",
|
||||
SwigType_manglestr(d), "));\n",
|
||||
0);
|
||||
break;
|
||||
|
||||
|
|
@ -714,7 +715,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Unknown type
|
||||
default :
|
||||
Printf(stderr,"%s : Line %d: Unable to use return type %s in function %s.\n",
|
||||
input_file, line_number, DataType_str(d,0), name);
|
||||
input_file, line_number, SwigType_str(d,0), name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -728,12 +729,12 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (NewObject) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"tcl8",d,iname,(char*)"result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"newfree",(char*)"tcl8",d,iname,(char*)"result",(char*)"",0))) {
|
||||
Printf(f->code,"%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"tcl8",d,name,(char*)"result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"ret",(char*)"tcl8",d,name,(char*)"result",(char*)"",0))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f->code,"%s\n", tm);
|
||||
}
|
||||
|
|
@ -760,46 +761,46 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// TCL8::link_variable(char *name, char *iname, DataType *t, int ex)
|
||||
// TCL8::link_variable(char *name, char *iname, SwigType *t, int ex)
|
||||
//
|
||||
// Create a TCL link to a variable.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void TCL8::link_variable(char *name, char *iname, DataType *t)
|
||||
void TCL8::link_variable(char *name, char *iname, SwigType *t)
|
||||
{
|
||||
char *tm, *tm1;
|
||||
|
||||
// See if there were any typemaps
|
||||
|
||||
tm = typemap_lookup((char*)"varin",(char*)"tcl8",t,name,(char*)"",(char*)"");
|
||||
tm1 = typemap_lookup((char*)"varout",(char*)"tcl8",t,name,(char*)"",(char*)"");
|
||||
tm = typemap_lookup((char*)"varin",(char*)"tcl8",t,name,(char*)"",(char*)"",0);
|
||||
tm1 = typemap_lookup((char*)"varout",(char*)"tcl8",t,name,(char*)"",(char*)"",0);
|
||||
if (tm || tm1) {
|
||||
Printf(stderr,"%s : Line %d. Warning. varin/varout typemap methods not supported.",
|
||||
input_file, line_number);
|
||||
}
|
||||
|
||||
// Dump a collection of set/get functions suitable for variable tracing
|
||||
if (!Getattr(setget,DataType_str(t,0))) {
|
||||
Setattr(setget,DataType_str(t,0),"1");
|
||||
if (!Getattr(setget,SwigType_lstr(t,0))) {
|
||||
Setattr(setget,SwigType_lstr(t,0),"1");
|
||||
Wrapper *get, *set;
|
||||
get = NewWrapper();
|
||||
set = NewWrapper();
|
||||
Printv(set->def, "static char *_swig_", DataType_manglestr(t), "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
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_", DataType_manglestr(t), "_get(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
|
||||
DataType_add_pointer(t);
|
||||
Wrapper_add_localv(get,"addr",DataType_str(t,0),"addr",0);
|
||||
Wrapper_add_localv(set,"addr",DataType_str(t,0),"addr",0);
|
||||
Printv(set->code, tab4, "addr = (", DataType_lstr(t,0), ") clientData;\n", 0);
|
||||
Printv(get->code, tab4, "addr = (", DataType_lstr(t,0), ") clientData;\n", 0);
|
||||
DataType_del_pointer(t);
|
||||
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, tab4, "addr = (", SwigType_lstr(t,0), ") clientData;\n", 0);
|
||||
Printv(get->code, tab4, "addr = (", SwigType_lstr(t,0), ") clientData;\n", 0);
|
||||
SwigType_del_pointer(t);
|
||||
Wrapper_add_local(set, "value", "char *value");
|
||||
Wrapper_add_local(get, "value", "Tcl_Obj *value");
|
||||
|
||||
Printv(set->code, tab4, "value = Tcl_GetVar2(interp, name1, name2, flags);\n",
|
||||
tab4, "if (!value) return NULL;\n", 0);
|
||||
|
||||
switch(DataType_type(t)) {
|
||||
switch(SwigType_type(t)) {
|
||||
case T_INT:
|
||||
case T_SHORT:
|
||||
case T_USHORT:
|
||||
|
|
@ -807,33 +808,33 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
case T_UCHAR:
|
||||
case T_SCHAR:
|
||||
case T_BOOL:
|
||||
Printv(set->code, tab4, "*(addr) = (", DataType_str(t,0), ") atol(value);\n", 0);
|
||||
Printv(set->code, tab4, "*(addr) = (", SwigType_str(t,0), ") atol(value);\n", 0);
|
||||
break;
|
||||
case T_UINT:
|
||||
case T_ULONG:
|
||||
Printv(set->code, tab4, "*(addr) = (", DataType_str(t,0), ") strtoul(value,0,0);\n",0);
|
||||
Printv(set->code, tab4, "*(addr) = (", SwigType_str(t,0), ") strtoul(value,0,0);\n",0);
|
||||
break;
|
||||
case T_FLOAT:
|
||||
case T_DOUBLE:
|
||||
Printv(set->code, tab4, "*(addr) = (", DataType_str(t,0), ") atof(value);\n",0);
|
||||
Printv(set->code, tab4, "*(addr) = (", SwigType_str(t,0), ") atof(value);\n",0);
|
||||
break;
|
||||
case T_CHAR: /* Single character. */
|
||||
Printv(set->code, tab4, "*(addr) = *value;\n",0);
|
||||
break;
|
||||
case T_USER:
|
||||
// User defined type. We return it as a pointer
|
||||
DataType_add_pointer(t);
|
||||
DataType_remember(t);
|
||||
SwigType_add_pointer(t);
|
||||
SwigType_remember(t);
|
||||
Printv(set->code, tab4, "{\n",
|
||||
tab8, "void *ptr;\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", DataType_manglestr(t), ") != TCL_OK) {\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", SwigType_manglestr(t), ") != TCL_OK) {\n",
|
||||
tab8, tab4, "return \"Type Error\";\n",
|
||||
tab8, "}\n",
|
||||
tab8, "*(addr) = *((", DataType_lstr(t,0), ") ptr);\n",
|
||||
tab8, "*(addr) = *((", SwigType_lstr(t,0), ") ptr);\n",
|
||||
tab4, "}\n",
|
||||
0);
|
||||
|
||||
DataType_del_pointer(t);
|
||||
SwigType_del_pointer(t);
|
||||
break;
|
||||
case T_STRING:
|
||||
Printv(set->code, tab4, "if (*addr) free(*addr);\n",
|
||||
|
|
@ -843,13 +844,13 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
break;
|
||||
case T_POINTER: case T_ARRAY: case T_REFERENCE:
|
||||
// User defined type. We return it as a pointer
|
||||
DataType_remember(t);
|
||||
SwigType_remember(t);
|
||||
Printv(set->code, tab4, "{\n",
|
||||
tab8, "void *ptr;\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", DataType_manglestr(t), ") != TCL_OK) {\n",
|
||||
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", SwigType_manglestr(t), ") != TCL_OK) {\n",
|
||||
tab8, tab4, "return \"Type Error\";\n",
|
||||
tab8, "}\n",
|
||||
tab8, "*(addr) = (", DataType_lstr(t,0), ") ptr;\n",
|
||||
tab8, "*(addr) = (", SwigType_lstr(t,0), ") ptr;\n",
|
||||
tab4, "}\n",
|
||||
0);
|
||||
break;
|
||||
|
|
@ -857,13 +858,13 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
break;
|
||||
|
||||
default:
|
||||
Printf(stderr,"Unknown type %s!\n", DataType_str(t,0));
|
||||
Printf(stderr,"Unknown type %s!\n", SwigType_str(t,0));
|
||||
break;
|
||||
}
|
||||
|
||||
Printv(set->code, tab4, "return NULL;\n", "}\n",0);
|
||||
|
||||
switch(DataType_type(t)) {
|
||||
switch(SwigType_type(t)) {
|
||||
case T_INT:
|
||||
case T_UINT:
|
||||
case T_SHORT:
|
||||
|
|
@ -899,12 +900,12 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
|
||||
case T_USER:
|
||||
Wrapper_add_local(get,"value", "Tcl_Obj *value");
|
||||
DataType_add_pointer(t);
|
||||
DataType_remember(t);
|
||||
Printv(get->code, tab4, "value = SWIG_NewPointerObj(addr, SWIGTYPE", DataType_manglestr(t), ");\n",
|
||||
SwigType_add_pointer(t);
|
||||
SwigType_remember(t);
|
||||
Printv(get->code, tab4, "value = SWIG_NewPointerObj(addr, SWIGTYPE", SwigType_manglestr(t), ");\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||
tab4, "Tcl_DecrRefCount(value);\n",0);
|
||||
DataType_del_pointer(t);
|
||||
SwigType_del_pointer(t);
|
||||
break;
|
||||
|
||||
case T_STRING:
|
||||
|
|
@ -913,9 +914,9 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
|
||||
case T_POINTER: case T_ARRAY: case T_REFERENCE:
|
||||
Wrapper_add_local(get,"value","Tcl_Obj *value");
|
||||
DataType_remember(t);
|
||||
SwigType_remember(t);
|
||||
Printv(get->code,
|
||||
tab4, "value = SWIG_NewPointerObj(*addr, SWIGTYPE", DataType_manglestr(t), ");\n",
|
||||
tab4, "value = SWIG_NewPointerObj(*addr, SWIGTYPE", SwigType_manglestr(t), ");\n",
|
||||
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
|
||||
tab4, "Tcl_DecrRefCount(value);\n",
|
||||
0);
|
||||
|
|
@ -930,7 +931,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
DelWrapper(get);
|
||||
DelWrapper(set);
|
||||
}
|
||||
Printv(var_info, tab4,"{ SWIG_prefix \"", iname, "\", (void *) &", name, ", _swig_", DataType_manglestr(t), "_get,", 0);
|
||||
Printv(var_info, tab4,"{ SWIG_prefix \"", iname, "\", (void *) &", name, ", _swig_", SwigType_manglestr(t), "_get,", 0);
|
||||
|
||||
if (Status & STAT_READONLY) {
|
||||
static int readonly = 0;
|
||||
|
|
@ -944,25 +945,25 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
|||
}
|
||||
Printf(var_info, "_swig_readonly},\n");
|
||||
} else {
|
||||
Printv(var_info, "_swig_", DataType_manglestr(t), "_set},\n",0);
|
||||
Printv(var_info, "_swig_", SwigType_manglestr(t), "_set},\n",0);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// TCL8::declare_const(char *name, char *iname, DataType *type, char *value)
|
||||
// TCL8::declare_const(char *name, char *iname, SwigType *type, char *value)
|
||||
//
|
||||
// Makes a constant. Really just creates a variable and links to it.
|
||||
// Tcl variable linkage allows read-only variables so we'll use that
|
||||
// instead of just creating a Tcl variable.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
||||
void TCL8::declare_const(char *name, char *, SwigType *type, char *value) {
|
||||
|
||||
int OldStatus = Status; // Save old status flags
|
||||
DataType *t;
|
||||
SwigType *t;
|
||||
char var_name[256];
|
||||
char *tm;
|
||||
DOHString *rvalue;
|
||||
String *rvalue;
|
||||
Status = STAT_READONLY; // Enable readonly mode.
|
||||
|
||||
// Make a static variable;
|
||||
|
|
@ -970,28 +971,28 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
sprintf(var_name,"_wrap_const_%s",name);
|
||||
|
||||
// See if there's a typemap
|
||||
if (DataType_type(type) == T_STRING) {
|
||||
if (SwigType_type(type) == T_STRING) {
|
||||
rvalue = NewStringf("\"%s\"",value);
|
||||
} else if (DataType_type(type) == T_CHAR) {
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
rvalue = NewStringf("\'%s\'",value);
|
||||
} else {
|
||||
rvalue = NewString(value);
|
||||
}
|
||||
if ((tm = typemap_lookup((char*)"const",(char*)"tcl8",type,name,Char(rvalue),name))) {
|
||||
if ((tm = typemap_lookup((char*)"const",(char*)"tcl8",type,name,Char(rvalue),name,0))) {
|
||||
// Yep. Use it instead of the default
|
||||
Printf(f_init,"%s\n",tm);
|
||||
} else {
|
||||
|
||||
// Create variable and assign it a value
|
||||
switch(DataType_type(type)) {
|
||||
switch(SwigType_type(type)) {
|
||||
case T_BOOL: case T_INT: case T_DOUBLE:
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_str(type,0), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", SwigType_str(type,0), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
break;
|
||||
case T_SHORT:
|
||||
case T_LONG:
|
||||
case T_SCHAR:
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_str(type,0), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", SwigType_str(type,0), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
Printf(f_init,"\t %s_char = new char[32];\n",var_name);
|
||||
|
|
@ -1000,16 +1001,16 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
|
||||
Printf(f_init,"\t sprintf(%s_char,\"%%ld\", (long) %s);\n", var_name, var_name);
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
t = NewDataType(T_CHAR);
|
||||
DataType_add_pointer(t);
|
||||
t = NewString("char");
|
||||
SwigType_add_pointer(t);
|
||||
link_variable(var_name,name,t);
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
break;
|
||||
case T_UINT:
|
||||
case T_USHORT:
|
||||
case T_ULONG:
|
||||
case T_UCHAR:
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_str(type,0), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", SwigType_str(type,0), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
Printf(f_init,"\t %s_char = new char[32];\n",var_name);
|
||||
|
|
@ -1018,47 +1019,45 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
|
||||
Printf(f_init,"\t sprintf(%s_char,\"%%lu\", (unsigned long) %s);\n", var_name, var_name);
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
t = NewDataType(T_CHAR);
|
||||
DataType_add_pointer(t);
|
||||
t = NewSwigType(T_CHAR);
|
||||
SwigType_add_pointer(t);
|
||||
link_variable(var_name,name,t);
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
break;
|
||||
case T_FLOAT:
|
||||
DataType_Settypecode(type,T_DOUBLE);
|
||||
DataType_Setname(type,"double");
|
||||
Printf(f_header,"static %s %s = (%s) (%s);\n", DataType_lstr(type,0), var_name, DataType_lstr(type,0), value);
|
||||
Printf(f_header,"static %s %s = (%s) (%s);\n", SwigType_lstr(type,0), var_name, SwigType_lstr(type,0), value);
|
||||
link_variable(var_name,name,type);
|
||||
break;
|
||||
|
||||
case T_CHAR:
|
||||
DataType_add_pointer(type);
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", DataType_lstr(type,0), var_name, value);
|
||||
SwigType_add_pointer(type);
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", SwigType_lstr(type,0), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
DataType_del_pointer(type);
|
||||
SwigType_del_pointer(type);
|
||||
break;
|
||||
|
||||
case T_STRING:
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", DataType_lstr(type,0), var_name, value);
|
||||
Printf(f_header,"static %s %s = \"%s\";\n", SwigType_lstr(type,0), var_name, value);
|
||||
link_variable(var_name,name,type);
|
||||
break;
|
||||
|
||||
case T_POINTER: case T_ARRAY: case T_REFERENCE:
|
||||
// Something else. Some sort of pointer value
|
||||
Printf(f_header,"static %s %s = %s;\n", DataType_lstr(type,0), var_name, value);
|
||||
Printf(f_header,"static %s %s = %s;\n", SwigType_lstr(type,0), var_name, value);
|
||||
Printf(f_header,"static char *%s_char;\n", var_name);
|
||||
if (CPlusPlus)
|
||||
Printf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) strlen(DataType_manglestr(type))+ 20);
|
||||
Printf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) Len(SwigType_manglestr(type))+ 20);
|
||||
else
|
||||
Printf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) strlen(DataType_manglestr(type))+ 20);
|
||||
Printf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) Len(SwigType_manglestr(type))+ 20);
|
||||
|
||||
t = NewDataType(T_CHAR);
|
||||
DataType_add_pointer(t);
|
||||
DataType_remember(type);
|
||||
t = NewSwigType(T_CHAR);
|
||||
SwigType_add_pointer(t);
|
||||
SwigType_remember(type);
|
||||
Printf(f_init,"\t SWIG_MakePtr(%s_char, (void *) %s, SWIGTYPE%s);\n",
|
||||
var_name, var_name, DataType_manglestr(type));
|
||||
var_name, var_name, SwigType_manglestr(type));
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
link_variable(var_name,name,t);
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
break;
|
||||
default:
|
||||
Printf(stderr,"%s : Line %d. Unsupported constant value.\n", input_file, line_number);
|
||||
|
|
@ -1070,12 +1069,12 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// TCL8::usage_var(char *iname, DataType *t, char **s)
|
||||
// TCL8::usage_var(char *iname, SwigType *t, char **s)
|
||||
//
|
||||
// Produces a usage string for a tcl variable. Stores it in s
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
char *TCL8::usage_var(char *iname, DataType *t) {
|
||||
char *TCL8::usage_var(char *iname, SwigType *t) {
|
||||
|
||||
static char temp[2048];
|
||||
|
||||
|
|
@ -1090,14 +1089,14 @@ char *TCL8::usage_var(char *iname, DataType *t) {
|
|||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// char *TCL8::usage_string(char *iname, DataType *t, ParmList *l),
|
||||
// char *TCL8::usage_string(char *iname, SwigType *t, ParmList *l),
|
||||
//
|
||||
// Generates a generic usage string for a Tcl function.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
|
||||
char * TCL8::usage_string(char *iname, SwigType *, ParmList *l) {
|
||||
|
||||
static DOHString *temp = 0;
|
||||
static String *temp = 0;
|
||||
Parm *p;
|
||||
int i, numopt,pcount;
|
||||
|
||||
|
|
@ -1112,8 +1111,8 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
|
|||
p = l;
|
||||
while (p != 0) {
|
||||
|
||||
DataType *pt = Gettype(p);
|
||||
char *pn = Getname(p);
|
||||
SwigType *pt = Gettype(p);
|
||||
String *pn = Getname(p);
|
||||
|
||||
// Only print an argument if not ignored
|
||||
|
||||
|
|
@ -1122,12 +1121,12 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
|
|||
Putc('?',temp);
|
||||
|
||||
/* If parameter has been named, use that. Otherwise, just print a type */
|
||||
if (DataType_type(pt) != T_VOID) {
|
||||
if (strlen(pn) > 0) {
|
||||
Printf(temp,pn);
|
||||
if (SwigType_type(pt) != T_VOID) {
|
||||
if (Len(pn) > 0) {
|
||||
Printf(temp,"%s",pn);
|
||||
}
|
||||
else {
|
||||
Printf(temp,"{ %s }", DataType_str(pt,0));
|
||||
Printf(temp,"%s", SwigType_str(pt,0));
|
||||
}
|
||||
}
|
||||
if (i >= (pcount-numopt))
|
||||
|
|
@ -1141,12 +1140,12 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// char *TCL8::usage_func(char *iname, DataType *t, ParmList *l),
|
||||
// char *TCL8::usage_func(char *iname, SwigType *t, ParmList *l),
|
||||
//
|
||||
// Produces a usage string for a function in Tcl
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
char * TCL8::usage_func(char *iname, DataType *t, ParmList *l) {
|
||||
char * TCL8::usage_func(char *iname, SwigType *t, ParmList *l) {
|
||||
char temp[1024];
|
||||
|
||||
if (nspace) {
|
||||
|
|
@ -1158,13 +1157,13 @@ char * TCL8::usage_func(char *iname, DataType *t, ParmList *l) {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// TCL8::usage_const(char *name, DataType *type, char *value)
|
||||
// TCL8::usage_const(char *name, SwigType *type, char *value)
|
||||
// char **s)
|
||||
//
|
||||
// Makes a usage string and returns it
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
char *TCL8::usage_const(char *name, DataType *, char *value) {
|
||||
char *TCL8::usage_const(char *name, SwigType *, char *value) {
|
||||
static char temp[1024];
|
||||
if (nspace) {
|
||||
sprintf(temp,"%s::%s = %s", ns_name,name,value);
|
||||
|
|
@ -1175,14 +1174,14 @@ char *TCL8::usage_const(char *name, DataType *, char *value) {
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// TCL8::add_native(char *name, char *funcname, DataType *t, ParmList *l)
|
||||
// TCL8::add_native(char *name, char *funcname, SwigType *t, ParmList *l)
|
||||
//
|
||||
// This adds an already written Tcl wrapper function to our
|
||||
// initialization function.
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
void TCL8::add_native(char *name, char *funcname, DataType *, ParmList *) {
|
||||
void TCL8::add_native(char *name, char *funcname, SwigType *, ParmList *) {
|
||||
|
||||
Printf(f_init,"\t Tcl_CreateObjCommand(%s, SWIG_prefix \"%s\", %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n",interp_name, name, funcname);
|
||||
|
||||
|
|
@ -1247,23 +1246,20 @@ void TCL8::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
|
|||
}
|
||||
|
||||
void TCL8::cpp_close_class() {
|
||||
DOHString *code;
|
||||
DataType *t;
|
||||
String *code;
|
||||
SwigType *t;
|
||||
|
||||
code = NewString("");
|
||||
|
||||
this->Language::cpp_close_class();
|
||||
if (shadow) {
|
||||
char temp[256];
|
||||
t = NewDataType(T_USER);
|
||||
sprintf(temp,"%s%s", class_type, real_classname);
|
||||
DataType_Setname(t,temp);
|
||||
DataType_add_pointer(t);
|
||||
t = NewStringf("%s%s", class_type, real_classname);
|
||||
SwigType_add_pointer(t);
|
||||
|
||||
if (have_destructor) {
|
||||
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n", 0);
|
||||
if (CPlusPlus) {
|
||||
Printv(code," delete (", DataType_str(t,0), ") obj;\n",0);
|
||||
Printv(code," delete (", SwigType_str(t,0), ") obj;\n",0);
|
||||
} else {
|
||||
Printv(code," free((char *) obj);\n",0);
|
||||
}
|
||||
|
|
@ -1277,10 +1273,10 @@ void TCL8::cpp_close_class() {
|
|||
Printv(code,attributes,0);
|
||||
|
||||
Printv(code, "static _swig_class _wrap_class_", class_name, " = { \"", class_name,
|
||||
"\", &SWIGTYPE", DataType_manglestr(t), ",",0);
|
||||
"\", &SWIGTYPE", SwigType_manglestr(t), ",",0);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(code, Swig_name_wrapper(Swig_name_construct(class_name)));
|
||||
Printf(code, "%s", Swig_name_wrapper(Swig_name_construct(class_name)));
|
||||
} else {
|
||||
Printf(code,"0");
|
||||
}
|
||||
|
|
@ -1298,7 +1294,7 @@ void TCL8::cpp_close_class() {
|
|||
|
||||
}
|
||||
|
||||
void TCL8::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||
void TCL8::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) {
|
||||
|
||||
char *realname;
|
||||
char temp[1024];
|
||||
|
|
@ -1314,16 +1310,16 @@ void TCL8::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
|
||||
// Add stubs for this member to our class handler function
|
||||
|
||||
strcpy(temp, Swig_name_member(class_name,realname));
|
||||
strcpy(temp, Char(Swig_name_member(class_name,realname)));
|
||||
rname = GetChar(repeatcmd,temp);
|
||||
if (!rname)
|
||||
rname = Swig_name_wrapper(temp);
|
||||
rname = Char(Swig_name_wrapper(temp));
|
||||
|
||||
Printv(methods, tab4, "{\"", realname, "\", ", rname, "}, \n", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TCL8::cpp_variable(char *name, char *iname, DataType *t) {
|
||||
void TCL8::cpp_variable(char *name, char *iname, SwigType *t) {
|
||||
char *realname;
|
||||
char temp[1024];
|
||||
char *rname;
|
||||
|
|
@ -1341,17 +1337,17 @@ void TCL8::cpp_variable(char *name, char *iname, DataType *t) {
|
|||
Printv(attributes, tab4, "{ \"-", realname, "\",", 0);
|
||||
|
||||
// Try to figure out if there is a wrapper for this function
|
||||
strcpy(temp, Swig_name_get(Swig_name_member(bc,realname)));
|
||||
strcpy(temp, Char(Swig_name_get(Swig_name_member(bc,realname))));
|
||||
rname = GetChar(repeatcmd,temp);
|
||||
if (!rname)
|
||||
rname = Swig_name_wrapper(temp);
|
||||
rname = Char(Swig_name_wrapper(temp));
|
||||
Printv(attributes, rname, ", ", 0);
|
||||
|
||||
if (!(Status & STAT_READONLY)) {
|
||||
strcpy(temp, Swig_name_set(Swig_name_member(bc,realname)));
|
||||
strcpy(temp, Char(Swig_name_set(Swig_name_member(bc,realname))));
|
||||
rname = GetChar(repeatcmd,temp);
|
||||
if (!rname)
|
||||
rname = Swig_name_wrapper(temp);
|
||||
rname = Char(Swig_name_wrapper(temp));
|
||||
Printv(attributes, rname, "},\n",0);
|
||||
} else {
|
||||
Printf(attributes, "0 },\n");
|
||||
|
|
@ -1377,12 +1373,12 @@ void TCL8::cpp_inherit(char **baseclass, int) {
|
|||
this->Language::cpp_inherit(baseclass);
|
||||
}
|
||||
|
||||
void TCL8::cpp_declare_const(char *name, char *iname, DataType *type, char *value) {
|
||||
void TCL8::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) {
|
||||
this->Language::cpp_declare_const(name,iname,type,value);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// TCL8::add_typedef(DataType *t, char *name)
|
||||
// TCL8::add_typedef(SwigType *t, char *name)
|
||||
//
|
||||
// This is called whenever a typedef is encountered. When shadow classes are
|
||||
// used, this function lets us discovered hidden uses of a class. For example :
|
||||
|
|
@ -1395,22 +1391,22 @@ void TCL8::cpp_declare_const(char *name, char *iname, DataType *type, char *valu
|
|||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
void TCL8::add_typedef(DataType *t, char *name) {
|
||||
void TCL8::add_typedef(SwigType *t, char *name) {
|
||||
|
||||
if (!shadow) return;
|
||||
|
||||
// First check to see if there aren't too many pointers
|
||||
|
||||
if (DataType_is_pointer(t) > 1) return;
|
||||
if (SwigType_ispointer(t) > 1) return;
|
||||
if (Getattr(hash,name)) return; // Already added
|
||||
|
||||
// Now look up the datatype in our shadow class hash table
|
||||
|
||||
if (Getattr(hash,DataType_Getname(t))) {
|
||||
if (Getattr(hash,t)) {
|
||||
|
||||
// Yep. This datatype is in the hash
|
||||
// Put this types 'new' name into the hash
|
||||
Setattr(hash,name,GetChar(hash,DataType_Getname(t)));
|
||||
Setattr(hash,name,GetChar(hash,t));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,26 +22,26 @@
|
|||
|
||||
class TCL8 : public Language {
|
||||
private:
|
||||
void get_pointer(char *iname, char *srcname, char *src, char *dest, DataType *t,
|
||||
void get_pointer(char *iname, char *srcname, char *src, char *dest, SwigType *t,
|
||||
DOHString *f, char *ret);
|
||||
char *char_result;
|
||||
char *usage_func(char *, DataType *, ParmList *);
|
||||
char *usage_string(char *, DataType *, ParmList *);
|
||||
char *usage_var(char *, DataType *);
|
||||
char *usage_const(char *, DataType *, char *);
|
||||
char *usage_func(char *, SwigType *, ParmList *);
|
||||
char *usage_string(char *, SwigType *, ParmList *);
|
||||
char *usage_var(char *, SwigType *);
|
||||
char *usage_const(char *, SwigType *, char *);
|
||||
|
||||
public :
|
||||
virtual void parse_args(int, char *argv[]);
|
||||
virtual void parse();
|
||||
virtual void create_function(char *, char *, DataType *, ParmList *);
|
||||
virtual void link_variable(char *, char *, DataType *);
|
||||
virtual void declare_const(char *, char *, DataType *, char *);
|
||||
virtual void create_function(char *, char *, SwigType *, ParmList *);
|
||||
virtual void link_variable(char *, char *, SwigType *);
|
||||
virtual void declare_const(char *, char *, SwigType *, char *);
|
||||
virtual void initialize(void);
|
||||
virtual void headers(void);
|
||||
virtual void close(void);
|
||||
virtual void set_module(char *,char **);
|
||||
virtual void set_init(char *);
|
||||
virtual void add_native(char *, char *, DataType *, ParmList *);
|
||||
virtual void add_native(char *, char *, SwigType *, ParmList *);
|
||||
virtual void pragma(char *,char *, char *);
|
||||
virtual void create_command(char *, char *);
|
||||
|
||||
|
|
@ -49,13 +49,13 @@ public :
|
|||
|
||||
virtual void cpp_open_class(char *classname, char *rename, char *ctype, int strip);
|
||||
virtual void cpp_close_class();
|
||||
virtual void cpp_member_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void cpp_variable(char *name, char *iname, DataType *t);
|
||||
virtual void cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void cpp_variable(char *name, char *iname, SwigType *t);
|
||||
virtual void cpp_constructor(char *name, char *iname, ParmList *l);
|
||||
virtual void cpp_destructor(char *name, char *newname);
|
||||
virtual void cpp_inherit(char **baseclass, int mode = INHERIT_ALL);
|
||||
virtual void cpp_declare_const(char *name, char *iname, DataType *type, char *value);
|
||||
virtual void add_typedef(DataType *, char *);
|
||||
virtual void cpp_declare_const(char *name, char *iname, SwigType *type, char *value);
|
||||
virtual void add_typedef(SwigType *, char *);
|
||||
virtual void cpp_class_decl(char *, char *, char *);
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -94,18 +94,18 @@ static int cpp_id = 0;
|
|||
|
||||
// Forward references
|
||||
|
||||
void cplus_member_func(char *, char *, DataType *, ParmList *, int);
|
||||
void cplus_member_func(char *, char *, SwigType *, ParmList *, int);
|
||||
void cplus_constructor(char *, char *, ParmList *);
|
||||
void cplus_destructor(char *, char *);
|
||||
void cplus_variable(char *, char *, DataType *);
|
||||
void cplus_static_func(char *, char *, DataType *, ParmList *);
|
||||
void cplus_declare_const(char *, char *, DataType *, char *);
|
||||
void cplus_static_var(char *, char *, DataType *);
|
||||
void cplus_variable(char *, char *, SwigType *);
|
||||
void cplus_static_func(char *, char *, SwigType *, ParmList *);
|
||||
void cplus_declare_const(char *, char *, SwigType *, char *);
|
||||
void cplus_static_var(char *, char *, SwigType *);
|
||||
void cplus_inherit_decl(char **);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void add_local_type(char *type, char *classname)
|
||||
// void add_local_type(DataType *type, char *classname)
|
||||
// void add_local_type(SwigType *type, char *classname)
|
||||
//
|
||||
// Adds a new datatype to the local datatype hash. This is used to handle
|
||||
// datatypes defined within a class.
|
||||
|
|
@ -118,19 +118,19 @@ static void add_local_type(char *type, char *classname) {
|
|||
Setattr(localtypes,type,str);
|
||||
}
|
||||
|
||||
void add_local_type(DataType *type, char *classname) {
|
||||
add_local_type(DataType_Getname(type),classname);
|
||||
void add_local_type(SwigType *type, char *classname) {
|
||||
add_local_type(Char(type),classname);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void update_local_type(DataType *type)
|
||||
// void update_local_type(SwigType *type)
|
||||
//
|
||||
// Checks to see whether this datatype is part of a class definition. If so,
|
||||
// we update the type-name by appending the class prefix to it. Uses the
|
||||
// name stored in current_class unless unavailable.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static void update_local_type(DataType *type) {
|
||||
static void update_local_type(SwigType *type) {
|
||||
|
||||
char *newname = 0;
|
||||
|
||||
|
|
@ -138,9 +138,9 @@ static void update_local_type(DataType *type) {
|
|||
|
||||
if (!localtypes) return;
|
||||
|
||||
newname = GetChar(localtypes,DataType_Getname(type));
|
||||
newname = GetChar(localtypes,SwigType_base(type));
|
||||
if (newname) {
|
||||
DataType_Setname(type,newname);
|
||||
SwigType_setbase(type,newname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,8 +153,8 @@ static void update_local_type(DataType *type) {
|
|||
|
||||
static void update_parms(ParmList *p) {
|
||||
while (p) {
|
||||
DataType *pt = Gettype(p);
|
||||
char *pvalue = Getvalue(p);
|
||||
SwigType *pt = Gettype(p);
|
||||
DOHString *pvalue = Getvalue(p);
|
||||
|
||||
update_local_type(pt);
|
||||
|
||||
|
|
@ -202,15 +202,15 @@ public:
|
|||
|
||||
class CPP_function : public CPP_member {
|
||||
public:
|
||||
DataType *ret_type;
|
||||
SwigType *ret_type;
|
||||
ParmList *parms;
|
||||
int new_object;
|
||||
int is_virtual;
|
||||
|
||||
CPP_function(char *n, char *i, DataType *t, ParmList *l, int s, int v = 0) {
|
||||
CPP_function(char *n, char *i, SwigType *t, ParmList *l, int s, int v = 0) {
|
||||
name = Swig_copy_string(n);
|
||||
iname = Swig_copy_string(i);
|
||||
ret_type = CopyDataType(t);
|
||||
ret_type = Copy(t);
|
||||
parms = CopyParmList(l);
|
||||
is_static = s;
|
||||
is_virtual = v;
|
||||
|
|
@ -220,11 +220,7 @@ public:
|
|||
next = 0;
|
||||
line = line_number;
|
||||
file = input_file;
|
||||
if (Inherit_mode) {
|
||||
id = cpp_id;
|
||||
} else {
|
||||
id = type_id;
|
||||
}
|
||||
id = cpp_id;
|
||||
if (AddMethods) {
|
||||
if (strlen(Char(CCode)))
|
||||
code = Swig_copy_string(Char(CCode));
|
||||
|
|
@ -255,7 +251,7 @@ public:
|
|||
}
|
||||
void emit() {
|
||||
ParmList *l;
|
||||
DataType *t;
|
||||
SwigType *t;
|
||||
AddMethods = new_method;
|
||||
NewObject = new_object;
|
||||
line_number = line; // Restore line and file
|
||||
|
|
@ -266,7 +262,7 @@ public:
|
|||
// Make a copy of the parameter list and upgrade its types
|
||||
|
||||
l = CopyParmList(parms);
|
||||
t = CopyDataType(ret_type);
|
||||
t = Copy(ret_type);
|
||||
update_parms(l);
|
||||
update_local_type(t);
|
||||
if (is_static) {
|
||||
|
|
@ -275,7 +271,7 @@ public:
|
|||
lang->cpp_member_func(name, iname, t, l);
|
||||
}
|
||||
Delete(l);
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
IsVirtual = 0;
|
||||
}
|
||||
};
|
||||
|
|
@ -298,7 +294,7 @@ public:
|
|||
next = 0;
|
||||
line = line_number;
|
||||
file = input_file;
|
||||
id = type_id;
|
||||
id = 0;
|
||||
if (AddMethods) {
|
||||
if (strlen(Char(CCode)))
|
||||
code = Swig_copy_string(Char(CCode));
|
||||
|
|
@ -344,7 +340,7 @@ public:
|
|||
inherited = 0;
|
||||
line = line_number;
|
||||
file = input_file;
|
||||
id = type_id;
|
||||
id = 0;
|
||||
if (AddMethods) {
|
||||
if (strlen(Char(CCode)))
|
||||
code = Swig_copy_string(Char(CCode));
|
||||
|
|
@ -372,12 +368,12 @@ public:
|
|||
|
||||
class CPP_variable : public CPP_member {
|
||||
public:
|
||||
DataType *type;
|
||||
SwigType *type;
|
||||
int status;
|
||||
CPP_variable(char *n, char *i, DataType *t, int s) {
|
||||
CPP_variable(char *n, char *i, SwigType *t, int s) {
|
||||
name = Swig_copy_string(n);
|
||||
iname = Swig_copy_string(i);
|
||||
type = CopyDataType(t);
|
||||
type = Copy(t);
|
||||
is_static = s;
|
||||
status = Status;
|
||||
next = 0;
|
||||
|
|
@ -387,7 +383,7 @@ public:
|
|||
if (Inherit_mode) {
|
||||
id = cpp_id;
|
||||
} else {
|
||||
id = type_id;
|
||||
id = 0;
|
||||
}
|
||||
code = 0;
|
||||
inherited = 0;
|
||||
|
|
@ -396,7 +392,7 @@ public:
|
|||
// Emit code for this
|
||||
|
||||
void emit() {
|
||||
DataType *t;
|
||||
SwigType *t;
|
||||
int old_status = Status;
|
||||
AddMethods = new_method;
|
||||
Status = status;
|
||||
|
|
@ -404,7 +400,7 @@ public:
|
|||
input_file = file;
|
||||
ccode = code;
|
||||
|
||||
t = CopyDataType(type);
|
||||
t = Copy(type);
|
||||
update_local_type(t);
|
||||
if (!is_static) {
|
||||
lang->cpp_variable(name,iname,t);
|
||||
|
|
@ -412,7 +408,7 @@ public:
|
|||
lang->cpp_static_var(name,iname,t);
|
||||
}
|
||||
Status = old_status;
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
}
|
||||
|
||||
// Inherit into another class
|
||||
|
|
@ -446,11 +442,11 @@ public:
|
|||
class CPP_constant : public CPP_member {
|
||||
public:
|
||||
char *value;
|
||||
DataType *type;
|
||||
CPP_constant(char *n, char *i, DataType *t, char *v) {
|
||||
SwigType *type;
|
||||
CPP_constant(char *n, char *i, SwigType *t, char *v) {
|
||||
name = Swig_copy_string(n);
|
||||
iname = Swig_copy_string(i);
|
||||
type = CopyDataType(t);
|
||||
type = Copy(t);
|
||||
value = Swig_copy_string(v);
|
||||
new_method = AddMethods;
|
||||
next = 0;
|
||||
|
|
@ -459,7 +455,7 @@ public:
|
|||
if (Inherit_mode)
|
||||
id = cpp_id;
|
||||
else
|
||||
id = type_id;
|
||||
id = 0;
|
||||
code = 0;
|
||||
inherited = 0;
|
||||
}
|
||||
|
|
@ -753,8 +749,8 @@ void cplus_open_class(char *name, char *rname, char *ctype) {
|
|||
if (strlen(name)) {
|
||||
if (strlen(ctype) > 0) {
|
||||
sprintf(temp,"%s %s", ctype, name);
|
||||
typeeq_derived(temp,name,0); // Map "struct foo" to "foo"
|
||||
typeeq_derived(name,temp,0); // Map "foo" to "struct foo"
|
||||
// typeeq_derived(temp,name,0); // Map "struct foo" to "foo"
|
||||
//typeeq_derived(name,temp,0); // Map "foo" to "struct foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -976,6 +972,7 @@ void cplus_generate_types(char **baseclass) {
|
|||
|
||||
// Write a function for casting derived type to parent class
|
||||
|
||||
#ifdef OLD
|
||||
Printv(cfunc,
|
||||
"static void *Swig", current_class->classname, "To", bc->classname,
|
||||
"(void *ptr) {\n",
|
||||
|
|
@ -986,8 +983,8 @@ void cplus_generate_types(char **baseclass) {
|
|||
tab4, "return (void *) dest;\n",
|
||||
"}\n",
|
||||
0);
|
||||
|
||||
Printf(f_wrappers,"%s\n",Char(cfunc));
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
Clear(temp3);
|
||||
|
|
@ -1002,14 +999,15 @@ void cplus_generate_types(char **baseclass) {
|
|||
|
||||
// Add various equivalences to the pointer table
|
||||
|
||||
typeeq_derived(bc->classname, current_class->classname,Char(temp3));
|
||||
typeeq_derived(temp2, current_class->classname,Char(temp3));
|
||||
typeeq_derived(temp2, temp1,Char(temp3));
|
||||
typeeq_derived(bc->classname, temp1,Char(temp3));
|
||||
// typeeq_derived(bc->classname, current_class->classname,Char(temp3));
|
||||
// typeeq_derived(temp2, current_class->classname,Char(temp3));
|
||||
// typeeq_derived(temp2, temp1,Char(temp3));
|
||||
// typeeq_derived(bc->classname, temp1,Char(temp3));
|
||||
} else {
|
||||
typeeq_derived(bc->classname, current_class->classname,Char(temp3));
|
||||
// typeeq_derived(bc->classname, current_class->classname,Char(temp3));
|
||||
}
|
||||
DataType_record_base(current_class->classname, bc->classname);
|
||||
// DataType_record_base(current_class->classname, bc->classname);
|
||||
SwigType_inherit(current_class->classname, bc->classname);
|
||||
// Now traverse the hierarchy some more
|
||||
cplus_generate_types(bc->baseclass);
|
||||
}
|
||||
|
|
@ -1105,7 +1103,7 @@ void cplus_inherit_members(char *baseclass, int mode) {
|
|||
// Adds member function to current class.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_member_func(char *name, char *iname, DataType *type, ParmList *l,
|
||||
void cplus_member_func(char *name, char *iname, SwigType *type, ParmList *l,
|
||||
int is_virtual) {
|
||||
|
||||
CPP_function *f;
|
||||
|
|
@ -1193,14 +1191,14 @@ void cplus_destructor(char *name, char *iname) {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_variable(char *name, char *iname, DataType *t)
|
||||
// void cplus_variable(char *name, char *iname, SwigType *t)
|
||||
//
|
||||
// Parser entry point for creating a new member variable.
|
||||
//
|
||||
// Inputs :
|
||||
// name = name of the variable
|
||||
// iname = Renamed version (may be NULL)
|
||||
// t = Datatype
|
||||
// t = SwigType
|
||||
//
|
||||
// Output : None
|
||||
//
|
||||
|
|
@ -1208,7 +1206,7 @@ void cplus_destructor(char *name, char *iname) {
|
|||
// Adds a member variable to the current class
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_variable(char *name, char *iname, DataType *t) {
|
||||
void cplus_variable(char *name, char *iname, SwigType *t) {
|
||||
|
||||
CPP_variable *v;
|
||||
char *temp_iname;
|
||||
|
|
@ -1231,14 +1229,14 @@ void cplus_variable(char *name, char *iname, DataType *t) {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_static_func(char *name, char *iname, DataType *type, ParmList *l)
|
||||
// void cplus_static_func(char *name, char *iname, SwigType *type, ParmList *l)
|
||||
//
|
||||
// Parser entry point for creating a new static member function.
|
||||
//
|
||||
// Inputs :
|
||||
// name = Real name of the function
|
||||
// iname = Renamed version (may be NULL)
|
||||
// type = Return datatype
|
||||
// type = Return SwigType
|
||||
// l = Parameter list
|
||||
//
|
||||
// Output : None
|
||||
|
|
@ -1248,7 +1246,7 @@ void cplus_variable(char *name, char *iname, DataType *t) {
|
|||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_static_func(char *name, char *iname, DataType *type, ParmList *l) {
|
||||
void cplus_static_func(char *name, char *iname, SwigType *type, ParmList *l) {
|
||||
|
||||
char *temp_iname;
|
||||
|
||||
|
|
@ -1269,7 +1267,7 @@ void cplus_static_func(char *name, char *iname, DataType *type, ParmList *l) {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_declare_const(char *name, char *iname, DataType *type, char *value)
|
||||
// void cplus_declare_const(char *name, char *iname, SwigType *type, char *value)
|
||||
//
|
||||
// Parser entry point for creating a C++ constant (usually contained in an
|
||||
// enum).
|
||||
|
|
@ -1286,7 +1284,7 @@ void cplus_static_func(char *name, char *iname, DataType *type, ParmList *l) {
|
|||
// Adds a constant to the current class.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_declare_const(char *name, char *iname, DataType *type, char *value) {
|
||||
void cplus_declare_const(char *name, char *iname, SwigType *type, char *value) {
|
||||
|
||||
char *temp_iname;
|
||||
|
||||
|
|
@ -1310,7 +1308,7 @@ void cplus_declare_const(char *name, char *iname, DataType *type, char *value) {
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_static_var(char *name, char *iname, DataType *type)
|
||||
// void cplus_static_var(char *name, char *iname, SwigType *type)
|
||||
//
|
||||
// Parser entry point for adding a static variable
|
||||
//
|
||||
|
|
@ -1325,7 +1323,7 @@ void cplus_declare_const(char *name, char *iname, DataType *type, char *value) {
|
|||
// Adds a static variable to the current class.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_static_var(char *name, char *iname, DataType *type) {
|
||||
void cplus_static_var(char *name, char *iname, SwigType *type) {
|
||||
|
||||
char *temp_iname;
|
||||
|
||||
|
|
@ -1394,7 +1392,7 @@ static DOHHash *member_hash = 0; // Hash wrapping member function wrappers to s
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
||||
// char *mname, char *mrename, DataType *type,
|
||||
// char *mname, char *mrename, SwigType *type,
|
||||
// ParmList *l, int mode)
|
||||
//
|
||||
// This is a generic function to produce a C wrapper around a C++ member function.
|
||||
|
|
@ -1469,7 +1467,7 @@ static DOHHash *member_hash = 0; // Hash wrapping member function wrappers to s
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
||||
char *mname, char *mrename, DataType *type, ParmList *l,
|
||||
char *mname, char *mrename, SwigType *type, ParmList *l,
|
||||
int mode) {
|
||||
|
||||
Wrapper *w;
|
||||
|
|
@ -1491,7 +1489,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
if (!classrename) classrename = classname;
|
||||
if (!mrename) mrename = mname;
|
||||
|
||||
strcpy(iname, Swig_name_member(classrename, mrename));
|
||||
strcpy(iname, Char(Swig_name_member(classrename, mrename)));
|
||||
|
||||
char *bc = cplus_base_class(mrename);
|
||||
if (!bc) bc = classname;
|
||||
|
|
@ -1523,7 +1521,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_emit_static_func(char *classname, char *classtype, char *classrename,
|
||||
// char *mname, char *mrename, DataType *type,
|
||||
// char *mname, char *mrename, SwigType *type,
|
||||
// ParmList *l, int mode)
|
||||
//
|
||||
// This is a generic function to produce a wrapper for a C++ static member function
|
||||
|
|
@ -1572,7 +1570,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_emit_static_func(char *classname, char *, char *classrename,
|
||||
char *mname, char *mrename, DataType *type, ParmList *l,
|
||||
char *mname, char *mrename, SwigType *type, ParmList *l,
|
||||
int mode) {
|
||||
|
||||
char cname[512], iname[512];
|
||||
|
|
@ -1593,12 +1591,12 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
|||
if ((!mode) && (!ObjCClass)) {
|
||||
sprintf(cname,"%s::%s", bc, mname);
|
||||
} else {
|
||||
strcpy(cname,Swig_name_member(bc,mname));
|
||||
strcpy(cname,Char(Swig_name_member(bc,mname)));
|
||||
}
|
||||
|
||||
// Generate the scripting name of this function
|
||||
if (!classrename) classrename = classname;
|
||||
strcpy(iname,Swig_name_member(classrename, mrename));
|
||||
strcpy(iname,Char(Swig_name_member(classrename, mrename)));
|
||||
|
||||
// Perform a hash table lookup to see if we've wrapped anything like this before
|
||||
Printf(key,"%s+%s",cname, ParmList_str(l));
|
||||
|
|
@ -1615,7 +1613,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
|||
lang->create_function(cname,iname, type, l);
|
||||
} else {
|
||||
if (!ccode) {
|
||||
strcpy(cname, Swig_name_member(classname,mname));
|
||||
strcpy(cname, Char(Swig_name_member(classname,mname)));
|
||||
lang->create_function(cname,iname, type, l);
|
||||
} else {
|
||||
Wrapper *w = Swig_cfunction_wrapper(cname, type, l, ccode);
|
||||
|
|
@ -1673,11 +1671,11 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
|||
|
||||
if (!classrename) classrename = classname;
|
||||
|
||||
strcpy(cname,Swig_name_destroy(classname));
|
||||
strcpy(cname,Char(Swig_name_destroy(classname)));
|
||||
if (mrename)
|
||||
strcpy(iname, Swig_name_destroy(mrename));
|
||||
strcpy(iname, Char(Swig_name_destroy(mrename)));
|
||||
else
|
||||
strcpy(iname, Swig_name_destroy(classrename));
|
||||
strcpy(iname, Char(Swig_name_destroy(classrename)));
|
||||
|
||||
sprintf(fclassname,"%s%s", classtype, classname);
|
||||
if (CPlusPlus) {
|
||||
|
|
@ -1730,11 +1728,11 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
|||
// Construct names for the function
|
||||
|
||||
if (!classrename) classrename = classname;
|
||||
strcpy(cname,Swig_name_construct(classname));
|
||||
strcpy(cname,Char(Swig_name_construct(classname)));
|
||||
if (mrename)
|
||||
strcpy(iname, Swig_name_construct(mrename));
|
||||
strcpy(iname, Char(Swig_name_construct(mrename)));
|
||||
else
|
||||
strcpy(iname, Swig_name_construct(classrename));
|
||||
strcpy(iname, Char(Swig_name_construct(classrename)));
|
||||
|
||||
sprintf(fclassname,"%s%s", classtype, classname);
|
||||
|
||||
|
|
@ -1761,7 +1759,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_emit_variable_get(char *classname, char *classtype, char *classrename,
|
||||
// char *mname, char *mrename, DataType *type, int mode)
|
||||
// char *mname, char *mrename, SwigType *type, int mode)
|
||||
//
|
||||
// Writes a C wrapper to extract a data member
|
||||
//
|
||||
|
|
@ -1800,7 +1798,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_emit_variable_get(char *classname, char *classtype, char *classrename,
|
||||
char *mname, char *mrename, DataType *type, int mode) {
|
||||
char *mname, char *mrename, SwigType *type, int mode) {
|
||||
|
||||
char cname[512],iname[512], fclassname[512];
|
||||
char key[512];
|
||||
|
|
@ -1819,11 +1817,11 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
|||
// Generate the name of the C wrapper function (is always the same, regardless
|
||||
// of renaming).
|
||||
|
||||
strcpy(cname, Swig_name_get(Swig_name_member(bc,mname)));
|
||||
strcpy(cname, Char(Swig_name_get(Swig_name_member(bc,mname))));
|
||||
|
||||
// Generate the scripting name of this function
|
||||
if (!classrename) classrename = classname;
|
||||
strcpy(iname, Swig_name_get(Swig_name_member(classrename,mrename)));
|
||||
strcpy(iname, Char(Swig_name_get(Swig_name_member(classrename,mrename))));
|
||||
|
||||
// Now check to see if we have already wrapped a variable like this.
|
||||
|
||||
|
|
@ -1855,7 +1853,7 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_emit_variable_set(char *classname, char *classtype, char *mname,
|
||||
// char *cname, char *iname, DataType *type, int mode)
|
||||
// char *cname, char *iname, SwigType *type, int mode)
|
||||
//
|
||||
// Writes a C wrapper to set a data member
|
||||
//
|
||||
|
|
@ -1903,7 +1901,7 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void cplus_emit_variable_set(char *classname, char *classtype, char *classrename,
|
||||
char *mname, char *mrename, DataType *type, int mode) {
|
||||
char *mname, char *mrename, SwigType *type, int mode) {
|
||||
|
||||
char cname[512], iname[512];
|
||||
char key[512];
|
||||
|
|
@ -1920,10 +1918,10 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
// Generate the name of the C wrapper function (is always the same, regardless
|
||||
// of renaming).
|
||||
|
||||
strcpy(cname, Swig_name_set(Swig_name_member(bc,mname)));
|
||||
strcpy(cname, Char(Swig_name_set(Swig_name_member(bc,mname))));
|
||||
|
||||
if (!classrename) classrename = classname;
|
||||
strcpy(iname, Swig_name_set(Swig_name_member(classrename, mrename)));
|
||||
strcpy(iname, Char(Swig_name_set(Swig_name_member(classrename, mrename))));
|
||||
|
||||
// Now check to see if we have already wrapped a variable like this.
|
||||
|
||||
|
|
@ -2028,9 +2026,9 @@ void cplus_inherit_scope(int count, char **baseclass) {
|
|||
for (i = 0; i < count; i++) {
|
||||
bc = CPP_class::search(baseclass[i]);
|
||||
if (bc) {
|
||||
if (bc->scope)
|
||||
DataType_merge_scope(bc->scope);
|
||||
|
||||
if (bc->scope) {
|
||||
SwigType_merge_scope(bc->scope,0);
|
||||
}
|
||||
if (bc->local) {
|
||||
// Copy local symbol table
|
||||
key = Firstkey(bc->local);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ extern "C" {
|
|||
static char cvsroot[] = "$Header$";
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int emit_args(char *d, DataType *rt, ParmList *l, Wrapper *f)
|
||||
* emit_args()
|
||||
*
|
||||
* Creates a list of variable declarations for both the return value
|
||||
* and function parameters.
|
||||
|
|
@ -29,15 +29,15 @@ static char cvsroot[] = "$Header$";
|
|||
* Returns the number of parameters associated with a function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
||||
int emit_args(SwigType *rt, ParmList *l, Wrapper *f) {
|
||||
|
||||
Parm *p;
|
||||
int i;
|
||||
char *tm;
|
||||
DataType *pt;
|
||||
char *pvalue;
|
||||
char *pname;
|
||||
char *lname;
|
||||
SwigType *pt;
|
||||
DOHString *pvalue;
|
||||
DOHString *pname;
|
||||
DOHString *lname;
|
||||
|
||||
/* Emit function arguments */
|
||||
Swig_cargs(f, l);
|
||||
|
|
@ -89,13 +89,13 @@ void emit_set_action(DOHString_or_char *decl) {
|
|||
fcall = NewString(decl);
|
||||
}
|
||||
|
||||
void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
|
||||
void emit_func_call(char *decl, SwigType *t, ParmList *l, Wrapper *f) {
|
||||
char *tm;
|
||||
|
||||
if ((tm = typemap_lookup((char*)"except",typemap_lang,t,decl,(char*)"result",(char*)""))) {
|
||||
if ((tm = typemap_lookup((char*)"except",typemap_lang,t,decl,(char*)"result",(char*)"",0))) {
|
||||
Printv(f->code,tm,0);
|
||||
Replace(f->code,"$name",decl,DOH_REPLACE_ANY);
|
||||
} else if ((tm = fragment_lookup((char*)"except",typemap_lang, t->_id))) {
|
||||
} else if ((tm = fragment_lookup((char*)"except",typemap_lang))) {
|
||||
Printv(f->code,tm,0);
|
||||
Replace(f->code,"$name",decl,DOH_REPLACE_ANY);
|
||||
} else {
|
||||
|
|
@ -150,16 +150,16 @@ strcpy((char *)$target,$source);\n\
|
|||
return ($ltype) $target;\n;";
|
||||
|
||||
|
||||
void emit_set_get(char *name, char *iname, DataType *t) {
|
||||
void emit_set_get(char *name, char *iname, SwigType *t) {
|
||||
|
||||
Wrapper *w;
|
||||
char new_iname[256];
|
||||
DOHString *new_iname;
|
||||
char *code = 0;
|
||||
|
||||
/* First write a function to set the variable of the variable */
|
||||
if (!(Status & STAT_READONLY)) {
|
||||
|
||||
if (DataType_type(t) == T_STRING) {
|
||||
if (SwigType_type(t) == T_STRING) {
|
||||
if (CPlusPlus)
|
||||
code = cpp_str;
|
||||
else
|
||||
|
|
@ -167,15 +167,19 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
}
|
||||
w = Swig_cvarset_wrapper(name, t, code);
|
||||
Wrapper_print(w,f_header);
|
||||
strcpy(new_iname, Swig_name_set(iname));
|
||||
lang->create_function(Wrapper_Getname(w), new_iname, Wrapper_Gettype(w), Wrapper_Getparms(w));
|
||||
new_iname = Swig_name_set(iname);
|
||||
DohIncref(new_iname);
|
||||
lang->create_function(Wrapper_Getname(w), Char(new_iname), Wrapper_Gettype(w), Wrapper_Getparms(w));
|
||||
Delete(new_iname);
|
||||
DelWrapper(w);
|
||||
}
|
||||
|
||||
w = Swig_cvarget_wrapper(name,t,0);
|
||||
Wrapper_print(w,f_header);
|
||||
strcpy(new_iname, Swig_name_get(iname));
|
||||
lang->create_function(Wrapper_Getname(w), new_iname, Wrapper_Gettype(w), Wrapper_Getparms(w));
|
||||
new_iname = Swig_name_get(iname);
|
||||
DohIncref(new_iname);
|
||||
lang->create_function(Wrapper_Getname(w), Char(new_iname), Wrapper_Gettype(w), Wrapper_Getparms(w));
|
||||
Delete(new_iname);
|
||||
DelWrapper(w);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,3 +39,4 @@ struct TMParm {
|
|||
|
||||
#define NI_NAMES 512
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,19 +24,14 @@ extern "C" {
|
|||
extern int add_symbol(char *name);
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* void Language::set_init(char *iname)
|
||||
*
|
||||
* Called to make an initialization function by %init (obsolete)
|
||||
* Language::set_init()
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
void Language::set_init(char *iname) {
|
||||
set_module(iname,0);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* void Language::create_command(char *cname, char *iname
|
||||
*
|
||||
* Method for adding a previous wrapped C function.
|
||||
* Language::create_command()
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
void Language::create_command(char *, char *) {
|
||||
|
|
@ -45,14 +40,11 @@ void Language::create_command(char *, char *) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* void Language::add_native(char *name, char *iname, DataType *t, ParmList *l)
|
||||
*
|
||||
* Method for adding a native function with full argument info
|
||||
* default is to call the old-style add_native method
|
||||
* Language::add_native()
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Language::add_native(char *, char *iname, DataType *, ParmList *) {
|
||||
Language::add_native(char *, char *iname, SwigType *, ParmList *) {
|
||||
Printf(stderr,"%s : Line %d. Adding native function %s not supported (ignored).\n", input_file, line_number, iname);
|
||||
}
|
||||
|
||||
|
|
@ -61,20 +53,7 @@ static char *ClassRename = 0; /* This is non-NULL if the class has been re
|
|||
static char *ClassType = 0; /* Type of class (ie. union, struct, class) */
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_open_class(char *classname, char *classrename, char *ctype, int strip)
|
||||
*
|
||||
* Open a new C++ class.
|
||||
*
|
||||
* INPUTS:
|
||||
* classname = Real name of the C++ class
|
||||
* classrename = New name of the class (if %name was used)
|
||||
* ctype = Class type (struct, class, union, etc...)
|
||||
* strip = Flag indicating whether we should strip the class type off
|
||||
*
|
||||
* This function is in charge of creating a new class. The SWIG parser has
|
||||
* already processed the entire class definition prior to calling this
|
||||
* function (which should simplify things considerably).
|
||||
*
|
||||
* Language::cpp_open_class()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_open_class(char *classname, char *classrename, char *ctype, int strip) {
|
||||
|
|
@ -102,9 +81,7 @@ void Language::cpp_open_class(char *classname, char *classrename, char *ctype, i
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_close_class()
|
||||
*
|
||||
* Close the current class
|
||||
* Language::cpp_close_class()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_close_class() {
|
||||
|
|
@ -114,28 +91,10 @@ void Language::cpp_close_class() {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l)
|
||||
*
|
||||
* Method for adding C++ member function
|
||||
*
|
||||
* INPUTS:
|
||||
* name - name of the member function
|
||||
* iname - renaming (if given)
|
||||
* t - Return datatype
|
||||
* l - Parameter list
|
||||
*
|
||||
* By default, we're going to create a function of the form :
|
||||
*
|
||||
* Foo_bar(this,args)
|
||||
*
|
||||
* Where Foo is the classname, bar is the member name and the this pointer is
|
||||
* explicitly attached to the beginning.
|
||||
*
|
||||
* The renaming only applies to the member function part, not the full classname.
|
||||
*
|
||||
* Language::cpp_member_func()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||
void Language::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) {
|
||||
char cname[256]; /* Name of the C function */
|
||||
char new_name[256];
|
||||
char *prefix;
|
||||
|
|
@ -154,19 +113,19 @@ void Language::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l
|
|||
if (AddMethods) {
|
||||
char *bc = cplus_base_class(name); /* Get base class name of this method */
|
||||
if (bc)
|
||||
strcpy(cname, Swig_name_member(bc,name));
|
||||
strcpy(cname, Char(Swig_name_member(bc,name)));
|
||||
else
|
||||
strcpy(cname, Swig_name_member(ClassName,name));
|
||||
strcpy(cname, Char(Swig_name_member(ClassName,name)));
|
||||
} else {
|
||||
strcpy(cname, Swig_name_member(ClassName,name));
|
||||
strcpy(cname, Char(Swig_name_member(ClassName,name)));
|
||||
}
|
||||
|
||||
/* Create the actual function name */
|
||||
|
||||
if (iname) {
|
||||
strcpy(new_name, Swig_name_member(prefix,iname));
|
||||
strcpy(new_name, Char(Swig_name_member(prefix,iname)));
|
||||
} else {
|
||||
strcpy(new_name, Swig_name_member(prefix,name));
|
||||
strcpy(new_name, Char(Swig_name_member(prefix,name)));
|
||||
}
|
||||
|
||||
/* Now do a symbol table lookup on it : */
|
||||
|
|
@ -180,14 +139,7 @@ void Language::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_constructor(char *name, char *iname, ParmList *l)
|
||||
*
|
||||
* Method for adding C++ member constructor
|
||||
*
|
||||
* INPUTS:
|
||||
* name - Name of the constructor (usually same as classname)
|
||||
* iname - Renamed version
|
||||
* l - parameters
|
||||
* Language::cpp_constructor()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||
|
|
@ -208,9 +160,9 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
prefix = ClassName;
|
||||
|
||||
if (iname)
|
||||
cname = Swig_name_construct(iname);
|
||||
cname = Char(Swig_name_construct(iname));
|
||||
else
|
||||
cname = Swig_name_construct(prefix);
|
||||
cname = Char(Swig_name_construct(prefix));
|
||||
|
||||
/* Add this function to the SWIG symbol table */
|
||||
|
||||
|
|
@ -227,14 +179,7 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_destructor(char *name, char *iname)
|
||||
*
|
||||
* Method for adding C++ member destructor
|
||||
*
|
||||
* INPUT:
|
||||
* name - Name of the destructor (classname)
|
||||
* iname - Renamed destructor
|
||||
*
|
||||
* Language::cpp_destructor()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_destructor(char *name, char *iname) {
|
||||
|
|
@ -242,9 +187,9 @@ void Language::cpp_destructor(char *name, char *iname) {
|
|||
char *cname;
|
||||
|
||||
if (ClassRename)
|
||||
cname = Swig_name_destroy(ClassRename);
|
||||
cname = Char(Swig_name_destroy(ClassRename));
|
||||
else
|
||||
cname = Swig_name_destroy(ClassName);
|
||||
cname = Char(Swig_name_destroy(ClassName));
|
||||
|
||||
/* Add this function to the SWIG symbol table */
|
||||
|
||||
|
|
@ -262,9 +207,7 @@ void Language::cpp_destructor(char *name, char *iname) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cleanup()
|
||||
*
|
||||
* Perform any necessary cleanup after reaching end of interface file
|
||||
* Language::cleanup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_cleanup() {
|
||||
|
|
@ -274,13 +217,7 @@ void Language::cpp_cleanup() {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_inherit(char **baseclass, int mode)
|
||||
*
|
||||
* Inherit attributes from given baseclass.
|
||||
*
|
||||
* INPUT:
|
||||
* baseclass = NULL terminate list of baseclasses
|
||||
*
|
||||
* Language::cpp_inherit()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_inherit(char **baseclass, int mode) {
|
||||
|
|
@ -296,19 +233,10 @@ void Language::cpp_inherit(char **baseclass, int mode) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_variable(char *name, char *iname, DataType *t)
|
||||
*
|
||||
* Wrap a C++ data member
|
||||
*
|
||||
* INPUTS :
|
||||
* name = Name of the C++ member
|
||||
* iname = Name as used in the interpreter
|
||||
* t = Datatype
|
||||
*
|
||||
* This creates a pair of functions to set/get the variable of a member.
|
||||
* Language::cpp_variable()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_variable(char *name, char *iname, DataType *t) {
|
||||
void Language::cpp_variable(char *name, char *iname, SwigType *t) {
|
||||
char *prefix, *cname;
|
||||
|
||||
/* Set the class prefix */
|
||||
|
|
@ -320,9 +248,9 @@ void Language::cpp_variable(char *name, char *iname, DataType *t) {
|
|||
}
|
||||
|
||||
if (iname)
|
||||
cname = Swig_name_get(Swig_name_member(prefix,iname));
|
||||
cname = Char(Swig_name_get(Swig_name_member(prefix,iname)));
|
||||
else
|
||||
cname = Swig_name_get(Swig_name_member(prefix,name));
|
||||
cname = Char(Swig_name_get(Swig_name_member(prefix,name)));
|
||||
|
||||
/* Check the symbol table */
|
||||
|
||||
|
|
@ -344,18 +272,10 @@ void Language::cpp_variable(char *name, char *iname, DataType *t) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l)
|
||||
*
|
||||
* Wrap a static C++ function
|
||||
*
|
||||
* INPUTS:
|
||||
* name = Real name of the function
|
||||
* iname = New name in interpreter
|
||||
* t = Return datatype
|
||||
* l = Parameters
|
||||
* Language::cpp_static_func()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||
void Language::cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l) {
|
||||
|
||||
char *prefix;
|
||||
char *mname;
|
||||
|
|
@ -375,7 +295,7 @@ void Language::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l
|
|||
else
|
||||
mname = name;
|
||||
|
||||
cname = Swig_name_member(prefix,mname);
|
||||
cname = Char(Swig_name_member(prefix,mname));
|
||||
|
||||
/* Now do a symbol table lookup on it : */
|
||||
|
||||
|
|
@ -393,19 +313,10 @@ void Language::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_declare_const(char *name, char *iname, DataType *t, char *value)
|
||||
*
|
||||
* Create a C++ constant
|
||||
*
|
||||
* INPUTS :
|
||||
* name = Real name of the constant
|
||||
* iname = new name
|
||||
* t = Datatype
|
||||
* value = value as a string
|
||||
*
|
||||
* Language::cpp_declare_const()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_declare_const(char *name, char *iname, DataType *type, char *value)
|
||||
void Language::cpp_declare_const(char *name, char *iname, SwigType *type, char *value)
|
||||
{
|
||||
|
||||
char *cname;
|
||||
|
|
@ -424,9 +335,9 @@ void Language::cpp_declare_const(char *name, char *iname, DataType *type, char *
|
|||
/* Set the constant name */
|
||||
|
||||
if (iname)
|
||||
cname = Swig_name_member(prefix,iname);
|
||||
cname = Char(Swig_name_member(prefix,iname));
|
||||
else
|
||||
cname = Swig_name_member(prefix,name);
|
||||
cname = Char(Swig_name_member(prefix,name));
|
||||
|
||||
/* Now do a symbol table lookup on it : */
|
||||
|
||||
|
|
@ -456,18 +367,10 @@ void Language::cpp_declare_const(char *name, char *iname, DataType *type, char *
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_static_var(char *name, char *iname, DataType *t)
|
||||
*
|
||||
* Wrap a static C++ variable
|
||||
*
|
||||
* INPUT :
|
||||
* name = name of the variable
|
||||
* iname = interpreter name
|
||||
* t = Datatype
|
||||
*
|
||||
* Language::cpp_static_var()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_static_var(char *name, char *iname, DataType *t) {
|
||||
void Language::cpp_static_var(char *name, char *iname, SwigType *t) {
|
||||
|
||||
char *cname;
|
||||
char mname[256];
|
||||
|
|
@ -484,9 +387,9 @@ void Language::cpp_static_var(char *name, char *iname, DataType *t) {
|
|||
/* Create the variable name */
|
||||
|
||||
if (iname)
|
||||
cname = Swig_name_member(prefix,iname);
|
||||
cname = Char(Swig_name_member(prefix,iname));
|
||||
else
|
||||
cname = Swig_name_member(prefix,name);
|
||||
cname = Char(Swig_name_member(prefix,name));
|
||||
|
||||
/* Now do a symbol table lookup on it : */
|
||||
|
||||
|
|
@ -506,21 +409,15 @@ void Language::cpp_static_var(char *name, char *iname, DataType *t) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_class_decl(char *classtype, char *classrename, char *classname)
|
||||
*
|
||||
* A forward class declaration
|
||||
* Language::cpp_class_decl()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_class_decl(char *, char *, char *) {
|
||||
|
||||
/* Does nothing by default */
|
||||
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::cpp_pragma(Pragma *plist)
|
||||
*
|
||||
* Handler C++ pragmas
|
||||
* Language::cpp_pragma()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::cpp_pragma(Pragma *) {
|
||||
|
|
@ -528,45 +425,25 @@ void Language::cpp_pragma(Pragma *) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::add_typedef(DataType *t, char *name)
|
||||
*
|
||||
* Process a typedef declaration.
|
||||
* Language::add_typedef()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::add_typedef(DataType *, char *) {
|
||||
|
||||
void Language::add_typedef(SwigType *, char *) {
|
||||
/* Does nothing by default */
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::pragma(char *target, char *var, char *value)
|
||||
*
|
||||
* A pragma declaration
|
||||
* Language::pragma()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::pragma(char *, char *, char *) {
|
||||
|
||||
/* Does nothing by default */
|
||||
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Language::import(char *filename)
|
||||
*
|
||||
* An import directive
|
||||
* Language::import()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Language::import(char *) {
|
||||
|
||||
/* Does nothing by default */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -129,12 +129,9 @@ static int freeze = 0;
|
|||
int SWIG_main(int argc, char *argv[], Language *l) {
|
||||
int i;
|
||||
char *c;
|
||||
extern FILE *LEX_in;
|
||||
extern char *get_time();
|
||||
char temp[512];
|
||||
char infile[512];
|
||||
char *outfile_name = 0;
|
||||
extern int add_iname(char *);
|
||||
int help = 0;
|
||||
int checkout = 0;
|
||||
int cpp_only = 0;
|
||||
|
|
@ -143,9 +140,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
int includecount = 0;
|
||||
extern int check_suffix(char *);
|
||||
extern void scanner_file(DOHFile *);
|
||||
extern void typemap_initialize(void);
|
||||
extern void parser_init(void);
|
||||
|
||||
extern void typemap_initialize();
|
||||
DOH *libfiles = 0;
|
||||
|
||||
{
|
||||
|
|
@ -166,7 +162,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
lang = l;
|
||||
Status = 0;
|
||||
|
||||
DataType_init_typedef(); // Initialize the type handler
|
||||
// DataType_init_typedef(); // Initialize the type handler
|
||||
|
||||
// Set up some default symbols (available in both SWIG interface files
|
||||
// and C files)
|
||||
|
|
@ -418,6 +414,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
f_init = NewString("");
|
||||
|
||||
// Set up the typemap for handling new return strings
|
||||
#ifdef OLD
|
||||
{
|
||||
DataType *temp_t = NewDataType(T_CHAR);
|
||||
DataType_add_pointer(temp_t);
|
||||
|
|
@ -428,6 +425,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
|
||||
DelDataType(temp_t);
|
||||
}
|
||||
#endif
|
||||
|
||||
// If in Objective-C mode. Load in a configuration file
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -42,8 +42,6 @@ static DOHString *header = 0;
|
|||
static DOHString *comment = 0;
|
||||
DOHString *CCode = 0; // String containing C code
|
||||
static char *yybuffer = 0;
|
||||
static int lex_pos = 0;
|
||||
static int lex_len = 0;
|
||||
|
||||
static char yytext[YYBSIZE];
|
||||
static int yylen = 0;
|
||||
|
|
@ -425,6 +423,10 @@ int yylook(void) {
|
|||
else if (c == '0') state = 83; // An octal or hex value
|
||||
else if (c == '\'') state = 9; // A character constant
|
||||
else if (c == '.') state = 100; // Maybe a number, maybe just a period
|
||||
else if (c == '`') {
|
||||
state = 200; // Back-tick type
|
||||
yylen = 0;
|
||||
}
|
||||
else if (isdigit(c)) state = 8; // A numerical value
|
||||
else if ((isalpha(c)) || (c == '_') || (c == '$')) state = 7;
|
||||
else state = 99;
|
||||
|
|
@ -779,6 +781,15 @@ int yylook(void) {
|
|||
return(PERIOD);
|
||||
}
|
||||
break;
|
||||
case 200:
|
||||
if ((c = nextchar()) == 0) return (0);
|
||||
if (c == '`') {
|
||||
yytext[yylen-1] = 0;
|
||||
yylval.type = NewString(yytext);
|
||||
return(TYPE_RAW);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!Error) {
|
||||
Printf(stderr,"%s : Line %d ::Illegal character '%c'=%d.\n",input_file, line_number,c,c);
|
||||
|
|
@ -838,45 +849,43 @@ extern "C" int yylex(void) {
|
|||
/* Look for keywords now */
|
||||
|
||||
if (strcmp(yytext,"int") == 0) {
|
||||
yylval.type = NewDataType(T_INT);
|
||||
yylval.type = NewSwigType(T_INT);
|
||||
return(TYPE_INT);
|
||||
}
|
||||
if (strcmp(yytext,"double") == 0) {
|
||||
yylval.type = NewDataType(T_DOUBLE);
|
||||
yylval.type = NewSwigType(T_DOUBLE);
|
||||
return(TYPE_DOUBLE);
|
||||
}
|
||||
if (strcmp(yytext,"void") == 0) {
|
||||
yylval.type = NewDataType(T_VOID);
|
||||
yylval.type = NewSwigType(T_VOID);
|
||||
return(TYPE_VOID);
|
||||
}
|
||||
if (strcmp(yytext,"char") == 0) {
|
||||
yylval.type = NewDataType(T_CHAR);
|
||||
yylval.type = NewSwigType(T_CHAR);
|
||||
return(TYPE_CHAR);
|
||||
}
|
||||
if (strcmp(yytext,"short") == 0) {
|
||||
yylval.type = NewDataType(T_SHORT);
|
||||
yylval.type = NewSwigType(T_SHORT);
|
||||
return(TYPE_SHORT);
|
||||
}
|
||||
if (strcmp(yytext,"long") == 0) {
|
||||
yylval.type = NewDataType(T_LONG);
|
||||
yylval.type = NewSwigType(T_LONG);
|
||||
return(TYPE_LONG);
|
||||
}
|
||||
if (strcmp(yytext,"float") == 0) {
|
||||
yylval.type = NewDataType(T_FLOAT);
|
||||
yylval.type = NewSwigType(T_FLOAT);
|
||||
return(TYPE_FLOAT);
|
||||
}
|
||||
if (strcmp(yytext,"signed") == 0) {
|
||||
yylval.type = NewDataType(T_INT);
|
||||
DataType_Setname(yylval.type,yytext);
|
||||
yylval.type = NewSwigType(T_INT);
|
||||
return(TYPE_SIGNED);
|
||||
}
|
||||
if (strcmp(yytext,"unsigned") == 0) {
|
||||
yylval.type = NewDataType(T_UINT);
|
||||
DataType_Setname(yylval.type,yytext);
|
||||
yylval.type = NewSwigType(T_UINT);
|
||||
return(TYPE_UNSIGNED);
|
||||
}
|
||||
if (strcmp(yytext,"bool") == 0) {
|
||||
yylval.type = NewDataType(T_BOOL);
|
||||
yylval.type = NewSwigType(T_BOOL);
|
||||
return(TYPE_BOOL);
|
||||
}
|
||||
// C++ keywords
|
||||
|
|
@ -993,10 +1002,8 @@ extern "C" int yylex(void) {
|
|||
// do a typedef lookup on it.
|
||||
|
||||
if (check_typedef) {
|
||||
if (DataType_is_typedef(yytext)) {
|
||||
yylval.type = NewDataType(T_USER);
|
||||
DataType_Setname(yylval.type,yytext);
|
||||
DataType_typedef_resolve(yylval.type,0);
|
||||
if (SwigType_istypedef(yytext)) {
|
||||
yylval.type = NewString(yytext);
|
||||
return(TYPE_TYPEDEF);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,21 +149,21 @@ struct Pragma {
|
|||
* Open a new C++ class definition.
|
||||
* cpp_close_class(char *)
|
||||
* Close current C++ class
|
||||
* cpp_member_func(char *name, char *rname, DataType *rt, ParmList *l)
|
||||
* cpp_member_func(char *name, char *rname, SwigType *rt, ParmList *l)
|
||||
* Create a C++ member function
|
||||
* cpp_constructor(char *name, char *iname, ParmList *l)
|
||||
* Create a C++ constructor.
|
||||
* cpp_destructor(char *name, char *iname)
|
||||
* Create a C++ destructor
|
||||
* cpp_variable(char *name, char *iname, DataType *t)
|
||||
* cpp_variable(char *name, char *iname, SwigType *t)
|
||||
* Create a C++ member data item.
|
||||
* cpp_declare_const(char *name, char *iname, int type, char *value)
|
||||
* Create a C++ constant.
|
||||
* cpp_inherit(char *baseclass)
|
||||
* Inherit data from baseclass.
|
||||
* cpp_static_func(char *name, char *iname, DataType *t, ParmList *l)
|
||||
* cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l)
|
||||
* A C++ static member function.
|
||||
* cpp_static_var(char *name, char *iname, DataType *t)
|
||||
* cpp_static_var(char *name, char *iname, SwigType *t)
|
||||
* A C++ static member data variable.
|
||||
*
|
||||
*************************************************************************/
|
||||
|
|
@ -172,16 +172,16 @@ class Language {
|
|||
public:
|
||||
virtual void parse_args(int argc, char *argv[]) = 0;
|
||||
virtual void parse() = 0;
|
||||
virtual void create_function(char *, char *, DataType *, ParmList *) = 0;
|
||||
virtual void link_variable(char *, char *, DataType *) = 0;
|
||||
virtual void declare_const(char *, char *, DataType *, char *) = 0;
|
||||
virtual void create_function(char *, char *, SwigType *, ParmList *) = 0;
|
||||
virtual void link_variable(char *, char *, SwigType *) = 0;
|
||||
virtual void declare_const(char *, char *, SwigType *, char *) = 0;
|
||||
virtual void initialize(void) = 0;
|
||||
virtual void headers(void) = 0;
|
||||
virtual void close(void) = 0;
|
||||
virtual void set_module(char *mod_name,char **mod_list) = 0;
|
||||
virtual void set_init(char *init_name);
|
||||
virtual void add_native(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void add_typedef(DataType *t, char *name);
|
||||
virtual void add_native(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void add_typedef(SwigType *t, char *name);
|
||||
virtual void create_command(char *cname, char *iname);
|
||||
|
||||
//
|
||||
|
|
@ -189,17 +189,17 @@ public:
|
|||
// You can redefine these, or use the defaults below
|
||||
//
|
||||
|
||||
virtual void cpp_member_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void cpp_constructor(char *name, char *iname, ParmList *l);
|
||||
virtual void cpp_destructor(char *name, char *newname);
|
||||
virtual void cpp_open_class(char *name, char *rename, char *ctype, int strip);
|
||||
virtual void cpp_close_class();
|
||||
virtual void cpp_cleanup();
|
||||
virtual void cpp_inherit(char **baseclass, int mode = INHERIT_ALL);
|
||||
virtual void cpp_variable(char *name, char *iname, DataType *t);
|
||||
virtual void cpp_static_func(char *name, char *iname, DataType *t, ParmList *l);
|
||||
virtual void cpp_declare_const(char *name, char *iname, DataType *type, char *value);
|
||||
virtual void cpp_static_var(char *name, char *iname, DataType *t);
|
||||
virtual void cpp_variable(char *name, char *iname, SwigType *t);
|
||||
virtual void cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l);
|
||||
virtual void cpp_declare_const(char *name, char *iname, SwigType *type, char *value);
|
||||
virtual void cpp_static_var(char *name, char *iname, SwigType *t);
|
||||
virtual void cpp_pragma(Pragma *plist);
|
||||
|
||||
// Pragma directive
|
||||
|
|
@ -218,8 +218,8 @@ public:
|
|||
|
||||
/* Emit functions */
|
||||
|
||||
extern void emit_func_call(char *, DataType *, ParmList *, FILE *);
|
||||
extern void emit_set_get(char *, char *, DataType *);
|
||||
extern void emit_func_call(char *, SwigType *, ParmList *, FILE *);
|
||||
extern void emit_set_get(char *, char *, SwigType *);
|
||||
extern void emit_set_action(DOHString_or_char *decl);
|
||||
|
||||
extern int SWIG_main(int, char **, Language *);
|
||||
|
|
@ -227,11 +227,11 @@ extern int SWIG_main(int, char **, Language *);
|
|||
// Some functions for emitting some C++ helper code
|
||||
|
||||
extern void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
||||
char *mname, char *mrename, DataType *type, ParmList *l,
|
||||
char *mname, char *mrename, SwigType *type, ParmList *l,
|
||||
int mode);
|
||||
|
||||
extern void cplus_emit_static_func(char *classname, char *classtype, char *classrename,
|
||||
char *mname, char *mrename, DataType *type, ParmList *l,
|
||||
char *mname, char *mrename, SwigType *type, ParmList *l,
|
||||
int mode);
|
||||
|
||||
extern void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
||||
|
|
@ -241,10 +241,10 @@ extern void cplus_emit_constructor(char *classname, char *classtype, char *class
|
|||
char *name, char *iname, ParmList *l, int mode);
|
||||
|
||||
extern void cplus_emit_variable_get(char *classname, char *classtype, char *classrename,
|
||||
char *name, char *iname, DataType *type, int mode);
|
||||
char *name, char *iname, SwigType *type, int mode);
|
||||
|
||||
extern void cplus_emit_variable_set(char *classname, char *classtype, char *classrename,
|
||||
char *name, char *iname, DataType *type, int mode);
|
||||
char *name, char *iname, SwigType *type, int mode);
|
||||
|
||||
extern char *cplus_base_class(char *name);
|
||||
|
||||
|
|
@ -264,24 +264,22 @@ extern "C" {
|
|||
|
||||
// Misc
|
||||
|
||||
extern int emit_args(DataType *, ParmList *, Wrapper *f);
|
||||
extern void emit_func_call(char *, DataType *, ParmList *, Wrapper *f);
|
||||
extern int emit_args(SwigType *, ParmList *, Wrapper *f);
|
||||
extern void emit_func_call(char *, SwigType *, ParmList *, Wrapper *f);
|
||||
extern void SWIG_exit(int);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Typemap support
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
extern void typemap_register(char *op, char *lang, DataType *type, char *pname, char *code, ParmList *l = 0);
|
||||
extern void typemap_register(char *op, char *lang, char *type, char *pname, char *code,ParmList *l = 0);
|
||||
extern void typemap_register_default(char *op, char *lang, int type, int ptr, char *arraystr, char *code, ParmList *l = 0);
|
||||
extern char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *source, char *target,
|
||||
Wrapper *f = 0);
|
||||
extern void typemap_clear(char *op, char *lang, DataType *type, char *pname);
|
||||
extern void typemap_copy(char *op, char *lang, DataType *stype, char *sname, DataType *ttype, char *tname);
|
||||
extern char *typemap_check(char *op, char *lang, DataType *type, char *pname);
|
||||
extern void typemap_apply(DataType *tm_type, char *tmname, DataType *type, char *pname);
|
||||
extern void typemap_clear_apply(DataType *type, char *pname);
|
||||
#ifndef OLD
|
||||
extern void typemap_register(char *op, char *lang, SwigType *type, String_or_char *pname, String_or_char *code, ParmList *l = 0);
|
||||
extern char *typemap_lookup(char *op, char *lang, SwigType *type, String_or_char *pname, String_or_char *source, String_or_char *target, Wrapper *f = 0);
|
||||
extern void typemap_clear(char *op, char *lang, SwigType *type, String_or_char *pname);
|
||||
extern void typemap_copy(char *op, char *lang, SwigType *stype, String_or_char *sname,
|
||||
SwigType *ttype, String_or_char *tname);
|
||||
extern char *typemap_check(char *op, char *lang, SwigType *type, String_or_char *pname);
|
||||
extern void typemap_apply(SwigType *tm_type, String_or_char *tmname, SwigType *type, String_or_char *pname);
|
||||
extern void typemap_clear_apply(SwigType *type, String_or_char *pname);
|
||||
extern int check_numopt(ParmList *);
|
||||
|
||||
|
||||
|
|
@ -289,8 +287,26 @@ extern int check_numopt(ParmList *);
|
|||
// Code fragment support
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
extern void fragment_register(char *op, char *lang, char *code);
|
||||
extern char *fragment_lookup(char *op, char *lang, int age);
|
||||
extern void fragment_register(char *op, char *lang, String_or_char *code);
|
||||
extern char *fragment_lookup(char *op, char *lang);
|
||||
extern void fragment_clear(char *op, char *lang);
|
||||
|
||||
#else
|
||||
|
||||
#define typemap_register(op,lang,type,pname,code,l)
|
||||
#define typemap_register_default(op,lang,type,ptr,arraystr,code,l)
|
||||
#define typemap_lookup(op,lang,type,pname,source,target,f) 0
|
||||
|
||||
#define typemap_clear(op,lang,type,pname)
|
||||
#define typemap_copy(op,lang,stype,sname,ttype,tname)
|
||||
#define typemap_check(op,lang,type,pname) 0
|
||||
#define typemap_apply(tm,tmname,type,pname)
|
||||
#define typemap_clear_apply(type,pname)
|
||||
#define check_numopt(l) ParmList_len(l)
|
||||
#define fragment_register(op,lang,code)
|
||||
#define fragment_lookup(op,lang,age) 0
|
||||
#define fragment_clear(op,lang)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,11 +65,13 @@ extern "C" {
|
|||
|
||||
static ParmList *last_args = 0;
|
||||
|
||||
int type_id = 0;
|
||||
|
||||
/* Structure for holding a typemap */
|
||||
|
||||
struct TypeMap {
|
||||
char *lang;
|
||||
DataType *type;
|
||||
SwigType *type;
|
||||
DOHString *code;
|
||||
int first;
|
||||
int last;
|
||||
|
|
@ -77,9 +79,9 @@ struct TypeMap {
|
|||
TypeMap *previous; /* Previously defined typemap (if any) */
|
||||
ParmList *args; /* Local variables (if any) */
|
||||
|
||||
TypeMap(char *l, DataType *t, char *c, ParmList *p = 0) {
|
||||
TypeMap(char *l, SwigType *t, String_or_char *c, ParmList *p = 0) {
|
||||
lang = Swig_copy_string(l);
|
||||
type = CopyDataType(t);
|
||||
type = Copy(t);
|
||||
code = NewString(c);
|
||||
first = type_id;
|
||||
last = INT_MAX;
|
||||
|
|
@ -91,7 +93,7 @@ struct TypeMap {
|
|||
args = 0;
|
||||
}
|
||||
}
|
||||
TypeMap(char *l, char *c) {
|
||||
TypeMap(char *l, String_or_char *c) {
|
||||
lang = Swig_copy_string(l);
|
||||
type = 0;
|
||||
code = NewString(c);
|
||||
|
|
@ -103,7 +105,7 @@ struct TypeMap {
|
|||
}
|
||||
TypeMap(TypeMap *t) {
|
||||
lang = Swig_copy_string(t->lang);
|
||||
type = CopyDataType(t->type);
|
||||
type = Copy(t->type);
|
||||
code = Copy(t->code);
|
||||
first = type_id;
|
||||
last = INT_MAX;
|
||||
|
|
@ -124,14 +126,14 @@ static DOH *typemap_hash = 0;
|
|||
/* Structure for holding "applications of a typemap" */
|
||||
|
||||
struct TmMethod {
|
||||
char *name; /* Typemap name; */
|
||||
DataType *type; /* Typemap type */
|
||||
String *name; /* Typemap name; */
|
||||
SwigType *type; /* Typemap type */
|
||||
TmMethod *next; /* Next method */
|
||||
TmMethod(char *n, DataType *t, TmMethod *m = 0) {
|
||||
if (n) name = Swig_copy_string(n);
|
||||
TmMethod(String *n, SwigType *t, TmMethod *m = 0) {
|
||||
if (n) name = Copy(n);
|
||||
else name = 0;
|
||||
if (t) {
|
||||
type = CopyDataType(t);
|
||||
type = Copy(t);
|
||||
} else {
|
||||
type = 0;
|
||||
}
|
||||
|
|
@ -150,13 +152,13 @@ static DOH *application_hash = 0;
|
|||
* Called by the %apply directive.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname) {
|
||||
void typemap_apply(SwigType *tm_type, String_or_char *tm_name, SwigType *type, String_or_char *pname) {
|
||||
TmMethod *m,*m1;
|
||||
char temp[512];
|
||||
String *temp;
|
||||
|
||||
/* Form the application name */
|
||||
if (!pname) pname = (char*)"";
|
||||
sprintf(temp,"%s$%s",DataType_str(type,0),pname);
|
||||
if (!pname) pname = (String_or_char*)"";
|
||||
temp = NewStringf("%s$%s",SwigType_str(type,0),pname);
|
||||
|
||||
/* See if there is a method already defined */
|
||||
|
||||
|
|
@ -168,26 +170,27 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
|
|||
SetVoid(application_hash,temp,m);
|
||||
}
|
||||
|
||||
Delete(temp);
|
||||
|
||||
/* Check to see if an array typemap has been applied to a non-array type */
|
||||
|
||||
if ((DataType_arraystr(tm_type)) && (!DataType_arraystr(type))) {
|
||||
if ((SwigType_isarray(tm_type)) && (!SwigType_isarray(type))) {
|
||||
Printf(stderr,"%s:%d: Warning. Array typemap has been applied to a non-array type.\n",
|
||||
input_file,line_number);
|
||||
}
|
||||
|
||||
/* If both are arrays, make sure they have the same dimension */
|
||||
|
||||
if ((DataType_arraystr(tm_type)) && (DataType_arraystr(type))) {
|
||||
char s[128],*t;
|
||||
if (DataType_array_dimensions(tm_type) != DataType_array_dimensions(type)) {
|
||||
if ((SwigType_isarray(tm_type)) && (SwigType_isarray(type))) {
|
||||
if (SwigType_array_ndim(tm_type) != SwigType_array_ndim(type)) {
|
||||
Printf(stderr,"%s:%d: Warning. Array types have different number of dimensions.\n",
|
||||
input_file,line_number);
|
||||
} else {
|
||||
for (int i = 0; i < DataType_array_dimensions(tm_type); i++) {
|
||||
strcpy(s,DataType_get_dimension(tm_type,i));
|
||||
t = DataType_get_dimension(type,i);
|
||||
if (strcmp(s,"ANY") != 0) {
|
||||
if (strcmp(s,t))
|
||||
for (int i = 0; i < SwigType_array_ndim(tm_type); i++) {
|
||||
String *s1 = SwigType_array_getdim(tm_type,i);
|
||||
String *s2 = SwigType_array_getdim(type,i);
|
||||
if (Cmp(s1,"") != 0) {
|
||||
if (Cmp(s1,s2))
|
||||
Printf(stderr,"%s:%d: Warning. Array typemap applied to an array of different size.\n",
|
||||
input_file, line_number);
|
||||
}
|
||||
|
|
@ -196,49 +199,38 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
|
|||
}
|
||||
|
||||
/* Add a new mapping corresponding to the typemap */
|
||||
|
||||
m1 = new TmMethod(tm_name,tm_type,m->next);
|
||||
m->next = m1;
|
||||
|
||||
}
|
||||
/* ------------------------------------------------------------------------
|
||||
* void typemap_clear_apply(DataType *type, char *pname)
|
||||
* void typemap_clear_apply(SwigType *type, char *pname)
|
||||
*
|
||||
* Clears the application of a typemap.
|
||||
* Called by the %clear directive.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
void typemap_clear_apply(DataType *type, char *pname) {
|
||||
char temp[512];
|
||||
if (!pname) pname = (char*)"";
|
||||
sprintf(temp,"%s$%s", DataType_str(type,0), pname);
|
||||
void typemap_clear_apply(SwigType *type, String_or_char *pname) {
|
||||
String *temp;
|
||||
if (!pname) pname = (String_or_char*)"";
|
||||
temp = NewStringf("%s$%s", SwigType_str(type,0), pname);
|
||||
if (!application_hash) application_hash = NewHash();
|
||||
Delattr(application_hash,temp);
|
||||
Delete(temp);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* char *typemap_string(char *lang, DataType *type, char *pname, char *ary, char *suffix)
|
||||
* char *typemap_string(char *lang, DataType *type, char *pname, char *suffix)
|
||||
*
|
||||
* Produces a character string corresponding to a lang, datatype, and
|
||||
* method. This string is used as the key for our typemap hash table.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
static char *typemap_string(char *lang, DataType *type, char *pname, char *ary, char *suffix) {
|
||||
static DOHString *str = 0;
|
||||
|
||||
int old_status;
|
||||
if (!str) str = NewString("");
|
||||
old_status = type->_status;
|
||||
type->_status = 0;
|
||||
Clear(str);
|
||||
|
||||
if (ary)
|
||||
Printv(str, lang, DataType_str(type,0), pname, ary, suffix, 0);
|
||||
else
|
||||
Printv(str, lang, DataType_str(type,0), pname, suffix,0);
|
||||
|
||||
type->_status = old_status;
|
||||
return Char(str);
|
||||
static String *typemap_string(char *op, char *lang, SwigType *type, String_or_char *pname) {
|
||||
String *str;
|
||||
str = NewStringf("%s-%s-%s",op,lang,SwigType_str(type,pname));
|
||||
/* Printf(stdout,"key: %s\n", str); */
|
||||
return Swig_temp_result(str);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
|
@ -248,69 +240,47 @@ static char *typemap_string(char *lang, DataType *type, char *pname, char *ary,
|
|||
* Register a new mapping with the type-mapper.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
||||
char *getcode, ParmList *args) {
|
||||
void typemap_register(char *op, char *lang, SwigType *type, String_or_char *pname,
|
||||
String_or_char *getcode, ParmList *args) {
|
||||
|
||||
char *key;
|
||||
TypeMap *tm,*tm_old;
|
||||
char temp[256];
|
||||
String *key;
|
||||
TypeMap *tm, *tm_old;
|
||||
int is_default = 0;
|
||||
|
||||
/* printf("Registering : %s %s %s %s\n%s\n", op, lang, DataType_print_type(type), pname, getcode); */
|
||||
|
||||
if (!typemap_hash) typemap_hash = NewHash();
|
||||
|
||||
|
||||
tm = new TypeMap(lang,type,getcode,args);
|
||||
/* If this is a default typemap, downgrade the type! */
|
||||
|
||||
if (strcmp(pname,"SWIG_DEFAULT_TYPE") == 0) {
|
||||
DataType_primitive(tm->type);
|
||||
if (Cmp(pname,"SWIG_DEFAULT_TYPE") == 0) {
|
||||
tm->type = SwigType_default(tm->type);
|
||||
is_default = 1;
|
||||
}
|
||||
|
||||
key = typemap_string(lang,tm->type,pname,DataType_arraystr(tm->type), op);
|
||||
key = typemap_string(op,lang,tm->type,pname);
|
||||
|
||||
/* Get any previous setting of the typemap */
|
||||
|
||||
tm_old = (TypeMap *) GetVoid(typemap_hash,key);
|
||||
|
||||
tm_old = (TypeMap *) GetVoid(typemap_hash, key);
|
||||
if (tm_old) {
|
||||
|
||||
/* Perform a chaining operation, but only if the last typemap is active. */
|
||||
|
||||
if (type_id < tm_old->last) {
|
||||
sprintf(temp,"$%s",op);
|
||||
Replace(tm->code,temp,tm_old->code, DOH_REPLACE_ANY);
|
||||
}
|
||||
|
||||
/* If found, we need to attach the old version to the new one */
|
||||
|
||||
tm->previous = tm_old;
|
||||
tm->next = tm_old;
|
||||
tm_old->last = type_id;
|
||||
|
||||
/* Remove the old one from the hash */
|
||||
|
||||
Delattr(typemap_hash,key);
|
||||
}
|
||||
|
||||
/* Add new typemap to the hash table */
|
||||
SetVoid(typemap_hash,key,tm);
|
||||
|
||||
/* Now try to perform default chaining operation (if available)
|
||||
* if (!is_default) {
|
||||
* sprintf(temp,"$%s",op);
|
||||
* if (strstr(tm->code,temp)) {
|
||||
* tm->code.replace(temp,typemap_resolve_default(op,lang,type));
|
||||
* }
|
||||
* } */
|
||||
|
||||
/* Just a sanity check to make sure args look okay. */
|
||||
|
||||
if (args) {
|
||||
Parm *p = tm->args;
|
||||
while (p) {
|
||||
char *pn = Getname(p);
|
||||
String *pn = Getname(p);
|
||||
if (pn) {
|
||||
/* printf(" %s %s\n", pt,pn); */
|
||||
} else {
|
||||
|
|
@ -322,50 +292,6 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* void typemap_register(char *op, char *lang, char *type, char *pname,
|
||||
* char *getcode, ParmList *args)
|
||||
*
|
||||
* Register a new mapping with the type-mapper. Special version that uses a
|
||||
* string instead of a datatype.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
void typemap_register(char *op, char *lang, char *type, char *pname,
|
||||
char *getcode, ParmList *args) {
|
||||
DataType *temp;
|
||||
temp = NewDataType(0);
|
||||
DataType_Setname(temp,type);
|
||||
DataType_Settypecode(temp,T_USER);
|
||||
typemap_register(op,lang,temp,pname,getcode,args);
|
||||
DelDataType(temp);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* void typemap_register_default(char *op, char *lang, int type, int ptr, char *arraystr,
|
||||
* char *code, ParmList *args)
|
||||
*
|
||||
* Registers a default typemap with the system using numerical type codes.
|
||||
* type is the numerical code, ptr is the level of indirection.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
void typemap_register_default(char *op, char *lang, int type, int ptr, char *arraystr,
|
||||
char *code, ParmList *args) {
|
||||
|
||||
DataType *t = NewDataType(type);
|
||||
|
||||
/* Create a raw datatype from the arguments */
|
||||
|
||||
t->_is_pointer = ptr;
|
||||
DataType_set_arraystr(t,arraystr);
|
||||
|
||||
/* Now, go register this as a default type */
|
||||
|
||||
typemap_register(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",code,args);
|
||||
DelDataType(t);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* static TypeMap *typemap_search(char *key, int id)
|
||||
*
|
||||
|
|
@ -377,10 +303,9 @@ void typemap_register_default(char *op, char *lang, int type, int ptr, char *arr
|
|||
* handle scoping problems.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
TypeMap *typemap_search(char *key, int id) {
|
||||
|
||||
static TypeMap *
|
||||
typemap_search(String_or_char *key, int id) {
|
||||
TypeMap *tm;
|
||||
|
||||
if (!typemap_hash) typemap_hash = NewHash();
|
||||
tm = (TypeMap *) GetVoid(typemap_hash,key);
|
||||
while (tm) {
|
||||
|
|
@ -399,69 +324,64 @@ TypeMap *typemap_search(char *key, int id) {
|
|||
* substituted.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
TypeMap *typemap_search_array(char *op, char *lang, DataType *type, char *pname, DOHString *str) {
|
||||
char origarr[1024];
|
||||
char *key;
|
||||
static
|
||||
TypeMap *typemap_search_array(char *op, char *lang, SwigType *type, String_or_char *pname, DOHString *str) {
|
||||
SwigType *atype;
|
||||
String *key;
|
||||
int ndim,i,j,k,n;
|
||||
TypeMap *tm;
|
||||
char temp[10];
|
||||
|
||||
if (!DataType_arraystr(type)) return 0;
|
||||
if (!SwigType_isarray(type)) return 0;
|
||||
|
||||
strcpy(origarr,DataType_arraystr(type));
|
||||
/* First check to see if exactly this array has been mapped */
|
||||
|
||||
key = typemap_string(lang,type,pname,DataType_arraystr(type),op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
key = typemap_string(op,lang,type,pname);
|
||||
tm = typemap_search(key,type_id);
|
||||
|
||||
/* Check for unnamed array of specific dimensions */
|
||||
if (!tm) {
|
||||
key = typemap_string(lang,type,(char*)"",DataType_arraystr(type),op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
key = typemap_string(op,lang,type,(char*)"");
|
||||
tm = typemap_search(key,type_id);
|
||||
}
|
||||
|
||||
if (!tm) {
|
||||
/* We're going to go search for matches with the ANY tag */
|
||||
DOHString *tempastr = NewString("");
|
||||
ndim = DataType_array_dimensions(type); /* Get number of dimensions */
|
||||
ndim = SwigType_array_ndim(type); /* Get number of dimensions */
|
||||
j = (1 << ndim) - 1; /* Status bits */
|
||||
for (i = 0; i < (1 << ndim); i++) {
|
||||
/* Form an array string */
|
||||
Clear(tempastr);
|
||||
atype = Copy(type);
|
||||
k = j;
|
||||
for (n = 0; n < ndim; n++) {
|
||||
if (k & 1) {
|
||||
Printf(tempastr,"[%s]",DataType_get_dimension(type,n));
|
||||
} else {
|
||||
Printf(tempastr,"[ANY]");
|
||||
if (!(k & 1)) {
|
||||
SwigType_array_setdim(atype,n,"ANY");
|
||||
}
|
||||
k = k >> 1;
|
||||
}
|
||||
DataType_set_arraystr(type, Char(tempastr));
|
||||
key = typemap_string(lang,type,pname,DataType_arraystr(type),op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
key = typemap_string(op,lang,type,pname);
|
||||
tm = typemap_search(key,type_id);
|
||||
if (!tm) {
|
||||
key = typemap_string(lang,type,(char*)"",DataType_arraystr(type),op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
key = typemap_string(op,lang,type,(char*)"");
|
||||
tm = typemap_search(key,type_id);
|
||||
}
|
||||
DataType_set_arraystr(type,origarr);
|
||||
if (tm) {
|
||||
Delete(tempastr);
|
||||
Delete(atype);
|
||||
break;
|
||||
}
|
||||
j--;
|
||||
}
|
||||
Delete(tempastr);
|
||||
Delete(atype);
|
||||
}
|
||||
|
||||
if (tm) {
|
||||
Printf(str,"%s",tm->code);
|
||||
ndim = DataType_array_dimensions(type);
|
||||
ndim = SwigType_array_ndim(type);
|
||||
sprintf(temp,"%d",ndim);
|
||||
Replace(str,"$ndim",temp, DOH_REPLACE_ANY);
|
||||
for (i = 0; i < ndim; i++) {
|
||||
sprintf(temp,"$dim%d",i);
|
||||
Replace(str,temp,DataType_get_dimension(type,i), DOH_REPLACE_ANY);
|
||||
Replace(str,temp,SwigType_array_getdim(type,i), DOH_REPLACE_ANY);
|
||||
}
|
||||
}
|
||||
return tm;
|
||||
|
|
@ -476,54 +396,37 @@ TypeMap *typemap_search_array(char *op, char *lang, DataType *type, char *pname,
|
|||
* Substitutes locals in the string with actual values used.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l, Wrapper *f) {
|
||||
static void typemap_locals(SwigType *t, String_or_char *pname, DOHString *s, ParmList *l, Wrapper *f) {
|
||||
Parm *p;
|
||||
char *new_name;
|
||||
|
||||
p = l;
|
||||
while (p) {
|
||||
DataType *pt = Gettype(p);
|
||||
char *pn = Getname(p);
|
||||
SwigType *pt = Gettype(p);
|
||||
String *pn = Getname(p);
|
||||
if (pn) {
|
||||
if (strlen(pn) > 0) {
|
||||
if (Len(pn) > 0) {
|
||||
DOHString *str;
|
||||
DataType *tt;
|
||||
SwigType *tt;
|
||||
|
||||
str = NewString("");
|
||||
/* If the user gave us $type as the name of the local variable, we'll use
|
||||
the passed datatype instead */
|
||||
|
||||
if (strcmp(pn,"$type")==0 || strcmp(DataType_Getname(pt),"$basetype")==0) {
|
||||
if (Cmp(SwigType_base(pt),"$type")==0 || Cmp(SwigType_base(pt),"$basetype")==0) {
|
||||
tt = t;
|
||||
} else {
|
||||
tt = pt;
|
||||
}
|
||||
|
||||
/* Have a real parameter here */
|
||||
if (DataType_arraystr(tt)) {
|
||||
DataType_del_pointer(tt);
|
||||
Printf(str,"%s%s",pn, DataType_arraystr(tt));
|
||||
}
|
||||
else {
|
||||
Printf(str,"%s",pn);
|
||||
}
|
||||
|
||||
Printf(str,"%s",pn);
|
||||
/* Substitute parameter names */
|
||||
Replace(str,"$arg",pname, DOH_REPLACE_ANY);
|
||||
if (strcmp(DataType_Getname(pt),"$basetype")==0) {
|
||||
if (Cmp(SwigType_base(pt),"$basetype")==0) {
|
||||
/* use $basetype */
|
||||
char temp_ip = tt->_is_pointer;
|
||||
char temp_ip1 = tt->_implicit_ptr;
|
||||
tt->_is_pointer = 0;
|
||||
tt->_implicit_ptr = 0;
|
||||
new_name = Wrapper_new_localv(f,str, DataType_str(tt,0), str, 0);
|
||||
tt->_is_pointer = temp_ip;
|
||||
tt->_implicit_ptr = temp_ip1;
|
||||
}
|
||||
else
|
||||
new_name = Wrapper_new_localv(f,str, DataType_str(tt,str), 0);
|
||||
|
||||
if (DataType_arraystr(tt)) tt->_is_pointer++;
|
||||
new_name = Wrapper_new_localv(f,str,SwigType_base(tt),str,0);
|
||||
} else {
|
||||
new_name = Wrapper_new_localv(f,str, SwigType_str(tt,str), 0);
|
||||
}
|
||||
/* Substitute */
|
||||
Replace(s,pn,new_name,DOH_REPLACE_ID);
|
||||
}
|
||||
|
|
@ -533,14 +436,13 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
|||
/* If the original datatype was an array. We're going to go through and substitute
|
||||
it's array dimensions */
|
||||
|
||||
if (DataType_arraystr(t)) {
|
||||
if (SwigType_isarray(t)) {
|
||||
char temp[10];
|
||||
for (int i = 0; i < DataType_array_dimensions(t); i++) {
|
||||
for (int i = 0; i < SwigType_array_ndim(t); i++) {
|
||||
sprintf(temp,"$dim%d",i);
|
||||
Replace(f->locals,temp,DataType_get_dimension(t,i), DOH_REPLACE_ANY);
|
||||
Replace(f->locals,temp,SwigType_array_getdim(t,i), DOH_REPLACE_ANY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
|
@ -577,84 +479,66 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
|
|||
* Array dimensions are substituted into the variables $dim1, $dim2,...,$dim9
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
static DataType *realtype; /* This is a gross hack */
|
||||
static char *realname = 0; /* Real parameter name */
|
||||
static SwigType *realtype; /* This is a gross hack */
|
||||
static String *realname = 0; /* Real parameter name */
|
||||
|
||||
char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname, char *source,
|
||||
char *target, Wrapper *f) {
|
||||
static DOHString *str = 0;
|
||||
char *key = 0;
|
||||
static char *typemap_lookup_internal(char *op, char *lang, SwigType *type, String_or_char *pname,
|
||||
String_or_char *source, String_or_char *target, Wrapper *f) {
|
||||
String *str = 0;
|
||||
String *key = 0;
|
||||
TypeMap *tm = 0;
|
||||
|
||||
last_args = 0;
|
||||
if (!str) str = NewString("");
|
||||
if (!lang) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
str = NewString("");
|
||||
/* First check for named array */
|
||||
Clear(str);
|
||||
tm = typemap_search_array(op,lang,type,pname,str);
|
||||
|
||||
/* Check for named argument */
|
||||
if (!tm) {
|
||||
key = typemap_string(lang,type,pname,0,op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
key = typemap_string(op,lang,type,pname);
|
||||
tm = typemap_search(key,type_id);
|
||||
if (tm)
|
||||
Printf(str,"%s",tm->code);
|
||||
}
|
||||
|
||||
/* Check for unnamed type */
|
||||
if (!tm) {
|
||||
key = typemap_string(lang,type,(char*)"",0,op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
key = typemap_string(op,lang,type,(char*)"");
|
||||
tm = typemap_search(key,type_id);
|
||||
if (tm)
|
||||
Printf(str,"%s", tm->code);
|
||||
}
|
||||
if (!tm) return 0;
|
||||
if (!tm) {
|
||||
Delete(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Now perform character replacements */
|
||||
|
||||
Replace(str,"$source",source,DOH_REPLACE_ANY);
|
||||
Replace(str,"$target",target,DOH_REPLACE_ANY);
|
||||
Replace(str,"$type",DataType_str(realtype,0),DOH_REPLACE_ANY);
|
||||
Replace(str,"$type",SwigType_str(realtype,0),DOH_REPLACE_ANY);
|
||||
if (realname) {
|
||||
Replace(str,"$parmname",realname,DOH_REPLACE_ANY);
|
||||
} else {
|
||||
Replace(str,"$parmname","", DOH_REPLACE_ANY);
|
||||
}
|
||||
/* Print base type (without any pointers) */
|
||||
{
|
||||
char temp_ip = realtype->_is_pointer;
|
||||
char temp_ip1 = realtype->_implicit_ptr;
|
||||
realtype->_is_pointer = 0;
|
||||
realtype->_implicit_ptr = 0;
|
||||
char *bt = DataType_str(realtype,0);
|
||||
if (bt[strlen(bt)-1] == ' ')
|
||||
bt[strlen(bt)-1] = 0;
|
||||
Replace(str,"$basetype",bt,DOH_REPLACE_ANY);
|
||||
Replace(str,"$basemangle",DataType_manglestr(realtype), DOH_REPLACE_ANY);
|
||||
realtype->_is_pointer = temp_ip;
|
||||
realtype->_implicit_ptr = temp_ip1;
|
||||
}
|
||||
|
||||
Replace(str,"$mangle",DataType_manglestr(realtype), DOH_REPLACE_ANY);
|
||||
Replace(str,"$basetype",SwigType_base(realtype), DOH_REPLACE_ANY);
|
||||
Replace(str,"$basemangle",SwigType_manglestr(SwigType_base(realtype)), DOH_REPLACE_ANY);
|
||||
Replace(str,"$mangle",SwigType_manglestr(realtype), DOH_REPLACE_ANY);
|
||||
|
||||
/* If there were locals and a wrapper function, replace */
|
||||
if ((tm->args) && f) {
|
||||
typemap_locals(realtype, pname, str,tm->args,f);
|
||||
}
|
||||
|
||||
/* If there were locals and no wrapper function, print a warning */
|
||||
/* if ((tm->args) && !f) {
|
||||
if (!pname) pname = (char*)"";
|
||||
Printf(stderr,"%s:%d: Warning. '%%typemap(%s,%s) %s %s' being applied with ignored locals.\n",
|
||||
input_file, line_number, lang,op, DataType_str(type,0), pname);
|
||||
}
|
||||
*/
|
||||
/* Return character string */
|
||||
|
||||
last_args = tm->args;
|
||||
Swig_temp_result(str);
|
||||
return Char(str);
|
||||
}
|
||||
|
||||
|
|
@ -662,17 +546,19 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
|
|||
* Real function call that takes care of application mappings
|
||||
* ---------------------------------------------------------- */
|
||||
|
||||
char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *source,
|
||||
char *target, Wrapper *f) {
|
||||
char *typemap_lookup(char *op, char *lang, SwigType *type, String_or_char *pname, String_or_char *source,
|
||||
String_or_char *target, Wrapper *f) {
|
||||
TmMethod *m;
|
||||
char temp[512];
|
||||
char *result;
|
||||
char *ppname;
|
||||
String *temp;
|
||||
String_or_char *ppname;
|
||||
char *tstr;
|
||||
|
||||
realtype = type; /* The other half of the gross hack */
|
||||
realname = pname;
|
||||
|
||||
// Printf(stdout,"Looking up %s\n", SwigType_str(type,pname));
|
||||
|
||||
/* Try to apply typemap right away */
|
||||
|
||||
result = typemap_lookup_internal(op,lang,type,pname,source,target,f);
|
||||
|
|
@ -680,159 +566,93 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
|
|||
/* If not found, try to pick up anything that might have been
|
||||
specified with %apply */
|
||||
|
||||
if ((!result) && (pname)) {
|
||||
int drop_pointer = 0;
|
||||
ppname = pname;
|
||||
if (!ppname) ppname = (char*)"";
|
||||
|
||||
/* The idea : We're going to cycle through applications and
|
||||
drop pointers off until we get a match. */
|
||||
|
||||
while (drop_pointer <= (type->_is_pointer - type->_implicit_ptr)) {
|
||||
type->_is_pointer -= drop_pointer;
|
||||
tstr = DataType_str(type,0);
|
||||
sprintf(temp,"%s$%s",tstr,ppname);
|
||||
/* No mapping was found. See if the name has been mapped with %apply */
|
||||
if (!result) {
|
||||
temp = NewStringf("%s$%s", SwigType_str(type,0), pname);
|
||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||
if (!m) {
|
||||
Clear(temp);
|
||||
Printf(temp,"%s$",SwigType_str(type,0));
|
||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||
if (!m) {
|
||||
sprintf(temp,"%s$",tstr);
|
||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||
}
|
||||
if (m) {
|
||||
m = m->next;
|
||||
while (m) {
|
||||
char *oldary = 0;
|
||||
static DOHString *newarray = 0;
|
||||
if (!newarray) newarray = NewString("");
|
||||
if (*(m->name)) ppname = m->name;
|
||||
else ppname = pname;
|
||||
m->type->_is_pointer += drop_pointer;
|
||||
|
||||
/* Copy old array string (just in case) */
|
||||
|
||||
if (DataType_arraystr(m->type))
|
||||
oldary = Swig_copy_string(DataType_arraystr(m->type));
|
||||
else
|
||||
oldary = 0;
|
||||
|
||||
/* If the mapping type is an array and has the 'ANY' keyword, we
|
||||
have to play some magic */
|
||||
|
||||
if ((DataType_arraystr(m->type)) && (DataType_arraystr(type))) {
|
||||
/* Build up the new array string */
|
||||
Clear(newarray);
|
||||
for (int n = 0; n < DataType_array_dimensions(m->type); n++) {
|
||||
char *d = DataType_get_dimension(m->type,n);
|
||||
if (strcmp(d,"ANY") == 0) {
|
||||
Printf(newarray,"[%s]", DataType_get_dimension(type,n));
|
||||
} else {
|
||||
Printf(newarray,"[%s]", d);
|
||||
}
|
||||
}
|
||||
DataType_set_arraystr(m->type, Char(newarray));
|
||||
} else if (DataType_arraystr(type)) {
|
||||
/* If an array string is available for the current datatype,
|
||||
make it available. */
|
||||
DataType_set_arraystr(m->type,DataType_arraystr(type));
|
||||
}
|
||||
result = typemap_lookup_internal(op,lang,m->type,ppname,source,target,f);
|
||||
DataType_set_arraystr(m->type,oldary);
|
||||
if (oldary)
|
||||
free(oldary);
|
||||
m->type->_is_pointer -= drop_pointer;
|
||||
if (result) {
|
||||
type->_is_pointer += drop_pointer;
|
||||
return result;
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
Delete(temp);
|
||||
if (m) {
|
||||
m = m->next;
|
||||
while (m) {
|
||||
result = typemap_lookup_internal(op,lang,m->type,m->name,source,target,f);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
m = m->next;
|
||||
}
|
||||
type->_is_pointer += drop_pointer;
|
||||
drop_pointer++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Still no idea, try to find a default typemap */
|
||||
|
||||
if (!result) {
|
||||
DataType *t = CopyDataType(type);
|
||||
DataType_primitive(t); /* Knock it down to its basic type */
|
||||
SwigType *t = SwigType_default(type);
|
||||
result = typemap_lookup_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",source,target,f);
|
||||
if (result) {
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
return result;
|
||||
}
|
||||
int tc = DataType_type(t);
|
||||
if (tc == T_STRING) return 0;
|
||||
if ((tc == T_USER) || (tc == T_POINTER)) {
|
||||
/* Still no result, go even more primitive */
|
||||
DataType_Settypecode(t, T_USER);
|
||||
t->_is_pointer = 1;
|
||||
DataType_set_arraystr(t,0);
|
||||
DataType_primitive(t);
|
||||
result = typemap_lookup_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",source,target,f);
|
||||
}
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* char *typemap_check(char *op, char *lang, DataType *type, char *pname)
|
||||
* char *typemap_check(char *op, char *lang, SwigType *type, String_or_char *pname)
|
||||
*
|
||||
* Checks to see if there is a typemap. Returns typemap string if found, NULL
|
||||
* if not.
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
char *typemap_check_internal(char *op, char *lang, DataType *type, char *pname) {
|
||||
static DOHString *str = 0;
|
||||
char *key = 0;
|
||||
char *typemap_check_internal(char *op, char *lang, SwigType *type, String_or_char *pname) {
|
||||
DOHString *str = 0;
|
||||
String *key = 0;
|
||||
TypeMap *tm = 0;
|
||||
|
||||
if (!str) str = NewString("");
|
||||
|
||||
if (!lang) {
|
||||
return 0;
|
||||
}
|
||||
str = NewString("");
|
||||
|
||||
/* First check for named array */
|
||||
|
||||
Clear(str);
|
||||
tm = typemap_search_array(op,lang,type,pname,str);
|
||||
|
||||
/* First check for named array
|
||||
*
|
||||
* if (type->arraystr) {
|
||||
* key = typemap_string(lang,type,pname,type->arraystr,op);
|
||||
* tm = typemap_search(key,type->_id);
|
||||
* } */
|
||||
|
||||
/* Check for named argument */
|
||||
if (!tm) {
|
||||
key = typemap_string(lang,type,pname,0,op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
key = typemap_string(op,lang,type,pname);
|
||||
tm = typemap_search(key,type_id);
|
||||
}
|
||||
|
||||
/* Check for unnamed array */
|
||||
if ((!tm) && (DataType_arraystr(type))) {
|
||||
key = typemap_string(lang,type,(char*)"",DataType_arraystr(type),op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
if ((!tm) && (SwigType_isarray(type))) {
|
||||
key = typemap_string(op,lang,type,(char*)"");
|
||||
tm = typemap_search(key,type_id);
|
||||
}
|
||||
|
||||
/* Check for unname type */
|
||||
/* Check for unnamed type */
|
||||
if (!tm) {
|
||||
key = typemap_string(lang,type,(char*)"",0,op);
|
||||
tm = typemap_search(key,type->_id);
|
||||
key = typemap_string(op,lang,type,(char*)"");
|
||||
tm = typemap_search(key,type_id);
|
||||
}
|
||||
if (!tm) {
|
||||
Delete(str);
|
||||
return 0;
|
||||
}
|
||||
if (!tm) return 0;
|
||||
|
||||
Clear(str);
|
||||
Printf(str,"%s",tm->code);
|
||||
|
||||
/* Return character string */
|
||||
Swig_temp_result(str);
|
||||
return Char(str);
|
||||
}
|
||||
|
||||
/** Function for checking with applications */
|
||||
|
||||
char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
||||
char *typemap_check(char *op, char *lang, SwigType *type, String_or_char *pname) {
|
||||
TmMethod *m;
|
||||
char temp[512];
|
||||
char *result;
|
||||
|
|
@ -842,6 +662,7 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
|||
|
||||
result = typemap_check_internal(op,lang,type,pname);
|
||||
|
||||
#ifdef OLD
|
||||
if (!result) {
|
||||
int drop_pointer = 0;
|
||||
ppname = pname;
|
||||
|
|
@ -908,27 +729,17 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
|||
drop_pointer++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If still no result, might have a default typemap */
|
||||
if (!result) {
|
||||
DataType *t = CopyDataType(type);
|
||||
DataType_primitive(t); /* Knock it down to its basic type */
|
||||
SwigType *t = SwigType_default(type);
|
||||
result = typemap_check_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE");
|
||||
if (result) {
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
return result;
|
||||
}
|
||||
int tc = DataType_type(t);
|
||||
if (tc == T_STRING) return 0;
|
||||
if ((tc == T_USER) || (tc == T_POINTER)) {
|
||||
/* Still no result, go even more primitive */
|
||||
DataType_Settypecode(t,T_USER);
|
||||
t->_is_pointer = 1;
|
||||
DataType_set_arraystr(t,0);
|
||||
DataType_primitive(t);
|
||||
result = typemap_check_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE");
|
||||
}
|
||||
DelDataType(t);
|
||||
Delete(t);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -941,12 +752,12 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
|||
* previous map, then don't worry about it.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
void typemap_clear(char *op, char *lang, DataType *type, char *pname) {
|
||||
void typemap_clear(char *op, char *lang, SwigType *type, String_or_char *pname) {
|
||||
|
||||
char *key;
|
||||
String *key;
|
||||
TypeMap *tm;
|
||||
|
||||
key = typemap_string(lang,type,pname,DataType_arraystr(type),op);
|
||||
key = typemap_string(op,lang,type,pname);
|
||||
|
||||
/* Look for any previous version, simply set the last id if
|
||||
applicable. */
|
||||
|
|
@ -965,29 +776,18 @@ void typemap_clear(char *op, char *lang, DataType *type, char *pname) {
|
|||
* Copies the code associate with a typemap
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
void typemap_copy(char *op, char *lang, DataType *stype, char *sname,
|
||||
DataType *ttype, char *tname) {
|
||||
void typemap_copy(char *op, char *lang, SwigType *stype, String_or_char *sname,
|
||||
SwigType *ttype, String_or_char *tname) {
|
||||
|
||||
char *key;
|
||||
String *key;
|
||||
TypeMap *tm, *tk, *tn;
|
||||
|
||||
/* Try to locate a previous typemap */
|
||||
|
||||
key = typemap_string(lang,stype,sname,DataType_arraystr(stype),op);
|
||||
tm = typemap_search(key,stype->_id);
|
||||
key = typemap_string(op,lang,stype,sname);
|
||||
tm = typemap_search(key,type_id);
|
||||
if (!tm) return;
|
||||
if (strcmp(DataType_Getname(ttype),"PREVIOUS") == 0) {
|
||||
/* Pop back up to the previous typemap (if any) */
|
||||
tk = tm->next;
|
||||
if (tk) {
|
||||
tn = new TypeMap(tk); /* Make a copy of the previous typemap */
|
||||
tn->next = tm; /* Set up symlinks */
|
||||
Delattr(typemap_hash,key); /* Remove old hash entry */
|
||||
SetVoid(typemap_hash,key, tn);
|
||||
}
|
||||
} else {
|
||||
typemap_register(op,lang,ttype,tname,Char(tm->code),tm->args);
|
||||
}
|
||||
typemap_register(op,lang,ttype,tname,tm->code,tm->args);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
|
@ -1009,7 +809,7 @@ static char *fragment_string(char *op, char *lang) {
|
|||
* Register a code fragment with the type-mapper.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
void fragment_register(char *op, char *lang, char *code) {
|
||||
void fragment_register(char *op, char *lang, String_or_char *code) {
|
||||
|
||||
char *key;
|
||||
TypeMap *tm,*tm_old;
|
||||
|
|
@ -1044,38 +844,35 @@ void fragment_register(char *op, char *lang, char *code) {
|
|||
|
||||
/* Add new typemap to the hash table */
|
||||
SetVoid(typemap_hash,key,tm);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* char *fragment_lookup(char *op, char *lang, int age)
|
||||
* char *fragment_lookup(char *op, char *lang)
|
||||
*
|
||||
* op is string code for type of mapping
|
||||
* lang is the target language string
|
||||
* age is age of fragment.
|
||||
*
|
||||
* Returns NULL if no mapping is found.
|
||||
*
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
char *fragment_lookup(char *op, char *lang, int age) {
|
||||
static DOHString *str = 0;
|
||||
char *fragment_lookup(char *op, char *lang) {
|
||||
DOHString *str;
|
||||
char *key = 0;
|
||||
TypeMap *tm = 0;
|
||||
|
||||
if (!str) str = NewString("");
|
||||
|
||||
if (!lang) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Clear(str);
|
||||
str = NewString("");
|
||||
key = fragment_string(op,lang);
|
||||
tm = typemap_search(key,age);
|
||||
tm = typemap_search(key,type_id);
|
||||
|
||||
if (!tm) return 0;
|
||||
|
||||
Append(str,tm->code);
|
||||
Swig_temp_result(str);
|
||||
return Char(str);
|
||||
}
|
||||
|
||||
|
|
@ -1127,8 +924,8 @@ int check_numopt(ParmList *p) {
|
|||
int state = 0;
|
||||
|
||||
for (;p; p = Getnext(p),i++) {
|
||||
DataType *pt = Gettype(p);
|
||||
char *pn = Getname(p);
|
||||
SwigType *pt = Gettype(p);
|
||||
String *pn = Getname(p);
|
||||
if (Getvalue(p)) {
|
||||
n++;
|
||||
state = 1;
|
||||
|
|
@ -1167,8 +964,8 @@ typemap_match_parms(ParmList *l) {
|
|||
|
||||
p = l;
|
||||
while (p) {
|
||||
DataType *pt = Gettype(p);
|
||||
char *pn = Getname(p);
|
||||
SwigType *pt = Gettype(p);
|
||||
String *pn = Getname(p);
|
||||
ParmList *vars = 0;
|
||||
|
||||
tm = NewHash();
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ srcdir = @srcdir@
|
|||
VPATH = @srcdir@
|
||||
|
||||
SRCS = map.c wrapfunc.c naming.c tree.c stype.c scanner.c include.c getopt.c misc.c \
|
||||
oldtypes.c parms.c cwrap.c
|
||||
parms.c cwrap.c
|
||||
OBJS = map.o wrapfunc.o naming.o tree.o stype.o scanner.o include.o getopt.o misc.o \
|
||||
oldtypes.o parms.o cwrap.o
|
||||
parms.o cwrap.o
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue