beautify/format source code with gnu indent
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9505 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cb8ae0ab98
commit
68891541d1
72 changed files with 27038 additions and 28016 deletions
|
|
@ -20,55 +20,51 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* cscanner.c */
|
/* cscanner.c */
|
||||||
extern char *cparse_file;
|
extern char *cparse_file;
|
||||||
extern int cparse_line;
|
extern int cparse_line;
|
||||||
extern int cparse_cplusplus;
|
extern int cparse_cplusplus;
|
||||||
extern int cparse_start_line;
|
extern int cparse_start_line;
|
||||||
|
|
||||||
extern void Swig_cparse_cplusplus(int);
|
extern void Swig_cparse_cplusplus(int);
|
||||||
extern void scanner_file(File *);
|
extern void scanner_file(File *);
|
||||||
extern void scanner_next_token(int);
|
extern void scanner_next_token(int);
|
||||||
extern void skip_balanced(int startchar, int endchar);
|
extern void skip_balanced(int startchar, int endchar);
|
||||||
extern void skip_decl(void);
|
extern void skip_decl(void);
|
||||||
extern void scanner_check_typedef(void);
|
extern void scanner_check_typedef(void);
|
||||||
extern void scanner_ignore_typedef(void);
|
extern void scanner_ignore_typedef(void);
|
||||||
extern void scanner_last_id(int);
|
extern void scanner_last_id(int);
|
||||||
extern void scanner_clear_rename(void);
|
extern void scanner_clear_rename(void);
|
||||||
extern void start_inline(char *, int);
|
extern void start_inline(char *, int);
|
||||||
extern String *scanner_ccode;
|
extern String *scanner_ccode;
|
||||||
extern int yylex();
|
extern int yylex();
|
||||||
|
|
||||||
/* parser.y */
|
/* parser.y */
|
||||||
extern SwigType *Swig_cparse_type(String *);
|
extern SwigType *Swig_cparse_type(String *);
|
||||||
extern Node *Swig_cparse(File *);
|
extern Node *Swig_cparse(File *);
|
||||||
extern Hash *Swig_cparse_features();
|
extern Hash *Swig_cparse_features();
|
||||||
extern void SWIG_cparse_set_compact_default_args(int defargs);
|
extern void SWIG_cparse_set_compact_default_args(int defargs);
|
||||||
extern int SWIG_cparse_template_reduce(int treduce);
|
extern int SWIG_cparse_template_reduce(int treduce);
|
||||||
|
|
||||||
/* util.c */
|
/* util.c */
|
||||||
extern void Swig_cparse_replace_descriptor(String *s);
|
extern void Swig_cparse_replace_descriptor(String *s);
|
||||||
extern void cparse_normalize_void(Node *);
|
extern void cparse_normalize_void(Node *);
|
||||||
extern Parm *Swig_cparse_parm(String *s);
|
extern Parm *Swig_cparse_parm(String *s);
|
||||||
extern ParmList *Swig_cparse_parms(String *s);
|
extern ParmList *Swig_cparse_parms(String *s);
|
||||||
|
|
||||||
|
|
||||||
/* templ.c */
|
/* templ.c */
|
||||||
extern int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope);
|
extern int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope);
|
||||||
extern Node *Swig_cparse_template_locate(String *name, ParmList *tparms, Symtab *tscope);
|
extern Node *Swig_cparse_template_locate(String *name, ParmList *tparms, Symtab *tscope);
|
||||||
extern void Swig_cparse_debug_templates(int);
|
extern void Swig_cparse_debug_templates(int);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SWIG_WARN_NODE_BEGIN(Node) \
|
#define SWIG_WARN_NODE_BEGIN(Node) \
|
||||||
{ \
|
{ \
|
||||||
String *wrnfilter = Node ? Getattr(Node,"feature:warnfilter") : 0; \
|
String *wrnfilter = Node ? Getattr(Node,"feature:warnfilter") : 0; \
|
||||||
if (wrnfilter) Swig_warnfilter(wrnfilter,1)
|
if (wrnfilter) Swig_warnfilter(wrnfilter,1)
|
||||||
|
|
||||||
#define SWIG_WARN_NODE_END(Node) \
|
#define SWIG_WARN_NODE_END(Node) \
|
||||||
if (wrnfilter) Swig_warnfilter(wrnfilter,0); \
|
if (wrnfilter) Swig_warnfilter(wrnfilter,0); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -18,8 +18,7 @@ static int template_debug = 0;
|
||||||
|
|
||||||
String *baselists[3];
|
String *baselists[3];
|
||||||
|
|
||||||
void SwigType_template_init()
|
void SwigType_template_init() {
|
||||||
{
|
|
||||||
baselists[0] = k_baselist;
|
baselists[0] = k_baselist;
|
||||||
baselists[1] = k_protectedbaselist;
|
baselists[1] = k_protectedbaselist;
|
||||||
baselists[2] = k_privatebaselist;
|
baselists[2] = k_privatebaselist;
|
||||||
|
|
@ -28,17 +27,17 @@ void SwigType_template_init()
|
||||||
|
|
||||||
static void add_parms(ParmList *p, List *patchlist, List *typelist) {
|
static void add_parms(ParmList *p, List *patchlist, List *typelist) {
|
||||||
while (p) {
|
while (p) {
|
||||||
SwigType *ty = Getattr(p,k_type);
|
SwigType *ty = Getattr(p, k_type);
|
||||||
SwigType *val = Getattr(p,k_value);
|
SwigType *val = Getattr(p, k_value);
|
||||||
Append(typelist,ty);
|
Append(typelist, ty);
|
||||||
Append(typelist,val);
|
Append(typelist, val);
|
||||||
Append(patchlist,val);
|
Append(patchlist, val);
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Swig_cparse_debug_templates(int x) {
|
void Swig_cparse_debug_templates(int x) {
|
||||||
template_debug = x;
|
template_debug = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -49,69 +48,70 @@ void Swig_cparse_debug_templates(int x) {
|
||||||
* template parameters
|
* template parameters
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int cparse_template_expand(Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) {
|
||||||
cparse_template_expand(Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) {
|
|
||||||
static int expanded = 0;
|
static int expanded = 0;
|
||||||
int ret;
|
int ret;
|
||||||
String *nodeType = Getattr(n,k_nodetype);
|
String *nodeType = Getattr(n, k_nodetype);
|
||||||
if (!n) return 0;
|
if (!n)
|
||||||
if (Getattr(n,k_error)) return 0;
|
return 0;
|
||||||
|
if (Getattr(n, k_error))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (StringEqual(nodeType,k_template)) {
|
if (StringEqual(nodeType, k_template)) {
|
||||||
/* Change the node type back to normal */
|
/* Change the node type back to normal */
|
||||||
if (!expanded) {
|
if (!expanded) {
|
||||||
expanded = 1;
|
expanded = 1;
|
||||||
Setattr(n,k_nodetype,Getattr(n,k_templatetype));
|
Setattr(n, k_nodetype, Getattr(n, k_templatetype));
|
||||||
ret = cparse_template_expand(n,tname, rname, templateargs, patchlist,typelist, cpatchlist);
|
ret = cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist);
|
||||||
expanded = 0;
|
expanded = 0;
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
/* Called when template appears inside another template */
|
/* Called when template appears inside another template */
|
||||||
/* Member templates */
|
/* Member templates */
|
||||||
|
|
||||||
Setattr(n,k_nodetype,Getattr(n,k_templatetype));
|
Setattr(n, k_nodetype, Getattr(n, k_templatetype));
|
||||||
ret = cparse_template_expand(n,tname, rname, templateargs, patchlist,typelist, cpatchlist);
|
ret = cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist);
|
||||||
Setattr(n,k_nodetype,k_template);
|
Setattr(n, k_nodetype, k_template);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else if (StringEqual(nodeType,k_cdecl)) {
|
} else if (StringEqual(nodeType, k_cdecl)) {
|
||||||
/* A simple C declaration */
|
/* A simple C declaration */
|
||||||
SwigType *t, *v, *d;
|
SwigType *t, *v, *d;
|
||||||
String *code;
|
String *code;
|
||||||
t = Getattr(n,k_type);
|
t = Getattr(n, k_type);
|
||||||
v = Getattr(n,k_value);
|
v = Getattr(n, k_value);
|
||||||
d = Getattr(n,k_decl);
|
d = Getattr(n, k_decl);
|
||||||
|
|
||||||
code = Getattr(n,k_code);
|
code = Getattr(n, k_code);
|
||||||
|
|
||||||
Append(typelist,t);
|
Append(typelist, t);
|
||||||
Append(typelist,d);
|
Append(typelist, d);
|
||||||
Append(patchlist,v);
|
Append(patchlist, v);
|
||||||
Append(cpatchlist,code);
|
Append(cpatchlist, code);
|
||||||
|
|
||||||
if (Getattr(n,k_conversionoperator)) {
|
if (Getattr(n, k_conversionoperator)) {
|
||||||
Append(cpatchlist, Getattr(n,k_name));
|
Append(cpatchlist, Getattr(n, k_name));
|
||||||
if (Getattr(n,k_symname)) {
|
if (Getattr(n, k_symname)) {
|
||||||
Append(cpatchlist, Getattr(n,k_symname));
|
Append(cpatchlist, Getattr(n, k_symname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_parms(Getattr(n,k_parms), cpatchlist, typelist);
|
|
||||||
add_parms(Getattr(n,k_throws), cpatchlist, typelist);
|
|
||||||
|
|
||||||
} else if (StringEqual(nodeType,k_class)) {
|
add_parms(Getattr(n, k_parms), cpatchlist, typelist);
|
||||||
|
add_parms(Getattr(n, k_throws), cpatchlist, typelist);
|
||||||
|
|
||||||
|
} else if (StringEqual(nodeType, k_class)) {
|
||||||
/* Patch base classes */
|
/* Patch base classes */
|
||||||
{
|
{
|
||||||
int b = 0;
|
int b = 0;
|
||||||
for (b = 0; b < 3; ++b) {
|
for (b = 0; b < 3; ++b) {
|
||||||
List *bases = Getattr(n,baselists[b]);
|
List *bases = Getattr(n, baselists[b]);
|
||||||
if (bases) {
|
if (bases) {
|
||||||
int i;
|
int i;
|
||||||
int ilen = Len(bases);
|
int ilen = Len(bases);
|
||||||
for (i = 0; i < ilen; i++) {
|
for (i = 0; i < ilen; i++) {
|
||||||
String *name = Copy(Getitem(bases,i));
|
String *name = Copy(Getitem(bases, i));
|
||||||
Setitem(bases,i,name);
|
Setitem(bases, i, name);
|
||||||
Append(typelist,name);
|
Append(typelist, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -120,90 +120,90 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
|
||||||
{
|
{
|
||||||
Node *cn = firstChild(n);
|
Node *cn = firstChild(n);
|
||||||
while (cn) {
|
while (cn) {
|
||||||
cparse_template_expand(cn,tname, rname, templateargs, patchlist,typelist,cpatchlist);
|
cparse_template_expand(cn, tname, rname, templateargs, patchlist, typelist, cpatchlist);
|
||||||
cn = nextSibling(cn);
|
cn = nextSibling(cn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (StringEqual(nodeType,k_constructor)) {
|
} else if (StringEqual(nodeType, k_constructor)) {
|
||||||
String *name = Getattr(n,k_name);
|
String *name = Getattr(n, k_name);
|
||||||
if (!(Getattr(n,k_templatetype))) {
|
if (!(Getattr(n, k_templatetype))) {
|
||||||
String *symname;
|
String *symname;
|
||||||
String *stripped_name = SwigType_templateprefix(name);
|
String *stripped_name = SwigType_templateprefix(name);
|
||||||
if (Strstr(tname,stripped_name)) {
|
if (Strstr(tname, stripped_name)) {
|
||||||
Replaceid(name,stripped_name,tname);
|
Replaceid(name, stripped_name, tname);
|
||||||
}
|
}
|
||||||
Delete(stripped_name);
|
Delete(stripped_name);
|
||||||
symname = Getattr(n,k_symname);
|
symname = Getattr(n, k_symname);
|
||||||
if (symname) {
|
if (symname) {
|
||||||
stripped_name = SwigType_templateprefix(symname);
|
stripped_name = SwigType_templateprefix(symname);
|
||||||
if (Strstr(tname,stripped_name)) {
|
if (Strstr(tname, stripped_name)) {
|
||||||
Replaceid(symname,stripped_name,tname);
|
Replaceid(symname, stripped_name, tname);
|
||||||
}
|
}
|
||||||
Delete(stripped_name);
|
Delete(stripped_name);
|
||||||
}
|
}
|
||||||
if (strchr(Char(name),'<')) {
|
if (strchr(Char(name), '<')) {
|
||||||
Append(patchlist,Getattr(n,k_name));
|
Append(patchlist, Getattr(n, k_name));
|
||||||
} else {
|
} else {
|
||||||
Append(name,templateargs);
|
Append(name, templateargs);
|
||||||
}
|
}
|
||||||
name = Getattr(n,k_symname);
|
name = Getattr(n, k_symname);
|
||||||
if (name) {
|
if (name) {
|
||||||
if (strchr(Char(name),'<')) {
|
if (strchr(Char(name), '<')) {
|
||||||
Clear(name);
|
Clear(name);
|
||||||
Append(name,rname);
|
Append(name, rname);
|
||||||
} else {
|
} else {
|
||||||
String *tmp = Copy(name);
|
String *tmp = Copy(name);
|
||||||
Replace(tmp,tname,rname, DOH_REPLACE_ANY);
|
Replace(tmp, tname, rname, DOH_REPLACE_ANY);
|
||||||
Clear(name);
|
Clear(name);
|
||||||
Append(name,tmp);
|
Append(name, tmp);
|
||||||
Delete(tmp);
|
Delete(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Setattr(n,k_symname,name); */
|
/* Setattr(n,k_symname,name); */
|
||||||
}
|
}
|
||||||
Append(cpatchlist,Getattr(n,k_code));
|
Append(cpatchlist, Getattr(n, k_code));
|
||||||
Append(typelist, Getattr(n,k_decl));
|
Append(typelist, Getattr(n, k_decl));
|
||||||
add_parms(Getattr(n,k_parms), cpatchlist, typelist);
|
add_parms(Getattr(n, k_parms), cpatchlist, typelist);
|
||||||
add_parms(Getattr(n,k_throws), cpatchlist, typelist);
|
add_parms(Getattr(n, k_throws), cpatchlist, typelist);
|
||||||
} else if (StringEqual(nodeType,k_destructor)) {
|
} else if (StringEqual(nodeType, k_destructor)) {
|
||||||
String *name = Getattr(n,k_name);
|
String *name = Getattr(n, k_name);
|
||||||
if (name && strchr(Char(name),'<')) {
|
if (name && strchr(Char(name), '<')) {
|
||||||
Append(patchlist,Getattr(n,k_name));
|
Append(patchlist, Getattr(n, k_name));
|
||||||
} else {
|
} else {
|
||||||
Append(name,templateargs);
|
Append(name, templateargs);
|
||||||
}
|
}
|
||||||
name = Getattr(n,k_symname);
|
name = Getattr(n, k_symname);
|
||||||
if (name && strchr(Char(name),'<')) {
|
if (name && strchr(Char(name), '<')) {
|
||||||
String *sn = Copy(tname);
|
String *sn = Copy(tname);
|
||||||
Setattr(n,k_symname, sn);
|
Setattr(n, k_symname, sn);
|
||||||
Delete(sn);
|
Delete(sn);
|
||||||
} else {
|
} else {
|
||||||
Replace(name,tname,rname, DOH_REPLACE_ANY);
|
Replace(name, tname, rname, DOH_REPLACE_ANY);
|
||||||
}
|
}
|
||||||
/* Setattr(n,k_symname,name); */
|
/* Setattr(n,k_symname,name); */
|
||||||
Append(cpatchlist,Getattr(n,k_code));
|
Append(cpatchlist, Getattr(n, k_code));
|
||||||
} else if (StringEqual(nodeType,k_using)) {
|
} else if (StringEqual(nodeType, k_using)) {
|
||||||
String *uname = Getattr(n,k_uname);
|
String *uname = Getattr(n, k_uname);
|
||||||
if (uname && strchr(Char(uname),'<')) {
|
if (uname && strchr(Char(uname), '<')) {
|
||||||
Append(patchlist, uname);
|
Append(patchlist, uname);
|
||||||
}
|
}
|
||||||
if (Getattr(n,k_namespace)) {
|
if (Getattr(n, k_namespace)) {
|
||||||
/* Namespace link. This is nasty. Is other namespace defined? */
|
/* Namespace link. This is nasty. Is other namespace defined? */
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Look for obvious parameters */
|
/* Look for obvious parameters */
|
||||||
Node *cn;
|
Node *cn;
|
||||||
Append(cpatchlist,Getattr(n,k_code));
|
Append(cpatchlist, Getattr(n, k_code));
|
||||||
Append(typelist, Getattr(n,k_type));
|
Append(typelist, Getattr(n, k_type));
|
||||||
Append(typelist, Getattr(n,k_decl));
|
Append(typelist, Getattr(n, k_decl));
|
||||||
add_parms(Getattr(n,k_parms), cpatchlist, typelist);
|
add_parms(Getattr(n, k_parms), cpatchlist, typelist);
|
||||||
add_parms(Getattr(n,k_kwargs), cpatchlist, typelist);
|
add_parms(Getattr(n, k_kwargs), cpatchlist, typelist);
|
||||||
add_parms(Getattr(n,k_pattern), cpatchlist, typelist);
|
add_parms(Getattr(n, k_pattern), cpatchlist, typelist);
|
||||||
add_parms(Getattr(n,k_throws), cpatchlist, typelist);
|
add_parms(Getattr(n, k_throws), cpatchlist, typelist);
|
||||||
cn = firstChild(n);
|
cn = firstChild(n);
|
||||||
while (cn) {
|
while (cn) {
|
||||||
cparse_template_expand(cn,tname, rname, templateargs, patchlist, typelist, cpatchlist);
|
cparse_template_expand(cn, tname, rname, templateargs, patchlist, typelist, cpatchlist);
|
||||||
cn = nextSibling(cn);
|
cn = nextSibling(cn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -219,19 +219,18 @@ String *partial_arg(String *s, String *p) {
|
||||||
|
|
||||||
/* Find the prefix on the partial argument */
|
/* Find the prefix on the partial argument */
|
||||||
|
|
||||||
c = strchr(cp,'$');
|
c = strchr(cp, '$');
|
||||||
if (!c) {
|
if (!c) {
|
||||||
return Copy(s);
|
return Copy(s);
|
||||||
}
|
}
|
||||||
prefix = NewStringWithSize(cp,c-cp);
|
prefix = NewStringWithSize(cp, c - cp);
|
||||||
newarg = Copy(s);
|
newarg = Copy(s);
|
||||||
Replace(newarg,prefix,"",DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
Replace(newarg, prefix, "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
||||||
Delete(prefix);
|
Delete(prefix);
|
||||||
return newarg;
|
return newarg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope) {
|
||||||
Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope) {
|
|
||||||
List *patchlist, *cpatchlist, *typelist;
|
List *patchlist, *cpatchlist, *typelist;
|
||||||
String *templateargs;
|
String *templateargs;
|
||||||
String *tname;
|
String *tname;
|
||||||
|
|
@ -244,31 +243,31 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
|
||||||
{
|
{
|
||||||
String *tmp = NewStringEmpty();
|
String *tmp = NewStringEmpty();
|
||||||
if (tparms) {
|
if (tparms) {
|
||||||
SwigType_add_template(tmp,tparms);
|
SwigType_add_template(tmp, tparms);
|
||||||
}
|
}
|
||||||
templateargs = Copy(tmp);
|
templateargs = Copy(tmp);
|
||||||
Delete(tmp);
|
Delete(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tname = Copy(Getattr(n,k_name));
|
tname = Copy(Getattr(n, k_name));
|
||||||
tbase = Swig_scopename_last(tname);
|
tbase = Swig_scopename_last(tname);
|
||||||
|
|
||||||
/* Look for partial specialization matching */
|
/* Look for partial specialization matching */
|
||||||
if (Getattr(n,k_partialargs)) {
|
if (Getattr(n, k_partialargs)) {
|
||||||
Parm *p, *tp;
|
Parm *p, *tp;
|
||||||
ParmList *ptargs = SwigType_function_parms(Getattr(n,k_partialargs));
|
ParmList *ptargs = SwigType_function_parms(Getattr(n, k_partialargs));
|
||||||
p = ptargs;
|
p = ptargs;
|
||||||
tp = tparms;
|
tp = tparms;
|
||||||
while (p && tp) {
|
while (p && tp) {
|
||||||
SwigType *ptype;
|
SwigType *ptype;
|
||||||
SwigType *tptype;
|
SwigType *tptype;
|
||||||
SwigType *partial_type;
|
SwigType *partial_type;
|
||||||
ptype = Getattr(p,k_type);
|
ptype = Getattr(p, k_type);
|
||||||
tptype = Getattr(tp,k_type);
|
tptype = Getattr(tp, k_type);
|
||||||
if (ptype && tptype) {
|
if (ptype && tptype) {
|
||||||
partial_type = partial_arg(tptype,ptype);
|
partial_type = partial_arg(tptype, ptype);
|
||||||
/* Printf(stdout,"partial '%s' '%s' ---> '%s'\n", tptype, ptype, partial_type); */
|
/* Printf(stdout,"partial '%s' '%s' ---> '%s'\n", tptype, ptype, partial_type); */
|
||||||
Setattr(tp,k_type,partial_type);
|
Setattr(tp, k_type, partial_type);
|
||||||
Delete(partial_type);
|
Delete(partial_type);
|
||||||
}
|
}
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
|
|
@ -281,93 +280,94 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
|
||||||
if (0) {
|
if (0) {
|
||||||
Parm *p = tparms;
|
Parm *p = tparms;
|
||||||
while (p) {
|
while (p) {
|
||||||
Printf(stdout,"tparm: '%s' '%s' '%s'\n", Getattr(p,k_name), Getattr(p,k_type), Getattr(p,k_value));
|
Printf(stdout, "tparm: '%s' '%s' '%s'\n", Getattr(p, k_name), Getattr(p, k_type), Getattr(p, k_value));
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Printf(stdout,"targs = '%s'\n", templateargs);
|
/* Printf(stdout,"targs = '%s'\n", templateargs);
|
||||||
Printf(stdout,"rname = '%s'\n", rname);
|
Printf(stdout,"rname = '%s'\n", rname);
|
||||||
Printf(stdout,"tname = '%s'\n", tname); */
|
Printf(stdout,"tname = '%s'\n", tname); */
|
||||||
cparse_template_expand(n,tname, rname, templateargs, patchlist, typelist, cpatchlist);
|
cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist);
|
||||||
|
|
||||||
/* Set the name */
|
/* Set the name */
|
||||||
{
|
{
|
||||||
String *name = Getattr(n,k_name);
|
String *name = Getattr(n, k_name);
|
||||||
if (name) {
|
if (name) {
|
||||||
Append(name,templateargs);
|
Append(name, templateargs);
|
||||||
}
|
}
|
||||||
iname = name;
|
iname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Patch all of the types */
|
/* Patch all of the types */
|
||||||
{
|
{
|
||||||
Parm *tp = Getattr(n,k_templateparms);
|
Parm *tp = Getattr(n, k_templateparms);
|
||||||
Parm *p = tparms;
|
Parm *p = tparms;
|
||||||
/* Printf(stdout,"%s\n", ParmList_str_defaultargs(tp)); */
|
/* Printf(stdout,"%s\n", ParmList_str_defaultargs(tp)); */
|
||||||
|
|
||||||
if (tp) {
|
if (tp) {
|
||||||
Symtab *tsdecl = Getattr(n,k_symsymtab);
|
Symtab *tsdecl = Getattr(n, k_symsymtab);
|
||||||
while (p && tp) {
|
while (p && tp) {
|
||||||
String *name, *value, *valuestr, *tydef, *tmp, *tmpr;
|
String *name, *value, *valuestr, *tydef, *tmp, *tmpr;
|
||||||
int sz, i;
|
int sz, i;
|
||||||
String *dvalue = 0;
|
String *dvalue = 0;
|
||||||
String *qvalue = 0;
|
String *qvalue = 0;
|
||||||
|
|
||||||
name = Getattr(tp,k_name);
|
name = Getattr(tp, k_name);
|
||||||
value = Getattr(p,k_value);
|
value = Getattr(p, k_value);
|
||||||
tydef = Getattr(p,k_typedef);
|
tydef = Getattr(p, k_typedef);
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
if (!value) value = Getattr(p,k_type);
|
if (!value)
|
||||||
|
value = Getattr(p, k_type);
|
||||||
qvalue = Swig_symbol_typedef_reduce(value, tsdecl);
|
qvalue = Swig_symbol_typedef_reduce(value, tsdecl);
|
||||||
dvalue = Swig_symbol_type_qualify(qvalue,tsdecl);
|
dvalue = Swig_symbol_type_qualify(qvalue, tsdecl);
|
||||||
if (SwigType_istemplate(dvalue)) {
|
if (SwigType_istemplate(dvalue)) {
|
||||||
String *ty = Swig_symbol_template_deftype(dvalue, tscope);
|
String *ty = Swig_symbol_template_deftype(dvalue, tscope);
|
||||||
Delete(dvalue);
|
Delete(dvalue);
|
||||||
dvalue = ty;
|
dvalue = ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(dvalue);
|
assert(dvalue);
|
||||||
valuestr = SwigType_str(dvalue,0);
|
valuestr = SwigType_str(dvalue, 0);
|
||||||
/* Need to patch default arguments */
|
/* Need to patch default arguments */
|
||||||
{
|
{
|
||||||
Parm *rp = nextSibling(p);
|
Parm *rp = nextSibling(p);
|
||||||
while (rp) {
|
while (rp) {
|
||||||
String *rvalue = Getattr(rp,k_value);
|
String *rvalue = Getattr(rp, k_value);
|
||||||
if (rvalue) {
|
if (rvalue) {
|
||||||
Replace(rvalue,name,dvalue, DOH_REPLACE_ID);
|
Replace(rvalue, name, dvalue, DOH_REPLACE_ID);
|
||||||
}
|
}
|
||||||
rp = nextSibling(rp);
|
rp = nextSibling(rp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sz = Len(patchlist);
|
sz = Len(patchlist);
|
||||||
for (i = 0; i < sz; i++) {
|
for (i = 0; i < sz; i++) {
|
||||||
String *s = Getitem(patchlist,i);
|
String *s = Getitem(patchlist, i);
|
||||||
Replace(s,name,dvalue, DOH_REPLACE_ID);
|
Replace(s, name, dvalue, DOH_REPLACE_ID);
|
||||||
}
|
}
|
||||||
sz = Len(typelist);
|
sz = Len(typelist);
|
||||||
for (i = 0; i < sz; i++) {
|
for (i = 0; i < sz; i++) {
|
||||||
String *s = Getitem(typelist,i);
|
String *s = Getitem(typelist, i);
|
||||||
/* Replace(s,name,value, DOH_REPLACE_ID); */
|
/* Replace(s,name,value, DOH_REPLACE_ID); */
|
||||||
/* Printf(stdout,"name = '%s', value = '%s', tbase = '%s', iname='%s' s = '%s' --> ", name, dvalue, tbase, iname, s); */
|
/* Printf(stdout,"name = '%s', value = '%s', tbase = '%s', iname='%s' s = '%s' --> ", name, dvalue, tbase, iname, s); */
|
||||||
SwigType_typename_replace(s,name,dvalue);
|
SwigType_typename_replace(s, name, dvalue);
|
||||||
SwigType_typename_replace(s,tbase,iname);
|
SwigType_typename_replace(s, tbase, iname);
|
||||||
/* Printf(stdout,"'%s'\n", s);*/
|
/* Printf(stdout,"'%s'\n", s); */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tydef) {
|
if (!tydef) {
|
||||||
tydef = dvalue;
|
tydef = dvalue;
|
||||||
}
|
}
|
||||||
tmp = NewStringf("#%s",name);
|
tmp = NewStringf("#%s", name);
|
||||||
tmpr = NewStringf("\"%s\"", valuestr);
|
tmpr = NewStringf("\"%s\"", valuestr);
|
||||||
|
|
||||||
sz = Len(cpatchlist);
|
sz = Len(cpatchlist);
|
||||||
for (i = 0; i < sz; i++) {
|
for (i = 0; i < sz; i++) {
|
||||||
String *s = Getitem(cpatchlist,i);
|
String *s = Getitem(cpatchlist, i);
|
||||||
Replace(s,tmp,tmpr, DOH_REPLACE_ID);
|
Replace(s, tmp, tmpr, DOH_REPLACE_ID);
|
||||||
/* Replace(s,name,tydef, DOH_REPLACE_ID); */
|
/* Replace(s,name,tydef, DOH_REPLACE_ID); */
|
||||||
Replace(s,name,valuestr, DOH_REPLACE_ID);
|
Replace(s, name, valuestr, DOH_REPLACE_ID);
|
||||||
}
|
}
|
||||||
Delete(tmp);
|
Delete(tmp);
|
||||||
Delete(tmpr);
|
Delete(tmpr);
|
||||||
|
|
@ -377,28 +377,29 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
|
||||||
}
|
}
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
tp = nextSibling(tp);
|
tp = nextSibling(tp);
|
||||||
if (!p) p = tp;
|
if (!p)
|
||||||
|
p = tp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* No template parameters at all. This could be a specialization */
|
/* No template parameters at all. This could be a specialization */
|
||||||
int i, sz;
|
int i, sz;
|
||||||
sz = Len(typelist);
|
sz = Len(typelist);
|
||||||
for (i = 0; i < sz; i++) {
|
for (i = 0; i < sz; i++) {
|
||||||
String *s = Getitem(typelist,i);
|
String *s = Getitem(typelist, i);
|
||||||
SwigType_typename_replace(s,tbase,iname);
|
SwigType_typename_replace(s, tbase, iname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Patch bases */
|
/* Patch bases */
|
||||||
{
|
{
|
||||||
List *bases = Getattr(n,k_baselist);
|
List *bases = Getattr(n, k_baselist);
|
||||||
if (bases) {
|
if (bases) {
|
||||||
Iterator b;
|
Iterator b;
|
||||||
for (b = First(bases); b.item; b = Next(b)) {
|
for (b = First(bases); b.item; b = Next(b)) {
|
||||||
String *qn = Swig_symbol_type_qualify(b.item,tscope);
|
String *qn = Swig_symbol_type_qualify(b.item, tscope);
|
||||||
Clear(b.item);
|
Clear(b.item);
|
||||||
Append(b.item,qn);
|
Append(b.item, qn);
|
||||||
Delete(qn);
|
Delete(qn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -410,7 +411,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
|
||||||
Delete(tname);
|
Delete(tname);
|
||||||
Delete(templateargs);
|
Delete(templateargs);
|
||||||
|
|
||||||
/* set_nodeType(n,k_template);*/
|
/* set_nodeType(n,k_template); */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -420,168 +421,166 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
|
||||||
* Search for a template that matches name with given parameters.
|
* Search for a template that matches name with given parameters.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static Node *
|
static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
||||||
template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
Node *n;
|
||||||
Node *n;
|
|
||||||
String *tname, *rname = 0;
|
String *tname, *rname = 0;
|
||||||
Node *templ;
|
Node *templ;
|
||||||
List *mpartials = 0;
|
List *mpartials = 0;
|
||||||
Parm *p;
|
Parm *p;
|
||||||
Parm *parms;
|
Parm *parms;
|
||||||
Parm *targs;
|
Parm *targs;
|
||||||
|
|
||||||
tname = Copy(name);
|
tname = Copy(name);
|
||||||
parms = CopyParmList(tparms);
|
parms = CopyParmList(tparms);
|
||||||
|
|
||||||
/* Search for generic template */
|
/* Search for generic template */
|
||||||
templ = Swig_symbol_clookup(name,0);
|
templ = Swig_symbol_clookup(name, 0);
|
||||||
|
|
||||||
/* Add default values from generic template */
|
/* Add default values from generic template */
|
||||||
if (templ) {
|
if (templ) {
|
||||||
Symtab *tsdecl = Getattr(templ,k_symsymtab);
|
Symtab *tsdecl = Getattr(templ, k_symsymtab);
|
||||||
|
|
||||||
targs = Getattr(templ,k_templateparms);
|
targs = Getattr(templ, k_templateparms);
|
||||||
Swig_symbol_template_defargs(parms, targs, tscope, tsdecl);
|
Swig_symbol_template_defargs(parms, targs, tscope, tsdecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* reduce the typedef */
|
/* reduce the typedef */
|
||||||
p = parms;
|
p = parms;
|
||||||
while (p) {
|
while (p) {
|
||||||
SwigType *ty = Getattr(p,k_type);
|
SwigType *ty = Getattr(p, k_type);
|
||||||
if (ty) {
|
if (ty) {
|
||||||
SwigType *nt = Swig_symbol_type_qualify(ty,tscope);
|
SwigType *nt = Swig_symbol_type_qualify(ty, tscope);
|
||||||
Setattr(p,k_type,nt);
|
Setattr(p, k_type, nt);
|
||||||
Delete(nt);
|
Delete(nt);
|
||||||
}
|
}
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType_add_template(tname,parms);
|
SwigType_add_template(tname, parms);
|
||||||
|
|
||||||
if (template_debug) {
|
if (template_debug) {
|
||||||
Printf(stdout,"\n%s:%d: template_debug: Searching for %s\n", cparse_file, cparse_line, tname);
|
Printf(stdout, "\n%s:%d: template_debug: Searching for %s\n", cparse_file, cparse_line, tname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for an exact specialization.
|
/* Search for an exact specialization.
|
||||||
Example: template<> class name<int> { ... } */
|
Example: template<> class name<int> { ... } */
|
||||||
{
|
{
|
||||||
if (template_debug) {
|
if (template_debug) {
|
||||||
Printf(stdout," searching: '%s' (exact specialization)\n", tname);
|
Printf(stdout, " searching: '%s' (exact specialization)\n", tname);
|
||||||
}
|
}
|
||||||
n = Swig_symbol_clookup_local(tname,0);
|
n = Swig_symbol_clookup_local(tname, 0);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
SwigType *rname = Swig_symbol_typedef_reduce(tname,tscope);
|
SwigType *rname = Swig_symbol_typedef_reduce(tname, tscope);
|
||||||
if (!StringEqual(rname,tname)) {
|
if (!StringEqual(rname, tname)) {
|
||||||
if (template_debug) {
|
if (template_debug) {
|
||||||
Printf(stdout," searching: '%s' (exact specialization)\n", rname);
|
Printf(stdout, " searching: '%s' (exact specialization)\n", rname);
|
||||||
}
|
}
|
||||||
n = Swig_symbol_clookup_local(rname,0);
|
n = Swig_symbol_clookup_local(rname, 0);
|
||||||
}
|
}
|
||||||
Delete(rname);
|
Delete(rname);
|
||||||
}
|
}
|
||||||
if (n) {
|
if (n) {
|
||||||
Node *tn;
|
Node *tn;
|
||||||
String *nodeType = Getattr(n,k_nodetype);
|
String *nodeType = Getattr(n, k_nodetype);
|
||||||
if (StringEqual(nodeType,k_template)) goto success;
|
if (StringEqual(nodeType, k_template))
|
||||||
tn = Getattr(n,k_template);
|
goto success;
|
||||||
|
tn = Getattr(n, k_template);
|
||||||
if (tn) {
|
if (tn) {
|
||||||
n = tn;
|
n = tn;
|
||||||
goto success; /* Previously wrapped by a template return that */
|
goto success; /* Previously wrapped by a template return that */
|
||||||
}
|
}
|
||||||
Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, Getattr(n,k_nodetype));
|
Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, Getattr(n, k_nodetype));
|
||||||
Delete(tname);
|
Delete(tname);
|
||||||
Delete(parms);
|
Delete(parms);
|
||||||
return 0; /* Found a match, but it's not a template of any kind. */
|
return 0; /* Found a match, but it's not a template of any kind. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for partial specialization.
|
/* Search for partial specialization.
|
||||||
Example: template<typename T> class name<T *> { ... } */
|
Example: template<typename T> class name<T *> { ... } */
|
||||||
|
|
||||||
/* Generate reduced template name (stripped of extraneous pointers, etc.) */
|
/* Generate reduced template name (stripped of extraneous pointers, etc.) */
|
||||||
|
|
||||||
rname = NewStringf("%s<(",name);
|
rname = NewStringf("%s<(", name);
|
||||||
p = parms;
|
p = parms;
|
||||||
while (p) {
|
while (p) {
|
||||||
String *t;
|
String *t;
|
||||||
t = Getattr(p,k_type);
|
t = Getattr(p, k_type);
|
||||||
if (!t) t = Getattr(p,k_value);
|
if (!t)
|
||||||
|
t = Getattr(p, k_value);
|
||||||
if (t) {
|
if (t) {
|
||||||
String *ty = Swig_symbol_typedef_reduce(t,tscope);
|
String *ty = Swig_symbol_typedef_reduce(t, tscope);
|
||||||
String *tb = SwigType_base(ty);
|
String *tb = SwigType_base(ty);
|
||||||
String *td = SwigType_default(ty);
|
String *td = SwigType_default(ty);
|
||||||
Replaceid(td,"enum SWIGTYPE",tb);
|
Replaceid(td, "enum SWIGTYPE", tb);
|
||||||
Replaceid(td,"SWIGTYPE",tb);
|
Replaceid(td, "SWIGTYPE", tb);
|
||||||
Append(rname,td);
|
Append(rname, td);
|
||||||
Delete(tb);
|
Delete(tb);
|
||||||
Delete(ty);
|
Delete(ty);
|
||||||
Delete(td);
|
Delete(td);
|
||||||
}
|
}
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
if (p) {
|
if (p) {
|
||||||
Append(rname,",");
|
Append(rname, ",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Append(rname,")>");
|
Append(rname, ")>");
|
||||||
|
|
||||||
mpartials = NewList();
|
mpartials = NewList();
|
||||||
if (templ) {
|
if (templ) {
|
||||||
/* First, we search using an exact type prototype */
|
/* First, we search using an exact type prototype */
|
||||||
Parm *p;
|
Parm *p;
|
||||||
char tmp[32];
|
char tmp[32];
|
||||||
int i;
|
int i;
|
||||||
List *partials;
|
List *partials;
|
||||||
String *ss;
|
String *ss;
|
||||||
Iterator pi;
|
Iterator pi;
|
||||||
|
|
||||||
partials = Getattr(templ,k_partials);
|
partials = Getattr(templ, k_partials);
|
||||||
if (partials) {
|
if (partials) {
|
||||||
for (pi = First(partials); pi.item; pi = Next(pi)) {
|
for (pi = First(partials); pi.item; pi = Next(pi)) {
|
||||||
ss = Copy(pi.item);
|
ss = Copy(pi.item);
|
||||||
p = parms;
|
p = parms;
|
||||||
i = 1;
|
i = 1;
|
||||||
while (p) {
|
while (p) {
|
||||||
String *t,*tn;
|
String *t, *tn;
|
||||||
sprintf(tmp,"$%d",i);
|
sprintf(tmp, "$%d", i);
|
||||||
t = Getattr(p,k_type);
|
t = Getattr(p, k_type);
|
||||||
if (!t) t = Getattr(p,k_value);
|
if (!t)
|
||||||
if (t) {
|
t = Getattr(p, k_value);
|
||||||
String *ty = Swig_symbol_typedef_reduce(t,tscope);
|
if (t) {
|
||||||
tn = SwigType_base(ty);
|
String *ty = Swig_symbol_typedef_reduce(t, tscope);
|
||||||
Replaceid(ss,tmp,tn);
|
tn = SwigType_base(ty);
|
||||||
Delete(tn);
|
Replaceid(ss, tmp, tn);
|
||||||
Delete(ty);
|
Delete(tn);
|
||||||
}
|
Delete(ty);
|
||||||
i++;
|
|
||||||
p = nextSibling(p);
|
|
||||||
}
|
}
|
||||||
if (template_debug) {
|
i++;
|
||||||
Printf(stdout," searching: '%s' (partial specialization - %s)\n", ss, pi.item);
|
p = nextSibling(p);
|
||||||
}
|
|
||||||
if ((StringEqual(ss,tname)) || (StringEqual(ss,rname))) {
|
|
||||||
Append(mpartials,pi.item);
|
|
||||||
}
|
|
||||||
Delete(ss);
|
|
||||||
}
|
}
|
||||||
|
if (template_debug) {
|
||||||
|
Printf(stdout, " searching: '%s' (partial specialization - %s)\n", ss, pi.item);
|
||||||
|
}
|
||||||
|
if ((StringEqual(ss, tname)) || (StringEqual(ss, rname))) {
|
||||||
|
Append(mpartials, pi.item);
|
||||||
|
}
|
||||||
|
Delete(ss);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template_debug) {
|
if (template_debug) {
|
||||||
Printf(stdout," Matched partials: %s\n", mpartials);
|
Printf(stdout, " Matched partials: %s\n", mpartials);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Len(mpartials)) {
|
if (Len(mpartials)) {
|
||||||
String *s = Getitem(mpartials,0);
|
String *s = Getitem(mpartials, 0);
|
||||||
n = Swig_symbol_clookup_local(s,0);
|
n = Swig_symbol_clookup_local(s, 0);
|
||||||
if (Len(mpartials) > 1) {
|
if (Len(mpartials) > 1) {
|
||||||
if (n) {
|
if (n) {
|
||||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG,cparse_file,cparse_line,
|
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, cparse_file, cparse_line, "Instantiation of template '%s' is ambiguous,\n", SwigType_namestr(tname));
|
||||||
"Instantiation of template '%s' is ambiguous,\n",
|
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(n), Getline(n), " instantiation '%s' is used.\n", SwigType_namestr(Getattr(n, k_name)));
|
||||||
SwigType_namestr(tname));
|
|
||||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG,Getfile(n),Getline(n),
|
|
||||||
" instantiation '%s' is used.\n",
|
|
||||||
SwigType_namestr(Getattr(n,k_name)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -591,20 +590,20 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
||||||
}
|
}
|
||||||
if (!n) {
|
if (!n) {
|
||||||
Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name);
|
Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name);
|
||||||
} else if (n) {
|
} else if (n) {
|
||||||
String *nodeType = Getattr(n,k_nodetype);
|
String *nodeType = Getattr(n, k_nodetype);
|
||||||
if (!StringEqual(nodeType,k_template)) {
|
if (!StringEqual(nodeType, k_template)) {
|
||||||
Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType);
|
Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType);
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
success:
|
success:
|
||||||
Delete(tname);
|
Delete(tname);
|
||||||
Delete(rname);
|
Delete(rname);
|
||||||
Delete(mpartials);
|
Delete(mpartials);
|
||||||
if ((template_debug) && (n)) {
|
if ((template_debug) && (n)) {
|
||||||
Printf(stdout,"Node: %p\n", n);
|
Printf(stdout, "Node: %p\n", n);
|
||||||
Swig_print_node(n);
|
Swig_print_node(n);
|
||||||
}
|
}
|
||||||
Delete(parms);
|
Delete(parms);
|
||||||
return n;
|
return n;
|
||||||
|
|
@ -620,15 +619,14 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
||||||
* template exists.
|
* template exists.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
Node *
|
Node *Swig_cparse_template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
||||||
Swig_cparse_template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
Node *n = template_locate(name, tparms, tscope); /* this function does what we want for templated classes */
|
||||||
Node *n = template_locate(name, tparms, tscope); /* this function does what we want for templated classes */
|
|
||||||
|
|
||||||
if (n) {
|
if (n) {
|
||||||
String *nodeType = Getattr(n,k_nodetype);
|
String *nodeType = Getattr(n, k_nodetype);
|
||||||
int isclass = 0;
|
int isclass = 0;
|
||||||
assert(StringEqual(nodeType,k_template));
|
assert(StringEqual(nodeType, k_template));
|
||||||
isclass = (StringEqual(Getattr(n,k_templatetype),k_class));
|
isclass = (StringEqual(Getattr(n, k_templatetype), k_class));
|
||||||
if (!isclass) {
|
if (!isclass) {
|
||||||
/* If not a templated class we must have a templated function.
|
/* If not a templated class we must have a templated function.
|
||||||
The template found is not necessarily the one we want when dealing with templated
|
The template found is not necessarily the one we want when dealing with templated
|
||||||
|
|
@ -638,31 +636,30 @@ Swig_cparse_template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
||||||
templated function with different numbers of template parameters. */
|
templated function with different numbers of template parameters. */
|
||||||
|
|
||||||
if (template_debug) {
|
if (template_debug) {
|
||||||
Printf(stdout," Not a templated class, seeking most appropriate templated function\n");
|
Printf(stdout, " Not a templated class, seeking most appropriate templated function\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
n = Swig_symbol_clookup_local(name,0);
|
n = Swig_symbol_clookup_local(name, 0);
|
||||||
while (n) {
|
while (n) {
|
||||||
Parm *tparmsfound = Getattr(n,k_templateparms);
|
Parm *tparmsfound = Getattr(n, k_templateparms);
|
||||||
if (ParmList_len(tparms) == ParmList_len(tparmsfound)) {
|
if (ParmList_len(tparms) == ParmList_len(tparmsfound)) {
|
||||||
/* successful match */
|
/* successful match */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* repeat until we find a match with correct number of templated parameters */
|
/* repeat until we find a match with correct number of templated parameters */
|
||||||
n = Getattr(n,k_symnextSibling);
|
n = Getattr(n, k_symnextSibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!n) {
|
if (!n) {
|
||||||
Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name);
|
Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((template_debug) && (n)) {
|
if ((template_debug) && (n)) {
|
||||||
Printf(stdout,"Templated function found: %p\n", n);
|
Printf(stdout, "Templated function found: %p\n", n);
|
||||||
Swig_print_node(n);
|
Swig_print_node(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,17 @@ char cvsroot_util_c[] = "$Header$";
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Swig_cparse_replace_descriptor(String *s) {
|
void Swig_cparse_replace_descriptor(String *s) {
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
String *arg = 0;
|
String *arg = 0;
|
||||||
SwigType *t;
|
SwigType *t;
|
||||||
char *c = 0;
|
char *c = 0;
|
||||||
|
|
||||||
while ((c = strstr(Char(s),"$descriptor("))) {
|
while ((c = strstr(Char(s), "$descriptor("))) {
|
||||||
char *d = tmp;
|
char *d = tmp;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == '(') level++;
|
if (*c == '(')
|
||||||
|
level++;
|
||||||
if (*c == ')') {
|
if (*c == ')') {
|
||||||
level--;
|
level--;
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
|
|
@ -42,7 +43,7 @@ void Swig_cparse_replace_descriptor(String *s) {
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
*d = 0;
|
*d = 0;
|
||||||
arg = NewString(tmp+12);
|
arg = NewString(tmp + 12);
|
||||||
t = Swig_cparse_type(arg);
|
t = Swig_cparse_type(arg);
|
||||||
Delete(arg);
|
Delete(arg);
|
||||||
arg = 0;
|
arg = 0;
|
||||||
|
|
@ -50,19 +51,19 @@ void Swig_cparse_replace_descriptor(String *s) {
|
||||||
if (t) {
|
if (t) {
|
||||||
String *mangle;
|
String *mangle;
|
||||||
String *descriptor;
|
String *descriptor;
|
||||||
|
|
||||||
mangle = SwigType_manglestr(t);
|
mangle = SwigType_manglestr(t);
|
||||||
descriptor = NewStringf("SWIGTYPE%s",mangle);
|
descriptor = NewStringf("SWIGTYPE%s", mangle);
|
||||||
SwigType_remember(t);
|
SwigType_remember(t);
|
||||||
*d = ')';
|
*d = ')';
|
||||||
d++;
|
d++;
|
||||||
*d = 0;
|
*d = 0;
|
||||||
Replace(s,tmp,descriptor,DOH_REPLACE_ANY);
|
Replace(s, tmp, descriptor, DOH_REPLACE_ANY);
|
||||||
Delete(mangle);
|
Delete(mangle);
|
||||||
Delete(descriptor);
|
Delete(descriptor);
|
||||||
Delete(t);
|
Delete(t);
|
||||||
} else {
|
} else {
|
||||||
Swig_error(Getfile(s),Getline(s),"Bad $descriptor() macro.\n");
|
Swig_error(Getfile(s), Getline(s), "Bad $descriptor() macro.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,15 +77,13 @@ void Swig_cparse_replace_descriptor(String *s) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void cparse_normalize_void(Node *n) {
|
void cparse_normalize_void(Node *n) {
|
||||||
String *decl = Getattr(n,k_decl);
|
String *decl = Getattr(n, k_decl);
|
||||||
Parm *parms = Getattr(n,k_parms);
|
Parm *parms = Getattr(n, k_parms);
|
||||||
|
|
||||||
if (SwigType_isfunction(decl)) {
|
if (SwigType_isfunction(decl)) {
|
||||||
if ((ParmList_len(parms) == 1) && (SwigType_type(Getattr(parms,k_type)) == T_VOID)) {
|
if ((ParmList_len(parms) == 1) && (SwigType_type(Getattr(parms, k_type)) == T_VOID)) {
|
||||||
Replaceall(decl,"f(void).","f().");
|
Replaceall(decl, "f(void).", "f().");
|
||||||
Delattr(n,k_parms);
|
Delattr(n, k_parms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -165,11 +165,11 @@ typedef void DOH;
|
||||||
/* Iterator objects */
|
/* Iterator objects */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *key; /* Current key (if any) */
|
void *key; /* Current key (if any) */
|
||||||
void *item; /* Current item */
|
void *item; /* Current item */
|
||||||
void *object; /* Object being iterated over */
|
void *object; /* Object being iterated over */
|
||||||
void *_current; /* Internal use */
|
void *_current; /* Internal use */
|
||||||
int _index; /* Internal use */
|
int _index; /* Internal use */
|
||||||
} DohIterator;
|
} DohIterator;
|
||||||
|
|
||||||
/* Memory management */
|
/* Memory management */
|
||||||
|
|
@ -184,77 +184,77 @@ typedef struct {
|
||||||
#define DohFree free
|
#define DohFree free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int DohCheck(const DOH *ptr); /* Check if a DOH object */
|
extern int DohCheck(const DOH *ptr); /* Check if a DOH object */
|
||||||
extern void DohIntern(DOH *); /* Intern an object */
|
extern void DohIntern(DOH *); /* Intern an object */
|
||||||
|
|
||||||
/* Basic object methods. Common to most objects */
|
/* Basic object methods. Common to most objects */
|
||||||
|
|
||||||
extern void DohDelete(DOH *obj); /* Delete an object */
|
extern void DohDelete(DOH *obj); /* Delete an object */
|
||||||
extern DOH *DohCopy(const DOH *obj);
|
extern DOH *DohCopy(const DOH *obj);
|
||||||
extern void DohClear(DOH *obj);
|
extern void DohClear(DOH *obj);
|
||||||
extern DOHString *DohStr(const DOH *obj);
|
extern DOHString *DohStr(const DOH *obj);
|
||||||
extern void *DohData(const DOH *obj);
|
extern void *DohData(const DOH *obj);
|
||||||
extern int DohDump(const DOH *obj, DOHFile *out);
|
extern int DohDump(const DOH *obj, DOHFile * out);
|
||||||
extern int DohLen(const DOH *obj);
|
extern int DohLen(const DOH *obj);
|
||||||
extern int DohHashval(const DOH *obj);
|
extern int DohHashval(const DOH *obj);
|
||||||
extern int DohCmp(const DOH *obj1, const DOH *obj2);
|
extern int DohCmp(const DOH *obj1, const DOH *obj2);
|
||||||
extern int DohEqual(const DOH *obj1, const DOH *obj2);
|
extern int DohEqual(const DOH *obj1, const DOH *obj2);
|
||||||
extern void DohIncref(DOH *obj);
|
extern void DohIncref(DOH *obj);
|
||||||
|
|
||||||
/* Mapping methods */
|
/* Mapping methods */
|
||||||
|
|
||||||
extern DOH *DohGetattr(DOH *obj, const DOHString_or_char *name);
|
extern DOH *DohGetattr(DOH *obj, const DOHString_or_char *name);
|
||||||
extern int DohSetattr(DOH *obj, const DOHString_or_char *name, const DOHObj_or_char *value);
|
extern int DohSetattr(DOH *obj, const DOHString_or_char *name, const DOHObj_or_char * value);
|
||||||
extern int DohDelattr(DOH *obj, const DOHString_or_char *name);
|
extern int DohDelattr(DOH *obj, const DOHString_or_char *name);
|
||||||
extern DOH *DohKeys(DOH *obj);
|
extern DOH *DohKeys(DOH *obj);
|
||||||
extern int DohGetInt(DOH *obj, const DOHString_or_char *name);
|
extern int DohGetInt(DOH *obj, const DOHString_or_char *name);
|
||||||
extern void DohSetInt(DOH *obj, const DOHString_or_char *name, int);
|
extern void DohSetInt(DOH *obj, const DOHString_or_char *name, int);
|
||||||
extern double DohGetDouble(DOH *obj, const DOHString_or_char *name);
|
extern double DohGetDouble(DOH *obj, const DOHString_or_char *name);
|
||||||
extern void DohSetDouble(DOH *obj, const DOHString_or_char *name, double);
|
extern void DohSetDouble(DOH *obj, const DOHString_or_char *name, double);
|
||||||
extern char *DohGetChar(DOH *obj, const DOHString_or_char *name);
|
extern char *DohGetChar(DOH *obj, const DOHString_or_char *name);
|
||||||
extern void DohSetChar(DOH *obj, const DOH *name, char *value);
|
extern void DohSetChar(DOH *obj, const DOH *name, char *value);
|
||||||
extern void *DohGetFlagAttr(DOH *obj, const DOHString_or_char *name);
|
extern void *DohGetFlagAttr(DOH *obj, const DOHString_or_char *name);
|
||||||
extern int DohGetFlag(DOH *obj, const DOHString_or_char *name);
|
extern int DohGetFlag(DOH *obj, const DOHString_or_char *name);
|
||||||
extern void DohSetFlagAttr(DOH *obj, const DOHString_or_char *name, const DOHString_or_char *attr);
|
extern void DohSetFlagAttr(DOH *obj, const DOHString_or_char *name, const DOHString_or_char *attr);
|
||||||
extern void DohSetFlag(DOH *obj, const DOHString_or_char *name);
|
extern void DohSetFlag(DOH *obj, const DOHString_or_char *name);
|
||||||
extern void *DohGetVoid(DOH *obj, const DOHString_or_char *name);
|
extern void *DohGetVoid(DOH *obj, const DOHString_or_char *name);
|
||||||
extern void DohSetVoid(DOH *obj, const DOHString_or_char *name, void *value);
|
extern void DohSetVoid(DOH *obj, const DOHString_or_char *name, void *value);
|
||||||
|
|
||||||
/* Sequence methods */
|
/* Sequence methods */
|
||||||
|
|
||||||
extern DOH *DohGetitem(DOH *obj, int index);
|
extern DOH *DohGetitem(DOH *obj, int index);
|
||||||
extern int DohSetitem(DOH *obj, int index, const DOHObj_or_char *value);
|
extern int DohSetitem(DOH *obj, int index, const DOHObj_or_char * value);
|
||||||
extern int DohDelitem(DOH *obj, int index);
|
extern int DohDelitem(DOH *obj, int index);
|
||||||
extern int DohInsertitem(DOH *obj, int index, const DOHObj_or_char *value);
|
extern int DohInsertitem(DOH *obj, int index, const DOHObj_or_char * value);
|
||||||
extern int DohDelslice(DOH *obj, int sindex, int eindex);
|
extern int DohDelslice(DOH *obj, int sindex, int eindex);
|
||||||
|
|
||||||
/* File methods */
|
/* File methods */
|
||||||
|
|
||||||
extern int DohWrite(DOHFile *obj, void *buffer, int length);
|
extern int DohWrite(DOHFile * obj, void *buffer, int length);
|
||||||
extern int DohRead(DOHFile *obj, void *buffer, int length);
|
extern int DohRead(DOHFile * obj, void *buffer, int length);
|
||||||
extern int DohSeek(DOHFile *obj, long offset, int whence);
|
extern int DohSeek(DOHFile * obj, long offset, int whence);
|
||||||
extern long DohTell(DOHFile *obj);
|
extern long DohTell(DOHFile * obj);
|
||||||
extern int DohGetc(DOHFile *obj);
|
extern int DohGetc(DOHFile * obj);
|
||||||
extern int DohPutc(int ch, DOHFile *obj);
|
extern int DohPutc(int ch, DOHFile * obj);
|
||||||
extern int DohUngetc(int ch, DOHFile *obj);
|
extern int DohUngetc(int ch, DOHFile * obj);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Iterators */
|
/* Iterators */
|
||||||
extern DohIterator DohFirst(DOH *obj);
|
extern DohIterator DohFirst(DOH *obj);
|
||||||
extern DohIterator DohNext(DohIterator x);
|
extern DohIterator DohNext(DohIterator x);
|
||||||
|
|
||||||
/* Positional */
|
/* Positional */
|
||||||
|
|
||||||
extern int DohGetline(DOH *obj);
|
extern int DohGetline(DOH *obj);
|
||||||
extern void DohSetline(DOH *obj, int line);
|
extern void DohSetline(DOH *obj, int line);
|
||||||
extern DOH *DohGetfile(DOH *obj);
|
extern DOH *DohGetfile(DOH *obj);
|
||||||
extern void DohSetfile(DOH *obj, DOH *file);
|
extern void DohSetfile(DOH *obj, DOH *file);
|
||||||
|
|
||||||
/* String Methods */
|
/* String Methods */
|
||||||
|
|
||||||
extern int DohReplace(DOHString *src, const DOHString_or_char *token, const DOHString_or_char *rep, int flags);
|
extern int DohReplace(DOHString * src, const DOHString_or_char *token, const DOHString_or_char *rep, int flags);
|
||||||
extern void DohChop(DOHString *src);
|
extern void DohChop(DOHString * src);
|
||||||
|
|
||||||
extern int DohString_putc(DOH *so, int ch);
|
extern int DohString_putc(DOH *so, int ch);
|
||||||
extern int DohString_getc(DOH *so);
|
extern int DohString_getc(DOH *so);
|
||||||
|
|
@ -274,39 +274,39 @@ extern int DohString_delslice(DOH *so, int sindex, int eindex);
|
||||||
#define DohStringEqual(s1,s2) DohString_equal((DOH *)s1, (DOH *)s2)
|
#define DohStringEqual(s1,s2) DohString_equal((DOH *)s1, (DOH *)s2)
|
||||||
|
|
||||||
/* Meta-variables */
|
/* Meta-variables */
|
||||||
extern DOH *DohGetmeta(DOH *, const DOH *);
|
extern DOH *DohGetmeta(DOH *, const DOH *);
|
||||||
extern int DohSetmeta(DOH *, const DOH *, const DOH *value);
|
extern int DohSetmeta(DOH *, const DOH *, const DOH *value);
|
||||||
extern int DohDelmeta(DOH *, const DOH *);
|
extern int DohDelmeta(DOH *, const DOH *);
|
||||||
|
|
||||||
/* Utility functions */
|
/* Utility functions */
|
||||||
|
|
||||||
extern void DohEncoding(char *name, DOH *(*fn)(DOH *s));
|
extern void DohEncoding(char *name, DOH *(*fn) (DOH *s));
|
||||||
extern int DohPrintf(DOHFile *obj, const char *format, ...);
|
extern int DohPrintf(DOHFile * obj, const char *format, ...);
|
||||||
extern int DohvPrintf(DOHFile *obj, const char *format, va_list ap);
|
extern int DohvPrintf(DOHFile * obj, const char *format, va_list ap);
|
||||||
extern int DohPrintv(DOHFile *obj, ...);
|
extern int DohPrintv(DOHFile * obj, ...);
|
||||||
extern DOH *DohReadline(DOHFile *in);
|
extern DOH *DohReadline(DOHFile * in);
|
||||||
|
|
||||||
/* Miscellaneous */
|
/* Miscellaneous */
|
||||||
|
|
||||||
extern int DohIsMapping(const DOH *obj);
|
extern int DohIsMapping(const DOH *obj);
|
||||||
extern int DohIsSequence(const DOH *obj);
|
extern int DohIsSequence(const DOH *obj);
|
||||||
extern int DohIsString(const DOH *obj);
|
extern int DohIsString(const DOH *obj);
|
||||||
extern int DohIsFile(const DOH *obj);
|
extern int DohIsFile(const DOH *obj);
|
||||||
|
|
||||||
extern void DohSetmark(DOH *obj, int x);
|
extern void DohSetmark(DOH *obj, int x);
|
||||||
extern int DohGetmark(DOH *obj);
|
extern int DohGetmark(DOH *obj);
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Strings.
|
* Strings.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
extern DOHString *DohNewStringEmpty();
|
extern DOHString *DohNewStringEmpty();
|
||||||
extern DOHString *DohNewString(const DOH *c);
|
extern DOHString *DohNewString(const DOH *c);
|
||||||
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
|
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
|
||||||
extern DOHString *DohNewStringf(const DOH *fmt, ...);
|
extern DOHString *DohNewStringf(const DOH *fmt, ...);
|
||||||
|
|
||||||
extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2);
|
extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2);
|
||||||
extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n);
|
extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n);
|
||||||
extern char *DohStrstr(const DOHString_or_char *s1, const DOHString_or_char *s2);
|
extern char *DohStrstr(const DOHString_or_char *s1, const DOHString_or_char *s2);
|
||||||
extern char *DohStrchr(const DOHString_or_char *s1, int ch);
|
extern char *DohStrchr(const DOHString_or_char *s1, int ch);
|
||||||
|
|
||||||
|
|
@ -329,36 +329,36 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch);
|
||||||
extern DOHFile *DohNewFile(DOH *file, const char *mode);
|
extern DOHFile *DohNewFile(DOH *file, const char *mode);
|
||||||
extern DOHFile *DohNewFileFromFile(FILE *f);
|
extern DOHFile *DohNewFileFromFile(FILE *f);
|
||||||
extern DOHFile *DohNewFileFromFd(int fd);
|
extern DOHFile *DohNewFileFromFd(int fd);
|
||||||
extern void DohFileErrorDisplay(DOHString *filename);
|
extern void DohFileErrorDisplay(DOHString * filename);
|
||||||
extern int DohClose(DOH *file);
|
extern int DohClose(DOH *file);
|
||||||
extern int DohCopyto(DOHFile *input, DOHFile *output);
|
extern int DohCopyto(DOHFile * input, DOHFile * output);
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* List
|
* List
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
extern DOHList *DohNewList();
|
extern DOHList *DohNewList();
|
||||||
extern void DohSortList(DOH *lo, int (*cmp)(const DOH *, const DOH *));
|
extern void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *));
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Hash
|
* Hash
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
extern DOHHash *DohNewHash();
|
extern DOHHash *DohNewHash();
|
||||||
extern DOH *DohHashGetAttr(DOH *hash, const DOH *key);
|
extern DOH *DohHashGetAttr(DOH *hash, const DOH *key);
|
||||||
extern int DohHashCheckAttr(DOH *hash, DOH *key, DOH *value);
|
extern int DohHashCheckAttr(DOH *hash, DOH *key, DOH *value);
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Void
|
* Void
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
extern DOHVoid *DohNewVoid(void *ptr, void (*del)(void *));
|
extern DOHVoid *DohNewVoid(void *ptr, void (*del) (void *));
|
||||||
extern DOHList *DohSplit(DOHFile *input, char ch, int nsplits);
|
extern DOHList *DohSplit(DOHFile * input, char ch, int nsplits);
|
||||||
extern DOHList *DohSplitLines(DOHFile *input);
|
extern DOHList *DohSplitLines(DOHFile * input);
|
||||||
extern DOH *DohNone;
|
extern DOH *DohNone;
|
||||||
|
|
||||||
extern void DohMemoryDebug(void);
|
extern void DohMemoryDebug(void);
|
||||||
|
|
||||||
#ifndef DOH_LONG_NAMES
|
#ifndef DOH_LONG_NAMES
|
||||||
/* Macros to invoke the above functions. Includes the location of
|
/* Macros to invoke the above functions. Includes the location of
|
||||||
|
|
@ -468,8 +468,4 @@ extern void DohMemoryDebug(void);
|
||||||
#define NIL (char *) NULL
|
#define NIL (char *) NULL
|
||||||
|
|
||||||
|
|
||||||
#endif /* DOH_H */
|
#endif /* DOH_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,37 +26,37 @@
|
||||||
|
|
||||||
/* Hash objects */
|
/* Hash objects */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DOH *(*doh_getattr)(DOH *obj, DOH *name); /* Get attribute */
|
DOH *(*doh_getattr) (DOH *obj, DOH *name); /* Get attribute */
|
||||||
int (*doh_setattr)(DOH *obj, DOH *name, DOH *value); /* Set attribute */
|
int (*doh_setattr) (DOH *obj, DOH *name, DOH *value); /* Set attribute */
|
||||||
int (*doh_delattr)(DOH *obj, DOH *name); /* Del attribute */
|
int (*doh_delattr) (DOH *obj, DOH *name); /* Del attribute */
|
||||||
DOH *(*doh_keys)(DOH *obj); /* All keys as a list */
|
DOH *(*doh_keys) (DOH *obj); /* All keys as a list */
|
||||||
} DohHashMethods;
|
} DohHashMethods;
|
||||||
|
|
||||||
/* List objects */
|
/* List objects */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DOH *(*doh_getitem)(DOH *obj, int index); /* Get item */
|
DOH *(*doh_getitem) (DOH *obj, int index); /* Get item */
|
||||||
int (*doh_setitem)(DOH *obj, int index, DOH *value); /* Set item */
|
int (*doh_setitem) (DOH *obj, int index, DOH *value); /* Set item */
|
||||||
int (*doh_delitem)(DOH *obj, int index); /* Delete item */
|
int (*doh_delitem) (DOH *obj, int index); /* Delete item */
|
||||||
int (*doh_insitem)(DOH *obj, int index, DOH *value); /* Insert item */
|
int (*doh_insitem) (DOH *obj, int index, DOH *value); /* Insert item */
|
||||||
int (*doh_delslice)(DOH *obj, int sindex, int eindex); /* Delete slice */
|
int (*doh_delslice) (DOH *obj, int sindex, int eindex); /* Delete slice */
|
||||||
} DohListMethods;
|
} DohListMethods;
|
||||||
|
|
||||||
/* File methods */
|
/* File methods */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int (*doh_read)(DOH *obj, void *buffer, int nbytes); /* Read bytes */
|
int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */
|
||||||
int (*doh_write)(DOH *obj, void *buffer, int nbytes); /* Write bytes */
|
int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */
|
||||||
int (*doh_putc)(DOH *obj, int ch); /* Put character */
|
int (*doh_putc) (DOH *obj, int ch); /* Put character */
|
||||||
int (*doh_getc)(DOH *obj); /* Get character */
|
int (*doh_getc) (DOH *obj); /* Get character */
|
||||||
int (*doh_ungetc)(DOH *obj, int ch); /* Unget character */
|
int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */
|
||||||
int (*doh_seek)(DOH *obj, long offset, int whence); /* Seek */
|
int (*doh_seek) (DOH *obj, long offset, int whence); /* Seek */
|
||||||
long (*doh_tell)(DOH *obj); /* Tell */
|
long (*doh_tell) (DOH *obj); /* Tell */
|
||||||
int (*doh_close)(DOH *obj); /* Close */
|
int (*doh_close) (DOH *obj); /* Close */
|
||||||
} DohFileMethods;
|
} DohFileMethods;
|
||||||
|
|
||||||
/* String methods */
|
/* String methods */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int (*doh_replace)(DOH *obj, DOH *old, DOH *rep, int flags);
|
int (*doh_replace) (DOH *obj, DOH *old, DOH *rep, int flags);
|
||||||
void (*doh_chop)(DOH *obj);
|
void (*doh_chop) (DOH *obj);
|
||||||
} DohStringMethods;
|
} DohStringMethods;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -64,55 +64,55 @@ typedef struct {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct DohObjInfo {
|
typedef struct DohObjInfo {
|
||||||
char *objname; /* Object name */
|
char *objname; /* Object name */
|
||||||
|
|
||||||
/* Basic object methods */
|
/* Basic object methods */
|
||||||
void (*doh_del)(DOH *obj); /* Delete object */
|
void (*doh_del) (DOH *obj); /* Delete object */
|
||||||
DOH *(*doh_copy)(DOH *obj); /* Copy and object */
|
DOH *(*doh_copy) (DOH *obj); /* Copy and object */
|
||||||
void (*doh_clear)(DOH *obj); /* Clear an object */
|
void (*doh_clear) (DOH *obj); /* Clear an object */
|
||||||
|
|
||||||
/* I/O methods */
|
/* I/O methods */
|
||||||
DOH *(*doh_str)(DOH *obj); /* Make a full string */
|
DOH *(*doh_str) (DOH *obj); /* Make a full string */
|
||||||
void *(*doh_data)(DOH *obj); /* Return raw data */
|
void *(*doh_data) (DOH *obj); /* Return raw data */
|
||||||
int (*doh_dump)(DOH *obj, DOH *out); /* Serialize on out */
|
int (*doh_dump) (DOH *obj, DOH *out); /* Serialize on out */
|
||||||
|
|
||||||
/* Length and hash values */
|
/* Length and hash values */
|
||||||
int (*doh_len)(DOH *obj);
|
int (*doh_len) (DOH *obj);
|
||||||
int (*doh_hashval)(DOH *obj);
|
int (*doh_hashval) (DOH *obj);
|
||||||
|
|
||||||
/* Compare */
|
/* Compare */
|
||||||
int (*doh_cmp)(DOH *obj1, DOH *obj2);
|
int (*doh_cmp) (DOH *obj1, DOH *obj2);
|
||||||
|
|
||||||
/* Equal */
|
/* Equal */
|
||||||
int (*doh_equal)(DOH *obj1, DOH *obj2);
|
int (*doh_equal) (DOH *obj1, DOH *obj2);
|
||||||
|
|
||||||
/* Iterators */
|
/* Iterators */
|
||||||
DohIterator (*doh_first)(DOH *obj);
|
DohIterator (*doh_first) (DOH *obj);
|
||||||
DohIterator (*doh_next)(DohIterator );
|
DohIterator (*doh_next) (DohIterator);
|
||||||
|
|
||||||
/* Positional */
|
/* Positional */
|
||||||
void (*doh_setfile)(DOH *obj, DOHString_or_char *file);
|
void (*doh_setfile) (DOH *obj, DOHString_or_char *file);
|
||||||
DOH *(*doh_getfile)(DOH *obj);
|
DOH *(*doh_getfile) (DOH *obj);
|
||||||
void (*doh_setline)(DOH *obj, int line);
|
void (*doh_setline) (DOH *obj, int line);
|
||||||
int (*doh_getline)(DOH *obj);
|
int (*doh_getline) (DOH *obj);
|
||||||
|
|
||||||
DohHashMethods *doh_hash; /* Hash methods */
|
DohHashMethods *doh_hash; /* Hash methods */
|
||||||
DohListMethods *doh_list; /* List methods */
|
DohListMethods *doh_list; /* List methods */
|
||||||
DohFileMethods *doh_file; /* File methods */
|
DohFileMethods *doh_file; /* File methods */
|
||||||
DohStringMethods *doh_string; /* String methods */
|
DohStringMethods *doh_string; /* String methods */
|
||||||
void *doh_reserved; /* Reserved */
|
void *doh_reserved; /* Reserved */
|
||||||
void *clientdata; /* User data */
|
void *clientdata; /* User data */
|
||||||
} DohObjInfo;
|
} DohObjInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *data; /* Data pointer */
|
void *data; /* Data pointer */
|
||||||
DohObjInfo *type;
|
DohObjInfo *type;
|
||||||
void *meta; /* Meta data */
|
void *meta; /* Meta data */
|
||||||
unsigned int flag_intern : 1; /* Interned object */
|
unsigned int flag_intern:1; /* Interned object */
|
||||||
unsigned int flag_marked : 1; /* Mark flag. Used to avoid recursive loops in places */
|
unsigned int flag_marked:1; /* Mark flag. Used to avoid recursive loops in places */
|
||||||
unsigned int flag_user : 1; /* User flag */
|
unsigned int flag_user:1; /* User flag */
|
||||||
unsigned int flag_usermark : 1; /* User marked */
|
unsigned int flag_usermark:1; /* User marked */
|
||||||
unsigned int refcount : 28; /* Reference count (max 16 million) */
|
unsigned int refcount:28; /* Reference count (max 16 million) */
|
||||||
} DohBase;
|
} DohBase;
|
||||||
|
|
||||||
/* Macros for decrefing and increfing (safe for null objects). */
|
/* Macros for decrefing and increfing (safe for null objects). */
|
||||||
|
|
@ -127,12 +127,7 @@ typedef struct {
|
||||||
#define ObjGetMark(a) ((DohBase *)a)->flag_marked
|
#define ObjGetMark(a) ((DohBase *)a)->flag_marked
|
||||||
#define ObjType(a) ((DohBase *)a)->type
|
#define ObjType(a) ((DohBase *)a)->type
|
||||||
|
|
||||||
extern DOH *DohObjMalloc(DohObjInfo *type, void *data); /* Allocate a DOH object */
|
extern DOH *DohObjMalloc(DohObjInfo *type, void *data); /* Allocate a DOH object */
|
||||||
extern void DohObjFree(DOH *ptr); /* Free a DOH object */
|
extern void DohObjFree(DOH *ptr); /* Free a DOH object */
|
||||||
|
|
||||||
#endif /* DOHINT_H */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DOHINT_H */
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,16 @@ char cvsroot_file_c[] = "$Header$";
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FILE *filep;
|
FILE *filep;
|
||||||
int fd;
|
int fd;
|
||||||
int closeondel;
|
int closeondel;
|
||||||
} DohFile;
|
} DohFile;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DelFile()
|
* DelFile()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void DelFile(DOH *fo) {
|
||||||
DelFile(DOH *fo) {
|
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
if (f->closeondel) {
|
if (f->closeondel) {
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
|
|
@ -49,15 +48,14 @@ DelFile(DOH *fo) {
|
||||||
* File_read()
|
* File_read()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int File_read(DOH *fo, void *buffer, int len) {
|
||||||
File_read(DOH *fo, void *buffer, int len) {
|
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
|
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
return fread(buffer,1,len,f->filep);
|
return fread(buffer, 1, len, f->filep);
|
||||||
} else if (f->fd) {
|
} else if (f->fd) {
|
||||||
#ifdef DOH_INTFILE
|
#ifdef DOH_INTFILE
|
||||||
return read(f->fd,buffer,len);
|
return read(f->fd, buffer, len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -67,16 +65,15 @@ File_read(DOH *fo, void *buffer, int len) {
|
||||||
* File_write()
|
* File_write()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int File_write(DOH *fo, void *buffer, int len) {
|
||||||
File_write(DOH *fo, void *buffer, int len) {
|
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
int ret = (int) fwrite(buffer, 1, len, f->filep);
|
int ret = (int) fwrite(buffer, 1, len, f->filep);
|
||||||
int err = (ret != len) ? ferror(f->filep) : 0;
|
int err = (ret != len) ? ferror(f->filep) : 0;
|
||||||
return err ? -1: ret;
|
return err ? -1 : ret;
|
||||||
} else if (f->fd) {
|
} else if (f->fd) {
|
||||||
#ifdef DOH_INTFILE
|
#ifdef DOH_INTFILE
|
||||||
return write(f->fd,buffer,len);
|
return write(f->fd, buffer, len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -86,11 +83,10 @@ File_write(DOH *fo, void *buffer, int len) {
|
||||||
* File_seek()
|
* File_seek()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int File_seek(DOH *fo, long offset, int whence) {
|
||||||
File_seek(DOH *fo, long offset, int whence) {
|
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
return fseek(f->filep,offset,whence);
|
return fseek(f->filep, offset, whence);
|
||||||
} else if (f->fd) {
|
} else if (f->fd) {
|
||||||
#ifdef DOH_INTFILE
|
#ifdef DOH_INTFILE
|
||||||
return lseek(f->fd, offset, whence);
|
return lseek(f->fd, offset, whence);
|
||||||
|
|
@ -103,8 +99,7 @@ File_seek(DOH *fo, long offset, int whence) {
|
||||||
* File_tell()
|
* File_tell()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static long
|
static long File_tell(DOH *fo) {
|
||||||
File_tell(DOH *fo) {
|
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
return ftell(f->filep);
|
return ftell(f->filep);
|
||||||
|
|
@ -120,16 +115,15 @@ File_tell(DOH *fo) {
|
||||||
* File_putc()
|
* File_putc()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int File_putc(DOH *fo, int ch) {
|
||||||
File_putc(DOH *fo, int ch) {
|
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
return fputc(ch,f->filep);
|
return fputc(ch, f->filep);
|
||||||
} else if (f->fd) {
|
} else if (f->fd) {
|
||||||
#ifdef DOH_INTFILE
|
#ifdef DOH_INTFILE
|
||||||
char c;
|
char c;
|
||||||
c = (char) ch;
|
c = (char) ch;
|
||||||
return write(f->fd,&c,1);
|
return write(f->fd, &c, 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -139,15 +133,15 @@ File_putc(DOH *fo, int ch) {
|
||||||
* File_getc()
|
* File_getc()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int File_getc(DOH *fo) {
|
||||||
File_getc(DOH *fo) {
|
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
return fgetc(f->filep);
|
return fgetc(f->filep);
|
||||||
} else if (f->fd) {
|
} else if (f->fd) {
|
||||||
#ifdef DOH_INTFILE
|
#ifdef DOH_INTFILE
|
||||||
char c;
|
char c;
|
||||||
if (read(f->fd,&c,1) < 0) return EOF;
|
if (read(f->fd, &c, 1) < 0)
|
||||||
|
return EOF;
|
||||||
return c;
|
return c;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -160,8 +154,7 @@ File_getc(DOH *fo) {
|
||||||
* Put a character back onto the input
|
* Put a character back onto the input
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int File_ungetc(DOH *fo, int ch) {
|
||||||
File_ungetc(DOH *fo, int ch) {
|
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
return ungetc(ch, f->filep);
|
return ungetc(ch, f->filep);
|
||||||
|
|
@ -179,8 +172,7 @@ File_ungetc(DOH *fo, int ch) {
|
||||||
* Close the file
|
* Close the file
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int File_close(DOH *fo) {
|
||||||
File_close(DOH *fo) {
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
DohFile *f = (DohFile *) ObjData(fo);
|
DohFile *f = (DohFile *) ObjData(fo);
|
||||||
if (f->filep) {
|
if (f->filep) {
|
||||||
|
|
@ -196,40 +188,40 @@ File_close(DOH *fo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static DohFileMethods FileFileMethods = {
|
static DohFileMethods FileFileMethods = {
|
||||||
File_read,
|
File_read,
|
||||||
File_write,
|
File_write,
|
||||||
File_putc,
|
File_putc,
|
||||||
File_getc,
|
File_getc,
|
||||||
File_ungetc,
|
File_ungetc,
|
||||||
File_seek,
|
File_seek,
|
||||||
File_tell,
|
File_tell,
|
||||||
File_close, /* close */
|
File_close, /* close */
|
||||||
};
|
};
|
||||||
|
|
||||||
static DohObjInfo DohFileType = {
|
static DohObjInfo DohFileType = {
|
||||||
"DohFile", /* objname */
|
"DohFile", /* objname */
|
||||||
DelFile, /* doh_del */
|
DelFile, /* doh_del */
|
||||||
0, /* doh_copy */
|
0, /* doh_copy */
|
||||||
0, /* doh_clear */
|
0, /* doh_clear */
|
||||||
0, /* doh_str */
|
0, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
0, /* doh_len */
|
0, /* doh_len */
|
||||||
0, /* doh_hash */
|
0, /* doh_hash */
|
||||||
0, /* doh_cmp */
|
0, /* doh_cmp */
|
||||||
0, /* doh_equal */
|
0, /* doh_equal */
|
||||||
0, /* doh_first */
|
0, /* doh_first */
|
||||||
0, /* doh_next */
|
0, /* doh_next */
|
||||||
0, /* doh_setfile */
|
0, /* doh_setfile */
|
||||||
0, /* doh_getfile */
|
0, /* doh_getfile */
|
||||||
0, /* doh_setline */
|
0, /* doh_setline */
|
||||||
0, /* doh_getline */
|
0, /* doh_getline */
|
||||||
0, /* doh_mapping */
|
0, /* doh_mapping */
|
||||||
0, /* doh_sequence */
|
0, /* doh_sequence */
|
||||||
&FileFileMethods,/* doh_file */
|
&FileFileMethods, /* doh_file */
|
||||||
0, /* doh_string */
|
0, /* doh_string */
|
||||||
0, /* doh_callable */
|
0, /* doh_callable */
|
||||||
0, /* doh_position */
|
0, /* doh_position */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -238,16 +230,15 @@ static DohObjInfo DohFileType = {
|
||||||
* Create a new file from a given filename and mode.
|
* Create a new file from a given filename and mode.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohNewFile(DOH *fn, const char *mode) {
|
||||||
DohNewFile(DOH *fn, const char *mode)
|
|
||||||
{
|
|
||||||
DohFile *f;
|
DohFile *f;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
filename = Char(fn);
|
filename = Char(fn);
|
||||||
file = fopen(filename,mode);
|
file = fopen(filename, mode);
|
||||||
if (!file) return 0;
|
if (!file)
|
||||||
|
return 0;
|
||||||
|
|
||||||
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
|
@ -257,7 +248,7 @@ DohNewFile(DOH *fn, const char *mode)
|
||||||
f->filep = file;
|
f->filep = file;
|
||||||
f->fd = 0;
|
f->fd = 0;
|
||||||
f->closeondel = 1;
|
f->closeondel = 1;
|
||||||
return DohObjMalloc(&DohFileType,f);
|
return DohObjMalloc(&DohFileType, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -266,16 +257,15 @@ DohNewFile(DOH *fn, const char *mode)
|
||||||
* Create a file object from an already open FILE *.
|
* Create a file object from an already open FILE *.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohNewFileFromFile(FILE *file) {
|
||||||
DohNewFileFromFile(FILE *file)
|
|
||||||
{
|
|
||||||
DohFile *f;
|
DohFile *f;
|
||||||
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
||||||
if (!f) return 0;
|
if (!f)
|
||||||
|
return 0;
|
||||||
f->filep = file;
|
f->filep = file;
|
||||||
f->fd = 0;
|
f->fd = 0;
|
||||||
f->closeondel = 0;
|
f->closeondel = 0;
|
||||||
return DohObjMalloc(&DohFileType,f);
|
return DohObjMalloc(&DohFileType, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -284,16 +274,15 @@ DohNewFileFromFile(FILE *file)
|
||||||
* Create a file object from an already open FILE *.
|
* Create a file object from an already open FILE *.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohNewFileFromFd(int fd) {
|
||||||
DohNewFileFromFd(int fd)
|
|
||||||
{
|
|
||||||
DohFile *f;
|
DohFile *f;
|
||||||
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
||||||
if (!f) return 0;
|
if (!f)
|
||||||
|
return 0;
|
||||||
f->filep = 0;
|
f->filep = 0;
|
||||||
f->fd = fd;
|
f->fd = fd;
|
||||||
f->closeondel = 0;
|
f->closeondel = 0;
|
||||||
return DohObjMalloc(&DohFileType,f);
|
return DohObjMalloc(&DohFileType, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -302,9 +291,6 @@ DohNewFileFromFd(int fd)
|
||||||
* Display cause of one of the NewFile functions failing.
|
* Display cause of one of the NewFile functions failing.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void DohFileErrorDisplay(DOHString * filename) {
|
||||||
DohFileErrorDisplay(DOHString *filename)
|
|
||||||
{
|
|
||||||
Printf(stderr, "Unable to open file %s: %s\n", filename, strerror(errno));
|
Printf(stderr, "Unable to open file %s: %s\n", filename, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ char cvsroot_fio_c[] = "$Header$";
|
||||||
|
|
||||||
#define OBUFLEN 512
|
#define OBUFLEN 512
|
||||||
|
|
||||||
static DOH *encodings = 0; /* Encoding hash */
|
static DOH *encodings = 0; /* Encoding hash */
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Writen()
|
* Writen()
|
||||||
|
|
@ -29,8 +29,9 @@ static int Writen(DOH *out, void *buffer, int len) {
|
||||||
int nw = len, ret;
|
int nw = len, ret;
|
||||||
char *cb = (char *) buffer;
|
char *cb = (char *) buffer;
|
||||||
while (nw) {
|
while (nw) {
|
||||||
ret = Write(out,cb,nw);
|
ret = Write(out, cb, nw);
|
||||||
if (ret < 0) return -1;
|
if (ret < 0)
|
||||||
|
return -1;
|
||||||
nw = nw - ret;
|
nw = nw - ret;
|
||||||
cb += ret;
|
cb += ret;
|
||||||
}
|
}
|
||||||
|
|
@ -44,36 +45,38 @@ static int Writen(DOH *out, void *buffer, int len) {
|
||||||
* two file-like objects and operate as a filter.
|
* two file-like objects and operate as a filter.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void DohEncoding(char *name, DOH *(*fn) (DOH *s)) {
|
||||||
DohEncoding(char *name, DOH *(*fn)(DOH *s)) {
|
if (!encodings)
|
||||||
if (!encodings) encodings = NewHash();
|
encodings = NewHash();
|
||||||
Setattr(encodings,(void *) name, NewVoid((void *)fn,0));
|
Setattr(encodings, (void *) name, NewVoid((void *) fn, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* internal function for processing an encoding */
|
/* internal function for processing an encoding */
|
||||||
static DOH *encode(char *name, DOH *s) {
|
static DOH *encode(char *name, DOH *s) {
|
||||||
DOH *handle, *ns;
|
DOH *handle, *ns;
|
||||||
DOH *(*fn)(DOH *);
|
DOH *(*fn) (DOH *);
|
||||||
long pos;
|
long pos;
|
||||||
char *cfmt = strchr(name,':');
|
char *cfmt = strchr(name, ':');
|
||||||
DOH *tmp = 0;
|
DOH *tmp = 0;
|
||||||
if (cfmt) {
|
if (cfmt) {
|
||||||
tmp = NewString(cfmt + 1);
|
tmp = NewString(cfmt + 1);
|
||||||
Append(tmp,s);
|
Append(tmp, s);
|
||||||
Setfile(tmp,Getfile((DOH *)s));
|
Setfile(tmp, Getfile((DOH *) s));
|
||||||
Setline(tmp,Getline((DOH *)s));
|
Setline(tmp, Getline((DOH *) s));
|
||||||
*cfmt = '\0';
|
*cfmt = '\0';
|
||||||
}
|
}
|
||||||
if (!encodings || !(handle = Getattr(encodings,name))) {
|
if (!encodings || !(handle = Getattr(encodings, name))) {
|
||||||
return Copy(s);
|
return Copy(s);
|
||||||
}
|
}
|
||||||
if (tmp) s = tmp;
|
if (tmp)
|
||||||
|
s = tmp;
|
||||||
pos = Tell(s);
|
pos = Tell(s);
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
fn = (DOH *(*)(DOH *)) Data(handle);
|
fn = (DOH *(*)(DOH *)) Data(handle);
|
||||||
ns = (*fn)(s);
|
ns = (*fn) (s);
|
||||||
Seek(s,pos,SEEK_SET);
|
Seek(s, pos, SEEK_SET);
|
||||||
if (tmp) Delete(tmp);
|
if (tmp)
|
||||||
|
Delete(tmp);
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,37 +98,35 @@ static DOH *encode(char *name, DOH *s) {
|
||||||
* It's better to use Dump() or some other method instead.
|
* It's better to use Dump() or some other method instead.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int DohvPrintf(DOH *so, const char *format, va_list ap) {
|
||||||
DohvPrintf(DOH *so, const char *format, va_list ap)
|
|
||||||
{
|
|
||||||
static char *fmt_codes = "dioxXucsSfeEgGpn";
|
static char *fmt_codes = "dioxXucsSfeEgGpn";
|
||||||
int state = 0;
|
int state = 0;
|
||||||
const char *p = format;
|
const char *p = format;
|
||||||
char newformat[256];
|
char newformat[256];
|
||||||
char obuffer[OBUFLEN];
|
char obuffer[OBUFLEN];
|
||||||
char *fmt = 0;
|
char *fmt = 0;
|
||||||
char temp[64];
|
char temp[64];
|
||||||
int widthval = 0;
|
int widthval = 0;
|
||||||
int precval = 0;
|
int precval = 0;
|
||||||
int maxwidth;
|
int maxwidth;
|
||||||
char *w = 0;
|
char *w = 0;
|
||||||
int ivalue;
|
int ivalue;
|
||||||
double dvalue;
|
double dvalue;
|
||||||
void *pvalue;
|
void *pvalue;
|
||||||
char *stemp;
|
char *stemp;
|
||||||
int nbytes = 0;
|
int nbytes = 0;
|
||||||
char encoder[128], *ec = 0;
|
char encoder[128], *ec = 0;
|
||||||
int plevel = 0;
|
int plevel = 0;
|
||||||
|
|
||||||
memset (newformat, 0, sizeof (newformat));
|
memset(newformat, 0, sizeof(newformat));
|
||||||
|
|
||||||
while (*p) {
|
while (*p) {
|
||||||
switch(state) {
|
switch (state) {
|
||||||
case 0: /* Ordinary text */
|
case 0: /* Ordinary text */
|
||||||
if (*p != '%') {
|
if (*p != '%') {
|
||||||
Putc(*p,so);
|
Putc(*p, so);
|
||||||
nbytes++;
|
nbytes++;
|
||||||
} else{
|
} else {
|
||||||
fmt = newformat;
|
fmt = newformat;
|
||||||
widthval = 0;
|
widthval = 0;
|
||||||
precval = 0;
|
precval = 0;
|
||||||
|
|
@ -134,26 +135,26 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
state = 10;
|
state = 10;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 10: /* Look for a width and precision */
|
case 10: /* Look for a width and precision */
|
||||||
if (isdigit((int)*p) && (*p != '0')) {
|
if (isdigit((int) *p) && (*p != '0')) {
|
||||||
w = temp;
|
w = temp;
|
||||||
*(w++) = *p;
|
*(w++) = *p;
|
||||||
*(fmt++) = *p;
|
*(fmt++) = *p;
|
||||||
state = 20;
|
state = 20;
|
||||||
} else if (strchr(fmt_codes,*p)) {
|
} else if (strchr(fmt_codes, *p)) {
|
||||||
/* Got one of the formatting codes */
|
/* Got one of the formatting codes */
|
||||||
p--;
|
p--;
|
||||||
state = 100;
|
state = 100;
|
||||||
} else if (*p == '*') {
|
} else if (*p == '*') {
|
||||||
/* Width field is specified in the format list */
|
/* Width field is specified in the format list */
|
||||||
widthval = va_arg(ap,int);
|
widthval = va_arg(ap, int);
|
||||||
sprintf(temp,"%d",widthval);
|
sprintf(temp, "%d", widthval);
|
||||||
for (w = temp; *w; w++) {
|
for (w = temp; *w; w++) {
|
||||||
*(fmt++) = *w;
|
*(fmt++) = *w;
|
||||||
}
|
}
|
||||||
state = 30;
|
state = 30;
|
||||||
} else if (*p == '%') {
|
} else if (*p == '%') {
|
||||||
Putc(*p,so);
|
Putc(*p, so);
|
||||||
fmt = newformat;
|
fmt = newformat;
|
||||||
nbytes++;
|
nbytes++;
|
||||||
state = 0;
|
state = 0;
|
||||||
|
|
@ -165,12 +166,12 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
*(fmt++) = *p;
|
*(fmt++) = *p;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 20: /* Hmmm. At the start of a width field */
|
case 20: /* Hmmm. At the start of a width field */
|
||||||
if (isdigit((int)*p)) {
|
if (isdigit((int) *p)) {
|
||||||
*(w++) = *p;
|
*(w++) = *p;
|
||||||
*(fmt++) = *p;
|
*(fmt++) = *p;
|
||||||
} else if (strchr(fmt_codes,*p)) {
|
} else if (strchr(fmt_codes, *p)) {
|
||||||
/* Got one of the formatting codes */
|
/* Got one of the formatting codes */
|
||||||
/* Figure out width */
|
/* Figure out width */
|
||||||
*w = 0;
|
*w = 0;
|
||||||
|
|
@ -191,12 +192,12 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 30: /* Parsed a width from an argument. Look for a . */
|
case 30: /* Parsed a width from an argument. Look for a . */
|
||||||
if (*p == '.') {
|
if (*p == '.') {
|
||||||
w = temp;
|
w = temp;
|
||||||
*(fmt++) = *p;
|
*(fmt++) = *p;
|
||||||
state = 40;
|
state = 40;
|
||||||
} else if (strchr(fmt_codes,*p)) {
|
} else if (strchr(fmt_codes, *p)) {
|
||||||
/* Got one of the formatting codes */
|
/* Got one of the formatting codes */
|
||||||
/* Figure out width */
|
/* Figure out width */
|
||||||
p--;
|
p--;
|
||||||
|
|
@ -209,19 +210,19 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
|
|
||||||
case 40:
|
case 40:
|
||||||
/* Start of precision expected */
|
/* Start of precision expected */
|
||||||
if (isdigit((int)*p) && (*p != '0')) {
|
if (isdigit((int) *p) && (*p != '0')) {
|
||||||
*(fmt++) = *p;
|
*(fmt++) = *p;
|
||||||
*(w++) = *p;
|
*(w++) = *p;
|
||||||
state = 41;
|
state = 41;
|
||||||
} else if (*p == '*') {
|
} else if (*p == '*') {
|
||||||
/* Precision field is specified in the format list */
|
/* Precision field is specified in the format list */
|
||||||
precval = va_arg(ap,int);
|
precval = va_arg(ap, int);
|
||||||
sprintf(temp,"%d",precval);
|
sprintf(temp, "%d", precval);
|
||||||
for (w = temp; *w; w++) {
|
for (w = temp; *w; w++) {
|
||||||
*(fmt++) = *w;
|
*(fmt++) = *w;
|
||||||
}
|
}
|
||||||
state = 50;
|
state = 50;
|
||||||
} else if (strchr(fmt_codes,*p)) {
|
} else if (strchr(fmt_codes, *p)) {
|
||||||
p--;
|
p--;
|
||||||
state = 100;
|
state = 100;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -230,10 +231,10 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 41:
|
case 41:
|
||||||
if (isdigit((int)*p)) {
|
if (isdigit((int) *p)) {
|
||||||
*(fmt++) = *p;
|
*(fmt++) = *p;
|
||||||
*(w++) = *p;
|
*(w++) = *p;
|
||||||
} else if (strchr(fmt_codes,*p)) {
|
} else if (strchr(fmt_codes, *p)) {
|
||||||
/* Got one of the formatting codes */
|
/* Got one of the formatting codes */
|
||||||
/* Figure out width */
|
/* Figure out width */
|
||||||
*w = 0;
|
*w = 0;
|
||||||
|
|
@ -249,7 +250,7 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
break;
|
break;
|
||||||
/* Hang out, wait for format specifier */
|
/* Hang out, wait for format specifier */
|
||||||
case 50:
|
case 50:
|
||||||
if (strchr(fmt_codes,*p)) {
|
if (strchr(fmt_codes, *p)) {
|
||||||
p--;
|
p--;
|
||||||
state = 100;
|
state = 100;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -279,43 +280,47 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
break;
|
break;
|
||||||
case 100:
|
case 100:
|
||||||
/* Got a formatting code */
|
/* Got a formatting code */
|
||||||
if (widthval < precval) maxwidth = precval;
|
if (widthval < precval)
|
||||||
else maxwidth = widthval;
|
maxwidth = precval;
|
||||||
if ((*p == 's') || (*p == 'S')) { /* Null-Terminated string */
|
else
|
||||||
DOH *doh;
|
maxwidth = widthval;
|
||||||
DOH *Sval;
|
if ((*p == 's') || (*p == 'S')) { /* Null-Terminated string */
|
||||||
DOH *enc = 0;
|
DOH *doh;
|
||||||
|
DOH *Sval;
|
||||||
|
DOH *enc = 0;
|
||||||
doh = va_arg(ap, DOH *);
|
doh = va_arg(ap, DOH *);
|
||||||
if (DohCheck(doh)) {
|
if (DohCheck(doh)) {
|
||||||
/* Is a DOH object. */
|
/* Is a DOH object. */
|
||||||
if (DohIsString(doh)) {
|
if (DohIsString(doh)) {
|
||||||
Sval = doh;
|
Sval = doh;
|
||||||
} else {
|
} else {
|
||||||
Sval = Str(doh);
|
Sval = Str(doh);
|
||||||
}
|
}
|
||||||
if (strlen(encoder)) {
|
if (strlen(encoder)) {
|
||||||
enc = encode(encoder,Sval);
|
enc = encode(encoder, Sval);
|
||||||
maxwidth = maxwidth+strlen(newformat)+Len(enc);
|
maxwidth = maxwidth + strlen(newformat) + Len(enc);
|
||||||
} else {
|
} else {
|
||||||
maxwidth = maxwidth+strlen(newformat)+Len(Sval);
|
maxwidth = maxwidth + strlen(newformat) + Len(Sval);
|
||||||
}
|
}
|
||||||
*(fmt++) = 's';
|
*(fmt++) = 's';
|
||||||
*fmt = 0;
|
*fmt = 0;
|
||||||
if ((maxwidth + 1) < OBUFLEN) {
|
if ((maxwidth + 1) < OBUFLEN) {
|
||||||
stemp = obuffer;
|
stemp = obuffer;
|
||||||
} else {
|
} else {
|
||||||
stemp = (char *) DohMalloc(maxwidth+1);
|
stemp = (char *) DohMalloc(maxwidth + 1);
|
||||||
}
|
}
|
||||||
if (enc) {
|
if (enc) {
|
||||||
nbytes+=sprintf(stemp,newformat,Data(enc));
|
nbytes += sprintf(stemp, newformat, Data(enc));
|
||||||
} else {
|
} else {
|
||||||
nbytes+=sprintf(stemp,newformat,Data(Sval));
|
nbytes += sprintf(stemp, newformat, Data(Sval));
|
||||||
}
|
}
|
||||||
if (Writen(so,stemp,strlen(stemp)) < 0) return -1;
|
if (Writen(so, stemp, strlen(stemp)) < 0)
|
||||||
|
return -1;
|
||||||
if ((DOH *) Sval != doh) {
|
if ((DOH *) Sval != doh) {
|
||||||
Delete(Sval);
|
Delete(Sval);
|
||||||
}
|
}
|
||||||
if (enc) Delete(enc);
|
if (enc)
|
||||||
|
Delete(enc);
|
||||||
if (*p == 'S') {
|
if (*p == 'S') {
|
||||||
Delete(doh);
|
Delete(doh);
|
||||||
}
|
}
|
||||||
|
|
@ -323,45 +328,48 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
DohFree(stemp);
|
DohFree(stemp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!doh) doh = (char *)"";
|
if (!doh)
|
||||||
|
doh = (char *) "";
|
||||||
|
|
||||||
if (strlen(encoder)) {
|
if (strlen(encoder)) {
|
||||||
DOH *s = NewString(doh);
|
DOH *s = NewString(doh);
|
||||||
Seek(s,0, SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
enc = encode(encoder,s);
|
enc = encode(encoder, s);
|
||||||
Delete(s);
|
Delete(s);
|
||||||
doh = Char(enc);
|
doh = Char(enc);
|
||||||
} else {
|
} else {
|
||||||
enc = 0;
|
enc = 0;
|
||||||
}
|
}
|
||||||
maxwidth = maxwidth+strlen(newformat)+strlen((char *) doh);
|
maxwidth = maxwidth + strlen(newformat) + strlen((char *) doh);
|
||||||
*(fmt++) = 's';
|
*(fmt++) = 's';
|
||||||
*fmt = 0;
|
*fmt = 0;
|
||||||
if ((maxwidth+1) < OBUFLEN) {
|
if ((maxwidth + 1) < OBUFLEN) {
|
||||||
stemp = obuffer;
|
stemp = obuffer;
|
||||||
} else {
|
} else {
|
||||||
stemp = (char *) DohMalloc(maxwidth + 1);
|
stemp = (char *) DohMalloc(maxwidth + 1);
|
||||||
}
|
}
|
||||||
nbytes+=sprintf(stemp,newformat,doh);
|
nbytes += sprintf(stemp, newformat, doh);
|
||||||
if (Writen(so,stemp,strlen(stemp)) < 0) return -1;
|
if (Writen(so, stemp, strlen(stemp)) < 0)
|
||||||
|
return -1;
|
||||||
if (stemp != obuffer) {
|
if (stemp != obuffer) {
|
||||||
DohFree(stemp);
|
DohFree(stemp);
|
||||||
}
|
}
|
||||||
if (enc) Delete(enc);
|
if (enc)
|
||||||
|
Delete(enc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*(fmt++) = *p;
|
*(fmt++) = *p;
|
||||||
*fmt = 0;
|
*fmt = 0;
|
||||||
maxwidth = maxwidth+strlen(newformat)+64;
|
maxwidth = maxwidth + strlen(newformat) + 64;
|
||||||
|
|
||||||
/* Only allocate a buffer if it is too big to fit. Shouldn't have to do
|
/* Only allocate a buffer if it is too big to fit. Shouldn't have to do
|
||||||
this very often */
|
this very often */
|
||||||
|
|
||||||
if (maxwidth < OBUFLEN)
|
if (maxwidth < OBUFLEN)
|
||||||
stemp = obuffer;
|
stemp = obuffer;
|
||||||
else
|
else
|
||||||
stemp = (char *) DohMalloc(maxwidth+1);
|
stemp = (char *) DohMalloc(maxwidth + 1);
|
||||||
switch(*p) {
|
switch (*p) {
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'o':
|
case 'o':
|
||||||
|
|
@ -369,26 +377,28 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X':
|
||||||
case 'c':
|
case 'c':
|
||||||
ivalue = va_arg(ap,int);
|
ivalue = va_arg(ap, int);
|
||||||
nbytes+=sprintf(stemp,newformat,ivalue);
|
nbytes += sprintf(stemp, newformat, ivalue);
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'G':
|
case 'G':
|
||||||
dvalue = va_arg(ap,double);
|
dvalue = va_arg(ap, double);
|
||||||
nbytes+=sprintf(stemp,newformat,dvalue);
|
nbytes += sprintf(stemp, newformat, dvalue);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
pvalue = va_arg(ap,void *);
|
pvalue = va_arg(ap, void *);
|
||||||
nbytes+=sprintf(stemp,newformat,pvalue);
|
nbytes += sprintf(stemp, newformat, pvalue);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Writen(so,stemp,strlen(stemp)) < 0) return -1;
|
if (Writen(so, stemp, strlen(stemp)) < 0)
|
||||||
if (stemp != obuffer) DohFree(stemp);
|
return -1;
|
||||||
|
if (stemp != obuffer)
|
||||||
|
DohFree(stemp);
|
||||||
}
|
}
|
||||||
state = 0;
|
state = 0;
|
||||||
break;
|
break;
|
||||||
|
|
@ -398,8 +408,9 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
if (state) {
|
if (state) {
|
||||||
int r;
|
int r;
|
||||||
*fmt = 0;
|
*fmt = 0;
|
||||||
r = Writen(so,fmt,strlen(fmt));
|
r = Writen(so, fmt, strlen(fmt));
|
||||||
if (r < 0) return -1;
|
if (r < 0)
|
||||||
|
return -1;
|
||||||
nbytes += r;
|
nbytes += r;
|
||||||
}
|
}
|
||||||
return nbytes;
|
return nbytes;
|
||||||
|
|
@ -411,12 +422,11 @@ DohvPrintf(DOH *so, const char *format, va_list ap)
|
||||||
* Variable length argument entry point to Printf
|
* Variable length argument entry point to Printf
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int DohPrintf(DOH *obj, const char *format, ...) {
|
||||||
DohPrintf(DOH *obj, const char *format, ...) {
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret;
|
int ret;
|
||||||
va_start(ap,format);
|
va_start(ap, format);
|
||||||
ret = DohvPrintf(obj,format,ap);
|
ret = DohvPrintf(obj, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -427,18 +437,19 @@ DohPrintf(DOH *obj, const char *format, ...) {
|
||||||
* Print a null-terminated variable length list of DOH objects
|
* Print a null-terminated variable length list of DOH objects
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int DohPrintv(DOHFile *f, ...) {
|
int DohPrintv(DOHFile * f, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
DOH *obj;
|
DOH *obj;
|
||||||
va_start(ap,f);
|
va_start(ap, f);
|
||||||
while(1) {
|
while (1) {
|
||||||
obj = va_arg(ap,void *);
|
obj = va_arg(ap, void *);
|
||||||
if ((!obj) || (obj == DohNone)) break;
|
if ((!obj) || (obj == DohNone))
|
||||||
|
break;
|
||||||
if (DohCheck(obj)) {
|
if (DohCheck(obj)) {
|
||||||
ret += DohDump(obj,f);
|
ret += DohDump(obj, f);
|
||||||
} else {
|
} else {
|
||||||
ret += DohWrite(f,obj,strlen((char *) obj));
|
ret += DohWrite(f, obj, strlen((char *) obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
@ -452,22 +463,23 @@ int DohPrintv(DOHFile *f, ...) {
|
||||||
* number of bytes copied.
|
* number of bytes copied.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int DohCopyto(DOH *in, DOH *out) {
|
||||||
DohCopyto(DOH *in, DOH *out) {
|
|
||||||
int nbytes = 0, ret;
|
int nbytes = 0, ret;
|
||||||
int nwrite = 0, wret;
|
int nwrite = 0, wret;
|
||||||
char *cw;
|
char *cw;
|
||||||
char buffer[16384];
|
char buffer[16384];
|
||||||
|
|
||||||
if ((!in) || (!out)) return 0;
|
if ((!in) || (!out))
|
||||||
|
return 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
ret = Read(in,buffer,16384);
|
ret = Read(in, buffer, 16384);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
nwrite = ret;
|
nwrite = ret;
|
||||||
cw = buffer;
|
cw = buffer;
|
||||||
while (nwrite) {
|
while (nwrite) {
|
||||||
wret = Write(out,cw,nwrite);
|
wret = Write(out, cw, nwrite);
|
||||||
if (wret < 0) return -1;
|
if (wret < 0)
|
||||||
|
return -1;
|
||||||
nwrite = nwrite - wret;
|
nwrite = nwrite - wret;
|
||||||
cw += wret;
|
cw += wret;
|
||||||
}
|
}
|
||||||
|
|
@ -486,16 +498,15 @@ DohCopyto(DOH *in, DOH *out) {
|
||||||
* character. Optionally accepts a maximum number of splits to perform.
|
* character. Optionally accepts a maximum number of splits to perform.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohSplit(DOH *in, char ch, int nsplits) {
|
||||||
DohSplit(DOH *in, char ch, int nsplits) {
|
|
||||||
DOH *list;
|
DOH *list;
|
||||||
DOH *str;
|
DOH *str;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
list = NewList();
|
list = NewList();
|
||||||
|
|
||||||
if (DohIsString(in)) {
|
if (DohIsString(in)) {
|
||||||
Seek(in,0,SEEK_SET);
|
Seek(in, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
@ -504,17 +515,19 @@ DohSplit(DOH *in, char ch, int nsplits) {
|
||||||
c = Getc(in);
|
c = Getc(in);
|
||||||
} while ((c != EOF) && (c == ch));
|
} while ((c != EOF) && (c == ch));
|
||||||
if (c != EOF) {
|
if (c != EOF) {
|
||||||
Putc(c,str);
|
Putc(c, str);
|
||||||
while (1) {
|
while (1) {
|
||||||
c = Getc(in);
|
c = Getc(in);
|
||||||
if ((c == EOF) || ((c == ch) && (nsplits != 0))) break;
|
if ((c == EOF) || ((c == ch) && (nsplits != 0)))
|
||||||
Putc(c,str);
|
break;
|
||||||
|
Putc(c, str);
|
||||||
}
|
}
|
||||||
nsplits--;
|
nsplits--;
|
||||||
}
|
}
|
||||||
Append(list,str);
|
Append(list, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
if (c == EOF) break;
|
if (c == EOF)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
@ -525,16 +538,15 @@ DohSplit(DOH *in, char ch, int nsplits) {
|
||||||
* Split an input stream into a list of strings delimited by newline characters.
|
* Split an input stream into a list of strings delimited by newline characters.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohSplitLines(DOH *in) {
|
||||||
DohSplitLines(DOH *in) {
|
|
||||||
DOH *list;
|
DOH *list;
|
||||||
DOH *str;
|
DOH *str;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
list = NewList();
|
list = NewList();
|
||||||
|
|
||||||
if (DohIsString(in)) {
|
if (DohIsString(in)) {
|
||||||
Seek(in,0,SEEK_SET);
|
Seek(in, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (c != EOF) {
|
while (c != EOF) {
|
||||||
|
|
@ -542,7 +554,7 @@ DohSplitLines(DOH *in) {
|
||||||
while ((c = Getc(in)) != '\n' && c != EOF) {
|
while ((c = Getc(in)) != '\n' && c != EOF) {
|
||||||
Putc(c, str);
|
Putc(c, str);
|
||||||
}
|
}
|
||||||
Append(list,str);
|
Append(list, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
@ -555,24 +567,23 @@ DohSplitLines(DOH *in) {
|
||||||
* Read a single input line and return it as a string.
|
* Read a single input line and return it as a string.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohReadline(DOH *in) {
|
||||||
DohReadline(DOH *in) {
|
|
||||||
char c;
|
char c;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
DOH *s = NewStringEmpty();
|
DOH *s = NewStringEmpty();
|
||||||
while (1) {
|
while (1) {
|
||||||
if (Read(in,&c,1) < 0) {
|
if (Read(in, &c, 1) < 0) {
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
Delete(s);
|
Delete(s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
if (c == '\n') return s;
|
if (c == '\n')
|
||||||
if (c == '\r') continue;
|
return s;
|
||||||
Putc(c,s);
|
if (c == '\r')
|
||||||
|
continue;
|
||||||
|
Putc(c, s);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,59 +17,65 @@ extern DohObjInfo DohHashType;
|
||||||
|
|
||||||
/* Hash node */
|
/* Hash node */
|
||||||
typedef struct HashNode {
|
typedef struct HashNode {
|
||||||
DOH *key;
|
DOH *key;
|
||||||
DOH *object;
|
DOH *object;
|
||||||
struct HashNode *next;
|
struct HashNode *next;
|
||||||
} HashNode;
|
} HashNode;
|
||||||
|
|
||||||
/* Hash object */
|
/* Hash object */
|
||||||
typedef struct Hash {
|
typedef struct Hash {
|
||||||
DOH *file;
|
DOH *file;
|
||||||
int line;
|
int line;
|
||||||
HashNode **hashtable;
|
HashNode **hashtable;
|
||||||
int hashsize;
|
int hashsize;
|
||||||
int nitems;
|
int nitems;
|
||||||
} Hash;
|
} Hash;
|
||||||
|
|
||||||
/* Key interning structure */
|
/* Key interning structure */
|
||||||
typedef struct KeyValue {
|
typedef struct KeyValue {
|
||||||
char *cstr;
|
char *cstr;
|
||||||
DOH *sstr;
|
DOH *sstr;
|
||||||
struct KeyValue *left;
|
struct KeyValue *left;
|
||||||
struct KeyValue *right;
|
struct KeyValue *right;
|
||||||
} KeyValue;
|
} KeyValue;
|
||||||
|
|
||||||
static KeyValue *root = 0;
|
static KeyValue *root = 0;
|
||||||
|
|
||||||
/* Find or create a key in the interned key table */
|
/* Find or create a key in the interned key table */
|
||||||
static DOH *find_key (DOH *doh_c) {
|
static DOH *find_key(DOH *doh_c) {
|
||||||
char *c = (char *) doh_c;
|
char *c = (char *) doh_c;
|
||||||
KeyValue *r, *s;
|
KeyValue *r, *s;
|
||||||
int d = 0;
|
int d = 0;
|
||||||
/* OK, sure, we use a binary tree for maintaining interned
|
/* OK, sure, we use a binary tree for maintaining interned
|
||||||
symbols. Then we use their hash values for accessing secondary
|
symbols. Then we use their hash values for accessing secondary
|
||||||
hash tables. */
|
hash tables. */
|
||||||
r = root;
|
r = root;
|
||||||
s = 0;
|
s = 0;
|
||||||
while (r) {
|
while (r) {
|
||||||
s = r;
|
s = r;
|
||||||
d = strcmp(r->cstr,c);
|
d = strcmp(r->cstr, c);
|
||||||
if (d == 0) return r->sstr;
|
if (d == 0)
|
||||||
if (d < 0) r = r->left;
|
return r->sstr;
|
||||||
else r = r->right;
|
if (d < 0)
|
||||||
|
r = r->left;
|
||||||
|
else
|
||||||
|
r = r->right;
|
||||||
}
|
}
|
||||||
/* fprintf(stderr,"Interning '%s'\n", c);*/
|
/* fprintf(stderr,"Interning '%s'\n", c); */
|
||||||
r = (KeyValue *) DohMalloc(sizeof(KeyValue));
|
r = (KeyValue *) DohMalloc(sizeof(KeyValue));
|
||||||
r->cstr = (char *) DohMalloc(strlen(c)+1);
|
r->cstr = (char *) DohMalloc(strlen(c) + 1);
|
||||||
strcpy(r->cstr,c);
|
strcpy(r->cstr, c);
|
||||||
r->sstr = NewString(c);
|
r->sstr = NewString(c);
|
||||||
DohIntern(r->sstr);
|
DohIntern(r->sstr);
|
||||||
r->left = 0;
|
r->left = 0;
|
||||||
r->right = 0;
|
r->right = 0;
|
||||||
if (!s) { root = r; }
|
if (!s) {
|
||||||
else {
|
root = r;
|
||||||
if (d < 0) s->left = r;
|
} else {
|
||||||
else s->right = r;
|
if (d < 0)
|
||||||
|
s->left = r;
|
||||||
|
else
|
||||||
|
s->right = r;
|
||||||
}
|
}
|
||||||
return r->sstr;
|
return r->sstr;
|
||||||
}
|
}
|
||||||
|
|
@ -78,20 +84,20 @@ static DOH *find_key (DOH *doh_c) {
|
||||||
|
|
||||||
/* Create a new hash node */
|
/* Create a new hash node */
|
||||||
static HashNode *NewNode(DOH *k, void *obj) {
|
static HashNode *NewNode(DOH *k, void *obj) {
|
||||||
HashNode *hn = (HashNode *) DohMalloc(sizeof(HashNode));
|
HashNode *hn = (HashNode *) DohMalloc(sizeof(HashNode));
|
||||||
hn->key = k;
|
hn->key = k;
|
||||||
Incref(hn->key);
|
Incref(hn->key);
|
||||||
hn->object = obj;
|
hn->object = obj;
|
||||||
Incref(obj);
|
Incref(obj);
|
||||||
hn->next = 0;
|
hn->next = 0;
|
||||||
return hn;
|
return hn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete a hash node */
|
/* Delete a hash node */
|
||||||
static void DelNode(HashNode *hn) {
|
static void DelNode(HashNode *hn) {
|
||||||
Delete(hn->key);
|
Delete(hn->key);
|
||||||
Delete(hn->object);
|
Delete(hn->object);
|
||||||
DohFree(hn);
|
DohFree(hn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -100,25 +106,24 @@ static void DelNode(HashNode *hn) {
|
||||||
* Delete a hash table.
|
* Delete a hash table.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void DelHash(DOH *ho) {
|
||||||
DelHash(DOH *ho) {
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
HashNode *n, *next;
|
||||||
HashNode *n,*next;
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < h->hashsize; i++) {
|
for (i = 0; i < h->hashsize; i++) {
|
||||||
if ((n = h->hashtable[i])) {
|
if ((n = h->hashtable[i])) {
|
||||||
while (n) {
|
while (n) {
|
||||||
next = n->next;
|
next = n->next;
|
||||||
DelNode(n);
|
DelNode(n);
|
||||||
n = next;
|
n = next;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DohFree(h->hashtable);
|
}
|
||||||
h->hashtable = 0;
|
DohFree(h->hashtable);
|
||||||
h->hashsize = 0;
|
h->hashtable = 0;
|
||||||
DohFree(h);
|
h->hashsize = 0;
|
||||||
|
DohFree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -127,67 +132,67 @@ DelHash(DOH *ho) {
|
||||||
* Clear all of the entries in the hash table.
|
* Clear all of the entries in the hash table.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void Hash_clear(DOH *ho) {
|
||||||
Hash_clear(DOH *ho) {
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
HashNode *n, *next;
|
||||||
HashNode *n,*next;
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < h->hashsize; i++) {
|
for (i = 0; i < h->hashsize; i++) {
|
||||||
if ((n = h->hashtable[i])) {
|
if ((n = h->hashtable[i])) {
|
||||||
while (n) {
|
while (n) {
|
||||||
next = n->next;
|
next = n->next;
|
||||||
DelNode(n);
|
DelNode(n);
|
||||||
n = next;
|
n = next;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
h->hashtable[i] = 0;
|
|
||||||
}
|
}
|
||||||
h->nitems = 0;
|
h->hashtable[i] = 0;
|
||||||
|
}
|
||||||
|
h->nitems = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resize the hash table */
|
/* resize the hash table */
|
||||||
static void resize(Hash *h) {
|
static void resize(Hash *h) {
|
||||||
HashNode *n, *next, **table;
|
HashNode *n, *next, **table;
|
||||||
int oldsize, newsize;
|
int oldsize, newsize;
|
||||||
int i, p, hv;
|
int i, p, hv;
|
||||||
|
|
||||||
if (h->nitems < 2*h->hashsize) return;
|
if (h->nitems < 2 * h->hashsize)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Too big. We have to rescale everything now */
|
/* Too big. We have to rescale everything now */
|
||||||
oldsize = h->hashsize;
|
oldsize = h->hashsize;
|
||||||
|
|
||||||
/* Calculate a new size */
|
/* Calculate a new size */
|
||||||
newsize = 2*oldsize+1;
|
newsize = 2 * oldsize + 1;
|
||||||
p = 3;
|
p = 3;
|
||||||
while (p < (newsize >> 1)) {
|
while (p < (newsize >> 1)) {
|
||||||
if (((newsize/p)*p) == newsize) {
|
if (((newsize / p) * p) == newsize) {
|
||||||
newsize+=2;
|
newsize += 2;
|
||||||
p = 3;
|
p = 3;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
p = p + 2;
|
|
||||||
}
|
}
|
||||||
|
p = p + 2;
|
||||||
|
}
|
||||||
|
|
||||||
table = (HashNode **) DohMalloc(newsize*sizeof(HashNode *));
|
table = (HashNode **) DohMalloc(newsize * sizeof(HashNode *));
|
||||||
for (i = 0; i < newsize; i++ ) {
|
for (i = 0; i < newsize; i++) {
|
||||||
table[i] = 0;
|
table[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Walk down the old set of nodes and re-place */
|
/* Walk down the old set of nodes and re-place */
|
||||||
h->hashsize = newsize;
|
h->hashsize = newsize;
|
||||||
for (i = 0; i < oldsize; i++) {
|
for (i = 0; i < oldsize; i++) {
|
||||||
n = h->hashtable[i];
|
n = h->hashtable[i];
|
||||||
while (n) {
|
while (n) {
|
||||||
hv = Hashval(n->key) % newsize;
|
hv = Hashval(n->key) % newsize;
|
||||||
next = n->next;
|
next = n->next;
|
||||||
n->next = table[hv];
|
n->next = table[hv];
|
||||||
table[hv] = n;
|
table[hv] = n;
|
||||||
n = next;
|
n = next;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DohFree(h->hashtable);
|
}
|
||||||
h->hashtable = table;
|
DohFree(h->hashtable);
|
||||||
|
h->hashtable = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -197,46 +202,48 @@ static void resize(Hash *h) {
|
||||||
* exists.
|
* exists.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int Hash_setattr(DOH *ho, DOH *k, DOH *obj) {
|
||||||
Hash_setattr(DOH *ho, DOH *k, DOH *obj) {
|
int hv;
|
||||||
int hv;
|
HashNode *n, *prev;
|
||||||
HashNode *n, *prev;
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
|
||||||
|
if (!obj) {
|
||||||
if (!obj) {
|
return DohDelattr(ho, k);
|
||||||
return DohDelattr(ho,k);
|
}
|
||||||
}
|
if (!DohCheck(k))
|
||||||
if (!DohCheck(k)) k = find_key(k);
|
k = find_key(k);
|
||||||
if (!DohCheck(obj)) {
|
if (!DohCheck(obj)) {
|
||||||
obj = NewString((char *) obj);
|
obj = NewString((char *) obj);
|
||||||
Decref(obj);
|
Decref(obj);
|
||||||
}
|
}
|
||||||
hv = (Hashval(k)) % h->hashsize;
|
hv = (Hashval(k)) % h->hashsize;
|
||||||
n = h->hashtable[hv];
|
n = h->hashtable[hv];
|
||||||
prev = 0;
|
prev = 0;
|
||||||
while (n) {
|
while (n) {
|
||||||
if (Cmp(n->key,k) == 0) {
|
if (Cmp(n->key, k) == 0) {
|
||||||
/* Node already exists. Just replace its contents */
|
/* Node already exists. Just replace its contents */
|
||||||
if (n->object == obj) {
|
if (n->object == obj) {
|
||||||
/* Whoa. Same object. Do nothing */
|
/* Whoa. Same object. Do nothing */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
Delete(n->object);
|
|
||||||
n->object = obj;
|
|
||||||
Incref(obj);
|
|
||||||
return 1; /* Return 1 to indicate a replacement */
|
|
||||||
} else {
|
|
||||||
prev = n;
|
|
||||||
n = n->next;
|
|
||||||
}
|
}
|
||||||
|
Delete(n->object);
|
||||||
|
n->object = obj;
|
||||||
|
Incref(obj);
|
||||||
|
return 1; /* Return 1 to indicate a replacement */
|
||||||
|
} else {
|
||||||
|
prev = n;
|
||||||
|
n = n->next;
|
||||||
}
|
}
|
||||||
/* Add this to the table */
|
}
|
||||||
n = NewNode(k,obj);
|
/* Add this to the table */
|
||||||
if (prev) prev->next = n;
|
n = NewNode(k, obj);
|
||||||
else h->hashtable[hv] = n;
|
if (prev)
|
||||||
h->nitems++;
|
prev->next = n;
|
||||||
resize(h);
|
else
|
||||||
return 0;
|
h->hashtable[hv] = n;
|
||||||
|
h->nitems++;
|
||||||
|
resize(h);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -244,7 +251,7 @@ Hash_setattr(DOH *ho, DOH *k, DOH *obj) {
|
||||||
*
|
*
|
||||||
* Get an attribute from the hash table. Returns 0 if it doesn't exist.
|
* Get an attribute from the hash table. Returns 0 if it doesn't exist.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
typedef int (*binop)(DOH *obj1, DOH *obj2);
|
typedef int (*binop) (DOH *obj1, DOH *obj2);
|
||||||
|
|
||||||
#define _Hash_getattr(h, k, o) \
|
#define _Hash_getattr(h, k, o) \
|
||||||
int hv = Hashval(k) % h->hashsize; \
|
int hv = Hashval(k) % h->hashsize; \
|
||||||
|
|
@ -267,8 +274,7 @@ typedef int (*binop)(DOH *obj1, DOH *obj2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DOH *
|
static DOH *Hash_getattr(DOH *h, DOH *k) {
|
||||||
Hash_getattr(DOH *h, DOH *k) {
|
|
||||||
DOH *obj = 0;
|
DOH *obj = 0;
|
||||||
Hash *ho = (Hash *) ObjData(h);
|
Hash *ho = (Hash *) ObjData(h);
|
||||||
DOH *ko = DohCheck(k) ? k : find_key(k);
|
DOH *ko = DohCheck(k) ? k : find_key(k);
|
||||||
|
|
@ -276,8 +282,7 @@ Hash_getattr(DOH *h, DOH *k) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
DOH *
|
DOH *DohHashGetAttr(DOH *h, const DOH *k) {
|
||||||
DohHashGetAttr(DOH *h, const DOH *k) {
|
|
||||||
DOH *obj = 0;
|
DOH *obj = 0;
|
||||||
Hash *ho = (Hash *) ObjData(h);
|
Hash *ho = (Hash *) ObjData(h);
|
||||||
_Hash_getattr(ho, (DOH *) k, obj);
|
_Hash_getattr(ho, (DOH *) k, obj);
|
||||||
|
|
@ -291,14 +296,13 @@ DohHashGetAttr(DOH *h, const DOH *k) {
|
||||||
* Check an attribute from the hash table.
|
* Check an attribute from the hash table.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int DohHashCheckAttr(DOH *h, DOH *k, DOH *v) {
|
||||||
DohHashCheckAttr(DOH *h, DOH *k, DOH *v) {
|
|
||||||
DOH *obj = 0;
|
DOH *obj = 0;
|
||||||
Hash *ho = (Hash *) ObjData(h);
|
Hash *ho = (Hash *) ObjData(h);
|
||||||
_Hash_getattr(ho, k, obj);
|
_Hash_getattr(ho, k, obj);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
DohObjInfo *o_type = ((DohBase*)obj)->type;
|
DohObjInfo *o_type = ((DohBase *) obj)->type;
|
||||||
if (o_type == ((DohBase*)v)->type) {
|
if (o_type == ((DohBase *) v)->type) {
|
||||||
binop equal = o_type->doh_equal;
|
binop equal = o_type->doh_equal;
|
||||||
return equal ? equal(obj, v) : (o_type->doh_cmp(obj, v) == 0);
|
return equal ? equal(obj, v) : (o_type->doh_cmp(obj, v) == 0);
|
||||||
}
|
}
|
||||||
|
|
@ -312,44 +316,43 @@ DohHashCheckAttr(DOH *h, DOH *k, DOH *v) {
|
||||||
* Delete an object from the hash table.
|
* Delete an object from the hash table.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int Hash_delattr(DOH *ho, DOH *k) {
|
||||||
Hash_delattr(DOH *ho, DOH *k) {
|
HashNode *n, *prev;
|
||||||
HashNode *n, *prev;
|
int hv;
|
||||||
int hv;
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
|
||||||
|
|
||||||
if (!DohCheck(k)) k = find_key(k);
|
if (!DohCheck(k))
|
||||||
hv = Hashval(k) % h->hashsize;
|
k = find_key(k);
|
||||||
n = h->hashtable[hv];
|
hv = Hashval(k) % h->hashsize;
|
||||||
prev = 0;
|
n = h->hashtable[hv];
|
||||||
while (n) {
|
prev = 0;
|
||||||
if (Cmp(n->key, k) == 0) {
|
while (n) {
|
||||||
/* Found it, kill it */
|
if (Cmp(n->key, k) == 0) {
|
||||||
|
/* Found it, kill it */
|
||||||
|
|
||||||
if (prev) {
|
if (prev) {
|
||||||
prev->next = n->next;
|
prev->next = n->next;
|
||||||
} else {
|
} else {
|
||||||
h->hashtable[hv] = n->next;
|
h->hashtable[hv] = n->next;
|
||||||
}
|
}
|
||||||
DelNode(n);
|
DelNode(n);
|
||||||
h->nitems--;
|
h->nitems--;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
prev = n;
|
|
||||||
n = n->next;
|
|
||||||
}
|
}
|
||||||
return 0;
|
prev = n;
|
||||||
|
n = n->next;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DohIterator
|
static DohIterator Hash_firstiter(DOH *ho) {
|
||||||
Hash_firstiter(DOH *ho) {
|
|
||||||
DohIterator iter;
|
DohIterator iter;
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
iter.object = ho;
|
iter.object = ho;
|
||||||
iter._current = 0;
|
iter._current = 0;
|
||||||
iter.item = 0;
|
iter.item = 0;
|
||||||
iter.key = 0;
|
iter.key = 0;
|
||||||
iter._index = 0; /* Index in hash table */
|
iter._index = 0; /* Index in hash table */
|
||||||
while ((iter._index < h->hashsize) && !h->hashtable[iter._index])
|
while ((iter._index < h->hashsize) && !h->hashtable[iter._index])
|
||||||
iter._index++;
|
iter._index++;
|
||||||
|
|
||||||
|
|
@ -359,15 +362,14 @@ Hash_firstiter(DOH *ho) {
|
||||||
iter._current = h->hashtable[iter._index];
|
iter._current = h->hashtable[iter._index];
|
||||||
iter.item = ((HashNode *) iter._current)->object;
|
iter.item = ((HashNode *) iter._current)->object;
|
||||||
iter.key = ((HashNode *) iter._current)->key;
|
iter.key = ((HashNode *) iter._current)->key;
|
||||||
|
|
||||||
/* Actually save the next slot in the hash. This makes it possible to
|
/* Actually save the next slot in the hash. This makes it possible to
|
||||||
delete the item being iterated over without trashing the universe */
|
delete the item being iterated over without trashing the universe */
|
||||||
iter._current = ((HashNode*)iter._current)->next;
|
iter._current = ((HashNode *) iter._current)->next;
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DohIterator
|
static DohIterator Hash_nextiter(DohIterator iter) {
|
||||||
Hash_nextiter(DohIterator iter) {
|
|
||||||
Hash *h = (Hash *) ObjData(iter.object);
|
Hash *h = (Hash *) ObjData(iter.object);
|
||||||
if (!iter._current) {
|
if (!iter._current) {
|
||||||
iter._index++;
|
iter._index++;
|
||||||
|
|
@ -386,7 +388,7 @@ Hash_nextiter(DohIterator iter) {
|
||||||
iter.item = ((HashNode *) iter._current)->object;
|
iter.item = ((HashNode *) iter._current)->object;
|
||||||
|
|
||||||
/* Store the next node to iterator on */
|
/* Store the next node to iterator on */
|
||||||
iter._current = ((HashNode*)iter._current)->next;
|
iter._current = ((HashNode *) iter._current)->next;
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -396,14 +398,13 @@ Hash_nextiter(DohIterator iter) {
|
||||||
* Return a list of keys
|
* Return a list of keys
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static DOH *
|
static DOH *Hash_keys(DOH *so) {
|
||||||
Hash_keys(DOH *so) {
|
|
||||||
DOH *keys;
|
DOH *keys;
|
||||||
Iterator i;
|
Iterator i;
|
||||||
|
|
||||||
keys = NewList();
|
keys = NewList();
|
||||||
for (i = First(so); i.key; i = Next(i)) {
|
for (i = First(so); i.key; i = Next(i)) {
|
||||||
Append(keys,i.key);
|
Append(keys, i.key);
|
||||||
}
|
}
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
@ -414,35 +415,36 @@ Hash_keys(DOH *so) {
|
||||||
* Create a string representation of a hash table (mainly for debugging).
|
* Create a string representation of a hash table (mainly for debugging).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static DOH *
|
static DOH *Hash_str(DOH *ho) {
|
||||||
Hash_str(DOH *ho) {
|
int i, j;
|
||||||
int i,j;
|
HashNode *n;
|
||||||
HashNode *n;
|
DOH *s;
|
||||||
DOH *s;
|
static int indent = 4;
|
||||||
static int indent = 4;
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
|
||||||
|
|
||||||
s = NewStringEmpty();
|
s = NewStringEmpty();
|
||||||
if (ObjGetMark(ho)) {
|
if (ObjGetMark(ho)) {
|
||||||
Printf(s,"Hash(0x%x)",ho);
|
Printf(s, "Hash(0x%x)", ho);
|
||||||
return s;
|
|
||||||
}
|
|
||||||
ObjSetMark(ho,1);
|
|
||||||
Printf(s,"Hash {\n");
|
|
||||||
for (i = 0; i < h->hashsize; i++) {
|
|
||||||
n = h->hashtable[i];
|
|
||||||
while (n) {
|
|
||||||
for (j = 0; j < indent; j++) Putc(' ',s);
|
|
||||||
indent+=4;
|
|
||||||
Printf(s,"'%s' : %s, \n", n->key, n->object);
|
|
||||||
indent-=4;
|
|
||||||
n = n->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (j = 0; j < (indent-4); j++) Putc(' ',s);
|
|
||||||
Printf(s,"}\n");
|
|
||||||
ObjSetMark(ho,0);
|
|
||||||
return s;
|
return s;
|
||||||
|
}
|
||||||
|
ObjSetMark(ho, 1);
|
||||||
|
Printf(s, "Hash {\n");
|
||||||
|
for (i = 0; i < h->hashsize; i++) {
|
||||||
|
n = h->hashtable[i];
|
||||||
|
while (n) {
|
||||||
|
for (j = 0; j < indent; j++)
|
||||||
|
Putc(' ', s);
|
||||||
|
indent += 4;
|
||||||
|
Printf(s, "'%s' : %s, \n", n->key, n->object);
|
||||||
|
indent -= 4;
|
||||||
|
n = n->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (j = 0; j < (indent - 4); j++)
|
||||||
|
Putc(' ', s);
|
||||||
|
Printf(s, "}\n");
|
||||||
|
ObjSetMark(ho, 0);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -451,8 +453,7 @@ Hash_str(DOH *ho) {
|
||||||
* Return number of entries in the hash table.
|
* Return number of entries in the hash table.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int Hash_len(DOH *ho) {
|
||||||
Hash_len(DOH *ho) {
|
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
return h->nitems;
|
return h->nitems;
|
||||||
}
|
}
|
||||||
|
|
@ -463,67 +464,64 @@ Hash_len(DOH *ho) {
|
||||||
* Make a copy of a hash table. Note: this is a shallow copy.
|
* Make a copy of a hash table. Note: this is a shallow copy.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static DOH *
|
static DOH *CopyHash(DOH *ho) {
|
||||||
CopyHash(DOH *ho) {
|
Hash *h, *nh;
|
||||||
Hash *h, *nh;
|
HashNode *n;
|
||||||
HashNode *n;
|
DOH *nho;
|
||||||
DOH *nho;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
h = (Hash *) ObjData(ho);
|
|
||||||
nh = (Hash *) DohMalloc(sizeof(Hash));
|
|
||||||
nh->hashsize = h->hashsize;
|
|
||||||
nh->hashtable = (HashNode **) DohMalloc(nh->hashsize*sizeof(HashNode *));
|
|
||||||
for (i = 0; i < nh->hashsize; i++) {
|
|
||||||
nh->hashtable[i] = 0;
|
|
||||||
}
|
|
||||||
nh->nitems = 0;
|
|
||||||
nh->line = h->line;
|
|
||||||
nh->file = h->file;
|
|
||||||
if (nh->file) Incref(nh->file);
|
|
||||||
|
|
||||||
nho = DohObjMalloc(&DohHashType, nh);
|
int i;
|
||||||
for (i = 0; i < h->hashsize; i++) {
|
h = (Hash *) ObjData(ho);
|
||||||
if ((n = h->hashtable[i])) {
|
nh = (Hash *) DohMalloc(sizeof(Hash));
|
||||||
while (n) {
|
nh->hashsize = h->hashsize;
|
||||||
Hash_setattr(nho, n->key, n->object);
|
nh->hashtable = (HashNode **) DohMalloc(nh->hashsize * sizeof(HashNode *));
|
||||||
n = n->next;
|
for (i = 0; i < nh->hashsize; i++) {
|
||||||
}
|
nh->hashtable[i] = 0;
|
||||||
}
|
}
|
||||||
|
nh->nitems = 0;
|
||||||
|
nh->line = h->line;
|
||||||
|
nh->file = h->file;
|
||||||
|
if (nh->file)
|
||||||
|
Incref(nh->file);
|
||||||
|
|
||||||
|
nho = DohObjMalloc(&DohHashType, nh);
|
||||||
|
for (i = 0; i < h->hashsize; i++) {
|
||||||
|
if ((n = h->hashtable[i])) {
|
||||||
|
while (n) {
|
||||||
|
Hash_setattr(nho, n->key, n->object);
|
||||||
|
n = n->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nho;
|
}
|
||||||
|
return nho;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void Hash_setfile(DOH *ho, DOH *file) {
|
||||||
Hash_setfile(DOH *ho, DOH *file) {
|
|
||||||
DOH *fo;
|
DOH *fo;
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
|
|
||||||
if (!DohCheck(file)) {
|
if (!DohCheck(file)) {
|
||||||
fo = NewString(file);
|
fo = NewString(file);
|
||||||
Decref(fo);
|
Decref(fo);
|
||||||
} else fo = file;
|
} else
|
||||||
|
fo = file;
|
||||||
Incref(fo);
|
Incref(fo);
|
||||||
Delete(h->file);
|
Delete(h->file);
|
||||||
h->file = fo;
|
h->file = fo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DOH *
|
static DOH *Hash_getfile(DOH *ho) {
|
||||||
Hash_getfile(DOH *ho) {
|
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
return h->file;
|
return h->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void Hash_setline(DOH *ho, int line) {
|
||||||
Hash_setline(DOH *ho, int line) {
|
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
h->line = line;
|
h->line = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int Hash_getline(DOH *ho) {
|
||||||
Hash_getline(DOH *ho) {
|
|
||||||
Hash *h = (Hash *) ObjData(ho);
|
Hash *h = (Hash *) ObjData(ho);
|
||||||
return h->line;
|
return h->line;
|
||||||
}
|
}
|
||||||
|
|
@ -540,29 +538,29 @@ static DohHashMethods HashHashMethods = {
|
||||||
};
|
};
|
||||||
|
|
||||||
DohObjInfo DohHashType = {
|
DohObjInfo DohHashType = {
|
||||||
"Hash", /* objname */
|
"Hash", /* objname */
|
||||||
DelHash, /* doh_del */
|
DelHash, /* doh_del */
|
||||||
CopyHash, /* doh_copy */
|
CopyHash, /* doh_copy */
|
||||||
Hash_clear, /* doh_clear */
|
Hash_clear, /* doh_clear */
|
||||||
Hash_str, /* doh_str */
|
Hash_str, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
Hash_len, /* doh_len */
|
Hash_len, /* doh_len */
|
||||||
0, /* doh_hash */
|
0, /* doh_hash */
|
||||||
0, /* doh_cmp */
|
0, /* doh_cmp */
|
||||||
0, /* doh_equal */
|
0, /* doh_equal */
|
||||||
Hash_firstiter, /* doh_first */
|
Hash_firstiter, /* doh_first */
|
||||||
Hash_nextiter, /* doh_next */
|
Hash_nextiter, /* doh_next */
|
||||||
Hash_setfile, /* doh_setfile */
|
Hash_setfile, /* doh_setfile */
|
||||||
Hash_getfile, /* doh_getfile */
|
Hash_getfile, /* doh_getfile */
|
||||||
Hash_setline, /* doh_setline */
|
Hash_setline, /* doh_setline */
|
||||||
Hash_getline, /* doh_getline */
|
Hash_getline, /* doh_getline */
|
||||||
&HashHashMethods, /* doh_mapping */
|
&HashHashMethods, /* doh_mapping */
|
||||||
0, /* doh_sequence */
|
0, /* doh_sequence */
|
||||||
0, /* doh_file */
|
0, /* doh_file */
|
||||||
0, /* doh_string */
|
0, /* doh_string */
|
||||||
0, /* doh_positional */
|
0, /* doh_positional */
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -571,18 +569,17 @@ DohObjInfo DohHashType = {
|
||||||
* Create a new hash table.
|
* Create a new hash table.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohNewHash() {
|
||||||
DohNewHash() {
|
Hash *h;
|
||||||
Hash *h;
|
int i;
|
||||||
int i;
|
h = (Hash *) DohMalloc(sizeof(Hash));
|
||||||
h = (Hash *) DohMalloc(sizeof(Hash));
|
h->hashsize = HASH_INIT_SIZE;
|
||||||
h->hashsize = HASH_INIT_SIZE;
|
h->hashtable = (HashNode **) DohMalloc(h->hashsize * sizeof(HashNode *));
|
||||||
h->hashtable = (HashNode **) DohMalloc(h->hashsize*sizeof(HashNode *));
|
for (i = 0; i < h->hashsize; i++) {
|
||||||
for (i = 0; i < h->hashsize; i++) {
|
h->hashtable[i] = 0;
|
||||||
h->hashtable[i] = 0;
|
}
|
||||||
}
|
h->nitems = 0;
|
||||||
h->nitems = 0;
|
h->file = 0;
|
||||||
h->file = 0;
|
h->line = 0;
|
||||||
h->line = 0;
|
return DohObjMalloc(&DohHashType, h);
|
||||||
return DohObjMalloc(&DohHashType,h);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,21 +14,21 @@ char cvsroot_list_c[] = "$Header$";
|
||||||
#include "dohint.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
typedef struct List {
|
typedef struct List {
|
||||||
int maxitems; /* Max size */
|
int maxitems; /* Max size */
|
||||||
int nitems; /* Num items */
|
int nitems; /* Num items */
|
||||||
DOH *file;
|
DOH *file;
|
||||||
int line;
|
int line;
|
||||||
DOH **items;
|
DOH **items;
|
||||||
} List;
|
} List;
|
||||||
|
|
||||||
extern DohObjInfo DohListType;
|
extern DohObjInfo DohListType;
|
||||||
|
|
||||||
/* Doubles amount of memory in a list */
|
/* Doubles amount of memory in a list */
|
||||||
static
|
static
|
||||||
void more(List *l) {
|
void more(List *l) {
|
||||||
l->items = (void **) DohRealloc(l->items, l->maxitems*2*sizeof(void *));
|
l->items = (void **) DohRealloc(l->items, l->maxitems * 2 * sizeof(void *));
|
||||||
assert(l->items);
|
assert(l->items);
|
||||||
l->maxitems *= 2;
|
l->maxitems *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -36,23 +36,23 @@ void more(List *l) {
|
||||||
*
|
*
|
||||||
* Make a shallow copy of a list.
|
* Make a shallow copy of a list.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
static DOH *
|
static DOH *CopyList(DOH *lo) {
|
||||||
CopyList(DOH *lo) {
|
List *l, *nl;
|
||||||
List *l,*nl;
|
int i;
|
||||||
int i;
|
l = (List *) ObjData(lo);
|
||||||
l = (List *) ObjData(lo);
|
nl = (List *) DohMalloc(sizeof(List));
|
||||||
nl = (List *) DohMalloc(sizeof(List));
|
nl->nitems = l->nitems;
|
||||||
nl->nitems = l->nitems;
|
nl->maxitems = l->maxitems;
|
||||||
nl->maxitems = l->maxitems;
|
nl->items = (void **) DohMalloc(l->maxitems * sizeof(void *));
|
||||||
nl->items = (void **) DohMalloc(l->maxitems*sizeof(void *));
|
for (i = 0; i < l->nitems; i++) {
|
||||||
for (i = 0; i < l->nitems; i++) {
|
nl->items[i] = l->items[i];
|
||||||
nl->items[i] = l->items[i];
|
Incref(nl->items[i]);
|
||||||
Incref(nl->items[i]);
|
}
|
||||||
}
|
nl->file = l->file;
|
||||||
nl->file = l->file;
|
if (nl->file)
|
||||||
if (nl->file) Incref(nl->file);
|
Incref(nl->file);
|
||||||
nl->line = l->line;
|
nl->line = l->line;
|
||||||
return DohObjMalloc(&DohListType, nl);
|
return DohObjMalloc(&DohListType, nl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -61,14 +61,13 @@ CopyList(DOH *lo) {
|
||||||
* Delete a list.
|
* Delete a list.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void DelList(DOH *lo) {
|
||||||
DelList(DOH *lo) {
|
List *l = (List *) ObjData(lo);
|
||||||
List *l = (List *) ObjData(lo);
|
int i;
|
||||||
int i;
|
for (i = 0; i < l->nitems; i++)
|
||||||
for (i = 0; i < l->nitems; i++)
|
Delete(l->items[i]);
|
||||||
Delete(l->items[i]);
|
DohFree(l->items);
|
||||||
DohFree(l->items);
|
DohFree(l);
|
||||||
DohFree(l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -77,14 +76,13 @@ DelList(DOH *lo) {
|
||||||
* Remove all of the list entries, but keep the list object intact.
|
* Remove all of the list entries, but keep the list object intact.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void List_clear(DOH *lo) {
|
||||||
List_clear(DOH *lo) {
|
List *l = (List *) ObjData(lo);
|
||||||
List *l = (List *) ObjData(lo);
|
int i;
|
||||||
int i;
|
for (i = 0; i < l->nitems; i++) {
|
||||||
for (i = 0; i < l->nitems; i++) {
|
Delete(l->items[i]);
|
||||||
Delete(l->items[i]);
|
}
|
||||||
}
|
l->nitems = 0;
|
||||||
l->nitems = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -94,22 +92,26 @@ List_clear(DOH *lo) {
|
||||||
* to be a 'char *' and is used to construct an equivalent string object.
|
* to be a 'char *' and is used to construct an equivalent string object.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int List_insert(DOH *lo, int pos, DOH *item) {
|
||||||
List_insert(DOH *lo, int pos, DOH *item) {
|
|
||||||
List *l = (List *) ObjData(lo);
|
List *l = (List *) ObjData(lo);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!item) return -1;
|
if (!item)
|
||||||
|
return -1;
|
||||||
if (!DohCheck(item)) {
|
if (!DohCheck(item)) {
|
||||||
item = NewString(item);
|
item = NewString(item);
|
||||||
Decref(item);
|
Decref(item);
|
||||||
}
|
}
|
||||||
if (pos == DOH_END) pos = l->nitems;
|
if (pos == DOH_END)
|
||||||
if (pos < 0) pos = 0;
|
pos = l->nitems;
|
||||||
if (pos > l->nitems) pos = l->nitems;
|
if (pos < 0)
|
||||||
if (l->nitems == l->maxitems) more(l);
|
pos = 0;
|
||||||
|
if (pos > l->nitems)
|
||||||
|
pos = l->nitems;
|
||||||
|
if (l->nitems == l->maxitems)
|
||||||
|
more(l);
|
||||||
for (i = l->nitems; i > pos; i--) {
|
for (i = l->nitems; i > pos; i--) {
|
||||||
l->items[i] = l->items[i-1];
|
l->items[i] = l->items[i - 1];
|
||||||
}
|
}
|
||||||
l->items[pos] = item;
|
l->items[pos] = item;
|
||||||
Incref(item);
|
Incref(item);
|
||||||
|
|
@ -122,20 +124,21 @@ List_insert(DOH *lo, int pos, DOH *item) {
|
||||||
*
|
*
|
||||||
* Remove an item from a list.
|
* Remove an item from a list.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int List_remove(DOH *lo, int pos) {
|
||||||
List_remove(DOH *lo, int pos) {
|
List *l = (List *) ObjData(lo);
|
||||||
List *l = (List *) ObjData(lo);
|
int i;
|
||||||
int i;
|
if (pos == DOH_END)
|
||||||
if (pos == DOH_END) pos = l->nitems-1;
|
pos = l->nitems - 1;
|
||||||
if (pos == DOH_BEGIN) pos = 0;
|
if (pos == DOH_BEGIN)
|
||||||
assert(!((pos < 0) || (pos >= l->nitems)));
|
pos = 0;
|
||||||
Delete(l->items[pos]);
|
assert(!((pos < 0) || (pos >= l->nitems)));
|
||||||
for (i = pos; i < l->nitems-1; i++) {
|
Delete(l->items[pos]);
|
||||||
l->items[i] = l->items[i+1];
|
for (i = pos; i < l->nitems - 1; i++) {
|
||||||
}
|
l->items[i] = l->items[i + 1];
|
||||||
l->nitems--;
|
}
|
||||||
return 0;
|
l->nitems--;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -144,8 +147,7 @@ List_remove(DOH *lo, int pos) {
|
||||||
* Return the number of elements in the list
|
* Return the number of elements in the list
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int List_len(DOH *lo) {
|
||||||
List_len(DOH *lo) {
|
|
||||||
List *l = (List *) ObjData(lo);
|
List *l = (List *) ObjData(lo);
|
||||||
return l->nitems;
|
return l->nitems;
|
||||||
}
|
}
|
||||||
|
|
@ -156,13 +158,14 @@ List_len(DOH *lo) {
|
||||||
* Get the nth item from the list.
|
* Get the nth item from the list.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static DOH *
|
static DOH *List_get(DOH *lo, int n) {
|
||||||
List_get(DOH *lo, int n) {
|
List *l = (List *) ObjData(lo);
|
||||||
List *l = (List *) ObjData(lo);
|
if (n == DOH_END)
|
||||||
if (n == DOH_END) n = l->nitems-1;
|
n = l->nitems - 1;
|
||||||
if (n == DOH_BEGIN) n = 0;
|
if (n == DOH_BEGIN)
|
||||||
assert(!((n < 0) || (n >= l->nitems)));
|
n = 0;
|
||||||
return l->items[n];
|
assert(!((n < 0) || (n >= l->nitems)));
|
||||||
|
return l->items[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -171,20 +174,20 @@ List_get(DOH *lo, int n) {
|
||||||
* Set the nth item in the list replacing any previous item.
|
* Set the nth item in the list replacing any previous item.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int List_set(DOH *lo, int n, DOH *val) {
|
||||||
List_set(DOH *lo, int n, DOH *val) {
|
List *l = (List *) ObjData(lo);
|
||||||
List *l = (List *) ObjData(lo);
|
if (!val)
|
||||||
if (!val) return -1;
|
return -1;
|
||||||
assert(!((n < 0) || (n >= l->nitems)));
|
assert(!((n < 0) || (n >= l->nitems)));
|
||||||
if (!DohCheck(val)) {
|
if (!DohCheck(val)) {
|
||||||
val = NewString(val);
|
val = NewString(val);
|
||||||
Decref(val);
|
Decref(val);
|
||||||
}
|
}
|
||||||
Delete(l->items[n]);
|
Delete(l->items[n]);
|
||||||
l->items[n] = val;
|
l->items[n] = val;
|
||||||
Incref(val);
|
Incref(val);
|
||||||
Delete(val);
|
Delete(val);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -193,8 +196,7 @@ List_set(DOH *lo, int n, DOH *val) {
|
||||||
* Return the first item in the list.
|
* Return the first item in the list.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static DohIterator
|
static DohIterator List_first(DOH *lo) {
|
||||||
List_first(DOH *lo) {
|
|
||||||
DohIterator iter;
|
DohIterator iter;
|
||||||
List *l = (List *) ObjData(lo);
|
List *l = (List *) ObjData(lo);
|
||||||
iter.object = lo;
|
iter.object = lo;
|
||||||
|
|
@ -215,8 +217,7 @@ List_first(DOH *lo) {
|
||||||
* Return the next item in the list.
|
* Return the next item in the list.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static DohIterator
|
static DohIterator List_next(DohIterator iter) {
|
||||||
List_next(DohIterator iter) {
|
|
||||||
List *l = (List *) ObjData(iter.object);
|
List *l = (List *) ObjData(iter.object);
|
||||||
iter._index = iter._index + 1;
|
iter._index = iter._index + 1;
|
||||||
if (iter._index >= l->nitems) {
|
if (iter._index >= l->nitems) {
|
||||||
|
|
@ -233,26 +234,25 @@ List_next(DohIterator iter) {
|
||||||
*
|
*
|
||||||
* Create a string representation of the list.
|
* Create a string representation of the list.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
static DOH *
|
static DOH *List_str(DOH *lo) {
|
||||||
List_str(DOH *lo) {
|
DOH *s;
|
||||||
DOH *s;
|
int i;
|
||||||
int i;
|
List *l = (List *) ObjData(lo);
|
||||||
List *l = (List *) ObjData(lo);
|
s = NewStringEmpty();
|
||||||
s = NewStringEmpty();
|
if (ObjGetMark(lo)) {
|
||||||
if (ObjGetMark(lo)) {
|
Printf(s, "List(%x)", lo);
|
||||||
Printf(s,"List(%x)", lo);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
ObjSetMark(lo,1);
|
|
||||||
Printf(s,"List[ ");
|
|
||||||
for (i = 0; i < l->nitems; i++) {
|
|
||||||
Printf(s, "%s", l->items[i]);
|
|
||||||
if ((i+1) < l->nitems)
|
|
||||||
Printf(s,", ");
|
|
||||||
}
|
|
||||||
Printf(s," ]\n");
|
|
||||||
ObjSetMark(lo,0);
|
|
||||||
return s;
|
return s;
|
||||||
|
}
|
||||||
|
ObjSetMark(lo, 1);
|
||||||
|
Printf(s, "List[ ");
|
||||||
|
for (i = 0; i < l->nitems; i++) {
|
||||||
|
Printf(s, "%s", l->items[i]);
|
||||||
|
if ((i + 1) < l->nitems)
|
||||||
|
Printf(s, ", ");
|
||||||
|
}
|
||||||
|
Printf(s, " ]\n");
|
||||||
|
ObjSetMark(lo, 0);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -261,41 +261,39 @@ List_str(DOH *lo) {
|
||||||
* Dump the items to an output stream.
|
* Dump the items to an output stream.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int List_dump(DOH *lo, DOH *out) {
|
||||||
List_dump(DOH *lo, DOH *out) {
|
|
||||||
int nsent = 0;
|
int nsent = 0;
|
||||||
int i,ret;
|
int i, ret;
|
||||||
List *l = (List *) ObjData(lo);
|
List *l = (List *) ObjData(lo);
|
||||||
for (i = 0; i < l->nitems; i++) {
|
for (i = 0; i < l->nitems; i++) {
|
||||||
ret = Dump(l->items[i],out);
|
ret = Dump(l->items[i], out);
|
||||||
if (ret < 0) return -1;
|
if (ret < 0)
|
||||||
|
return -1;
|
||||||
nsent += ret;
|
nsent += ret;
|
||||||
}
|
}
|
||||||
return nsent;
|
return nsent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void List_setfile(DOH *lo, DOH *file) {
|
||||||
List_setfile(DOH *lo, DOH *file) {
|
|
||||||
DOH *fo;
|
DOH *fo;
|
||||||
List *l = (List *) ObjData(lo);
|
List *l = (List *) ObjData(lo);
|
||||||
|
|
||||||
if (!DohCheck(file)) {
|
if (!DohCheck(file)) {
|
||||||
fo = NewString(file);
|
fo = NewString(file);
|
||||||
Decref(fo);
|
Decref(fo);
|
||||||
} else fo = file;
|
} else
|
||||||
|
fo = file;
|
||||||
Incref(fo);
|
Incref(fo);
|
||||||
Delete(l->file);
|
Delete(l->file);
|
||||||
l->file = fo;
|
l->file = fo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DOH *
|
static DOH *List_getfile(DOH *lo) {
|
||||||
List_getfile(DOH *lo) {
|
|
||||||
List *l = (List *) ObjData(lo);
|
List *l = (List *) ObjData(lo);
|
||||||
return l->file;
|
return l->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void List_setline(DOH *lo, int line) {
|
||||||
List_setline(DOH *lo, int line) {
|
|
||||||
List *l = (List *) ObjData(lo);
|
List *l = (List *) ObjData(lo);
|
||||||
l->line = line;
|
l->line = line;
|
||||||
}
|
}
|
||||||
|
|
@ -310,33 +308,33 @@ static DohListMethods ListListMethods = {
|
||||||
List_set,
|
List_set,
|
||||||
List_remove,
|
List_remove,
|
||||||
List_insert,
|
List_insert,
|
||||||
0, /* delslice */
|
0, /* delslice */
|
||||||
};
|
};
|
||||||
|
|
||||||
DohObjInfo DohListType = {
|
DohObjInfo DohListType = {
|
||||||
"List", /* objname */
|
"List", /* objname */
|
||||||
DelList, /* doh_del */
|
DelList, /* doh_del */
|
||||||
CopyList, /* doh_copy */
|
CopyList, /* doh_copy */
|
||||||
List_clear, /* doh_clear */
|
List_clear, /* doh_clear */
|
||||||
List_str, /* doh_str */
|
List_str, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
List_dump, /* doh_dump */
|
List_dump, /* doh_dump */
|
||||||
List_len, /* doh_len */
|
List_len, /* doh_len */
|
||||||
0, /* doh_hash */
|
0, /* doh_hash */
|
||||||
0, /* doh_cmp */
|
0, /* doh_cmp */
|
||||||
0, /* doh_equal */
|
0, /* doh_equal */
|
||||||
List_first, /* doh_first */
|
List_first, /* doh_first */
|
||||||
List_next, /* doh_next */
|
List_next, /* doh_next */
|
||||||
List_setfile, /* doh_setfile */
|
List_setfile, /* doh_setfile */
|
||||||
List_getfile, /* doh_getfile */
|
List_getfile, /* doh_getfile */
|
||||||
List_setline, /* doh_setline */
|
List_setline, /* doh_setline */
|
||||||
List_getline, /* doh_getline */
|
List_getline, /* doh_getline */
|
||||||
0, /* doh_mapping */
|
0, /* doh_mapping */
|
||||||
&ListListMethods, /* doh_sequence */
|
&ListListMethods, /* doh_sequence */
|
||||||
0, /* doh_file */
|
0, /* doh_file */
|
||||||
0, /* doh_string */
|
0, /* doh_string */
|
||||||
0, /* doh_callable */
|
0, /* doh_callable */
|
||||||
0, /* doh_position */
|
0, /* doh_position */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -347,29 +345,28 @@ DohObjInfo DohListType = {
|
||||||
|
|
||||||
#define MAXLISTITEMS 8
|
#define MAXLISTITEMS 8
|
||||||
|
|
||||||
DOH *
|
DOH *DohNewList() {
|
||||||
DohNewList() {
|
List *l;
|
||||||
List *l;
|
int i;
|
||||||
int i;
|
l = (List *) DohMalloc(sizeof(List));
|
||||||
l = (List *) DohMalloc(sizeof(List));
|
l->nitems = 0;
|
||||||
l->nitems = 0;
|
l->maxitems = MAXLISTITEMS;
|
||||||
l->maxitems = MAXLISTITEMS;
|
l->items = (void **) DohMalloc(l->maxitems * sizeof(void *));
|
||||||
l->items = (void **) DohMalloc(l->maxitems*sizeof(void *));
|
for (i = 0; i < MAXLISTITEMS; i++) {
|
||||||
for (i = 0; i < MAXLISTITEMS; i++) {
|
l->items[i] = 0;
|
||||||
l->items[i] = 0;
|
}
|
||||||
}
|
l->file = 0;
|
||||||
l->file = 0;
|
l->line = 0;
|
||||||
l->line = 0;
|
return DohObjMalloc(&DohListType, l);
|
||||||
return DohObjMalloc(&DohListType,l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int (*List_sort_compare_func)(const DOH *, const DOH *);
|
static int (*List_sort_compare_func) (const DOH *, const DOH *);
|
||||||
static int List_qsort_compare(const void *a, const void *b) {
|
static int List_qsort_compare(const void *a, const void *b) {
|
||||||
return List_sort_compare_func(*((DOH **)a), *((DOH **)b));
|
return List_sort_compare_func(*((DOH **) a), *((DOH **) b));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort a list */
|
/* Sort a list */
|
||||||
void DohSortList(DOH *lo, int (*cmp)(const DOH *, const DOH *)) {
|
void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *)) {
|
||||||
List *l = (List *) ObjData(lo);
|
List *l = (List *) ObjData(lo);
|
||||||
if (cmp) {
|
if (cmp) {
|
||||||
List_sort_compare_func = cmp;
|
List_sort_compare_func = cmp;
|
||||||
|
|
|
||||||
|
|
@ -18,40 +18,39 @@ char cvsroot_memory_c[] = "$Header$";
|
||||||
#define DOH_POOL_SIZE 16384
|
#define DOH_POOL_SIZE 16384
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int PoolSize = DOH_POOL_SIZE;
|
static int PoolSize = DOH_POOL_SIZE;
|
||||||
|
|
||||||
DOH *DohNone = 0; /* The DOH None object */
|
DOH *DohNone = 0; /* The DOH None object */
|
||||||
|
|
||||||
typedef struct pool {
|
typedef struct pool {
|
||||||
DohBase *ptr; /* Start of pool */
|
DohBase *ptr; /* Start of pool */
|
||||||
int len; /* Length of pool */
|
int len; /* Length of pool */
|
||||||
int blen; /* Byte length of pool */
|
int blen; /* Byte length of pool */
|
||||||
int current; /* Current position for next allocation */
|
int current; /* Current position for next allocation */
|
||||||
char* pbeg; /* Beg of pool */
|
char *pbeg; /* Beg of pool */
|
||||||
char* pend; /* End of pool */
|
char *pend; /* End of pool */
|
||||||
struct pool *next; /* Next pool */
|
struct pool *next; /* Next pool */
|
||||||
} Pool;
|
} Pool;
|
||||||
|
|
||||||
static DohBase *FreeList = 0; /* List of free objects */
|
static DohBase *FreeList = 0; /* List of free objects */
|
||||||
static Pool *Pools = 0;
|
static Pool *Pools = 0;
|
||||||
static int pools_initialized = 0;
|
static int pools_initialized = 0;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
* CreatePool() - Create a new memory pool
|
* CreatePool() - Create a new memory pool
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void CreatePool() {
|
||||||
CreatePool() {
|
|
||||||
Pool *p = 0;
|
Pool *p = 0;
|
||||||
p = (Pool *) DohMalloc(sizeof(Pool));
|
p = (Pool *) DohMalloc(sizeof(Pool));
|
||||||
assert(p);
|
assert(p);
|
||||||
p->ptr = (DohBase *) DohMalloc(sizeof(DohBase)*PoolSize);
|
p->ptr = (DohBase *) DohMalloc(sizeof(DohBase) * PoolSize);
|
||||||
assert(p->ptr);
|
assert(p->ptr);
|
||||||
memset(p->ptr,0,sizeof(DohBase)*PoolSize);
|
memset(p->ptr, 0, sizeof(DohBase) * PoolSize);
|
||||||
p->len = PoolSize;
|
p->len = PoolSize;
|
||||||
p->blen = PoolSize*sizeof(DohBase);
|
p->blen = PoolSize * sizeof(DohBase);
|
||||||
p->current = 0;
|
p->current = 0;
|
||||||
p->pbeg = ((char *)p->ptr);
|
p->pbeg = ((char *) p->ptr);
|
||||||
p->pend = p->pbeg + p->blen;
|
p->pend = p->pbeg + p->blen;
|
||||||
p->next = Pools;
|
p->next = Pools;
|
||||||
Pools = p;
|
Pools = p;
|
||||||
|
|
@ -61,12 +60,12 @@ CreatePool() {
|
||||||
* InitPools() - Initialize the memory allocator
|
* InitPools() - Initialize the memory allocator
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void InitPools() {
|
||||||
InitPools() {
|
if (pools_initialized)
|
||||||
if (pools_initialized) return;
|
return;
|
||||||
CreatePool(); /* Create initial pool */
|
CreatePool(); /* Create initial pool */
|
||||||
pools_initialized = 1;
|
pools_initialized = 1;
|
||||||
DohNone = NewVoid(0,0); /* Create the None object */
|
DohNone = NewVoid(0, 0); /* Create the None object */
|
||||||
DohIntern(DohNone);
|
DohIntern(DohNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,15 +75,15 @@ InitPools() {
|
||||||
* Returns 1 if an arbitrary pointer is a DOH object.
|
* Returns 1 if an arbitrary pointer is a DOH object.
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int DohCheck(const DOH *ptr) {
|
||||||
DohCheck(const DOH *ptr) {
|
|
||||||
register Pool *p = Pools;
|
register Pool *p = Pools;
|
||||||
register char *cptr = (char *) ptr;
|
register char *cptr = (char *) ptr;
|
||||||
while (p) {
|
while (p) {
|
||||||
if ((cptr >= p->pbeg) && (cptr < p->pend)) return 1;
|
if ((cptr >= p->pbeg) && (cptr < p->pend))
|
||||||
|
return 1;
|
||||||
/*
|
/*
|
||||||
pptr = (char *) p->ptr;
|
pptr = (char *) p->ptr;
|
||||||
if ((cptr >= pptr) && (cptr < (pptr+(p->current*sizeof(DohBase))))) return 1; */
|
if ((cptr >= pptr) && (cptr < (pptr+(p->current*sizeof(DohBase))))) return 1; */
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -94,8 +93,7 @@ DohCheck(const DOH *ptr) {
|
||||||
* DohIntern()
|
* DohIntern()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void DohIntern(DOH *obj) {
|
||||||
DohIntern(DOH *obj) {
|
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
b->flag_intern = 1;
|
b->flag_intern = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -106,10 +104,10 @@ DohIntern(DOH *obj) {
|
||||||
* Allocate memory for a new object.
|
* Allocate memory for a new object.
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohObjMalloc(DohObjInfo *type, void *data) {
|
||||||
DohObjMalloc(DohObjInfo *type, void *data) {
|
|
||||||
DohBase *obj;
|
DohBase *obj;
|
||||||
if (!pools_initialized) InitPools();
|
if (!pools_initialized)
|
||||||
|
InitPools();
|
||||||
if (FreeList) {
|
if (FreeList) {
|
||||||
obj = FreeList;
|
obj = FreeList;
|
||||||
FreeList = (DohBase *) obj->data;
|
FreeList = (DohBase *) obj->data;
|
||||||
|
|
@ -135,12 +133,12 @@ DohObjMalloc(DohObjInfo *type, void *data) {
|
||||||
* DohObjFree() - Free a DOH object
|
* DohObjFree() - Free a DOH object
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void DohObjFree(DOH *ptr) {
|
||||||
DohObjFree(DOH *ptr) {
|
DohBase *b, *meta;
|
||||||
DohBase *b, *meta;
|
|
||||||
b = (DohBase *) ptr;
|
b = (DohBase *) ptr;
|
||||||
if (b->flag_intern) return;
|
if (b->flag_intern)
|
||||||
meta = (DohBase *)b->meta;
|
return;
|
||||||
|
meta = (DohBase *) b->meta;
|
||||||
b->data = (void *) FreeList;
|
b->data = (void *) FreeList;
|
||||||
b->meta = 0;
|
b->meta = 0;
|
||||||
b->type = 0;
|
b->type = 0;
|
||||||
|
|
@ -156,42 +154,45 @@ DohObjFree(DOH *ptr) {
|
||||||
* Display memory usage statistics
|
* Display memory usage statistics
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void DohMemoryDebug(void) {
|
||||||
DohMemoryDebug(void) {
|
|
||||||
extern DohObjInfo DohStringType;
|
extern DohObjInfo DohStringType;
|
||||||
extern DohObjInfo DohListType;
|
extern DohObjInfo DohListType;
|
||||||
extern DohObjInfo DohHashType;
|
extern DohObjInfo DohHashType;
|
||||||
|
|
||||||
Pool *p;
|
Pool *p;
|
||||||
int totsize = 0;
|
int totsize = 0;
|
||||||
int totused = 0;
|
int totused = 0;
|
||||||
int totfree = 0;
|
int totfree = 0;
|
||||||
|
|
||||||
int numstring = 0;
|
int numstring = 0;
|
||||||
int numlist = 0;
|
int numlist = 0;
|
||||||
int numhash = 0;
|
int numhash = 0;
|
||||||
|
|
||||||
printf("Memory statistics:\n\n");
|
printf("Memory statistics:\n\n");
|
||||||
printf("Pools:\n");
|
printf("Pools:\n");
|
||||||
|
|
||||||
p = Pools;
|
p = Pools;
|
||||||
while(p) {
|
while (p) {
|
||||||
/* Calculate number of used, free items */
|
/* Calculate number of used, free items */
|
||||||
int i;
|
int i;
|
||||||
int nused = 0, nfree = 0;
|
int nused = 0, nfree = 0;
|
||||||
for (i = 0; i < p->len; i++) {
|
for (i = 0; i < p->len; i++) {
|
||||||
if (p->ptr[i].refcount <= 0) nfree++;
|
if (p->ptr[i].refcount <= 0)
|
||||||
|
nfree++;
|
||||||
else {
|
else {
|
||||||
nused++;
|
nused++;
|
||||||
if (p->ptr[i].type == &DohStringType) numstring++;
|
if (p->ptr[i].type == &DohStringType)
|
||||||
else if (p->ptr[i].type == &DohListType) numlist++;
|
numstring++;
|
||||||
else if (p->ptr[i].type == &DohHashType) numhash++;
|
else if (p->ptr[i].type == &DohListType)
|
||||||
|
numlist++;
|
||||||
|
else if (p->ptr[i].type == &DohHashType)
|
||||||
|
numhash++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf(" Pool %8p: size = %10d. used = %10d. free = %10d\n", (void *)p, p->len, nused, nfree);
|
printf(" Pool %8p: size = %10d. used = %10d. free = %10d\n", (void *) p, p->len, nused, nfree);
|
||||||
totsize += p->len;
|
totsize += p->len;
|
||||||
totused+= nused;
|
totused += nused;
|
||||||
totfree+= nfree;
|
totfree += nfree;
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
printf("\n Total: size = %10d, used = %10d, free = %10d\n", totsize, totused, totfree);
|
printf("\n Total: size = %10d, used = %10d, free = %10d\n", totsize, totused, totfree);
|
||||||
|
|
@ -203,12 +204,12 @@ DohMemoryDebug(void) {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
p = Pools;
|
p = Pools;
|
||||||
while(p) {
|
while (p) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < p->len; i++) {
|
for (i = 0; i < p->len; i++) {
|
||||||
if (p->ptr[i].refcount > 0) {
|
if (p->ptr[i].refcount > 0) {
|
||||||
if (p->ptr[i].type == &DohStringType) {
|
if (p->ptr[i].type == &DohStringType) {
|
||||||
Printf(stdout,"%s\n", p->ptr+i);
|
Printf(stdout, "%s\n", p->ptr + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -15,8 +15,8 @@ char cvsroot_void_c[] = "$Header$";
|
||||||
#include "dohint.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
void (*del)(void *);
|
void (*del) (void *);
|
||||||
} VoidObj;
|
} VoidObj;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -25,11 +25,10 @@ typedef struct {
|
||||||
* Delete a void object. Invokes the destructor supplied at the time of creation.
|
* Delete a void object. Invokes the destructor supplied at the time of creation.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void Void_delete(DOH *vo) {
|
||||||
Void_delete(DOH *vo) {
|
|
||||||
VoidObj *v = (VoidObj *) ObjData(vo);
|
VoidObj *v = (VoidObj *) ObjData(vo);
|
||||||
if (v->del)
|
if (v->del)
|
||||||
(*v->del)(v->ptr);
|
(*v->del) (v->ptr);
|
||||||
DohFree(v);
|
DohFree(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,10 +39,9 @@ Void_delete(DOH *vo) {
|
||||||
* function is not copied in order to avoid potential double-free problems.
|
* function is not copied in order to avoid potential double-free problems.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static DOH *
|
static DOH *Void_copy(DOH *vo) {
|
||||||
Void_copy(DOH *vo) {
|
|
||||||
VoidObj *v = (VoidObj *) ObjData(vo);
|
VoidObj *v = (VoidObj *) ObjData(vo);
|
||||||
return NewVoid(v->ptr,0);
|
return NewVoid(v->ptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -52,36 +50,35 @@ Void_copy(DOH *vo) {
|
||||||
* Returns the void * stored in the object.
|
* Returns the void * stored in the object.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void *
|
static void *Void_data(DOH *vo) {
|
||||||
Void_data(DOH *vo) {
|
|
||||||
VoidObj *v = (VoidObj *) ObjData(vo);
|
VoidObj *v = (VoidObj *) ObjData(vo);
|
||||||
return v->ptr;
|
return v->ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DohObjInfo DohVoidType = {
|
static DohObjInfo DohVoidType = {
|
||||||
"VoidObj", /* objname */
|
"VoidObj", /* objname */
|
||||||
Void_delete, /* doh_del */
|
Void_delete, /* doh_del */
|
||||||
Void_copy, /* doh_copy */
|
Void_copy, /* doh_copy */
|
||||||
0, /* doh_clear */
|
0, /* doh_clear */
|
||||||
0, /* doh_str */
|
0, /* doh_str */
|
||||||
Void_data, /* doh_data */
|
Void_data, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
0, /* doh_len */
|
0, /* doh_len */
|
||||||
0, /* doh_hash */
|
0, /* doh_hash */
|
||||||
0, /* doh_cmp */
|
0, /* doh_cmp */
|
||||||
0, /* doh_equal */
|
0, /* doh_equal */
|
||||||
0, /* doh_first */
|
0, /* doh_first */
|
||||||
0, /* doh_next */
|
0, /* doh_next */
|
||||||
0, /* doh_setfile */
|
0, /* doh_setfile */
|
||||||
0, /* doh_getfile */
|
0, /* doh_getfile */
|
||||||
0, /* doh_setline */
|
0, /* doh_setline */
|
||||||
0, /* doh_getline */
|
0, /* doh_getline */
|
||||||
0, /* doh_mapping */
|
0, /* doh_mapping */
|
||||||
0, /* doh_sequence */
|
0, /* doh_sequence */
|
||||||
0, /* doh_file */
|
0, /* doh_file */
|
||||||
0, /* doh_string */
|
0, /* doh_string */
|
||||||
0, /* doh_reserved */
|
0, /* doh_reserved */
|
||||||
0, /* clientdata */
|
0, /* clientdata */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -90,11 +87,10 @@ static DohObjInfo DohVoidType = {
|
||||||
* Creates a new Void object given a void * and an optional destructor function.
|
* Creates a new Void object given a void * and an optional destructor function.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *DohNewVoid(void *obj, void (*del) (void *)) {
|
||||||
DohNewVoid(void *obj, void (*del)(void *)) {
|
|
||||||
VoidObj *v;
|
VoidObj *v;
|
||||||
v = (VoidObj *) DohMalloc(sizeof(VoidObj));
|
v = (VoidObj *) DohMalloc(sizeof(VoidObj));
|
||||||
v->ptr = obj;
|
v->ptr = obj;
|
||||||
v->del = del;
|
v->del = del;
|
||||||
return DohObjMalloc(&DohVoidType,v);
|
return DohObjMalloc(&DohVoidType, v);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,53 +84,53 @@
|
||||||
#define WARN_PARSE_REDUNDANT 322
|
#define WARN_PARSE_REDUNDANT 322
|
||||||
#define WARN_PARSE_REC_INHERITANCE 323
|
#define WARN_PARSE_REC_INHERITANCE 323
|
||||||
|
|
||||||
#define WARN_IGNORE_OPERATOR_NEW 350 /* new */
|
#define WARN_IGNORE_OPERATOR_NEW 350 /* new */
|
||||||
#define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */
|
#define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */
|
||||||
#define WARN_IGNORE_OPERATOR_PLUS 352 /* + */
|
#define WARN_IGNORE_OPERATOR_PLUS 352 /* + */
|
||||||
#define WARN_IGNORE_OPERATOR_MINUS 353 /* - */
|
#define WARN_IGNORE_OPERATOR_MINUS 353 /* - */
|
||||||
#define WARN_IGNORE_OPERATOR_MUL 354 /* * */
|
#define WARN_IGNORE_OPERATOR_MUL 354 /* * */
|
||||||
#define WARN_IGNORE_OPERATOR_DIV 355 /* / */
|
#define WARN_IGNORE_OPERATOR_DIV 355 /* / */
|
||||||
#define WARN_IGNORE_OPERATOR_MOD 356 /* % */
|
#define WARN_IGNORE_OPERATOR_MOD 356 /* % */
|
||||||
#define WARN_IGNORE_OPERATOR_XOR 357 /* ^ */
|
#define WARN_IGNORE_OPERATOR_XOR 357 /* ^ */
|
||||||
#define WARN_IGNORE_OPERATOR_AND 358 /* & */
|
#define WARN_IGNORE_OPERATOR_AND 358 /* & */
|
||||||
#define WARN_IGNORE_OPERATOR_OR 359 /* | */
|
#define WARN_IGNORE_OPERATOR_OR 359 /* | */
|
||||||
#define WARN_IGNORE_OPERATOR_NOT 360 /* ~ */
|
#define WARN_IGNORE_OPERATOR_NOT 360 /* ~ */
|
||||||
#define WARN_IGNORE_OPERATOR_LNOT 361 /* ! */
|
#define WARN_IGNORE_OPERATOR_LNOT 361 /* ! */
|
||||||
#define WARN_IGNORE_OPERATOR_EQ 362 /* = */
|
#define WARN_IGNORE_OPERATOR_EQ 362 /* = */
|
||||||
#define WARN_IGNORE_OPERATOR_LT 363 /* < */
|
#define WARN_IGNORE_OPERATOR_LT 363 /* < */
|
||||||
#define WARN_IGNORE_OPERATOR_GT 364 /* > */
|
#define WARN_IGNORE_OPERATOR_GT 364 /* > */
|
||||||
#define WARN_IGNORE_OPERATOR_PLUSEQ 365 /* += */
|
#define WARN_IGNORE_OPERATOR_PLUSEQ 365 /* += */
|
||||||
#define WARN_IGNORE_OPERATOR_MINUSEQ 366 /* -= */
|
#define WARN_IGNORE_OPERATOR_MINUSEQ 366 /* -= */
|
||||||
#define WARN_IGNORE_OPERATOR_MULEQ 367 /* *= */
|
#define WARN_IGNORE_OPERATOR_MULEQ 367 /* *= */
|
||||||
#define WARN_IGNORE_OPERATOR_DIVEQ 368 /* /= */
|
#define WARN_IGNORE_OPERATOR_DIVEQ 368 /* /= */
|
||||||
#define WARN_IGNORE_OPERATOR_MODEQ 369 /* %= */
|
#define WARN_IGNORE_OPERATOR_MODEQ 369 /* %= */
|
||||||
#define WARN_IGNORE_OPERATOR_XOREQ 370 /* ^= */
|
#define WARN_IGNORE_OPERATOR_XOREQ 370 /* ^= */
|
||||||
#define WARN_IGNORE_OPERATOR_ANDEQ 371 /* &= */
|
#define WARN_IGNORE_OPERATOR_ANDEQ 371 /* &= */
|
||||||
#define WARN_IGNORE_OPERATOR_OREQ 372 /* |= */
|
#define WARN_IGNORE_OPERATOR_OREQ 372 /* |= */
|
||||||
#define WARN_IGNORE_OPERATOR_LSHIFT 373 /* << */
|
#define WARN_IGNORE_OPERATOR_LSHIFT 373 /* << */
|
||||||
#define WARN_IGNORE_OPERATOR_RSHIFT 374 /* >> */
|
#define WARN_IGNORE_OPERATOR_RSHIFT 374 /* >> */
|
||||||
#define WARN_IGNORE_OPERATOR_LSHIFTEQ 375 /* <<= */
|
#define WARN_IGNORE_OPERATOR_LSHIFTEQ 375 /* <<= */
|
||||||
#define WARN_IGNORE_OPERATOR_RSHIFTEQ 376 /* >>= */
|
#define WARN_IGNORE_OPERATOR_RSHIFTEQ 376 /* >>= */
|
||||||
#define WARN_IGNORE_OPERATOR_EQUALTO 377 /* == */
|
#define WARN_IGNORE_OPERATOR_EQUALTO 377 /* == */
|
||||||
#define WARN_IGNORE_OPERATOR_NOTEQUAL 378 /* != */
|
#define WARN_IGNORE_OPERATOR_NOTEQUAL 378 /* != */
|
||||||
#define WARN_IGNORE_OPERATOR_LTEQUAL 379 /* <= */
|
#define WARN_IGNORE_OPERATOR_LTEQUAL 379 /* <= */
|
||||||
#define WARN_IGNORE_OPERATOR_GTEQUAL 380 /* >= */
|
#define WARN_IGNORE_OPERATOR_GTEQUAL 380 /* >= */
|
||||||
#define WARN_IGNORE_OPERATOR_LAND 381 /* && */
|
#define WARN_IGNORE_OPERATOR_LAND 381 /* && */
|
||||||
#define WARN_IGNORE_OPERATOR_LOR 382 /* || */
|
#define WARN_IGNORE_OPERATOR_LOR 382 /* || */
|
||||||
#define WARN_IGNORE_OPERATOR_PLUSPLUS 383 /* ++ */
|
#define WARN_IGNORE_OPERATOR_PLUSPLUS 383 /* ++ */
|
||||||
#define WARN_IGNORE_OPERATOR_MINUSMINUS 384 /* -- */
|
#define WARN_IGNORE_OPERATOR_MINUSMINUS 384 /* -- */
|
||||||
#define WARN_IGNORE_OPERATOR_COMMA 385 /* , */
|
#define WARN_IGNORE_OPERATOR_COMMA 385 /* , */
|
||||||
#define WARN_IGNORE_OPERATOR_ARROWSTAR 386 /* ->* */
|
#define WARN_IGNORE_OPERATOR_ARROWSTAR 386 /* ->* */
|
||||||
#define WARN_IGNORE_OPERATOR_ARROW 387 /* -> */
|
#define WARN_IGNORE_OPERATOR_ARROW 387 /* -> */
|
||||||
#define WARN_IGNORE_OPERATOR_CALL 388 /* () */
|
#define WARN_IGNORE_OPERATOR_CALL 388 /* () */
|
||||||
#define WARN_IGNORE_OPERATOR_INDEX 389 /* [] */
|
#define WARN_IGNORE_OPERATOR_INDEX 389 /* [] */
|
||||||
#define WARN_IGNORE_OPERATOR_UPLUS 390 /* + */
|
#define WARN_IGNORE_OPERATOR_UPLUS 390 /* + */
|
||||||
#define WARN_IGNORE_OPERATOR_UMINUS 391 /* - */
|
#define WARN_IGNORE_OPERATOR_UMINUS 391 /* - */
|
||||||
#define WARN_IGNORE_OPERATOR_UMUL 392 /* * */
|
#define WARN_IGNORE_OPERATOR_UMUL 392 /* * */
|
||||||
#define WARN_IGNORE_OPERATOR_UAND 393 /* & */
|
#define WARN_IGNORE_OPERATOR_UAND 393 /* & */
|
||||||
#define WARN_IGNORE_OPERATOR_NEWARR 394 /* new [] */
|
#define WARN_IGNORE_OPERATOR_NEWARR 394 /* new [] */
|
||||||
#define WARN_IGNORE_OPERATOR_DELARR 395 /* delete [] */
|
#define WARN_IGNORE_OPERATOR_DELARR 395 /* delete [] */
|
||||||
#define WARN_IGNORE_OPERATOR_REF 396 /* operator *() */
|
#define WARN_IGNORE_OPERATOR_REF 396 /* operator *() */
|
||||||
|
|
||||||
/* 394-399 are reserved */
|
/* 394-399 are reserved */
|
||||||
|
|
||||||
|
|
@ -157,10 +157,10 @@
|
||||||
#define WARN_TYPEMAP_TYPECHECK 467
|
#define WARN_TYPEMAP_TYPECHECK 467
|
||||||
#define WARN_TYPEMAP_THROW 468
|
#define WARN_TYPEMAP_THROW 468
|
||||||
#define WARN_TYPEMAP_DIRECTORIN_UNDEF 469
|
#define WARN_TYPEMAP_DIRECTORIN_UNDEF 469
|
||||||
#define WARN_TYPEMAP_THREAD_UNSAFE 470 /* mostly used in directorout typemaps */
|
#define WARN_TYPEMAP_THREAD_UNSAFE 470 /* mostly used in directorout typemaps */
|
||||||
#define WARN_TYPEMAP_DIRECTOROUT_UNDEF 471
|
#define WARN_TYPEMAP_DIRECTOROUT_UNDEF 471
|
||||||
#define WARN_TYPEMAP_TYPECHECK_UNDEF 472
|
#define WARN_TYPEMAP_TYPECHECK_UNDEF 472
|
||||||
#define WARN_TYPEMAP_DIRECTOROUT_PTR 473
|
#define WARN_TYPEMAP_DIRECTOROUT_PTR 473
|
||||||
|
|
||||||
/* -- Fragments -- */
|
/* -- Fragments -- */
|
||||||
#define WARN_FRAGMENT_NOT_FOUND 490
|
#define WARN_FRAGMENT_NOT_FOUND 490
|
||||||
|
|
@ -171,7 +171,7 @@
|
||||||
#define WARN_LANG_OVERLOAD_CONSTRUCT 502
|
#define WARN_LANG_OVERLOAD_CONSTRUCT 502
|
||||||
#define WARN_LANG_IDENTIFIER 503
|
#define WARN_LANG_IDENTIFIER 503
|
||||||
#define WARN_LANG_RETURN_TYPE 504
|
#define WARN_LANG_RETURN_TYPE 504
|
||||||
#define WARN_LANG_VARARGS 505
|
#define WARN_LANG_VARARGS 505
|
||||||
#define WARN_LANG_VARARGS_KEYWORD 506
|
#define WARN_LANG_VARARGS_KEYWORD 506
|
||||||
#define WARN_LANG_NATIVE_UNIMPL 507
|
#define WARN_LANG_NATIVE_UNIMPL 507
|
||||||
#define WARN_LANG_DEREF_SHADOW 508
|
#define WARN_LANG_DEREF_SHADOW 508
|
||||||
|
|
@ -254,6 +254,3 @@
|
||||||
add an entry here */
|
add an entry here */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -15,62 +15,60 @@ char cvsroot_browser_cxx[] = "$Header$";
|
||||||
#ifdef SWIG_SWILL
|
#ifdef SWIG_SWILL
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "swill.h"
|
#include "swill.h"
|
||||||
}
|
} static FILE *out = 0;
|
||||||
|
|
||||||
static FILE *out = 0;
|
|
||||||
static Node *view_top = 0;
|
static Node *view_top = 0;
|
||||||
|
|
||||||
class Browser : public Dispatcher {
|
class Browser:public Dispatcher {
|
||||||
void show_checkbox(Node *t, Node *n) {
|
void show_checkbox(Node *t, Node *n) {
|
||||||
int v = 0;
|
int v = 0;
|
||||||
if (Getmeta(n,"visible")) {
|
if (Getmeta(n, "visible")) {
|
||||||
v = 1;
|
v = 1;
|
||||||
}
|
}
|
||||||
if (v) {
|
if (v) {
|
||||||
Printf(out,"<a name=\"n%x\"></a>[<a href=\"hide.html?node=0x%x&hn=0x%x#n%x\">-</a>] ", n, t, n,n);
|
Printf(out, "<a name=\"n%x\"></a>[<a href=\"hide.html?node=0x%x&hn=0x%x#n%x\">-</a>] ", n, t, n, n);
|
||||||
} else {
|
} else {
|
||||||
Printf(out,"<a name=\"n%x\"></a>[<a href=\"show.html?node=0x%x&hn=0x%x#n%x\">+</a>] ", n, t, n,n);
|
Printf(out, "<a name=\"n%x\"></a>[<a href=\"show.html?node=0x%x&hn=0x%x#n%x\">+</a>] ", n, t, n, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void show_attributes(Node *obj) {
|
void show_attributes(Node *obj) {
|
||||||
if (!Getmeta(obj,"visible")) return;
|
if (!Getmeta(obj, "visible"))
|
||||||
|
return;
|
||||||
String *os = NewString("");
|
String *os = NewString("");
|
||||||
String *k;
|
String *k;
|
||||||
Iterator ki;
|
Iterator ki;
|
||||||
ki = First(obj);
|
ki = First(obj);
|
||||||
while (ki.key) {
|
while (ki.key) {
|
||||||
k = ki.key;
|
k = ki.key;
|
||||||
if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
|
if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) ||
|
||||||
(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
|
(Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) {
|
||||||
(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
|
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
} else if (Cmp(k,"parms") == 0) {
|
} else if (Cmp(k, "parms") == 0) {
|
||||||
String *o = NewString("");
|
String *o = NewString("");
|
||||||
Printf(o,"%s", ParmList_protostr(Getattr(obj,k)));
|
Printf(o, "%s", ParmList_protostr(Getattr(obj, k)));
|
||||||
Replaceall(o,"&","&");
|
Replaceall(o, "&", "&");
|
||||||
Replaceall(o,"<","<");
|
Replaceall(o, "<", "<");
|
||||||
Replaceall(o,">",">");
|
Replaceall(o, ">", ">");
|
||||||
Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - %s\n", Getattr(obj,k), k, o);
|
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - %s\n", Getattr(obj, k), k, o);
|
||||||
Delete(o);
|
Delete(o);
|
||||||
} else {
|
} else {
|
||||||
DOH *o;
|
DOH *o;
|
||||||
char *trunc = "";
|
char *trunc = "";
|
||||||
if (DohIsString(Getattr(obj,k))) {
|
if (DohIsString(Getattr(obj, k))) {
|
||||||
o = Str(Getattr(obj,k));
|
o = Str(Getattr(obj, k));
|
||||||
if (Len(o) > 70) {
|
if (Len(o) > 70) {
|
||||||
trunc = "...";
|
trunc = "...";
|
||||||
}
|
}
|
||||||
Replaceall(o,"&","&");
|
Replaceall(o, "&", "&");
|
||||||
Replaceall(o,"<","<");
|
Replaceall(o, "<", "<");
|
||||||
Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj,k), k, o, trunc);
|
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||||
Delete(o);
|
Delete(o);
|
||||||
} else {
|
} else {
|
||||||
Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k));
|
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ki = Next(ki);
|
ki = Next(ki);
|
||||||
}
|
}
|
||||||
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
||||||
Delete(os);
|
Delete(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,24 +76,24 @@ public:
|
||||||
virtual int emit_one(Node *n) {
|
virtual int emit_one(Node *n) {
|
||||||
char *tag = Char(nodeType(n));
|
char *tag = Char(nodeType(n));
|
||||||
char *file = Char(Getfile(n));
|
char *file = Char(Getfile(n));
|
||||||
int line = Getline(n);
|
int line = Getline(n);
|
||||||
char *name = GetChar(n,"name");
|
char *name = GetChar(n, "name");
|
||||||
|
|
||||||
show_checkbox(view_top, n);
|
show_checkbox(view_top, n);
|
||||||
Printf(out,"<b><a href=\"index.html?node=0x%x\">%s</a></b>", n, tag);
|
Printf(out, "<b><a href=\"index.html?node=0x%x\">%s</a></b>", n, tag);
|
||||||
if (name) {
|
if (name) {
|
||||||
Printf(out," (%s)", name);
|
Printf(out, " (%s)", name);
|
||||||
}
|
}
|
||||||
Printf(out,". %s:%d\n", file, line);
|
Printf(out, ". %s:%d\n", file, line);
|
||||||
Printf(out,"<br>");
|
Printf(out, "<br>");
|
||||||
Dispatcher::emit_one(n);
|
Dispatcher::emit_one(n);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
virtual int emit_children(Node *n) {
|
virtual int emit_children(Node *n) {
|
||||||
if (Getmeta(n,"visible")) {
|
if (Getmeta(n, "visible")) {
|
||||||
Printf(out,"<blockquote>\n");
|
Printf(out, "<blockquote>\n");
|
||||||
Dispatcher::emit_children(n);
|
Dispatcher::emit_children(n);
|
||||||
Printf(out,"</blockquote>\n");
|
Printf(out, "</blockquote>\n");
|
||||||
}
|
}
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +167,7 @@ static Browser *browse = 0;
|
||||||
|
|
||||||
void exit_handler(FILE *f) {
|
void exit_handler(FILE *f) {
|
||||||
browser_exit = 1;
|
browser_exit = 1;
|
||||||
Printf(f,"Terminated.\n");
|
Printf(f, "Terminated.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
@ -178,23 +176,23 @@ void exit_handler(FILE *f) {
|
||||||
|
|
||||||
static void display(FILE *f, Node *n) {
|
static void display(FILE *f, Node *n) {
|
||||||
/* Print standard HTML header */
|
/* Print standard HTML header */
|
||||||
|
|
||||||
Printf(f,"<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
|
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
|
||||||
Printf(f,"<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
|
Printf(f, "<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
|
||||||
Printf(f,"[ <a href=\"exit.html\">Exit</a> ]");
|
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||||
Printf(f," [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||||
if (n != tree_top) {
|
if (n != tree_top) {
|
||||||
Printf(f," [ <a href=\"index.html?node=0x%x\">Up</a> ]", parentNode(n));
|
Printf(f, " [ <a href=\"index.html?node=0x%x\">Up</a> ]", parentNode(n));
|
||||||
}
|
}
|
||||||
Printf(f," [ <a href=\"symbol.html\">Symbols</a> ]");
|
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
|
||||||
Printf(f,"<br><hr><p>\n");
|
Printf(f, "<br><hr><p>\n");
|
||||||
|
|
||||||
out = f;
|
out = f;
|
||||||
|
|
||||||
browse->emit_one(n);
|
browse->emit_one(n);
|
||||||
|
|
||||||
/* Print standard footer */
|
/* Print standard footer */
|
||||||
Printf(f,"<br><hr></BODY></HTML>\n");
|
Printf(f, "<br><hr></BODY></HTML>\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,7 +202,7 @@ void node_handler(FILE *f) {
|
||||||
n = tree_top;
|
n = tree_top;
|
||||||
}
|
}
|
||||||
view_top = n;
|
view_top = n;
|
||||||
display(f,n);
|
display(f, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -218,7 +216,7 @@ void hide_handler(FILE *f) {
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
if (n) {
|
if (n) {
|
||||||
Delmeta(n,"visible");
|
Delmeta(n, "visible");
|
||||||
}
|
}
|
||||||
node_handler(f);
|
node_handler(f);
|
||||||
}
|
}
|
||||||
|
|
@ -229,65 +227,66 @@ void show_handler(FILE *f) {
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
if (n) {
|
if (n) {
|
||||||
Setmeta(n,"visible","1");
|
Setmeta(n, "visible", "1");
|
||||||
}
|
}
|
||||||
node_handler(f);
|
node_handler(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_data(FILE *out, Node *obj) {
|
void raw_data(FILE *out, Node *obj) {
|
||||||
if (!obj) return;
|
if (!obj)
|
||||||
|
return;
|
||||||
if (DohIsMapping(obj)) {
|
if (DohIsMapping(obj)) {
|
||||||
String *k;
|
String *k;
|
||||||
Iterator ki;
|
Iterator ki;
|
||||||
String *os = NewString("");
|
String *os = NewString("");
|
||||||
Printf(os,"Hash {\n");
|
Printf(os, "Hash {\n");
|
||||||
ki = First(obj);
|
ki = First(obj);
|
||||||
while (ki.key) {
|
while (ki.key) {
|
||||||
k = ki.key;
|
k = ki.key;
|
||||||
DOH *o;
|
DOH *o;
|
||||||
const char *trunc = "";
|
const char *trunc = "";
|
||||||
if (DohIsString(Getattr(obj,k))) {
|
if (DohIsString(Getattr(obj, k))) {
|
||||||
o = Str(Getattr(obj,k));
|
o = Str(Getattr(obj, k));
|
||||||
if (Len(o) > 70) {
|
if (Len(o) > 70) {
|
||||||
trunc = "...";
|
trunc = "...";
|
||||||
}
|
}
|
||||||
Replaceall(o,"<","<");
|
Replaceall(o, "<", "<");
|
||||||
Printf(os," <a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj,k), k, o, trunc);
|
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||||
Delete(o);
|
Delete(o);
|
||||||
} else {
|
} else {
|
||||||
Printf(os," <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k));
|
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||||
}
|
}
|
||||||
ki = Next(ki);
|
ki = Next(ki);
|
||||||
}
|
}
|
||||||
Printf(os,"}\n");
|
Printf(os, "}\n");
|
||||||
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
||||||
Delete(os);
|
Delete(os);
|
||||||
} else if (DohIsString(obj)) {
|
} else if (DohIsString(obj)) {
|
||||||
String *o = Str(obj);
|
String *o = Str(obj);
|
||||||
Replaceall(o,"<","<");
|
Replaceall(o, "<", "<");
|
||||||
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(o));
|
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(o));
|
||||||
Delete(o);
|
Delete(o);
|
||||||
} else if (DohIsSequence(obj)) {
|
} else if (DohIsSequence(obj)) {
|
||||||
int i;
|
int i;
|
||||||
String *os = NewString("");
|
String *os = NewString("");
|
||||||
Printf(os,"List [\n");
|
Printf(os, "List [\n");
|
||||||
for (i = 0; i < Len(obj); i++) {
|
for (i = 0; i < Len(obj); i++) {
|
||||||
DOH *o = Getitem(obj,i);
|
DOH *o = Getitem(obj, i);
|
||||||
const char *trunc = "";
|
const char *trunc = "";
|
||||||
if (DohIsString(o)) {
|
if (DohIsString(o)) {
|
||||||
String *s = Str(o);
|
String *s = Str(o);
|
||||||
if (Len(s) > 70) {
|
if (Len(s) > 70) {
|
||||||
trunc = "...";
|
trunc = "...";
|
||||||
}
|
}
|
||||||
Replaceall(o,"<","<");
|
Replaceall(o, "<", "<");
|
||||||
Printf(os," <a href=\"data.html?n=0x%x\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o,i,s, trunc);
|
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc);
|
||||||
Delete(s);
|
Delete(s);
|
||||||
} else {
|
} else {
|
||||||
Printf(os," <a href=\"data.html?n=0x%x\">?</a> [%d] - 0x%x\n", o, i, o);
|
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> [%d] - 0x%x\n", o, i, o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Printf(os,"\n]\n");
|
Printf(os, "\n]\n");
|
||||||
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
||||||
Delete(os);
|
Delete(os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -297,86 +296,85 @@ void data_handler(FILE *f) {
|
||||||
if (!swill_getargs("p(n)", &n)) {
|
if (!swill_getargs("p(n)", &n)) {
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
Printf(f,"<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
|
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
|
||||||
Printf(f,"<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
|
Printf(f, "<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
|
||||||
Printf(f,"[ <a href=\"exit.html\">Exit</a> ]");
|
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||||
Printf(f," [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||||
Printf(f,"<br><hr><p>\n");
|
Printf(f, "<br><hr><p>\n");
|
||||||
if (n) {
|
if (n) {
|
||||||
raw_data(f,n);
|
raw_data(f, n);
|
||||||
}
|
}
|
||||||
/* Print standard footer */
|
/* Print standard footer */
|
||||||
Printf(f,"<br><hr></BODY></HTML>\n");
|
Printf(f, "<br><hr></BODY></HTML>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void symbol_handler(FILE *f) {
|
void symbol_handler(FILE *f) {
|
||||||
Symtab *sym;
|
Symtab *sym;
|
||||||
char *name = 0;
|
char *name = 0;
|
||||||
|
|
||||||
|
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
|
||||||
|
Printf(f, "<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
|
||||||
|
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||||
|
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||||
|
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
|
||||||
|
Printf(f, "<br><hr><p>\n");
|
||||||
|
|
||||||
Printf(f,"<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
|
|
||||||
Printf(f,"<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
|
|
||||||
Printf(f,"[ <a href=\"exit.html\">Exit</a> ]");
|
|
||||||
Printf(f," [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
|
||||||
Printf(f," [ <a href=\"symbol.html\">Symbols</a> ]");
|
|
||||||
Printf(f,"<br><hr><p>\n");
|
|
||||||
|
|
||||||
if (!swill_getargs("p(sym)|s(name)", &sym, &name)) {
|
if (!swill_getargs("p(sym)|s(name)", &sym, &name)) {
|
||||||
sym = Swig_symbol_getscope("");
|
sym = Swig_symbol_getscope("");
|
||||||
name = 0;
|
name = 0;
|
||||||
}
|
}
|
||||||
if (!sym) {
|
if (!sym) {
|
||||||
Printf(f,"No symbol table specified!\n");
|
Printf(f, "No symbol table specified!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
String *q = Swig_symbol_qualifiedscopename(sym);
|
String *q = Swig_symbol_qualifiedscopename(sym);
|
||||||
if (!Len(q)) {
|
if (!Len(q)) {
|
||||||
Printf(f,"<b>Symbol table: :: (global)</b><br>\n");
|
Printf(f, "<b>Symbol table: :: (global)</b><br>\n");
|
||||||
} else {
|
} else {
|
||||||
Printf(f,"<b>Symbol table: %s</b><br>\n", q);
|
Printf(f, "<b>Symbol table: %s</b><br>\n", q);
|
||||||
}
|
}
|
||||||
Delete(q);
|
Delete(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f,"<p><form action=\"symbol.html\" method=GET>\n");
|
fprintf(f, "<p><form action=\"symbol.html\" method=GET>\n");
|
||||||
fprintf(f,"Symbol lookup: <input type=text name=name size=40></input><br>\n");
|
fprintf(f, "Symbol lookup: <input type=text name=name size=40></input><br>\n");
|
||||||
fprintf(f,"<input type=hidden name=sym value=\"0x%x\">\n", sym);
|
fprintf(f, "<input type=hidden name=sym value=\"0x%x\">\n", sym);
|
||||||
fprintf(f,"Submit : <input type=submit></input>\n");
|
fprintf(f, "Submit : <input type=submit></input>\n");
|
||||||
fprintf(f,"</form>");
|
fprintf(f, "</form>");
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
Node *n = Swig_symbol_clookup(name,sym);
|
Node *n = Swig_symbol_clookup(name, sym);
|
||||||
Printf(f,"Symbol '%s':\n", name);
|
Printf(f, "Symbol '%s':\n", name);
|
||||||
Printf(f,"<blockquote>\n");
|
Printf(f, "<blockquote>\n");
|
||||||
if (!n) {
|
if (!n) {
|
||||||
Printf(f,"Not defined!\n");
|
Printf(f, "Not defined!\n");
|
||||||
} else {
|
} else {
|
||||||
raw_data(f,n);
|
raw_data(f, n);
|
||||||
}
|
}
|
||||||
Printf(f,"</blockquote>\n");
|
Printf(f, "</blockquote>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(f,"<p><b>Nested scopes</b><br>\n");
|
Printf(f, "<p><b>Nested scopes</b><br>\n");
|
||||||
Printf(f,"<blockquote><pre>\n");
|
Printf(f, "<blockquote><pre>\n");
|
||||||
{
|
{
|
||||||
Hash *h;
|
Hash *h;
|
||||||
h = firstChild(sym);
|
h = firstChild(sym);
|
||||||
while (h) {
|
while (h) {
|
||||||
Printf(f,"<a href=\"symbol.html?sym=0x%x\">%s</a>\n", h, Getattr(h,"name"));
|
Printf(f, "<a href=\"symbol.html?sym=0x%x\">%s</a>\n", h, Getattr(h, "name"));
|
||||||
h = nextSibling(h);
|
h = nextSibling(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Printf(f,"</pre></blockquote>\n");
|
Printf(f, "</pre></blockquote>\n");
|
||||||
|
|
||||||
Printf(f,"<p><b>Symbol table contents</b></br>\n");
|
Printf(f, "<p><b>Symbol table contents</b></br>\n");
|
||||||
raw_data(f,Getattr(sym,"symtab"));
|
raw_data(f, Getattr(sym, "symtab"));
|
||||||
Printf(f,"<br><hr></BODY></HTML>\n");
|
Printf(f, "<br><hr></BODY></HTML>\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void Swig_browser(Node *top, int port) {
|
||||||
Swig_browser(Node *top, int port) {
|
|
||||||
#ifdef SWIG_SWILL
|
#ifdef SWIG_SWILL
|
||||||
int sport;
|
int sport;
|
||||||
browser_exit = 0;
|
browser_exit = 0;
|
||||||
|
|
@ -384,37 +382,32 @@ Swig_browser(Node *top, int port) {
|
||||||
/* Initialize the server */
|
/* Initialize the server */
|
||||||
sport = swill_init(port);
|
sport = swill_init(port);
|
||||||
if (sport < 0) {
|
if (sport < 0) {
|
||||||
Printf(stderr,"Couldn't open socket on port %d. Sorry.\n", port);
|
Printf(stderr, "Couldn't open socket on port %d. Sorry.\n", port);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
browse = new Browser();
|
browse = new Browser();
|
||||||
Setmeta(top,"visible","1");
|
Setmeta(top, "visible", "1");
|
||||||
tree_top = top;
|
tree_top = top;
|
||||||
|
|
||||||
Printf(stderr,"SWIG: Tree browser listening on port %d\n", sport);
|
Printf(stderr, "SWIG: Tree browser listening on port %d\n", sport);
|
||||||
|
|
||||||
swill_handle("exit.html", exit_handler,0);
|
swill_handle("exit.html", exit_handler, 0);
|
||||||
swill_handle("index.html", node_handler, 0);
|
swill_handle("index.html", node_handler, 0);
|
||||||
swill_handle("hide.html", hide_handler,0);
|
swill_handle("hide.html", hide_handler, 0);
|
||||||
swill_handle("show.html", show_handler,0);
|
swill_handle("show.html", show_handler, 0);
|
||||||
swill_handle("data.html", data_handler,0);
|
swill_handle("data.html", data_handler, 0);
|
||||||
swill_handle("symbol.html", symbol_handler, 0);
|
swill_handle("symbol.html", symbol_handler, 0);
|
||||||
swill_netscape("index.html");
|
swill_netscape("index.html");
|
||||||
|
|
||||||
while (!browser_exit) {
|
while (!browser_exit) {
|
||||||
swill_serve();
|
swill_serve();
|
||||||
}
|
}
|
||||||
Printf(stderr,"Browser terminated.\n");
|
Printf(stderr, "Browser terminated.\n");
|
||||||
swill_close();
|
swill_close();
|
||||||
delete browse;
|
delete browse;
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
(void)top;
|
(void) top;
|
||||||
(void)port;
|
(void) port;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -11,343 +11,335 @@ char cvsroot_clisp_cxx[] = "$Header$";
|
||||||
|
|
||||||
#include "swigmod.h"
|
#include "swigmod.h"
|
||||||
|
|
||||||
class CLISP : public Language {
|
class CLISP:public Language {
|
||||||
public:
|
public:
|
||||||
File *f_cl;
|
File *f_cl;
|
||||||
String *module;
|
String *module;
|
||||||
virtual void main(int argc, char *argv[]);
|
virtual void main(int argc, char *argv[]);
|
||||||
virtual int top(Node *n);
|
virtual int top(Node *n);
|
||||||
virtual int functionWrapper(Node *n);
|
virtual int functionWrapper(Node *n);
|
||||||
virtual int variableWrapper(Node *n);
|
virtual int variableWrapper(Node *n);
|
||||||
virtual int constantWrapper(Node *n);
|
virtual int constantWrapper(Node *n);
|
||||||
virtual int classDeclaration(Node *n);
|
virtual int classDeclaration(Node *n);
|
||||||
virtual int enumDeclaration(Node *n);
|
virtual int enumDeclaration(Node *n);
|
||||||
virtual int typedefHandler(Node *n);
|
virtual int typedefHandler(Node *n);
|
||||||
List *entries;
|
List *entries;
|
||||||
private:
|
private:
|
||||||
String* get_ffi_type(SwigType *ty);
|
String *get_ffi_type(SwigType *ty);
|
||||||
String* convert_literal(String *num_param, String *type);
|
String *convert_literal(String *num_param, String *type);
|
||||||
String* strip_parens(String *string);
|
String *strip_parens(String *string);
|
||||||
int extern_all_flag;
|
int extern_all_flag;
|
||||||
int generate_typedef_flag;
|
int generate_typedef_flag;
|
||||||
int is_function;
|
int is_function;
|
||||||
};
|
};
|
||||||
|
|
||||||
void CLISP :: main(int argc, char *argv[]) {
|
void CLISP::main(int argc, char *argv[]) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SWIG_library_directory("clisp");
|
SWIG_library_directory("clisp");
|
||||||
SWIG_config_file("clisp.swg");
|
SWIG_config_file("clisp.swg");
|
||||||
generate_typedef_flag = 0;
|
generate_typedef_flag = 0;
|
||||||
extern_all_flag=0;
|
extern_all_flag = 0;
|
||||||
|
|
||||||
for(i=1; i<argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "-help")) {
|
if (!strcmp(argv[i], "-help")) {
|
||||||
Printf(stdout, "clisp Options (available with -clisp)\n");
|
Printf(stdout, "clisp Options (available with -clisp)\n");
|
||||||
Printf(stdout,
|
Printf(stdout,
|
||||||
" -extern-all\n"
|
" -extern-all\n"
|
||||||
"\t If this option is given then clisp definitions for all the functions\n"
|
"\t If this option is given then clisp definitions for all the functions\n"
|
||||||
"and global variables will be created otherwise only definitions for \n"
|
"and global variables will be created otherwise only definitions for \n"
|
||||||
"externed functions and variables are created.\n"
|
"externed functions and variables are created.\n"
|
||||||
" -generate-typedef\n"
|
" -generate-typedef\n"
|
||||||
"\t If this option is given then def-c-type will be used to generate shortcuts\n"
|
"\t If this option is given then def-c-type will be used to generate shortcuts\n"
|
||||||
"according to the typedefs in the input.\n"
|
"according to the typedefs in the input.\n");
|
||||||
);
|
} else if ((Strcmp(argv[i], "-extern-all") == 0)) {
|
||||||
}
|
|
||||||
else if ( (Strcmp(argv[i],"-extern-all") == 0)) {
|
|
||||||
extern_all_flag = 1;
|
extern_all_flag = 1;
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
}
|
} else if ((Strcmp(argv[i], "-generate-typedef") == 0)) {
|
||||||
else if ( (Strcmp(argv[i],"-generate-typedef") == 0)) {
|
|
||||||
generate_typedef_flag = 1;
|
generate_typedef_flag = 1;
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLISP :: top(Node *n) {
|
int CLISP::top(Node *n) {
|
||||||
|
|
||||||
File *f_null=NewString("");
|
File *f_null = NewString("");
|
||||||
module=Getattr(n, "name");
|
module = Getattr(n, "name");
|
||||||
String *output_filename;
|
String *output_filename;
|
||||||
entries = NewList();
|
entries = NewList();
|
||||||
|
|
||||||
/* Get the output file name */
|
/* Get the output file name */
|
||||||
String *outfile = Getattr(n,"outfile");
|
String *outfile = Getattr(n, "outfile");
|
||||||
|
|
||||||
if(!outfile)
|
if (!outfile)
|
||||||
output_filename=outfile;
|
output_filename = outfile;
|
||||||
else {
|
else {
|
||||||
output_filename=NewString("");
|
output_filename = NewString("");
|
||||||
Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module);
|
Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module);
|
||||||
}
|
}
|
||||||
|
|
||||||
f_cl=NewFile(output_filename, "w+");
|
f_cl = NewFile(output_filename, "w+");
|
||||||
if (!f_cl) {
|
if (!f_cl) {
|
||||||
FileErrorDisplay(output_filename);
|
FileErrorDisplay(output_filename);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Swig_register_filebyname("header",f_null);
|
Swig_register_filebyname("header", f_null);
|
||||||
Swig_register_filebyname("runtime",f_null);
|
Swig_register_filebyname("runtime", f_null);
|
||||||
Swig_register_filebyname("wrapper", f_null);
|
Swig_register_filebyname("wrapper", f_null);
|
||||||
|
|
||||||
String *header=NewStringf(";; This is an automatically generated file. \n;;Make changes as you feel are necessary (but remember if you try to regenerate this file, your changes will be lost). \n\n(defpackage :%s\n (:use :common-lisp :ffi)", module);
|
String *header =
|
||||||
|
NewStringf
|
||||||
|
(";; This is an automatically generated file. \n;;Make changes as you feel are necessary (but remember if you try to regenerate this file, your changes will be lost). \n\n(defpackage :%s\n (:use :common-lisp :ffi)",
|
||||||
|
module);
|
||||||
|
|
||||||
Language::top(n);
|
Language::top(n);
|
||||||
|
|
||||||
Iterator i;
|
Iterator i;
|
||||||
|
|
||||||
long len=Len(entries);
|
long len = Len(entries);
|
||||||
if(len > 0) {
|
if (len > 0) {
|
||||||
Printf(header,"\n (:export");
|
Printf(header, "\n (:export");
|
||||||
}
|
}
|
||||||
//else nothing to export
|
//else nothing to export
|
||||||
|
|
||||||
for (i = First(entries); i.item; i = Next(i)) {
|
|
||||||
Printf(header,"\n\t:%s", i.item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(len > 0) {
|
|
||||||
Printf(header,")");
|
|
||||||
}
|
|
||||||
|
|
||||||
Printf(header, ")\n");
|
|
||||||
Printf(header,"\n(in-package :%s)\n",module);
|
|
||||||
Printf(header,"\n(default-foreign-language :stdc)\n");
|
|
||||||
|
|
||||||
len= Tell(f_cl);
|
|
||||||
|
|
||||||
Printf(f_cl,"%s",header);
|
for (i = First(entries); i.item; i = Next(i)) {
|
||||||
|
Printf(header, "\n\t:%s", i.item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > 0) {
|
||||||
|
Printf(header, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
Printf(header, ")\n");
|
||||||
|
Printf(header, "\n(in-package :%s)\n", module);
|
||||||
|
Printf(header, "\n(default-foreign-language :stdc)\n");
|
||||||
|
|
||||||
|
len = Tell(f_cl);
|
||||||
|
|
||||||
|
Printf(f_cl, "%s", header);
|
||||||
|
|
||||||
long end = Tell(f_cl);
|
long end = Tell(f_cl);
|
||||||
|
|
||||||
for(len--;len >=0 ; len --) {
|
for (len--; len >= 0; len--) {
|
||||||
end--;
|
end--;
|
||||||
Seek(f_cl,len,SEEK_SET);
|
Seek(f_cl, len, SEEK_SET);
|
||||||
int ch=Getc(f_cl);
|
int ch = Getc(f_cl);
|
||||||
Seek(f_cl,end,SEEK_SET);
|
Seek(f_cl, end, SEEK_SET);
|
||||||
Putc(ch,f_cl);
|
Putc(ch, f_cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
Seek(f_cl,0,SEEK_SET);
|
Seek(f_cl, 0, SEEK_SET);
|
||||||
Write(f_cl,Char(header), Len(header));
|
Write(f_cl, Char(header), Len(header));
|
||||||
|
|
||||||
Close(f_cl);
|
Close(f_cl);
|
||||||
Delete(f_cl); // Deletes the handle, not the file
|
Delete(f_cl); // Deletes the handle, not the file
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CLISP :: functionWrapper(Node *n) {
|
int CLISP::functionWrapper(Node *n) {
|
||||||
is_function=1;
|
is_function = 1;
|
||||||
String *storage=Getattr(n,"storage");
|
String *storage = Getattr(n, "storage");
|
||||||
if(!extern_all_flag && (!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc"))))
|
if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc"))))
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
||||||
String *func_name=Getattr(n, "sym:name");
|
|
||||||
|
|
||||||
ParmList *pl=Getattr(n, "parms");
|
String *func_name = Getattr(n, "sym:name");
|
||||||
|
|
||||||
int argnum=0, first=1;
|
ParmList *pl = Getattr(n, "parms");
|
||||||
|
|
||||||
Printf(f_cl, "\n(ffi:def-call-out %s\n\t(:name \"%s\")\n", func_name,func_name);
|
int argnum = 0, first = 1;
|
||||||
|
|
||||||
Append(entries,func_name);
|
Printf(f_cl, "\n(ffi:def-call-out %s\n\t(:name \"%s\")\n", func_name, func_name);
|
||||||
|
|
||||||
|
Append(entries, func_name);
|
||||||
|
|
||||||
if (ParmList_len(pl) != 0) {
|
if (ParmList_len(pl) != 0) {
|
||||||
Printf(f_cl, "\t(:arguments ");
|
Printf(f_cl, "\t(:arguments ");
|
||||||
}
|
}
|
||||||
for (Parm *p=pl; p; p=nextSibling(p), argnum++) {
|
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
|
||||||
|
|
||||||
String *argname=Getattr(p, "name");
|
String *argname = Getattr(p, "name");
|
||||||
// SwigType *argtype;
|
// SwigType *argtype;
|
||||||
|
|
||||||
String *ffitype=get_ffi_type(Getattr(p, "type"));
|
String *ffitype = get_ffi_type(Getattr(p, "type"));
|
||||||
|
|
||||||
int tempargname=0;
|
int tempargname = 0;
|
||||||
|
|
||||||
if (!argname) {
|
if (!argname) {
|
||||||
argname=NewStringf("arg%d", argnum);
|
argname = NewStringf("arg%d", argnum);
|
||||||
tempargname=1;
|
tempargname = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!first) {
|
if (!first) {
|
||||||
Printf(f_cl, "\n\t\t");
|
Printf(f_cl, "\n\t\t");
|
||||||
}
|
}
|
||||||
Printf(f_cl, "(%s %s)", argname, ffitype);
|
Printf(f_cl, "(%s %s)", argname, ffitype);
|
||||||
first=0;
|
first = 0;
|
||||||
|
|
||||||
Delete(ffitype);
|
Delete(ffitype);
|
||||||
|
|
||||||
if (tempargname)
|
if (tempargname)
|
||||||
Delete(argname);
|
Delete(argname);
|
||||||
}
|
}
|
||||||
if (ParmList_len(pl) != 0) {
|
if (ParmList_len(pl) != 0) {
|
||||||
Printf(f_cl, ")\n"); /* finish arg list */
|
Printf(f_cl, ")\n"); /* finish arg list */
|
||||||
}
|
}
|
||||||
String *ffitype=get_ffi_type(Getattr(n, "type"));
|
String *ffitype = get_ffi_type(Getattr(n, "type"));
|
||||||
if(Strcmp(ffitype,"NIL")) { //when return type is not nil
|
if (Strcmp(ffitype, "NIL")) { //when return type is not nil
|
||||||
Printf(f_cl, "\t(:return-type %s)\n", ffitype);
|
Printf(f_cl, "\t(:return-type %s)\n", ffitype);
|
||||||
}
|
}
|
||||||
Printf(f_cl, "\t(:library +library-name+))\n");
|
Printf(f_cl, "\t(:library +library-name+))\n");
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CLISP :: constantWrapper(Node *n) {
|
int CLISP::constantWrapper(Node *n) {
|
||||||
is_function=0;
|
is_function = 0;
|
||||||
String *type=Getattr(n, "type");
|
String *type = Getattr(n, "type");
|
||||||
String *converted_value=convert_literal(Getattr(n, "value"), type);
|
String *converted_value = convert_literal(Getattr(n, "value"), type);
|
||||||
String *name=Getattr(n, "sym:name");
|
String *name = Getattr(n, "sym:name");
|
||||||
|
|
||||||
Printf(f_cl, "\n(defconstant %s %s)\n", name, converted_value);
|
Printf(f_cl, "\n(defconstant %s %s)\n", name, converted_value);
|
||||||
Append(entries,name);
|
Append(entries, name);
|
||||||
Delete(converted_value);
|
Delete(converted_value);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLISP :: variableWrapper(Node *n) {
|
int CLISP::variableWrapper(Node *n) {
|
||||||
is_function=0;
|
is_function = 0;
|
||||||
// SwigType *type=;
|
// SwigType *type=;
|
||||||
String *storage=Getattr(n,"storage");
|
String *storage = Getattr(n, "storage");
|
||||||
|
|
||||||
if(!extern_all_flag && (!storage || (Strcmp(storage,"extern") && Strcmp(storage,"externc"))))
|
if (!extern_all_flag && (!storage || (Strcmp(storage, "extern") && Strcmp(storage, "externc"))))
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
||||||
String *var_name=Getattr(n, "sym:name");
|
String *var_name = Getattr(n, "sym:name");
|
||||||
String *lisp_type=get_ffi_type(Getattr(n, "type"));
|
String *lisp_type = get_ffi_type(Getattr(n, "type"));
|
||||||
Printf(f_cl,"\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n",var_name,var_name,lisp_type);
|
Printf(f_cl, "\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n", var_name, var_name, lisp_type);
|
||||||
Printf(f_cl, "\t(:library +library-name+))\n");
|
Printf(f_cl, "\t(:library +library-name+))\n");
|
||||||
Append(entries,var_name);
|
Append(entries, var_name);
|
||||||
|
|
||||||
Delete(lisp_type);
|
Delete(lisp_type);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLISP :: typedefHandler(Node *n) {
|
int CLISP::typedefHandler(Node *n) {
|
||||||
if(generate_typedef_flag) {
|
if (generate_typedef_flag) {
|
||||||
is_function=0;
|
is_function = 0;
|
||||||
Printf(f_cl,"\n(ffi:def-c-type %s %s)\n",Getattr(n,"name"),get_ffi_type(Getattr(n,"type")));
|
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(Getattr(n, "type")));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Language::typedefHandler(n);
|
return Language::typedefHandler(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLISP :: enumDeclaration(Node *n) {
|
int CLISP::enumDeclaration(Node *n) {
|
||||||
is_function=0;
|
is_function = 0;
|
||||||
String *name=Getattr(n, "sym:name");
|
String *name = Getattr(n, "sym:name");
|
||||||
|
|
||||||
Printf(f_cl,"\n(ffi:def-c-enum %s ",name);
|
|
||||||
|
|
||||||
for (Node *c=firstChild(n); c; c=nextSibling(c)) {
|
Printf(f_cl, "\n(ffi:def-c-enum %s ", name);
|
||||||
|
|
||||||
|
for (Node *c = firstChild(n); c; c = nextSibling(c)) {
|
||||||
|
|
||||||
String *slot_name = Getattr(c, "name");
|
String *slot_name = Getattr(c, "name");
|
||||||
String *value = Getattr(c, "enumvalue");
|
String *value = Getattr(c, "enumvalue");
|
||||||
|
|
||||||
Printf(f_cl,"(%s %s)",slot_name,value);
|
|
||||||
|
|
||||||
Append(entries,slot_name);
|
Printf(f_cl, "(%s %s)", slot_name, value);
|
||||||
|
|
||||||
|
Append(entries, slot_name);
|
||||||
|
|
||||||
Delete(value);
|
Delete(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(f_cl, ")\n");
|
Printf(f_cl, ")\n");
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Includes structs
|
// Includes structs
|
||||||
int CLISP :: classDeclaration(Node *n) {
|
int CLISP::classDeclaration(Node *n) {
|
||||||
is_function=0;
|
is_function = 0;
|
||||||
String *name=Getattr(n, "sym:name");
|
String *name = Getattr(n, "sym:name");
|
||||||
String *kind = Getattr(n,"kind");
|
String *kind = Getattr(n, "kind");
|
||||||
|
|
||||||
if (Strcmp(kind, "struct")) {
|
if (Strcmp(kind, "struct")) {
|
||||||
Printf(stderr, "Don't know how to deal with %s kind of class yet.\n",
|
Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind);
|
||||||
kind);
|
|
||||||
Printf(stderr, " (name: %s)\n", name);
|
Printf(stderr, " (name: %s)\n", name);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Printf(f_cl,"\n(ffi:def-c-struct %s",name);
|
|
||||||
|
|
||||||
Append(entries,NewStringf("make-%s",name));
|
Printf(f_cl, "\n(ffi:def-c-struct %s", name);
|
||||||
|
|
||||||
for (Node *c=firstChild(n); c; c=nextSibling(c)) {
|
Append(entries, NewStringf("make-%s", name));
|
||||||
|
|
||||||
|
for (Node *c = firstChild(n); c; c = nextSibling(c)) {
|
||||||
|
|
||||||
if (Strcmp(nodeType(c), "cdecl")) {
|
if (Strcmp(nodeType(c), "cdecl")) {
|
||||||
Printf(stderr, "Structure %s has a slot that we can't deal with.\n",
|
Printf(stderr, "Structure %s has a slot that we can't deal with.\n", name);
|
||||||
name);
|
Printf(stderr, "nodeType: %s, name: %s, type: %s\n", nodeType(c), Getattr(c, "name"), Getattr(c, "type"));
|
||||||
Printf(stderr, "nodeType: %s, name: %s, type: %s\n",
|
|
||||||
nodeType(c),
|
|
||||||
Getattr(c, "name"),
|
|
||||||
Getattr(c, "type"));
|
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
String *temp=Copy(Getattr(c,"decl"));
|
String *temp = Copy(Getattr(c, "decl"));
|
||||||
Append(temp,Getattr(c,"type")); //appending type to the end, otherwise wrong type
|
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
|
||||||
String *lisp_type=get_ffi_type(temp);
|
String *lisp_type = get_ffi_type(temp);
|
||||||
Delete(temp);
|
Delete(temp);
|
||||||
|
|
||||||
String *slot_name = Getattr(c, "sym:name");
|
String *slot_name = Getattr(c, "sym:name");
|
||||||
Printf(f_cl,
|
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
|
||||||
"\n\t(%s %s)",
|
|
||||||
slot_name,
|
Append(entries, NewStringf("%s-%s", name, slot_name));
|
||||||
lisp_type);
|
|
||||||
|
|
||||||
Append(entries,NewStringf("%s-%s",name,slot_name));
|
|
||||||
|
|
||||||
Delete(lisp_type);
|
Delete(lisp_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(f_cl, ")\n");
|
Printf(f_cl, ")\n");
|
||||||
|
|
||||||
/* Add this structure to the known lisp types */
|
/* Add this structure to the known lisp types */
|
||||||
//Printf(stdout, "Adding %s foreign type\n", name);
|
//Printf(stdout, "Adding %s foreign type\n", name);
|
||||||
// add_defined_foreign_type(name);
|
// add_defined_foreign_type(name);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* utilities */
|
/* utilities */
|
||||||
/* returns new string w/ parens stripped */
|
/* returns new string w/ parens stripped */
|
||||||
String* CLISP::strip_parens(String *string) {
|
String *CLISP::strip_parens(String *string) {
|
||||||
char *s=Char(string), *p;
|
char *s = Char(string), *p;
|
||||||
int len=Len(string);
|
int len = Len(string);
|
||||||
String *res;
|
String *res;
|
||||||
|
|
||||||
if (len==0 || s[0] != '(' || s[len-1] != ')') {
|
if (len == 0 || s[0] != '(' || s[len - 1] != ')') {
|
||||||
return NewString(string);
|
return NewString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
p=(char *)malloc(len-2+1);
|
p = (char *) malloc(len - 2 + 1);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
Printf(stderr, "Malloc failed\n");
|
Printf(stderr, "Malloc failed\n");
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(p, s+1, len-1);
|
strncpy(p, s + 1, len - 1);
|
||||||
p[len-2]=0; /* null terminate */
|
p[len - 2] = 0; /* null terminate */
|
||||||
|
|
||||||
res=NewString(p);
|
res = NewString(p);
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
String* CLISP::convert_literal(String *num_param, String *type) {
|
String *CLISP::convert_literal(String *num_param, String *type) {
|
||||||
String *num=strip_parens(num_param), *res;
|
String *num = strip_parens(num_param), *res;
|
||||||
char *s=Char(num);
|
char *s = Char(num);
|
||||||
|
|
||||||
/* Make sure doubles use 'd' instead of 'e' */
|
/* Make sure doubles use 'd' instead of 'e' */
|
||||||
if (!Strcmp(type, "double")) {
|
if (!Strcmp(type, "double")) {
|
||||||
String *updated=Copy(num);
|
String *updated = Copy(num);
|
||||||
if (Replace(updated, "e", "d", DOH_REPLACE_ANY) > 1) {
|
if (Replace(updated, "e", "d", DOH_REPLACE_ANY) > 1) {
|
||||||
Printf(stderr, "Weird!! number %s looks invalid.\n", num);
|
Printf(stderr, "Weird!! number %s looks invalid.\n", num);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
|
|
@ -359,154 +351,145 @@ String* CLISP::convert_literal(String *num_param, String *type) {
|
||||||
if (SwigType_type(type) == T_CHAR) {
|
if (SwigType_type(type) == T_CHAR) {
|
||||||
/* Use CL syntax for character literals */
|
/* Use CL syntax for character literals */
|
||||||
return NewStringf("#\\%s", num_param);
|
return NewStringf("#\\%s", num_param);
|
||||||
}
|
} else if (SwigType_type(type) == T_STRING) {
|
||||||
else if (SwigType_type(type) == T_STRING) {
|
|
||||||
/* Use CL syntax for string literals */
|
/* Use CL syntax for string literals */
|
||||||
return NewStringf("\"%s\"", num_param);
|
return NewStringf("\"%s\"", num_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Len(num) < 2 || s[0] != '0') {
|
if (Len(num) < 2 || s[0] != '0') {
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* octal or hex */
|
/* octal or hex */
|
||||||
|
|
||||||
res=NewStringf("#%c%s",
|
res = NewStringf("#%c%s", s[1] == 'x' ? 'x' : 'o', s + 2);
|
||||||
s[1] == 'x' ? 'x' : 'o',
|
|
||||||
s+2);
|
|
||||||
Delete(num);
|
Delete(num);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
String* CLISP::get_ffi_type(SwigType *ty) {
|
String *CLISP::get_ffi_type(SwigType *ty) {
|
||||||
Hash *typemap =Swig_typemap_search("in", ty,"", 0);
|
Hash *typemap = Swig_typemap_search("in", ty, "", 0);
|
||||||
if (typemap) {
|
if (typemap) {
|
||||||
String *typespec = Getattr(typemap, "code");
|
String *typespec = Getattr(typemap, "code");
|
||||||
return NewString(typespec);
|
return NewString(typespec);
|
||||||
}
|
} else if (SwigType_ispointer(ty)) {
|
||||||
else if(SwigType_ispointer(ty)) {
|
|
||||||
SwigType *cp = Copy(ty);
|
SwigType *cp = Copy(ty);
|
||||||
SwigType_del_pointer(cp);
|
SwigType_del_pointer(cp);
|
||||||
String *inner_type=get_ffi_type(cp);
|
String *inner_type = get_ffi_type(cp);
|
||||||
|
|
||||||
if(SwigType_isfunction(cp)) {
|
if (SwigType_isfunction(cp)) {
|
||||||
return inner_type;
|
return inner_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *base=SwigType_base(ty);
|
SwigType *base = SwigType_base(ty);
|
||||||
String *base_name=SwigType_str(base,0);
|
String *base_name = SwigType_str(base, 0);
|
||||||
|
|
||||||
String *str;
|
String *str;
|
||||||
if(!Strcmp(base_name,"int") || !Strcmp(base_name,"float") || !Strcmp(base_name,"short")
|
if (!Strcmp(base_name, "int") || !Strcmp(base_name, "float") || !Strcmp(base_name, "short")
|
||||||
|| !Strcmp(base_name,"double") || !Strcmp(base_name,"long") || !Strcmp(base_name,"char")) {
|
|| !Strcmp(base_name, "double") || !Strcmp(base_name, "long") || !Strcmp(base_name, "char")) {
|
||||||
|
|
||||||
str = NewStringf("(ffi:c-ptr %s)",inner_type);
|
str = NewStringf("(ffi:c-ptr %s)", inner_type);
|
||||||
}
|
} else {
|
||||||
else {
|
str = NewStringf("(ffi:c-pointer %s)", inner_type);
|
||||||
str = NewStringf("(ffi:c-pointer %s)",inner_type);
|
|
||||||
}
|
}
|
||||||
Delete(base_name);
|
Delete(base_name);
|
||||||
Delete(base);
|
Delete(base);
|
||||||
Delete(cp);
|
Delete(cp);
|
||||||
Delete(inner_type);
|
Delete(inner_type);
|
||||||
return str;
|
return str;
|
||||||
}
|
} else if (SwigType_isarray(ty)) {
|
||||||
else if(SwigType_isarray(ty)) {
|
|
||||||
SwigType *cp = Copy(ty);
|
SwigType *cp = Copy(ty);
|
||||||
String *array_dim=SwigType_array_getdim(ty,0);
|
String *array_dim = SwigType_array_getdim(ty, 0);
|
||||||
|
|
||||||
if(!Strcmp(array_dim,"")) { //dimension less array convert to pointer
|
if (!Strcmp(array_dim, "")) { //dimension less array convert to pointer
|
||||||
Delete(array_dim);
|
Delete(array_dim);
|
||||||
SwigType_del_array(cp);
|
SwigType_del_array(cp);
|
||||||
SwigType_add_pointer(cp);
|
SwigType_add_pointer(cp);
|
||||||
String *str =get_ffi_type(cp);
|
String *str = get_ffi_type(cp);
|
||||||
Delete(cp);
|
Delete(cp);
|
||||||
return str;
|
return str;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SwigType_pop_arrays(cp);
|
SwigType_pop_arrays(cp);
|
||||||
String *inner_type = get_ffi_type(cp);
|
String *inner_type = get_ffi_type(cp);
|
||||||
Delete(cp);
|
Delete(cp);
|
||||||
|
|
||||||
int ndim=SwigType_array_ndim(ty);
|
int ndim = SwigType_array_ndim(ty);
|
||||||
String *dimension;
|
String *dimension;
|
||||||
if(ndim == 1) {
|
if (ndim == 1) {
|
||||||
dimension=array_dim;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dimension = array_dim;
|
dimension = array_dim;
|
||||||
for(int i=1;i<ndim;i++) {
|
} else {
|
||||||
array_dim=SwigType_array_getdim(ty,i);
|
dimension = array_dim;
|
||||||
Append(dimension," ");
|
for (int i = 1; i < ndim; i++) {
|
||||||
Append(dimension,array_dim);
|
array_dim = SwigType_array_getdim(ty, i);
|
||||||
|
Append(dimension, " ");
|
||||||
|
Append(dimension, array_dim);
|
||||||
Delete(array_dim);
|
Delete(array_dim);
|
||||||
}
|
}
|
||||||
String *temp=dimension;
|
String *temp = dimension;
|
||||||
dimension=NewStringf("(%s)",dimension);
|
dimension = NewStringf("(%s)", dimension);
|
||||||
Delete(temp);
|
Delete(temp);
|
||||||
}
|
}
|
||||||
String *str;
|
String *str;
|
||||||
if(is_function)
|
if (is_function)
|
||||||
str=NewStringf("(ffi:c-ptr (ffi:c-array %s %s))",inner_type,dimension);
|
str = NewStringf("(ffi:c-ptr (ffi:c-array %s %s))", inner_type, dimension);
|
||||||
else
|
else
|
||||||
str=NewStringf("(ffi:c-array %s %s)",inner_type,dimension);
|
str = NewStringf("(ffi:c-array %s %s)", inner_type, dimension);
|
||||||
|
|
||||||
Delete(inner_type);
|
Delete(inner_type);
|
||||||
Delete(dimension);
|
Delete(dimension);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
} else if (SwigType_isfunction(ty)) {
|
||||||
else if(SwigType_isfunction(ty)) {
|
|
||||||
SwigType *cp = Copy(ty);
|
SwigType *cp = Copy(ty);
|
||||||
SwigType *fn=SwigType_pop_function(cp);
|
SwigType *fn = SwigType_pop_function(cp);
|
||||||
String *args=NewString("");
|
String *args = NewString("");
|
||||||
ParmList *pl= SwigType_function_parms(fn);
|
ParmList *pl = SwigType_function_parms(fn);
|
||||||
if (ParmList_len(pl) != 0) {
|
if (ParmList_len(pl) != 0) {
|
||||||
Printf(args, "(:arguments ");
|
Printf(args, "(:arguments ");
|
||||||
}
|
}
|
||||||
int argnum=0, first=1;
|
int argnum = 0, first = 1;
|
||||||
for (Parm *p=pl; p; p=nextSibling(p), argnum++) {
|
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
|
||||||
String *argname=Getattr(p, "name");
|
String *argname = Getattr(p, "name");
|
||||||
SwigType *argtype=Getattr(p, "type");
|
SwigType *argtype = Getattr(p, "type");
|
||||||
String *ffitype=get_ffi_type(argtype);
|
String *ffitype = get_ffi_type(argtype);
|
||||||
|
|
||||||
int tempargname=0;
|
int tempargname = 0;
|
||||||
|
|
||||||
if (!argname) {
|
if (!argname) {
|
||||||
argname=NewStringf("arg%d", argnum);
|
argname = NewStringf("arg%d", argnum);
|
||||||
tempargname=1;
|
tempargname = 1;
|
||||||
}
|
}
|
||||||
if (!first) {
|
if (!first) {
|
||||||
Printf(args, "\n\t\t");
|
Printf(args, "\n\t\t");
|
||||||
}
|
}
|
||||||
Printf(args, "(%s %s)", argname, ffitype);
|
Printf(args, "(%s %s)", argname, ffitype);
|
||||||
first=0;
|
first = 0;
|
||||||
Delete(ffitype);
|
Delete(ffitype);
|
||||||
if (tempargname)
|
if (tempargname)
|
||||||
Delete(argname);
|
Delete(argname);
|
||||||
}
|
}
|
||||||
if (ParmList_len(pl) != 0) {
|
if (ParmList_len(pl) != 0) {
|
||||||
Printf(args, ")\n"); /* finish arg list */
|
Printf(args, ")\n"); /* finish arg list */
|
||||||
}
|
}
|
||||||
String *ffitype = get_ffi_type(cp);
|
String *ffitype = get_ffi_type(cp);
|
||||||
String *str=NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))",args,ffitype);
|
String *str = NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))", args, ffitype);
|
||||||
Delete(fn);
|
Delete(fn);
|
||||||
Delete(args);
|
Delete(args);
|
||||||
Delete(cp);
|
Delete(cp);
|
||||||
Delete(ffitype);
|
Delete(ffitype);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
String *str=SwigType_str(ty,0);
|
String *str = SwigType_str(ty, 0);
|
||||||
if(str) {
|
if (str) {
|
||||||
char *st = Strstr(str,"struct");
|
char *st = Strstr(str, "struct");
|
||||||
if(st) {
|
if (st) {
|
||||||
st+=7;
|
st += 7;
|
||||||
return NewString(st);
|
return NewString(st);
|
||||||
}
|
}
|
||||||
char *cl = Strstr(str,"class");
|
char *cl = Strstr(str, "class");
|
||||||
if(cl) {
|
if (cl) {
|
||||||
cl+=6;
|
cl += 6;
|
||||||
return NewString(cl);
|
return NewString(cl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -516,5 +499,3 @@ String* CLISP::get_ffi_type(SwigType *ty) {
|
||||||
extern "C" Language *swig_clisp(void) {
|
extern "C" Language *swig_clisp(void) {
|
||||||
return new CLISP();
|
return new CLISP();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ struct contract {
|
||||||
|
|
||||||
static contract Rules[] = {
|
static contract Rules[] = {
|
||||||
{"require:", "&&"},
|
{"require:", "&&"},
|
||||||
{"ensure:", "||"},
|
{"ensure:", "||"},
|
||||||
{ NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
|
|
@ -34,14 +34,14 @@ static contract Rules[] = {
|
||||||
* "wrap by contract" module.
|
* "wrap by contract" module.
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
class Contracts : public Dispatcher {
|
class Contracts:public Dispatcher {
|
||||||
String *make_expression(String *s, Node *n);
|
String *make_expression(String *s, Node *n);
|
||||||
void substitute_parms(String *s, ParmList *p, int method);
|
void substitute_parms(String *s, ParmList *p, int method);
|
||||||
public:
|
public:
|
||||||
Hash *ContractSplit(Node *n);
|
Hash *ContractSplit(Node *n);
|
||||||
int emit_contract(Node *n, int method);
|
int emit_contract(Node *n, int method);
|
||||||
int cDeclaration(Node *n);
|
int cDeclaration(Node *n);
|
||||||
int constructorDeclaration(Node *n);
|
int constructorDeclaration(Node *n);
|
||||||
int externDeclaration(Node *n);
|
int externDeclaration(Node *n);
|
||||||
int extendDirective(Node *n);
|
int extendDirective(Node *n);
|
||||||
int importDirective(Node *n);
|
int importDirective(Node *n);
|
||||||
|
|
@ -50,16 +50,17 @@ public:
|
||||||
virtual int top(Node *n);
|
virtual int top(Node *n);
|
||||||
};
|
};
|
||||||
|
|
||||||
static int Contract_Mode = 0; /* contract option */
|
static int Contract_Mode = 0; /* contract option */
|
||||||
static int InClass = 0; /* Parsing C++ or not */
|
static int InClass = 0; /* Parsing C++ or not */
|
||||||
static int InConstructor = 0;
|
static int InConstructor = 0;
|
||||||
static Node *CurrentClass = 0;
|
static Node *CurrentClass = 0;
|
||||||
|
|
||||||
/* Set the contract mode, default is 0 (not open) */
|
/* Set the contract mode, default is 0 (not open) */
|
||||||
/* Normally set in main.cxx, when get the "-contracts" option */
|
/* Normally set in main.cxx, when get the "-contracts" option */
|
||||||
void Swig_contract_mode_set(int flag) {
|
void Swig_contract_mode_set(int flag) {
|
||||||
Contract_Mode = flag;
|
Contract_Mode = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the contract mode */
|
/* Get the contract mode */
|
||||||
int Swig_contract_mode_get() {
|
int Swig_contract_mode_get() {
|
||||||
return Contract_Mode;
|
return Contract_Mode;
|
||||||
|
|
@ -76,50 +77,56 @@ void Swig_contracts(Node *n) {
|
||||||
/* Split the whole contract into preassertion, postassertion and others */
|
/* Split the whole contract into preassertion, postassertion and others */
|
||||||
Hash *Contracts::ContractSplit(Node *n) {
|
Hash *Contracts::ContractSplit(Node *n) {
|
||||||
|
|
||||||
String *contract = Getattr(n, "feature:contract");
|
String *contract = Getattr(n, "feature:contract");
|
||||||
Hash *result;
|
Hash *result;
|
||||||
if (!contract)
|
if (!contract)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
result = NewHash();
|
result = NewHash();
|
||||||
String *current_section = NewString("");
|
String *current_section = NewString("");
|
||||||
const char *current_section_name = Rules[0].section;
|
const char *current_section_name = Rules[0].section;
|
||||||
List *l = SplitLines(contract);
|
List *l = SplitLines(contract);
|
||||||
|
|
||||||
Iterator i;
|
Iterator i;
|
||||||
for (i = First(l); i.item; i = Next(i)) {
|
for (i = First(l); i.item; i = Next(i)) {
|
||||||
int found = 0;
|
int found = 0;
|
||||||
if (Strchr(i.item,'{')) continue;
|
if (Strchr(i.item, '{'))
|
||||||
if (Strchr(i.item,'}')) continue;
|
continue;
|
||||||
|
if (Strchr(i.item, '}'))
|
||||||
|
continue;
|
||||||
for (int j = 0; Rules[j].section; j++) {
|
for (int j = 0; Rules[j].section; j++) {
|
||||||
if (Strstr(i.item,Rules[j].section)) {
|
if (Strstr(i.item, Rules[j].section)) {
|
||||||
if (Len(current_section)) {
|
if (Len(current_section)) {
|
||||||
Setattr(result,current_section_name,current_section);
|
Setattr(result, current_section_name, current_section);
|
||||||
current_section = Getattr(result,Rules[j].section);
|
current_section = Getattr(result, Rules[j].section);
|
||||||
if (!current_section) current_section = NewString("");
|
if (!current_section)
|
||||||
|
current_section = NewString("");
|
||||||
}
|
}
|
||||||
current_section_name = Rules[j].section;
|
current_section_name = Rules[j].section;
|
||||||
found = 1;
|
found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) Append(current_section, i.item);
|
if (!found)
|
||||||
|
Append(current_section, i.item);
|
||||||
}
|
}
|
||||||
if (Len(current_section)) Setattr(result, current_section_name, current_section);
|
if (Len(current_section))
|
||||||
|
Setattr(result, current_section_name, current_section);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function looks in base classes and collects contracts found */
|
/* This function looks in base classes and collects contracts found */
|
||||||
void inherit_contracts(Node *c, Node *n, Hash *contracts, Hash *messages) {
|
void inherit_contracts(Node *c, Node *n, Hash *contracts, Hash *messages) {
|
||||||
|
|
||||||
Node *b, *temp;
|
Node *b, *temp;
|
||||||
String *name, *type, *local_decl, *base_decl;
|
String *name, *type, *local_decl, *base_decl;
|
||||||
List *bases;
|
List *bases;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
|
bases = Getattr(c, "bases");
|
||||||
|
if (!bases)
|
||||||
|
return;
|
||||||
|
|
||||||
bases = Getattr(c,"bases");
|
|
||||||
if (!bases) return;
|
|
||||||
|
|
||||||
name = Getattr(n, "name");
|
name = Getattr(n, "name");
|
||||||
type = Getattr(n, "type");
|
type = Getattr(n, "type");
|
||||||
local_decl = Getattr(n, "decl");
|
local_decl = Getattr(n, "decl");
|
||||||
|
|
@ -130,19 +137,17 @@ void inherit_contracts(Node *c, Node *n, Hash *contracts, Hash *messages) {
|
||||||
}
|
}
|
||||||
/* Width first search */
|
/* Width first search */
|
||||||
for (int i = 0; i < Len(bases); i++) {
|
for (int i = 0; i < Len(bases); i++) {
|
||||||
b = Getitem(bases,i);
|
b = Getitem(bases, i);
|
||||||
temp = firstChild (b);
|
temp = firstChild(b);
|
||||||
while (temp) {
|
while (temp) {
|
||||||
base_decl = Getattr(temp, "decl");
|
base_decl = Getattr(temp, "decl");
|
||||||
if (base_decl) {
|
if (base_decl) {
|
||||||
base_decl = SwigType_typedef_resolve_all(base_decl);
|
base_decl = SwigType_typedef_resolve_all(base_decl);
|
||||||
if ( (checkAttribute(temp, "storage", "virtual")) &&
|
if ((checkAttribute(temp, "storage", "virtual")) &&
|
||||||
(checkAttribute(temp, "name", name)) &&
|
(checkAttribute(temp, "name", name)) && (checkAttribute(temp, "type", type)) && (!Strcmp(local_decl, base_decl))) {
|
||||||
(checkAttribute(temp, "type", type)) &&
|
|
||||||
(!Strcmp(local_decl, base_decl)) ) {
|
|
||||||
/* Yes, match found. */
|
/* Yes, match found. */
|
||||||
Hash *icontracts = Getattr(temp,"contract:rules");
|
Hash *icontracts = Getattr(temp, "contract:rules");
|
||||||
Hash *imessages = Getattr(temp,"contract:messages");
|
Hash *imessages = Getattr(temp, "contract:messages");
|
||||||
found = 1;
|
found = 1;
|
||||||
if (icontracts && imessages) {
|
if (icontracts && imessages) {
|
||||||
/* Add inherited contracts and messages to the contract rules above */
|
/* Add inherited contracts and messages to the contract rules above */
|
||||||
|
|
@ -152,13 +157,13 @@ void inherit_contracts(Node *c, Node *n, Hash *contracts, Hash *messages) {
|
||||||
String *s = Getattr(icontracts, Rules[j].section);
|
String *s = Getattr(icontracts, Rules[j].section);
|
||||||
if (s) {
|
if (s) {
|
||||||
if (t) {
|
if (t) {
|
||||||
Insert(t,0,"(");
|
Insert(t, 0, "(");
|
||||||
Printf(t,") %s (%s)", Rules[j].combiner, s);
|
Printf(t, ") %s (%s)", Rules[j].combiner, s);
|
||||||
String *m = Getattr(messages, Rules[j].section);
|
String *m = Getattr(messages, Rules[j].section);
|
||||||
Printf(m," %s [%s from %s]", Rules[j].combiner, Getattr(imessages,Rules[j].section), Getattr(b,"name"));
|
Printf(m, " %s [%s from %s]", Rules[j].combiner, Getattr(imessages, Rules[j].section), Getattr(b, "name"));
|
||||||
} else {
|
} else {
|
||||||
Setattr(contracts, Rules[j].section, NewString(s));
|
Setattr(contracts, Rules[j].section, NewString(s));
|
||||||
Setattr(messages,Rules[j].section,NewStringf("[%s from %s]", Getattr(imessages,Rules[j].section), Getattr(b,"name")));
|
Setattr(messages, Rules[j].section, NewStringf("[%s from %s]", Getattr(imessages, Rules[j].section), Getattr(b, "name")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -172,8 +177,8 @@ void inherit_contracts(Node *c, Node *n, Hash *contracts, Hash *messages) {
|
||||||
Delete(local_decl);
|
Delete(local_decl);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
for (int j = 0; j < Len(bases); j++) {
|
for (int j = 0; j < Len(bases); j++) {
|
||||||
b = Getitem(bases,j);
|
b = Getitem(bases, j);
|
||||||
inherit_contracts(b,n,contracts,messages);
|
inherit_contracts(b, n, contracts, messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -182,8 +187,8 @@ void inherit_contracts(Node *c, Node *n, Hash *contracts, Hash *messages) {
|
||||||
Splitting the assertion into pieces */
|
Splitting the assertion into pieces */
|
||||||
|
|
||||||
String *Contracts::make_expression(String *s, Node *n) {
|
String *Contracts::make_expression(String *s, Node *n) {
|
||||||
String *str_assert, *expr = 0;
|
String *str_assert, *expr = 0;
|
||||||
List *list_assert;
|
List *list_assert;
|
||||||
|
|
||||||
str_assert = NewString(s);
|
str_assert = NewString(s);
|
||||||
/* Omit all useless characters and split by ; */
|
/* Omit all useless characters and split by ; */
|
||||||
|
|
@ -195,7 +200,7 @@ String *Contracts::make_expression(String *s, Node *n) {
|
||||||
|
|
||||||
list_assert = Split(str_assert, ';', -1);
|
list_assert = Split(str_assert, ';', -1);
|
||||||
Delete(str_assert);
|
Delete(str_assert);
|
||||||
|
|
||||||
/* build up new assertion */
|
/* build up new assertion */
|
||||||
str_assert = NewString("");
|
str_assert = NewString("");
|
||||||
Iterator ei;
|
Iterator ei;
|
||||||
|
|
@ -203,7 +208,7 @@ String *Contracts::make_expression(String *s, Node *n) {
|
||||||
for (ei = First(list_assert); ei.item; ei = Next(ei)) {
|
for (ei = First(list_assert); ei.item; ei = Next(ei)) {
|
||||||
expr = ei.item;
|
expr = ei.item;
|
||||||
if (Len(expr)) {
|
if (Len(expr)) {
|
||||||
Replaceid(expr, Getattr(n,"name"), "result");
|
Replaceid(expr, Getattr(n, "name"), "result");
|
||||||
if (Len(str_assert))
|
if (Len(str_assert))
|
||||||
Append(str_assert, "&&");
|
Append(str_assert, "&&");
|
||||||
Printf(str_assert, "(%s)", expr);
|
Printf(str_assert, "(%s)", expr);
|
||||||
|
|
@ -218,18 +223,18 @@ String *Contracts::make_expression(String *s, Node *n) {
|
||||||
uses arg1--argn for arguments. */
|
uses arg1--argn for arguments. */
|
||||||
|
|
||||||
void Contracts::substitute_parms(String *s, ParmList *p, int method) {
|
void Contracts::substitute_parms(String *s, ParmList *p, int method) {
|
||||||
int argnum = 1;
|
int argnum = 1;
|
||||||
char argname[32];
|
char argname[32];
|
||||||
|
|
||||||
if (method) {
|
if (method) {
|
||||||
Replaceid(s,"self","arg0");
|
Replaceid(s, "self", "arg0");
|
||||||
argnum++;
|
argnum++;
|
||||||
}
|
}
|
||||||
while (p) {
|
while (p) {
|
||||||
sprintf(argname,"arg%d",argnum);
|
sprintf(argname, "arg%d", argnum);
|
||||||
String *name = Getattr(p,"name");
|
String *name = Getattr(p, "name");
|
||||||
if (name) {
|
if (name) {
|
||||||
Replaceid(s,name,argname);
|
Replaceid(s, name, argname);
|
||||||
}
|
}
|
||||||
argnum++;
|
argnum++;
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
|
|
@ -237,8 +242,8 @@ void Contracts::substitute_parms(String *s, ParmList *p, int method) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Contracts::emit_contract(Node *n, int method) {
|
int Contracts::emit_contract(Node *n, int method) {
|
||||||
Hash *contracts;
|
Hash *contracts;
|
||||||
Hash *messages;
|
Hash *messages;
|
||||||
String *c;
|
String *c;
|
||||||
|
|
||||||
ParmList *cparms;
|
ParmList *cparms;
|
||||||
|
|
@ -249,9 +254,10 @@ int Contracts::emit_contract(Node *n, int method) {
|
||||||
/* Get contract parameters */
|
/* Get contract parameters */
|
||||||
cparms = Getmeta(Getattr(n, "feature:contract"), "parms");
|
cparms = Getmeta(Getattr(n, "feature:contract"), "parms");
|
||||||
|
|
||||||
/* Split contract into preassert & postassert */
|
/* Split contract into preassert & postassert */
|
||||||
contracts = ContractSplit(n);
|
contracts = ContractSplit(n);
|
||||||
if (!contracts) return SWIG_ERROR;
|
if (!contracts)
|
||||||
|
return SWIG_ERROR;
|
||||||
|
|
||||||
/* This messages hash is used to hold the error messages that will be displayed on
|
/* This messages hash is used to hold the error messages that will be displayed on
|
||||||
failed contract. */
|
failed contract. */
|
||||||
|
|
@ -263,66 +269,71 @@ int Contracts::emit_contract(Node *n, int method) {
|
||||||
for (i = First(contracts); i.item; i = Next(i)) {
|
for (i = First(contracts); i.item; i = Next(i)) {
|
||||||
String *e = make_expression(i.item, n);
|
String *e = make_expression(i.item, n);
|
||||||
substitute_parms(e, cparms, method);
|
substitute_parms(e, cparms, method);
|
||||||
Setattr(contracts,i.key,e);
|
Setattr(contracts, i.key, e);
|
||||||
|
|
||||||
/* Make a string containing error messages */
|
/* Make a string containing error messages */
|
||||||
Setattr(messages,i.key, NewString(e));
|
Setattr(messages, i.key, NewString(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're in a class. We need to inherit other assertions. */
|
/* If we're in a class. We need to inherit other assertions. */
|
||||||
if (InClass) {
|
if (InClass) {
|
||||||
inherit_contracts(CurrentClass, n, contracts, messages);
|
inherit_contracts(CurrentClass, n, contracts, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save information */
|
/* Save information */
|
||||||
Setattr(n,"contract:rules", contracts);
|
Setattr(n, "contract:rules", contracts);
|
||||||
Setattr(n,"contract:messages", messages);
|
Setattr(n, "contract:messages", messages);
|
||||||
|
|
||||||
/* Okay. Generate the contract runtime code. */
|
/* Okay. Generate the contract runtime code. */
|
||||||
|
|
||||||
if ((c = Getattr(contracts,"require:"))) {
|
if ((c = Getattr(contracts, "require:"))) {
|
||||||
Setattr(n,"contract:preassert",
|
Setattr(n, "contract:preassert", NewStringf("SWIG_contract_assert(%s, \"Contract violation: require: %s\");\n", c, Getattr(messages, "require:")));
|
||||||
NewStringf("SWIG_contract_assert(%s, \"Contract violation: require: %s\");\n",
|
|
||||||
c, Getattr(messages,"require:")));
|
|
||||||
}
|
}
|
||||||
if ((c = Getattr(contracts,"ensure:"))) {
|
if ((c = Getattr(contracts, "ensure:"))) {
|
||||||
Setattr(n,"contract:postassert",
|
Setattr(n, "contract:postassert", NewStringf("SWIG_contract_assert(%s, \"Contract violation: ensure: %s\");\n", c, Getattr(messages, "ensure:")));
|
||||||
NewStringf("SWIG_contract_assert(%s, \"Contract violation: ensure: %s\");\n",
|
|
||||||
c, Getattr(messages,"ensure:")));
|
|
||||||
}
|
}
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Contracts::cDeclaration(Node *n) {
|
int Contracts::cDeclaration(Node *n) {
|
||||||
int ret = SWIG_OK;
|
int ret = SWIG_OK;
|
||||||
String *decl = Getattr(n,"decl");
|
String *decl = Getattr(n, "decl");
|
||||||
|
|
||||||
/* Not a function. Don't even bother with it (for now) */
|
/* Not a function. Don't even bother with it (for now) */
|
||||||
if (!SwigType_isfunction(decl)) return SWIG_OK;
|
if (!SwigType_isfunction(decl))
|
||||||
|
return SWIG_OK;
|
||||||
|
|
||||||
if (Getattr(n, "feature:contract"))
|
if (Getattr(n, "feature:contract"))
|
||||||
ret = emit_contract(n, (InClass && !checkAttribute(n,"storage","static")));
|
ret = emit_contract(n, (InClass && !checkAttribute(n, "storage", "static")));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Contracts::constructorDeclaration(Node *n){
|
int Contracts::constructorDeclaration(Node *n) {
|
||||||
int ret = SWIG_OK;
|
int ret = SWIG_OK;
|
||||||
InConstructor = 1;
|
InConstructor = 1;
|
||||||
if (Getattr(n, "feature:contract"))
|
if (Getattr(n, "feature:contract"))
|
||||||
ret = emit_contract(n,0);
|
ret = emit_contract(n, 0);
|
||||||
InConstructor = 0;
|
InConstructor = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Contracts::externDeclaration(Node *n) { return emit_children(n); }
|
int Contracts::externDeclaration(Node *n) {
|
||||||
int Contracts::extendDirective(Node *n) { return emit_children(n); }
|
return emit_children(n);
|
||||||
int Contracts::importDirective(Node *n) { return emit_children(n); }
|
}
|
||||||
int Contracts::includeDirective(Node *n) { return emit_children(n); }
|
int Contracts::extendDirective(Node *n) {
|
||||||
|
return emit_children(n);
|
||||||
|
}
|
||||||
|
int Contracts::importDirective(Node *n) {
|
||||||
|
return emit_children(n);
|
||||||
|
}
|
||||||
|
int Contracts::includeDirective(Node *n) {
|
||||||
|
return emit_children(n);
|
||||||
|
}
|
||||||
|
|
||||||
int Contracts::classDeclaration(Node *n) {
|
int Contracts::classDeclaration(Node *n) {
|
||||||
int ret = SWIG_OK;
|
int ret = SWIG_OK;
|
||||||
InClass = 1;
|
InClass = 1;
|
||||||
CurrentClass = n;
|
CurrentClass = n;
|
||||||
emit_children(n);
|
emit_children(n);
|
||||||
InClass = 0;
|
InClass = 0;
|
||||||
CurrentClass = 0;
|
CurrentClass = 0;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -20,7 +20,7 @@ char cvsroot_directors_cxx[] = "$Header";
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String *Swig_csuperclass_call(String* base, String* method, ParmList* l) {
|
String *Swig_csuperclass_call(String *base, String *method, ParmList *l) {
|
||||||
String *call = NewString("");
|
String *call = NewString("");
|
||||||
int arg_idx = 0;
|
int arg_idx = 0;
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
@ -28,13 +28,14 @@ String *Swig_csuperclass_call(String* base, String* method, ParmList* l) {
|
||||||
Printf(call, "%s::", base);
|
Printf(call, "%s::", base);
|
||||||
}
|
}
|
||||||
Printf(call, "%s(", method);
|
Printf(call, "%s(", method);
|
||||||
for (p=l; p; p = nextSibling(p)) {
|
for (p = l; p; p = nextSibling(p)) {
|
||||||
String *pname = Getattr(p, "name");
|
String *pname = Getattr(p, "name");
|
||||||
if (!pname && Cmp(Getattr(p,"type"), "void")) {
|
if (!pname && Cmp(Getattr(p, "type"), "void")) {
|
||||||
pname = NewString("");
|
pname = NewString("");
|
||||||
Printf(pname, "arg%d", arg_idx++);
|
Printf(pname, "arg%d", arg_idx++);
|
||||||
}
|
}
|
||||||
if (p != l) Printf(call, ", ");
|
if (p != l)
|
||||||
|
Printf(call, ", ");
|
||||||
Printv(call, pname, NIL);
|
Printv(call, pname, NIL);
|
||||||
}
|
}
|
||||||
Printf(call, ")");
|
Printf(call, ")");
|
||||||
|
|
@ -47,7 +48,7 @@ String *Swig_csuperclass_call(String* base, String* method, ParmList* l) {
|
||||||
* e.g. "class myclass"
|
* e.g. "class myclass"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String *Swig_class_declaration(Node *n, String *name) {
|
String *Swig_class_declaration(Node *n, String *name) {
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = Getattr(n, "sym:name");
|
name = Getattr(n, "sym:name");
|
||||||
|
|
@ -63,7 +64,7 @@ String *Swig_class_name(Node *n) {
|
||||||
name = Copy(Getattr(n, "sym:name"));
|
name = Copy(Getattr(n, "sym:name"));
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Swig_director_declaration()
|
/* Swig_director_declaration()
|
||||||
*
|
*
|
||||||
* Generate the full director class declaration, complete with base classes.
|
* Generate the full director class declaration, complete with base classes.
|
||||||
|
|
@ -72,7 +73,7 @@ String *Swig_class_name(Node *n) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String *Swig_director_declaration(Node *n) {
|
String *Swig_director_declaration(Node *n) {
|
||||||
String* classname = Swig_class_name(n);
|
String *classname = Swig_class_name(n);
|
||||||
String *directorname = NewStringf("SwigDirector_%s", classname);
|
String *directorname = NewStringf("SwigDirector_%s", classname);
|
||||||
String *base = Getattr(n, "classtype");
|
String *base = Getattr(n, "classtype");
|
||||||
String *declaration = Swig_class_declaration(n, directorname);
|
String *declaration = Swig_class_declaration(n, directorname);
|
||||||
|
|
@ -89,24 +90,25 @@ String *Swig_method_call(String_or_char *name, ParmList *parms) {
|
||||||
int comma = 0;
|
int comma = 0;
|
||||||
Parm *p = parms;
|
Parm *p = parms;
|
||||||
SwigType *pt;
|
SwigType *pt;
|
||||||
String *nname;
|
String *nname;
|
||||||
|
|
||||||
func = NewString("");
|
func = NewString("");
|
||||||
nname = SwigType_namestr(name);
|
nname = SwigType_namestr(name);
|
||||||
Printf(func,"%s(", nname);
|
Printf(func, "%s(", nname);
|
||||||
while (p) {
|
while (p) {
|
||||||
String *pname;
|
String *pname;
|
||||||
pt = Getattr(p,"type");
|
pt = Getattr(p, "type");
|
||||||
if ((SwigType_type(pt) != T_VOID)) {
|
if ((SwigType_type(pt) != T_VOID)) {
|
||||||
if (comma) Printf(func,",");
|
if (comma)
|
||||||
|
Printf(func, ",");
|
||||||
pname = Getattr(p, "name");
|
pname = Getattr(p, "name");
|
||||||
Printf(func,"%s", pname);
|
Printf(func, "%s", pname);
|
||||||
comma = 1;
|
comma = 1;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
Printf(func,")");
|
Printf(func, ")");
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,7 +150,7 @@ String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int
|
||||||
}
|
}
|
||||||
for (i = 0; i < nelements; i++) {
|
for (i = 0; i < nelements; i++) {
|
||||||
if (i < (nelements - 1)) {
|
if (i < (nelements - 1)) {
|
||||||
nextelement = Getitem(elements, i+1);
|
nextelement = Getitem(elements, i + 1);
|
||||||
} else {
|
} else {
|
||||||
nextelement = 0;
|
nextelement = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -160,74 +162,75 @@ String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int
|
||||||
if (!Cmp(q, "const")) {
|
if (!Cmp(q, "const")) {
|
||||||
is_const = 1;
|
is_const = 1;
|
||||||
is_func = SwigType_isfunction(nextelement);
|
is_func = SwigType_isfunction(nextelement);
|
||||||
if (is_func) skip = 1;
|
if (is_func)
|
||||||
|
skip = 1;
|
||||||
skip = 1;
|
skip = 1;
|
||||||
}
|
}
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
Insert(result,0," ");
|
Insert(result, 0, " ");
|
||||||
Insert(result,0,q);
|
Insert(result, 0, q);
|
||||||
}
|
}
|
||||||
Delete(q);
|
Delete(q);
|
||||||
}
|
}
|
||||||
} else if (SwigType_ispointer(element)) {
|
} else if (SwigType_ispointer(element)) {
|
||||||
Insert(result,0,"*");
|
Insert(result, 0, "*");
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result,0,"(");
|
Insert(result, 0, "(");
|
||||||
Append(result,")");
|
Append(result, ")");
|
||||||
}
|
}
|
||||||
} else if (SwigType_ismemberpointer(element)) {
|
} else if (SwigType_ismemberpointer(element)) {
|
||||||
String *q;
|
String *q;
|
||||||
q = SwigType_parm(element);
|
q = SwigType_parm(element);
|
||||||
Insert(result,0,"::*");
|
Insert(result, 0, "::*");
|
||||||
Insert(result,0,q);
|
Insert(result, 0, q);
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result,0,"(");
|
Insert(result, 0, "(");
|
||||||
Append(result,")");
|
Append(result, ")");
|
||||||
}
|
}
|
||||||
Delete(q);
|
Delete(q);
|
||||||
}
|
} else if (SwigType_isreference(element)) {
|
||||||
else if (SwigType_isreference(element)) {
|
Insert(result, 0, "&");
|
||||||
Insert(result,0,"&");
|
} else if (SwigType_isarray(element)) {
|
||||||
} else if (SwigType_isarray(element)) {
|
|
||||||
DOH *size;
|
DOH *size;
|
||||||
Append(result,"[");
|
Append(result, "[");
|
||||||
size = SwigType_parm(element);
|
size = SwigType_parm(element);
|
||||||
Append(result,size);
|
Append(result, size);
|
||||||
Append(result,"]");
|
Append(result, "]");
|
||||||
Delete(size);
|
Delete(size);
|
||||||
} else if (SwigType_isfunction(element)) {
|
} else if (SwigType_isfunction(element)) {
|
||||||
Parm *parm;
|
Parm *parm;
|
||||||
String *p;
|
String *p;
|
||||||
Append(result,"(");
|
Append(result, "(");
|
||||||
parm = args;
|
parm = args;
|
||||||
while (parm != 0) {
|
while (parm != 0) {
|
||||||
String *type = Getattr(parm, "type");
|
String *type = Getattr(parm, "type");
|
||||||
String* name = Getattr(parm, "name");
|
String *name = Getattr(parm, "name");
|
||||||
if (!name && Cmp(type, "void")) {
|
if (!name && Cmp(type, "void")) {
|
||||||
name = NewString("");
|
name = NewString("");
|
||||||
Printf(name, "arg%d", arg_idx++);
|
Printf(name, "arg%d", arg_idx++);
|
||||||
Setattr(parm, "name", name);
|
Setattr(parm, "name", name);
|
||||||
}
|
}
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = NewString("");
|
name = NewString("");
|
||||||
}
|
}
|
||||||
p = SwigType_str(type, name);
|
p = SwigType_str(type, name);
|
||||||
Append(result,p);
|
Append(result, p);
|
||||||
String* value = Getattr(parm, "value");
|
String *value = Getattr(parm, "value");
|
||||||
if (values && (value != 0)) {
|
if (values && (value != 0)) {
|
||||||
Printf(result, " = %s", value);
|
Printf(result, " = %s", value);
|
||||||
}
|
}
|
||||||
parm = nextSibling(parm);
|
parm = nextSibling(parm);
|
||||||
if (parm != 0) Append(result,", ");
|
if (parm != 0)
|
||||||
|
Append(result, ", ");
|
||||||
}
|
}
|
||||||
Append(result,")");
|
Append(result, ")");
|
||||||
} else {
|
} else {
|
||||||
if (Strcmp(element,"v(...)") == 0) {
|
if (Strcmp(element, "v(...)") == 0) {
|
||||||
Insert(result,0,"...");
|
Insert(result, 0, "...");
|
||||||
} else {
|
} else {
|
||||||
String *bs = SwigType_namestr(element);
|
String *bs = SwigType_namestr(element);
|
||||||
Insert(result,0," ");
|
Insert(result, 0, " ");
|
||||||
Insert(result,0,bs);
|
Insert(result, 0, bs);
|
||||||
Delete(bs);
|
Delete(bs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -245,4 +248,3 @@ String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int
|
||||||
Chop(result);
|
Chop(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,11 @@ void emit_args(SwigType *rt, ParmList *l, Wrapper *f) {
|
||||||
SwigType *vt = cplus_value_type(rt);
|
SwigType *vt = cplus_value_type(rt);
|
||||||
SwigType *tt = vt ? vt : rt;
|
SwigType *tt = vt ? vt : rt;
|
||||||
SwigType *lt = SwigType_ltype(tt);
|
SwigType *lt = SwigType_ltype(tt);
|
||||||
String *lstr = SwigType_str(lt,"result");
|
String *lstr = SwigType_str(lt, "result");
|
||||||
if (SwigType_ispointer(lt)) {
|
if (SwigType_ispointer(lt)) {
|
||||||
Wrapper_add_localv(f,"result", lstr, "= 0", NULL);
|
Wrapper_add_localv(f, "result", lstr, "= 0", NULL);
|
||||||
} else{
|
} else {
|
||||||
Wrapper_add_local(f,"result", lstr);
|
Wrapper_add_local(f, "result", lstr);
|
||||||
}
|
}
|
||||||
if (vt) {
|
if (vt) {
|
||||||
Delete(vt);
|
Delete(vt);
|
||||||
|
|
@ -46,21 +46,21 @@ void emit_args(SwigType *rt, ParmList *l, Wrapper *f) {
|
||||||
Delete(lt);
|
Delete(lt);
|
||||||
Delete(lstr);
|
Delete(lstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attach typemaps to parameters */
|
/* Attach typemaps to parameters */
|
||||||
/* Swig_typemap_attach_parms("ignore",l,f); */
|
/* Swig_typemap_attach_parms("ignore",l,f); */
|
||||||
|
|
||||||
Swig_typemap_attach_parms("default",l,f);
|
Swig_typemap_attach_parms("default", l, f);
|
||||||
Swig_typemap_attach_parms("arginit",l,f);
|
Swig_typemap_attach_parms("arginit", l, f);
|
||||||
|
|
||||||
/* Apply the arginit and default */
|
/* Apply the arginit and default */
|
||||||
p = l;
|
p = l;
|
||||||
while (p) {
|
while (p) {
|
||||||
tm = Getattr(p,"tmap:arginit");
|
tm = Getattr(p, "tmap:arginit");
|
||||||
if (tm) {
|
if (tm) {
|
||||||
Replace(tm,"$target", Getattr(p,"lname"), DOH_REPLACE_ANY);
|
Replace(tm, "$target", Getattr(p, "lname"), DOH_REPLACE_ANY);
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
p = Getattr(p,"tmap:arginit:next");
|
p = Getattr(p, "tmap:arginit:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
@ -69,11 +69,11 @@ void emit_args(SwigType *rt, ParmList *l, Wrapper *f) {
|
||||||
/* Apply the default typemap */
|
/* Apply the default typemap */
|
||||||
p = l;
|
p = l;
|
||||||
while (p) {
|
while (p) {
|
||||||
tm = Getattr(p,"tmap:default");
|
tm = Getattr(p, "tmap:default");
|
||||||
if (tm) {
|
if (tm) {
|
||||||
Replace(tm,"$target", Getattr(p,"lname"), DOH_REPLACE_ANY);
|
Replace(tm, "$target", Getattr(p, "lname"), DOH_REPLACE_ANY);
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
p = Getattr(p,"tmap:default:next");
|
p = Getattr(p, "tmap:default:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
@ -88,11 +88,11 @@ void emit_args(SwigType *rt, ParmList *l, Wrapper *f) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
||||||
Swig_typemap_attach_parms("in",l,f);
|
Swig_typemap_attach_parms("in", l, f);
|
||||||
Swig_typemap_attach_parms("typecheck",l,0);
|
Swig_typemap_attach_parms("typecheck", l, 0);
|
||||||
Swig_typemap_attach_parms("argout",l,f);
|
Swig_typemap_attach_parms("argout", l, f);
|
||||||
Swig_typemap_attach_parms("check",l,f);
|
Swig_typemap_attach_parms("check", l, f);
|
||||||
Swig_typemap_attach_parms("freearg",l,f);
|
Swig_typemap_attach_parms("freearg", l, f);
|
||||||
|
|
||||||
{
|
{
|
||||||
/* This is compatibility code to deal with the deprecated "ignore" typemap */
|
/* This is compatibility code to deal with the deprecated "ignore" typemap */
|
||||||
|
|
@ -100,17 +100,17 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
||||||
Parm *np;
|
Parm *np;
|
||||||
String *tm;
|
String *tm;
|
||||||
while (p) {
|
while (p) {
|
||||||
tm = Getattr(p,"tmap:in");
|
tm = Getattr(p, "tmap:in");
|
||||||
if (tm && checkAttribute(p,"tmap:in:numinputs","0")) {
|
if (tm && checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||||
Replaceall(tm,"$target", Getattr(p,"lname"));
|
Replaceall(tm, "$target", Getattr(p, "lname"));
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
np = Getattr(p,"tmap:in:next");
|
np = Getattr(p, "tmap:in:next");
|
||||||
while (p && (p != np)) {
|
while (p && (p != np)) {
|
||||||
Setattr(p,"ignore","1");
|
Setattr(p, "ignore", "1");
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
} else if (tm) {
|
} else if (tm) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
@ -125,22 +125,22 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
||||||
Parm *p = l;
|
Parm *p = l;
|
||||||
Parm *npin, *npfreearg;
|
Parm *npin, *npfreearg;
|
||||||
while (p) {
|
while (p) {
|
||||||
npin = Getattr(p,"tmap:in:next");
|
npin = Getattr(p, "tmap:in:next");
|
||||||
|
|
||||||
/*
|
|
||||||
if (Getattr(p,"tmap:ignore")) {
|
|
||||||
npin = Getattr(p,"tmap:ignore:next");
|
|
||||||
} else if (Getattr(p,"tmap:in")) {
|
|
||||||
npin = Getattr(p,"tmap:in:next");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (Getattr(p,"tmap:freearg")) {
|
/*
|
||||||
npfreearg = Getattr(p,"tmap:freearg:next");
|
if (Getattr(p,"tmap:ignore")) {
|
||||||
|
npin = Getattr(p,"tmap:ignore:next");
|
||||||
|
} else if (Getattr(p,"tmap:in")) {
|
||||||
|
npin = Getattr(p,"tmap:in:next");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (Getattr(p, "tmap:freearg")) {
|
||||||
|
npfreearg = Getattr(p, "tmap:freearg:next");
|
||||||
if (npin != npfreearg) {
|
if (npin != npfreearg) {
|
||||||
while (p != npin) {
|
while (p != npin) {
|
||||||
Delattr(p,"tmap:freearg");
|
Delattr(p, "tmap:freearg");
|
||||||
Delattr(p,"tmap:freearg:next");
|
Delattr(p, "tmap:freearg:next");
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +148,7 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
||||||
p = npin;
|
p = npin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for variable length arguments with no input typemap.
|
/* Check for variable length arguments with no input typemap.
|
||||||
If no input is defined, we set this to ignore and print a
|
If no input is defined, we set this to ignore and print a
|
||||||
message.
|
message.
|
||||||
|
|
@ -157,25 +157,25 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
||||||
Parm *p = l;
|
Parm *p = l;
|
||||||
Parm *lp = 0;
|
Parm *lp = 0;
|
||||||
while (p) {
|
while (p) {
|
||||||
if (!checkAttribute(p,"tmap:in:numinputs","0")) {
|
if (!checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||||
lp = p;
|
lp = p;
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (SwigType_isvarargs(Getattr(p,"type"))) {
|
if (SwigType_isvarargs(Getattr(p, "type"))) {
|
||||||
Swig_warning(WARN_LANG_VARARGS,input_file,line_number,"Variable length arguments discarded.\n");
|
Swig_warning(WARN_LANG_VARARGS, input_file, line_number, "Variable length arguments discarded.\n");
|
||||||
Setattr(p,"tmap:in","");
|
Setattr(p, "tmap:in", "");
|
||||||
}
|
}
|
||||||
lp = 0;
|
lp = 0;
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if last input argument is variable length argument */
|
/* Check if last input argument is variable length argument */
|
||||||
if (lp) {
|
if (lp) {
|
||||||
p = lp;
|
p = lp;
|
||||||
while (p) {
|
while (p) {
|
||||||
if (SwigType_isvarargs(Getattr(p,"type"))) {
|
if (SwigType_isvarargs(Getattr(p, "type"))) {
|
||||||
Setattr(l,"emit:varargs",lp);
|
Setattr(l, "emit:varargs", lp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
|
|
@ -194,12 +194,12 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
||||||
|
|
||||||
int emit_num_arguments(ParmList *parms) {
|
int emit_num_arguments(ParmList *parms) {
|
||||||
Parm *p = parms;
|
Parm *p = parms;
|
||||||
int nargs = 0;
|
int nargs = 0;
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
if (Getattr(p,"tmap:in")) {
|
if (Getattr(p, "tmap:in")) {
|
||||||
nargs += GetInt(p,"tmap:in:numinputs");
|
nargs += GetInt(p, "tmap:in:numinputs");
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
@ -207,12 +207,12 @@ int emit_num_arguments(ParmList *parms) {
|
||||||
|
|
||||||
/* DB 04/02/2003: Not sure this is necessary with tmap:in:numinputs */
|
/* DB 04/02/2003: Not sure this is necessary with tmap:in:numinputs */
|
||||||
/*
|
/*
|
||||||
if (parms && (p = Getattr(parms,"emit:varargs"))) {
|
if (parms && (p = Getattr(parms,"emit:varargs"))) {
|
||||||
if (!nextSibling(p)) {
|
if (!nextSibling(p)) {
|
||||||
nargs--;
|
nargs--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return nargs;
|
return nargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,23 +227,25 @@ int emit_num_arguments(ParmList *parms) {
|
||||||
|
|
||||||
int emit_num_required(ParmList *parms) {
|
int emit_num_required(ParmList *parms) {
|
||||||
Parm *p = parms;
|
Parm *p = parms;
|
||||||
int nargs = 0;
|
int nargs = 0;
|
||||||
Parm *first_default_arg = 0;
|
Parm *first_default_arg = 0;
|
||||||
int compactdefargs = ParmList_is_compactdefargs(p);
|
int compactdefargs = ParmList_is_compactdefargs(p);
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
if (Getattr(p,"tmap:in") && checkAttribute(p,"tmap:in:numinputs","0")) {
|
if (Getattr(p, "tmap:in") && checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
} else {
|
} else {
|
||||||
if (Getattr(p,"tmap:default")) break;
|
if (Getattr(p, "tmap:default"))
|
||||||
if (Getattr(p,"value")) {
|
break;
|
||||||
if (!first_default_arg)
|
if (Getattr(p, "value")) {
|
||||||
first_default_arg = p;
|
if (!first_default_arg)
|
||||||
if (compactdefargs) break;
|
first_default_arg = p;
|
||||||
|
if (compactdefargs)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
nargs+= GetInt(p,"tmap:in:numinputs");
|
nargs += GetInt(p, "tmap:in:numinputs");
|
||||||
if (Getattr(p,"tmap:in")) {
|
if (Getattr(p, "tmap:in")) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
@ -255,29 +257,29 @@ int emit_num_required(ParmList *parms) {
|
||||||
if (first_default_arg) {
|
if (first_default_arg) {
|
||||||
p = first_default_arg;
|
p = first_default_arg;
|
||||||
while (p) {
|
while (p) {
|
||||||
if (Getattr(p,"tmap:in") && checkAttribute(p,"tmap:in:numinputs","0")) {
|
if (Getattr(p, "tmap:in") && checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
} else {
|
} else {
|
||||||
if (!Getattr(p,"value") && (!Getattr(p,"tmap:default"))) {
|
if (!Getattr(p, "value") && (!Getattr(p, "tmap:default"))) {
|
||||||
Swig_error(Getfile(p),Getline(p),"Non-optional argument '%s' follows an optional argument.\n",Getattr(p,"name"));
|
Swig_error(Getfile(p), Getline(p), "Non-optional argument '%s' follows an optional argument.\n", Getattr(p, "name"));
|
||||||
}
|
}
|
||||||
if (Getattr(p,"tmap:in")) {
|
if (Getattr(p, "tmap:in")) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DB 04/02/2003: Not sure this is necessary with tmap:in:numinputs */
|
/* DB 04/02/2003: Not sure this is necessary with tmap:in:numinputs */
|
||||||
/*
|
/*
|
||||||
if (parms && (p = Getattr(parms,"emit:varargs"))) {
|
if (parms && (p = Getattr(parms,"emit:varargs"))) {
|
||||||
if (!nextSibling(p)) {
|
if (!nextSibling(p)) {
|
||||||
nargs--;
|
nargs--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return nargs;
|
return nargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -287,10 +289,11 @@ int emit_num_required(ParmList *parms) {
|
||||||
* Checks if a function is a varargs function
|
* Checks if a function is a varargs function
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int emit_isvarargs(ParmList *p) {
|
||||||
emit_isvarargs(ParmList *p) {
|
if (!p)
|
||||||
if (!p) return 0;
|
return 0;
|
||||||
if (Getattr(p,"emit:varargs")) return 1;
|
if (Getattr(p, "emit:varargs"))
|
||||||
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,9 +308,9 @@ emit_isvarargs(ParmList *p) {
|
||||||
void emit_mark_varargs(ParmList *l) {
|
void emit_mark_varargs(ParmList *l) {
|
||||||
Parm *p = l;
|
Parm *p = l;
|
||||||
while (p) {
|
while (p) {
|
||||||
if (SwigType_isvarargs(Getattr(p,"type")))
|
if (SwigType_isvarargs(Getattr(p, "type")))
|
||||||
if (!Getattr(p,"tmap:in"))
|
if (!Getattr(p, "tmap:in"))
|
||||||
Setattr(p,"varargs:ignore","1");
|
Setattr(p, "varargs:ignore", "1");
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -316,12 +319,11 @@ void emit_mark_varargs(ParmList *l) {
|
||||||
/* replace_contract_args. This function replaces argument names in contract
|
/* replace_contract_args. This function replaces argument names in contract
|
||||||
specifications. Used in conjunction with the %contract directive. */
|
specifications. Used in conjunction with the %contract directive. */
|
||||||
|
|
||||||
static
|
static void replace_contract_args(Parm *cp, Parm *rp, String *s) {
|
||||||
void replace_contract_args(Parm *cp, Parm *rp, String *s) {
|
|
||||||
while (cp && rp) {
|
while (cp && rp) {
|
||||||
String *n = Getattr(cp,"name");
|
String *n = Getattr(cp, "name");
|
||||||
if (n) {
|
if (n) {
|
||||||
Replace(s,n,Getattr(rp,"lname"), DOH_REPLACE_ID);
|
Replace(s, n, Getattr(rp, "lname"), DOH_REPLACE_ID);
|
||||||
}
|
}
|
||||||
cp = nextSibling(cp);
|
cp = nextSibling(cp);
|
||||||
rp = nextSibling(rp);
|
rp = nextSibling(rp);
|
||||||
|
|
@ -336,18 +338,19 @@ void replace_contract_args(Parm *cp, Parm *rp, String *s) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
int emit_action_code(Node *n, Wrapper *f, String *eaction) {
|
int emit_action_code(Node *n, Wrapper *f, String *eaction) {
|
||||||
/* Look for except feature */
|
/* Look for except feature */
|
||||||
String *tm = GetFlagAttr(n,"feature:except");
|
String *tm = GetFlagAttr(n, "feature:except");
|
||||||
if (tm) tm = Copy(tm);
|
if (tm)
|
||||||
if ((tm) && Len(tm) && (Strcmp(tm,"1") != 0)) {
|
tm = Copy(tm);
|
||||||
Replaceall(tm,"$name",Getattr(n,"name"));
|
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||||
Replaceall(tm,"$symname", Getattr(n,"sym:name"));
|
Replaceall(tm, "$name", Getattr(n, "name"));
|
||||||
Replaceall(tm,"$function", eaction);
|
Replaceall(tm, "$symname", Getattr(n, "sym:name"));
|
||||||
Replaceall(tm,"$action", eaction);
|
Replaceall(tm, "$function", eaction);
|
||||||
Printv(f->code,tm,"\n", NIL);
|
Replaceall(tm, "$action", eaction);
|
||||||
|
Printv(f->code, tm, "\n", NIL);
|
||||||
Delete(tm);
|
Delete(tm);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
Printv(f->code,eaction,"\n", NIL);
|
Printv(f->code, eaction, "\n", NIL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -357,120 +360,118 @@ void emit_action(Node *n, Wrapper *f) {
|
||||||
String *action;
|
String *action;
|
||||||
String *wrap;
|
String *wrap;
|
||||||
SwigType *rt;
|
SwigType *rt;
|
||||||
ParmList *catchlist = Getattr(n,"catchlist");
|
ParmList *catchlist = Getattr(n, "catchlist");
|
||||||
|
|
||||||
/* Look for fragments */
|
/* Look for fragments */
|
||||||
{
|
{
|
||||||
String *f;
|
String *f;
|
||||||
f = Getattr(n,"feature:fragment");
|
f = Getattr(n, "feature:fragment");
|
||||||
if (f) {
|
if (f) {
|
||||||
char *c, *tok;
|
char *c, *tok;
|
||||||
String *t = Copy(f);
|
String *t = Copy(f);
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
tok = strtok(c,",");
|
tok = strtok(c, ",");
|
||||||
while (tok) {
|
while (tok) {
|
||||||
String *fname = NewString(tok);
|
String *fname = NewString(tok);
|
||||||
Setfile(fname, Getfile(n));
|
Setfile(fname, Getfile(n));
|
||||||
Setline(fname, Getline(n));
|
Setline(fname, Getline(n));
|
||||||
Swig_fragment_emit(fname);
|
Swig_fragment_emit(fname);
|
||||||
Delete(fname);
|
Delete(fname);
|
||||||
tok = strtok(NULL,",");
|
tok = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
Delete(t);
|
Delete(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit wrapper code (if any) */
|
/* Emit wrapper code (if any) */
|
||||||
wrap = Getattr(n,"wrap:code");
|
wrap = Getattr(n, "wrap:code");
|
||||||
if (wrap && Swig_filebyname("header")!=Getattr(n,"wrap:code:done") ) {
|
if (wrap && Swig_filebyname("header") != Getattr(n, "wrap:code:done")) {
|
||||||
File *f_code = Swig_filebyname("header");
|
File *f_code = Swig_filebyname("header");
|
||||||
if (f_code) {
|
if (f_code) {
|
||||||
Printv(f_code,wrap,NIL);
|
Printv(f_code, wrap, NIL);
|
||||||
}
|
}
|
||||||
Setattr(n,"wrap:code:done",f_code);
|
Setattr(n, "wrap:code:done", f_code);
|
||||||
}
|
}
|
||||||
action = Getattr(n,"feature:action");
|
action = Getattr(n, "feature:action");
|
||||||
if (!action)
|
if (!action)
|
||||||
action = Getattr(n,"wrap:action");
|
action = Getattr(n, "wrap:action");
|
||||||
assert(action != 0);
|
assert(action != 0);
|
||||||
|
|
||||||
if (!is_public(n) && (is_member_director(n) || GetFlag(n, "explicitcall"))) {
|
if (!is_public(n) && (is_member_director(n) || GetFlag(n, "explicitcall"))) {
|
||||||
/* In order to call protected virtual director methods from the target language, we need
|
/* In order to call protected virtual director methods from the target language, we need
|
||||||
* to add an extra dynamic_cast to call the public C++ wrapper in the director class. */
|
* to add an extra dynamic_cast to call the public C++ wrapper in the director class. */
|
||||||
Node* parent = Getattr(n,"parentNode");
|
Node *parent = Getattr(n, "parentNode");
|
||||||
String* symname = Getattr(parent, "sym:name");
|
String *symname = Getattr(parent, "sym:name");
|
||||||
String* dirname = NewStringf("SwigDirector_%s", symname);
|
String *dirname = NewStringf("SwigDirector_%s", symname);
|
||||||
String* dirdecl = NewStringf("%s *darg = 0", dirname);
|
String *dirdecl = NewStringf("%s *darg = 0", dirname);
|
||||||
Wrapper_add_local(f, "darg", dirdecl);
|
Wrapper_add_local(f, "darg", dirdecl);
|
||||||
Printf(f->code, "darg = dynamic_cast<%s *>(arg1);\n",dirname);
|
Printf(f->code, "darg = dynamic_cast<%s *>(arg1);\n", dirname);
|
||||||
Delete(dirname);
|
Delete(dirname);
|
||||||
Delete(dirdecl);
|
Delete(dirdecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the return type */
|
/* Get the return type */
|
||||||
|
|
||||||
rt = Getattr(n,"type");
|
rt = Getattr(n, "type");
|
||||||
|
|
||||||
/* Emit contract code (if any) */
|
/* Emit contract code (if any) */
|
||||||
if (Swig_contract_mode_get()) {
|
if (Swig_contract_mode_get()) {
|
||||||
/* Preassertion */
|
/* Preassertion */
|
||||||
tm = Getattr(n, "contract:preassert");
|
tm = Getattr(n, "contract:preassert");
|
||||||
if (Len(tm)) {
|
if (Len(tm)) {
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Exception handling code */
|
/* Exception handling code */
|
||||||
|
|
||||||
/* saves action -> eaction for postcatching exception */
|
/* saves action -> eaction for postcatching exception */
|
||||||
String *eaction = NewString("");
|
String *eaction = NewString("");
|
||||||
|
|
||||||
/* If we are in C++ mode and there is an exception specification. We're going to
|
/* If we are in C++ mode and there is an exception specification. We're going to
|
||||||
enclose the block in a try block */
|
enclose the block in a try block */
|
||||||
if (catchlist) {
|
if (catchlist) {
|
||||||
Printf(eaction,"try {\n");
|
Printf(eaction, "try {\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Printv(eaction, action, NIL);
|
Printv(eaction, action, NIL);
|
||||||
|
|
||||||
if (catchlist) {
|
if (catchlist) {
|
||||||
int unknown_catch = 0;
|
int unknown_catch = 0;
|
||||||
Printf(eaction,"}\n");
|
Printf(eaction, "}\n");
|
||||||
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
||||||
String *em = Swig_typemap_lookup_new("throws",ep,"_e",0);
|
String *em = Swig_typemap_lookup_new("throws", ep, "_e", 0);
|
||||||
if (em) {
|
if (em) {
|
||||||
SwigType *et = Getattr(ep,"type");
|
SwigType *et = Getattr(ep, "type");
|
||||||
SwigType *etr = SwigType_typedef_resolve_all(et);
|
SwigType *etr = SwigType_typedef_resolve_all(et);
|
||||||
if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) {
|
if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) {
|
||||||
Printf(eaction,"catch(%s) {", SwigType_str(et, "_e"));
|
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||||
} else if (SwigType_isvarargs(etr)) {
|
} else if (SwigType_isvarargs(etr)) {
|
||||||
Printf(eaction,"catch(...) {");
|
Printf(eaction, "catch(...) {");
|
||||||
} else {
|
} else {
|
||||||
Printf(eaction,"catch(%s) {", SwigType_str(et, "&_e"));
|
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||||
}
|
}
|
||||||
Printv(eaction,em,"\n",NIL);
|
Printv(eaction, em, "\n", NIL);
|
||||||
Printf(eaction,"}\n");
|
Printf(eaction, "}\n");
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_TYPEMAP_THROW, Getfile(n), Getline(n),
|
Swig_warning(WARN_TYPEMAP_THROW, Getfile(n), Getline(n), "No 'throws' typemap defined for exception type '%s'\n", SwigType_str(Getattr(ep, "type"), 0));
|
||||||
"No 'throws' typemap defined for exception type '%s'\n",
|
|
||||||
SwigType_str(Getattr(ep,"type"),0));
|
|
||||||
unknown_catch = 1;
|
unknown_catch = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unknown_catch) {
|
if (unknown_catch) {
|
||||||
Printf(eaction,"catch(...) { throw; }\n");
|
Printf(eaction, "catch(...) { throw; }\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look for except typemap (Deprecated) */
|
/* Look for except typemap (Deprecated) */
|
||||||
tm = Swig_typemap_lookup_new("except",n,"result",0);
|
tm = Swig_typemap_lookup_new("except", n, "result", 0);
|
||||||
if (tm) {
|
if (tm) {
|
||||||
Setattr(n,"feature:except", tm);
|
Setattr(n, "feature:except", tm);
|
||||||
tm = 0;
|
tm = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* emit the except feature code */
|
/* emit the except feature code */
|
||||||
emit_action_code(n, f, eaction);
|
emit_action_code(n, f, eaction);
|
||||||
|
|
||||||
Delete(eaction);
|
Delete(eaction);
|
||||||
|
|
||||||
/* Emit contract code (if any) */
|
/* Emit contract code (if any) */
|
||||||
|
|
@ -478,10 +479,8 @@ void emit_action(Node *n, Wrapper *f) {
|
||||||
/* Postassertion */
|
/* Postassertion */
|
||||||
tm = Getattr(n, "contract:postassert");
|
tm = Getattr(n, "contract:postassert");
|
||||||
if (Len(tm)) {
|
if (Len(tm)) {
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -49,27 +49,26 @@ char cvsroot_lua_cxx[] = "$Header$";
|
||||||
This helps me search the parse tree & figure out what is going on inside SWIG
|
This helps me search the parse tree & figure out what is going on inside SWIG
|
||||||
(because its not clear or documented)
|
(because its not clear or documented)
|
||||||
*/
|
*/
|
||||||
#define REPORT(T,D) // no info:
|
#define REPORT(T,D) // no info:
|
||||||
//#define REPORT(T,D) {Printf(stdout,T"\n");} // only title
|
//#define REPORT(T,D) {Printf(stdout,T"\n");} // only title
|
||||||
//#define REPORT(T,D) {Printf(stdout,T"\n");display_mapping(D);} // the works
|
//#define REPORT(T,D) {Printf(stdout,T"\n");display_mapping(D);} // the works
|
||||||
//#define REPORT(T,D) {Printf(stdout,T"\n");Swig_print_node(D);} // the works
|
//#define REPORT(T,D) {Printf(stdout,T"\n");Swig_print_node(D);} // the works
|
||||||
|
|
||||||
void display_mapping(DOH* d)
|
void display_mapping(DOH *d) {
|
||||||
{
|
if (d == 0 || !DohIsMapping(d))
|
||||||
if (d==0 || !DohIsMapping(d)) return;
|
return;
|
||||||
for(DohIterator it=DohFirst(d);it.item;it=DohNext(it))
|
for (DohIterator it = DohFirst(d); it.item; it = DohNext(it)) {
|
||||||
{
|
if (DohIsString(it.item))
|
||||||
if (DohIsString(it.item))
|
Printf(stdout, " %s = %s\n", it.key, it.item);
|
||||||
Printf(stdout, " %s = %s\n", it.key,it.item);
|
else if (DohIsMapping(it.item))
|
||||||
else if (DohIsMapping(it.item))
|
Printf(stdout, " %s = <mapping>\n", it.key);
|
||||||
Printf(stdout, " %s = <mapping>\n", it.key);
|
else if (DohIsSequence(it.item))
|
||||||
else if (DohIsSequence(it.item))
|
Printf(stdout, " %s = <sequence>\n", it.key);
|
||||||
Printf(stdout, " %s = <sequence>\n", it.key);
|
else
|
||||||
else
|
Printf(stdout, " %s = <unknown>\n", it.key);
|
||||||
Printf(stdout, " %s = <unknown>\n", it.key);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
|
|
@ -77,7 +76,7 @@ void display_mapping(DOH* d)
|
||||||
you can add new ones here
|
you can add new ones here
|
||||||
(though for now I have not bothered)
|
(though for now I have not bothered)
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
static const char *usage = (char*)"\
|
static const char *usage = (char *) "\
|
||||||
Lua Options (available with -lua)\n\
|
Lua Options (available with -lua)\n\
|
||||||
(coming soon.)\n\n";
|
(coming soon.)\n\n";
|
||||||
|
|
||||||
|
|
@ -89,7 +88,7 @@ Lua Options (available with -lua)\n\
|
||||||
(more on this as I figure it out)
|
(more on this as I figure it out)
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
|
|
||||||
class LUA : public Language {
|
class LUA:public Language {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
File *f_runtime;
|
File *f_runtime;
|
||||||
|
|
@ -98,16 +97,16 @@ private:
|
||||||
File *f_init;
|
File *f_init;
|
||||||
File *f_initbeforefunc;
|
File *f_initbeforefunc;
|
||||||
String *PrefixPlusUnderscore;
|
String *PrefixPlusUnderscore;
|
||||||
String *s_cmd_tab; // table of command names
|
String *s_cmd_tab; // table of command names
|
||||||
String *s_var_tab; // table of global variables
|
String *s_var_tab; // table of global variables
|
||||||
String *s_const_tab; // table of global constants
|
String *s_const_tab; // table of global constants
|
||||||
String *s_methods_tab; // table of class methods
|
String *s_methods_tab; // table of class methods
|
||||||
String *s_attr_tab; // table of class atributes
|
String *s_attr_tab; // table of class atributes
|
||||||
|
|
||||||
int have_constructor;
|
int have_constructor;
|
||||||
int have_destructor;
|
int have_destructor;
|
||||||
String* destructor_action;
|
String *destructor_action;
|
||||||
String* class_name;
|
String *class_name;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -118,7 +117,7 @@ public:
|
||||||
* Initialize member data
|
* Initialize member data
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
LUA() {
|
LUA() {
|
||||||
f_runtime = 0;
|
f_runtime = 0;
|
||||||
f_header = 0;
|
f_header = 0;
|
||||||
f_wrappers = 0;
|
f_wrappers = 0;
|
||||||
|
|
@ -126,22 +125,23 @@ public:
|
||||||
f_initbeforefunc = 0;
|
f_initbeforefunc = 0;
|
||||||
PrefixPlusUnderscore = 0;
|
PrefixPlusUnderscore = 0;
|
||||||
|
|
||||||
s_cmd_tab=s_var_tab=s_const_tab=0;
|
s_cmd_tab = s_var_tab = s_const_tab = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
This is called to initalise the system & read any command line args
|
This is called to initalise the system & read any command line args
|
||||||
most of this is boilerplate code, except the command line args
|
most of this is boilerplate code, except the command line args
|
||||||
which depends upon what args your code supports
|
which depends upon what args your code supports
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
/* ---------------------------------------------------------------------
|
|
||||||
|
/* ---------------------------------------------------------------------
|
||||||
* main()
|
* main()
|
||||||
*
|
*
|
||||||
* Parse command line options and initializes variables.
|
* Parse command line options and initializes variables.
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
virtual void main(int argc, char *argv[]) {
|
virtual void main(int argc, char *argv[]) {
|
||||||
|
|
||||||
/* Set location of SWIG library */
|
/* Set location of SWIG library */
|
||||||
SWIG_library_directory("lua");
|
SWIG_library_directory("lua");
|
||||||
|
|
@ -149,9 +149,9 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
/* Look for certain command line options */
|
/* Look for certain command line options */
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (argv[i]) {
|
if (argv[i]) {
|
||||||
if (strcmp (argv[i], "-help") == 0) { // usage flags
|
if (strcmp(argv[i], "-help") == 0) { // usage flags
|
||||||
fputs(usage,stderr);
|
fputs(usage, stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,10 +224,10 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
just before it is written to file
|
just before it is written to file
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
// Initialize some variables for the object interface
|
// Initialize some variables for the object interface
|
||||||
s_cmd_tab = NewString("");
|
s_cmd_tab = NewString("");
|
||||||
s_var_tab = NewString("");
|
s_var_tab = NewString("");
|
||||||
// s_methods_tab = NewString("");
|
// s_methods_tab = NewString("");
|
||||||
s_const_tab = NewString("");
|
s_const_tab = NewString("");
|
||||||
|
|
||||||
/* Standard stuff for the SWIG runtime section */
|
/* Standard stuff for the SWIG runtime section */
|
||||||
Swig_banner(f_runtime);
|
Swig_banner(f_runtime);
|
||||||
|
|
@ -235,34 +235,34 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
// Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
|
// Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
String *init_name = NewStringf("%(title)s_Init",module);
|
String *init_name = NewStringf("%(title)s_Init", module);
|
||||||
Printf(f_header, "#define SWIG_init %s\n", init_name);
|
Printf(f_header, "#define SWIG_init %s\n", init_name);
|
||||||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||||
/* SWIG_import is a special function name for importing within Lua5.1 */
|
/* SWIG_import is a special function name for importing within Lua5.1 */
|
||||||
Printf(f_header, "#define SWIG_import luaopen_%s\n\n", module);
|
Printf(f_header, "#define SWIG_import luaopen_%s\n\n", module);
|
||||||
|
|
||||||
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
||||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||||
Printf(f_wrappers,"#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||||
|
|
||||||
/* Change naming scheme for constructors and destructors */
|
/* Change naming scheme for constructors and destructors */
|
||||||
// Swig_name_register("construct","%c_create");
|
// Swig_name_register("construct","%c_create");
|
||||||
// Swig_name_register("destroy","%c_destroy");
|
// Swig_name_register("destroy","%c_destroy");
|
||||||
|
|
||||||
/* %init code inclusion, effectively in the SWIG_init function */
|
/* %init code inclusion, effectively in the SWIG_init function */
|
||||||
Printf(f_init,"#ifdef __cplusplus\nextern \"C\"\n#endif\n");
|
Printf(f_init, "#ifdef __cplusplus\nextern \"C\"\n#endif\n");
|
||||||
Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n");
|
Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n");
|
||||||
Language::top(n);
|
Language::top(n);
|
||||||
Printf(f_init, "}\n" );
|
Printf(f_init, "}\n");
|
||||||
|
|
||||||
Printf(f_wrappers,"#ifdef __cplusplus\n}\n#endif\n");
|
Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n");
|
||||||
|
|
||||||
// Done. Close up the module & write to the wrappers
|
// Done. Close up the module & write to the wrappers
|
||||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n",NIL);
|
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n",NIL);
|
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab,NIL);
|
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -317,21 +317,22 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
virtual int functionWrapper(Node *n) {
|
virtual int functionWrapper(Node *n) {
|
||||||
// REPORT("functionWrapper",n);
|
// REPORT("functionWrapper",n);
|
||||||
|
|
||||||
String *name = Getattr(n,"name");
|
String *name = Getattr(n, "name");
|
||||||
String *iname = Getattr(n,"sym:name");
|
String *iname = Getattr(n, "sym:name");
|
||||||
SwigType *d = Getattr(n,"type");
|
SwigType *d = Getattr(n, "type");
|
||||||
ParmList *l = Getattr(n,"parms");
|
ParmList *l = Getattr(n, "parms");
|
||||||
|
|
||||||
Parm *p;
|
Parm *p;
|
||||||
String *tm;
|
String *tm;
|
||||||
int i;
|
int i;
|
||||||
// int returnval=0; // number of arguments returned
|
// int returnval=0; // number of arguments returned
|
||||||
|
|
||||||
String *overname = 0;
|
String *overname = 0;
|
||||||
if (Getattr(n,"sym:overloaded")) {
|
if (Getattr(n, "sym:overloaded")) {
|
||||||
overname = Getattr(n,"sym:overname");
|
overname = Getattr(n, "sym:overname");
|
||||||
} else {
|
} else {
|
||||||
if (!addSymbol(iname,n)) return SWIG_ERROR;
|
if (!addSymbol(iname, n))
|
||||||
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
|
|
@ -339,12 +340,12 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
we need to add a couple of local variables
|
we need to add a couple of local variables
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
Wrapper *f = NewWrapper();
|
Wrapper *f = NewWrapper();
|
||||||
Wrapper_add_local(f,"SWIG_arg", "int SWIG_arg = -1");
|
Wrapper_add_local(f, "SWIG_arg", "int SWIG_arg = -1");
|
||||||
|
|
||||||
|
|
||||||
String *wname = Swig_name_wrapper(iname);
|
String *wname = Swig_name_wrapper(iname);
|
||||||
if (overname) {
|
if (overname) {
|
||||||
Append(wname,overname);
|
Append(wname, overname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
|
|
@ -352,9 +353,7 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
static int wrap_XXX(lua_State* L){...}
|
static int wrap_XXX(lua_State* L){...}
|
||||||
this line adds this into the wrappering code
|
this line adds this into the wrappering code
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
Printv(f->def,
|
Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL);
|
||||||
"static int ", wname, "(lua_State* L) {",
|
|
||||||
NIL);
|
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
this prints the list of args, eg for a C fn
|
this prints the list of args, eg for a C fn
|
||||||
|
|
@ -368,12 +367,12 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
emit_args(d, l, f);
|
emit_args(d, l, f);
|
||||||
|
|
||||||
/* Attach the standard typemaps */
|
/* Attach the standard typemaps */
|
||||||
emit_attach_parmmaps(l,f);
|
emit_attach_parmmaps(l, f);
|
||||||
Setattr(n,"wrap:parms",l);
|
Setattr(n, "wrap:parms", l);
|
||||||
|
|
||||||
/* Get number of required and total arguments */
|
/* Get number of required and total arguments */
|
||||||
int num_arguments = emit_num_arguments(l);
|
int num_arguments = emit_num_arguments(l);
|
||||||
int num_required = emit_num_required(l);
|
int num_required = emit_num_required(l);
|
||||||
int varargs = emit_isvarargs(l);
|
int varargs = emit_isvarargs(l);
|
||||||
|
|
||||||
/* Which input argument to start with? */
|
/* Which input argument to start with? */
|
||||||
|
|
@ -398,25 +397,25 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
String *argument_check = NewString("");
|
String *argument_check = NewString("");
|
||||||
String *argument_parse = NewString("");
|
String *argument_parse = NewString("");
|
||||||
String *checkfn=NULL;
|
String *checkfn = NULL;
|
||||||
// String *numoutputs=NULL;
|
// String *numoutputs=NULL;
|
||||||
char source[64];
|
char source[64];
|
||||||
for (i = 0, p = l; i < num_arguments; i++) {
|
for (i = 0, p = l; i < num_arguments; i++) {
|
||||||
|
|
||||||
while (checkAttribute(p,"tmap:in:numinputs","0")) {
|
while (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *pt = Getattr(p,"type");
|
SwigType *pt = Getattr(p, "type");
|
||||||
String *ln = Getattr(p,"lname");
|
String *ln = Getattr(p, "lname");
|
||||||
|
|
||||||
/* Look for an input typemap */
|
/* Look for an input typemap */
|
||||||
sprintf(source, "%d", i+1);
|
sprintf(source, "%d", i + 1);
|
||||||
if ((tm = Getattr(p,"tmap:in"))) {
|
if ((tm = Getattr(p, "tmap:in"))) {
|
||||||
Replaceall(tm, "$source", source);
|
Replaceall(tm, "$source", source);
|
||||||
Replaceall(tm, "$target", ln);
|
Replaceall(tm, "$target", ln);
|
||||||
Replaceall(tm, "$input", source);
|
Replaceall(tm, "$input", source);
|
||||||
Setattr(p, "emit:input", source);
|
Setattr(p, "emit:input", source);
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
look for a 'checkfn' typemap
|
look for a 'checkfn' typemap
|
||||||
|
|
@ -425,61 +424,55 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
this will result in code either in the
|
this will result in code either in the
|
||||||
argument_check or argument_parse string
|
argument_check or argument_parse string
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
if ((checkfn=Getattr(p,"tmap:in:checkfn"))){
|
if ((checkfn = Getattr(p, "tmap:in:checkfn"))) {
|
||||||
if (i<num_required)
|
if (i < num_required) {
|
||||||
{
|
Printf(argument_check, "if(!%s(L,%s))", checkfn, source);
|
||||||
Printf(argument_check,"if(!%s(L,%s))",checkfn,source);
|
} else {
|
||||||
}
|
Printf(argument_check, "if(lua_gettop(L)>=%s && !%s(L,%s))", source, checkfn, source);
|
||||||
else
|
}
|
||||||
{
|
Printf(argument_check, " SWIG_fail_arg(%s);\n", source);
|
||||||
Printf(argument_check,"if(lua_gettop(L)>=%s && !%s(L,%s))",source,checkfn,source);
|
}
|
||||||
}
|
|
||||||
Printf(argument_check," SWIG_fail_arg(%s);\n",source);
|
|
||||||
}
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
lua states the number of arguments passed to a function using the fn
|
lua states the number of arguments passed to a function using the fn
|
||||||
lua_gettop()
|
lua_gettop()
|
||||||
we can use this to deal with default arguments
|
we can use this to deal with default arguments
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
if (i<num_required){
|
if (i < num_required) {
|
||||||
Printf(argument_parse, "%s\n", tm);
|
Printf(argument_parse, "%s\n", tm);
|
||||||
}
|
} else {
|
||||||
else
|
Printf(argument_parse, "if(lua_gettop(L)>=%s){%s}\n", source, tm);
|
||||||
{
|
}
|
||||||
Printf(argument_parse,"if(lua_gettop(L)>=%s){%s}\n",source,tm);
|
p = Getattr(p, "tmap:in:next");
|
||||||
}
|
continue;
|
||||||
p = Getattr(p,"tmap:in:next");
|
} else {
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
// why is this code not called when I dont have a typemap?
|
// why is this code not called when I dont have a typemap?
|
||||||
// instead of giving a warning, no code is generated
|
// instead of giving a warning, no code is generated
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number,
|
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
|
||||||
"Unable to use type %s as a function argument.\n",SwigType_str(pt,0));
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all argcheck code
|
// add all argcheck code
|
||||||
Printv(f->code,argument_check,argument_parse,NIL);
|
Printv(f->code, argument_check, argument_parse, NIL);
|
||||||
|
|
||||||
/* Check for trailing varargs */
|
/* Check for trailing varargs */
|
||||||
if (varargs) {
|
if (varargs) {
|
||||||
if (p && (tm = Getattr(p,"tmap:in"))) {
|
if (p && (tm = Getattr(p, "tmap:in"))) {
|
||||||
Replaceall(tm,"$input", "varargs");
|
Replaceall(tm, "$input", "varargs");
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert constraint checking code */
|
/* Insert constraint checking code */
|
||||||
for (p = l; p;) {
|
for (p = l; p;) {
|
||||||
if ((tm = Getattr(p,"tmap:check"))) {
|
if ((tm = Getattr(p, "tmap:check"))) {
|
||||||
Replaceall(tm,"$target",Getattr(p,"lname"));
|
Replaceall(tm, "$target", Getattr(p, "lname"));
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
p = Getattr(p,"tmap:check:next");
|
p = Getattr(p, "tmap:check:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
@ -488,10 +481,10 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
/* Insert cleanup code */
|
/* Insert cleanup code */
|
||||||
String *cleanup = NewString("");
|
String *cleanup = NewString("");
|
||||||
for (p = l; p;) {
|
for (p = l; p;) {
|
||||||
if ((tm = Getattr(p,"tmap:freearg"))) {
|
if ((tm = Getattr(p, "tmap:freearg"))) {
|
||||||
Replaceall(tm,"$source",Getattr(p,"lname"));
|
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||||
Printv(cleanup,tm,"\n",NIL);
|
Printv(cleanup, tm, "\n", NIL);
|
||||||
p = Getattr(p,"tmap:freearg:next");
|
p = Getattr(p, "tmap:freearg:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
@ -500,109 +493,108 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
/* Insert argument output code */
|
/* Insert argument output code */
|
||||||
String *outarg = NewString("");
|
String *outarg = NewString("");
|
||||||
for (p = l; p;) {
|
for (p = l; p;) {
|
||||||
if ((tm = Getattr(p,"tmap:argout"))) {
|
if ((tm = Getattr(p, "tmap:argout"))) {
|
||||||
// // managing the number of returning variables
|
// // managing the number of returning variables
|
||||||
// if (numoutputs=Getattr(p,"tmap:argout:numoutputs")){
|
// if (numoutputs=Getattr(p,"tmap:argout:numoutputs")){
|
||||||
// int i=GetInt(p,"tmap:argout:numoutputs");
|
// int i=GetInt(p,"tmap:argout:numoutputs");
|
||||||
// printf("got argout:numoutputs of %d\n",i);
|
// printf("got argout:numoutputs of %d\n",i);
|
||||||
// returnval+=GetInt(p,"tmap:argout:numoutputs");
|
// returnval+=GetInt(p,"tmap:argout:numoutputs");
|
||||||
// }
|
// }
|
||||||
// else returnval++;
|
// else returnval++;
|
||||||
Replaceall(tm,"$source",Getattr(p,"lname"));
|
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||||
Replaceall(tm,"$target","result");
|
Replaceall(tm, "$target", "result");
|
||||||
Replaceall(tm,"$arg",Getattr(p,"emit:input"));
|
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
|
||||||
Replaceall(tm,"$input",Getattr(p,"emit:input"));
|
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||||
Printv(outarg,tm,"\n",NIL);
|
Printv(outarg, tm, "\n", NIL);
|
||||||
p = Getattr(p,"tmap:argout:next");
|
p = Getattr(p, "tmap:argout:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit the function call */
|
/* Emit the function call */
|
||||||
emit_action(n,f);
|
emit_action(n, f);
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
FIXME:
|
FIXME:
|
||||||
returns 1 if there is a void return type
|
returns 1 if there is a void return type
|
||||||
this is because there is a typemap for void
|
this is because there is a typemap for void
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
Printv(f->code,"SWIG_arg=0;\n",NIL);
|
Printv(f->code, "SWIG_arg=0;\n", NIL);
|
||||||
// Return value if necessary
|
// Return value if necessary
|
||||||
if ((tm = Swig_typemap_lookup_new("out",n,"result",0))) {
|
if ((tm = Swig_typemap_lookup_new("out", n, "result", 0))) {
|
||||||
// managing the number of returning variables
|
// managing the number of returning variables
|
||||||
// if (numoutputs=Getattr(tm,"numoutputs")){
|
// if (numoutputs=Getattr(tm,"numoutputs")){
|
||||||
// int i=GetInt(tm,"numoutputs");
|
// int i=GetInt(tm,"numoutputs");
|
||||||
// printf("return numoutputs %d\n",i);
|
// printf("return numoutputs %d\n",i);
|
||||||
// returnval+=GetInt(tm,"numoutputs");
|
// returnval+=GetInt(tm,"numoutputs");
|
||||||
// }
|
// }
|
||||||
// else returnval++;
|
// else returnval++;
|
||||||
Replaceall(tm,"$source", "result");
|
Replaceall(tm, "$source", "result");
|
||||||
if (GetFlag(n,"feature:new")) {
|
if (GetFlag(n, "feature:new")) {
|
||||||
Replaceall(tm,"$owner","1");
|
Replaceall(tm, "$owner", "1");
|
||||||
} else {
|
} else {
|
||||||
Replaceall(tm,"$owner","0");
|
Replaceall(tm, "$owner", "0");
|
||||||
}
|
}
|
||||||
Printf(f->code,"%s\n", tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
// returnval++;
|
// returnval++;
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number,
|
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name);
|
||||||
"Unable to use return type %s in function %s.\n", SwigType_str(d,0), name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output argument output code */
|
/* Output argument output code */
|
||||||
Printv(f->code,outarg,NIL);
|
Printv(f->code, outarg, NIL);
|
||||||
|
|
||||||
/* Output cleanup code */
|
/* Output cleanup code */
|
||||||
Printv(f->code,cleanup,NIL);
|
Printv(f->code, cleanup, NIL);
|
||||||
|
|
||||||
/* Look to see if there is any newfree cleanup code */
|
/* Look to see if there is any newfree cleanup code */
|
||||||
if (GetFlag(n,"feature:new")) {
|
if (GetFlag(n, "feature:new")) {
|
||||||
if ((tm = Swig_typemap_lookup_new("newfree",n,"result",0))) {
|
if ((tm = Swig_typemap_lookup_new("newfree", n, "result", 0))) {
|
||||||
Replaceall(tm,"$source","result");
|
Replaceall(tm, "$source", "result");
|
||||||
Printf(f->code,"%s\n",tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if there is any return cleanup code */
|
/* See if there is any return cleanup code */
|
||||||
if ((tm = Swig_typemap_lookup_new("ret", n, "result", 0))) {
|
if ((tm = Swig_typemap_lookup_new("ret", n, "result", 0))) {
|
||||||
Replaceall(tm,"$source","result");
|
Replaceall(tm, "$source", "result");
|
||||||
Printf(f->code,"%s\n",tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Close the function */
|
/* Close the function */
|
||||||
Printv(f->code, "return SWIG_arg;\n",NIL);
|
Printv(f->code, "return SWIG_arg;\n", NIL);
|
||||||
// add the failure cleanup code:
|
// add the failure cleanup code:
|
||||||
Printv(f->code, "\nfail:\n",NIL);
|
Printv(f->code, "\nfail:\n", NIL);
|
||||||
Printv(f->code, "$cleanup","lua_error(L);\n",NIL);
|
Printv(f->code, "$cleanup", "lua_error(L);\n", NIL);
|
||||||
Printv(f->code, "return SWIG_arg;\n",NIL);
|
Printv(f->code, "return SWIG_arg;\n", NIL);
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
|
|
||||||
/* Substitute the cleanup code */
|
/* Substitute the cleanup code */
|
||||||
Replaceall(f->code,"$cleanup",cleanup);
|
Replaceall(f->code, "$cleanup", cleanup);
|
||||||
|
|
||||||
/* Substitute the function name */
|
/* Substitute the function name */
|
||||||
Replaceall(f->code,"$symname",iname);
|
Replaceall(f->code, "$symname", iname);
|
||||||
Replaceall(f->code,"$result","result");
|
Replaceall(f->code, "$result", "result");
|
||||||
|
|
||||||
/* Dump the function out */
|
/* Dump the function out */
|
||||||
Wrapper_print(f,f_wrappers);
|
Wrapper_print(f, f_wrappers);
|
||||||
|
|
||||||
Setattr(n,"wrap:name", wname); // you need this to make the overloading work
|
Setattr(n, "wrap:name", wname); // you need this to make the overloading work
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
register the function in SWIG
|
register the function in SWIG
|
||||||
different language mappings seem to use different ideas
|
different language mappings seem to use different ideas
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
/* Now register the function with the interpreter. */
|
/* Now register the function with the interpreter. */
|
||||||
if (!Getattr(n,"sym:overloaded")) {
|
if (!Getattr(n, "sym:overloaded")) {
|
||||||
// add_method(n, iname, wname, description);
|
// add_method(n, iname, wname, description);
|
||||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL);
|
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||||
} else {
|
} else {
|
||||||
// Setattr(n,"wrap:name", wname);
|
// Setattr(n,"wrap:name", wname);
|
||||||
if (!Getattr(n,"sym:nextSibling")) {
|
if (!Getattr(n, "sym:nextSibling")) {
|
||||||
dispatchFunction(n);
|
dispatchFunction(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -636,37 +628,34 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
|
|
||||||
int maxargs;
|
int maxargs;
|
||||||
String *tmp = NewString("");
|
String *tmp = NewString("");
|
||||||
String *dispatch = Swig_overload_dispatch(n,"return %s(L);",&maxargs);
|
String *dispatch = Swig_overload_dispatch(n, "return %s(L);", &maxargs);
|
||||||
|
|
||||||
/* Generate a dispatch wrapper for all overloaded functions */
|
/* Generate a dispatch wrapper for all overloaded functions */
|
||||||
|
|
||||||
Wrapper *f = NewWrapper();
|
Wrapper *f = NewWrapper();
|
||||||
String *symname = Getattr(n,"sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
String *wname = Swig_name_wrapper(symname);
|
String *wname = Swig_name_wrapper(symname);
|
||||||
|
|
||||||
//Printf(stdout,"Swig_overload_dispatch %s %s '%s' %d\n",symname,wname,dispatch,maxargs);
|
//Printf(stdout,"Swig_overload_dispatch %s %s '%s' %d\n",symname,wname,dispatch,maxargs);
|
||||||
|
|
||||||
Printv(f->def,
|
Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL);
|
||||||
"static int ", wname, "(lua_State* L) {",
|
Wrapper_add_local(f, "argc", "int argc");
|
||||||
NIL);
|
Printf(tmp, "int argv[%d]={1", maxargs + 1);
|
||||||
Wrapper_add_local(f,"argc","int argc");
|
for (int i = 1; i <= maxargs; i++) {
|
||||||
Printf(tmp,"int argv[%d]={1", maxargs+1);
|
Printf(tmp, ",%d", i + 1);
|
||||||
for(int i=1;i<=maxargs;i++)
|
}
|
||||||
{
|
Printf(tmp, "}");
|
||||||
Printf(tmp,",%d",i+1);
|
Wrapper_add_local(f, "argv", tmp);
|
||||||
}
|
Printf(f->code, "argc = lua_gettop(L);\n");
|
||||||
Printf(tmp,"}");
|
|
||||||
Wrapper_add_local(f,"argv",tmp);
|
|
||||||
Printf(f->code,"argc = lua_gettop(L);\n");
|
|
||||||
|
|
||||||
Replaceall(dispatch,"$args","self,args");
|
Replaceall(dispatch, "$args", "self,args");
|
||||||
Printv(f->code,dispatch,"\n",NIL);
|
Printv(f->code, dispatch, "\n", NIL);
|
||||||
Printf(f->code,"lua_pushstring(L,\"No matching function for overloaded '%s'\");\n", symname);
|
Printf(f->code, "lua_pushstring(L,\"No matching function for overloaded '%s'\");\n", symname);
|
||||||
Printf(f->code,"lua_error(L);return 0;\n");
|
Printf(f->code, "lua_error(L);return 0;\n");
|
||||||
Printv(f->code,"}\n",NIL);
|
Printv(f->code, "}\n", NIL);
|
||||||
Wrapper_print(f,f_wrappers);
|
Wrapper_print(f, f_wrappers);
|
||||||
//add_method(symname,wname,0);
|
//add_method(symname,wname,0);
|
||||||
Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wname, "},\n", NIL);
|
Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wname, "},\n", NIL);
|
||||||
|
|
||||||
DelWrapper(f);
|
DelWrapper(f);
|
||||||
Delete(dispatch);
|
Delete(dispatch);
|
||||||
|
|
@ -687,68 +676,68 @@ so we will just add these into the variable lists
|
||||||
ideally we should not have registered these as functions,
|
ideally we should not have registered these as functions,
|
||||||
only WRT this variable will look into this later.
|
only WRT this variable will look into this later.
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
REPORT("variableWrapper",n);
|
REPORT("variableWrapper", n);
|
||||||
String *iname = Getattr(n,"sym:name");
|
String *iname = Getattr(n, "sym:name");
|
||||||
SwigType *type = Getattr(n,"type");
|
SwigType *type = Getattr(n, "type");
|
||||||
// let SWIG generate the wrappers
|
// let SWIG generate the wrappers
|
||||||
int result=Language::variableWrapper(n);
|
int result = Language::variableWrapper(n);
|
||||||
// normally SWIG will generate 2 wrappers, a get and a set
|
// normally SWIG will generate 2 wrappers, a get and a set
|
||||||
// but in certain scenarios (immutable, or if its arrays), it will not
|
// but in certain scenarios (immutable, or if its arrays), it will not
|
||||||
String *getName=Swig_name_wrapper(Swig_name_get(iname));
|
String *getName = Swig_name_wrapper(Swig_name_get(iname));
|
||||||
String *setName=0;
|
String *setName = 0;
|
||||||
if (is_assignable(n)==false || SwigType_isarray(type)) {
|
if (is_assignable(n) == false || SwigType_isarray(type)) {
|
||||||
// TODO: how about calling a 'this is not settable' error message?
|
// TODO: how about calling a 'this is not settable' error message?
|
||||||
setName=NewString("0");
|
setName = NewString("0");
|
||||||
} else {
|
} else {
|
||||||
setName=Swig_name_wrapper(Swig_name_set(iname));
|
setName = Swig_name_wrapper(Swig_name_set(iname));
|
||||||
}
|
}
|
||||||
// register the variable
|
// register the variable
|
||||||
Printf(s_var_tab,"%s{ \"%s\", %s, %s },\n",tab4,iname,getName,setName);
|
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||||
Delete(getName);
|
Delete(getName);
|
||||||
Delete(setName);
|
Delete(setName);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* constantWrapper()
|
* constantWrapper()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
virtual int constantWrapper(Node *n) {
|
virtual int constantWrapper(Node *n) {
|
||||||
REPORT("constantWrapper",n);
|
REPORT("constantWrapper", n);
|
||||||
String *name = Getattr(n,"name");
|
String *name = Getattr(n, "name");
|
||||||
String *iname = Getattr(n,"sym:name");
|
String *iname = Getattr(n, "sym:name");
|
||||||
//String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s",ns_name,iname);
|
//String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s",ns_name,iname);
|
||||||
String *nsname = Copy(iname);
|
String *nsname = Copy(iname);
|
||||||
SwigType *type = Getattr(n,"type");
|
SwigType *type = Getattr(n, "type");
|
||||||
String *rawval = Getattr(n,"rawval");
|
String *rawval = Getattr(n, "rawval");
|
||||||
String *value = rawval ? rawval : Getattr(n,"value");
|
String *value = rawval ? rawval : Getattr(n, "value");
|
||||||
String *tm;
|
String *tm;
|
||||||
|
|
||||||
if (!addSymbol(iname,n)) return SWIG_ERROR;
|
if (!addSymbol(iname, n))
|
||||||
|
return SWIG_ERROR;
|
||||||
//if (nspace) Setattr(n,"sym:name",nsname);
|
//if (nspace) Setattr(n,"sym:name",nsname);
|
||||||
|
|
||||||
/* Special hook for member pointer */
|
/* Special hook for member pointer */
|
||||||
if (SwigType_type(type) == T_MPOINTER) {
|
if (SwigType_type(type) == T_MPOINTER) {
|
||||||
String *wname = Swig_name_wrapper(iname);
|
String *wname = Swig_name_wrapper(iname);
|
||||||
Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type,wname), value);
|
Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type, wname), value);
|
||||||
value = Char(wname);
|
value = Char(wname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tm = Swig_typemap_lookup_new("consttab",n,name,0))) {
|
if ((tm = Swig_typemap_lookup_new("consttab", n, name, 0))) {
|
||||||
Replaceall(tm,"$source",value);
|
Replaceall(tm, "$source", value);
|
||||||
Replaceall(tm,"$target",name);
|
Replaceall(tm, "$target", name);
|
||||||
Replaceall(tm,"$value",value);
|
Replaceall(tm, "$value", value);
|
||||||
Replaceall(tm,"$nsname",nsname);
|
Replaceall(tm, "$nsname", nsname);
|
||||||
Printf(s_const_tab,"%s,\n", tm);
|
Printf(s_const_tab, "%s,\n", tm);
|
||||||
} else if ((tm = Swig_typemap_lookup_new("constcode", n, name, 0))) {
|
} else if ((tm = Swig_typemap_lookup_new("constcode", n, name, 0))) {
|
||||||
Replaceall(tm,"$source", value);
|
Replaceall(tm, "$source", value);
|
||||||
Replaceall(tm,"$target", name);
|
Replaceall(tm, "$target", name);
|
||||||
Replaceall(tm,"$value",value);
|
Replaceall(tm, "$value", value);
|
||||||
Replaceall(tm,"$nsname",nsname);
|
Replaceall(tm, "$nsname", nsname);
|
||||||
Printf(f_init, "%s\n", tm);
|
Printf(f_init, "%s\n", tm);
|
||||||
} else {
|
} else {
|
||||||
Delete(nsname);
|
Delete(nsname);
|
||||||
Swig_warning(WARN_TYPEMAP_CONST_UNDEF,
|
Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n");
|
||||||
input_file, line_number, "Unsupported constant value.\n");
|
|
||||||
return SWIG_NOWRAP;
|
return SWIG_NOWRAP;
|
||||||
}
|
}
|
||||||
Delete(nsname);
|
Delete(nsname);
|
||||||
|
|
@ -760,10 +749,11 @@ virtual int constantWrapper(Node *n) {
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int nativeWrapper(Node *n) {
|
virtual int nativeWrapper(Node *n) {
|
||||||
REPORT("nativeWrapper",n);
|
REPORT("nativeWrapper", n);
|
||||||
String *symname = Getattr(n,"sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
String *wrapname = Getattr(n,"wrap:name");
|
String *wrapname = Getattr(n, "wrap:name");
|
||||||
if (!addSymbol(wrapname,n)) return SWIG_ERROR;
|
if (!addSymbol(wrapname, n))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
|
||||||
Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wrapname, "},\n", NIL);
|
Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wrapname, "},\n", NIL);
|
||||||
// return Language::nativeWrapper(n); // this does nothing...
|
// return Language::nativeWrapper(n); // this does nothing...
|
||||||
|
|
@ -798,20 +788,21 @@ virtual int constantWrapper(Node *n) {
|
||||||
* classHandler()
|
* classHandler()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int classHandler(Node *n) {
|
virtual int classHandler(Node *n) {
|
||||||
REPORT("classHandler",n);
|
REPORT("classHandler", n);
|
||||||
|
|
||||||
String *mangled_classname = 0;
|
String *mangled_classname = 0;
|
||||||
String *real_classname = 0;
|
String *real_classname = 0;
|
||||||
|
|
||||||
have_constructor = 0;
|
have_constructor = 0;
|
||||||
have_destructor = 0;
|
have_destructor = 0;
|
||||||
destructor_action = 0;
|
destructor_action = 0;
|
||||||
|
|
||||||
class_name = Getattr(n,"sym:name");
|
class_name = Getattr(n, "sym:name");
|
||||||
if (!addSymbol(class_name,n)) return SWIG_ERROR;
|
if (!addSymbol(class_name, n))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
|
||||||
real_classname = Getattr(n,"name");
|
real_classname = Getattr(n, "name");
|
||||||
mangled_classname = Swig_name_mangle(real_classname);
|
mangled_classname = Swig_name_mangle(real_classname);
|
||||||
|
|
||||||
// note: tcl has a static hashtable of all classes emitted, I wonder why?
|
// note: tcl has a static hashtable of all classes emitted, I wonder why?
|
||||||
|
|
@ -825,21 +816,21 @@ virtual int constantWrapper(Node *n) {
|
||||||
Printv(s_attr_tab, mangled_classname, "_attributes[] = {\n", NIL);
|
Printv(s_attr_tab, mangled_classname, "_attributes[] = {\n", NIL);
|
||||||
|
|
||||||
s_methods_tab = NewString("");
|
s_methods_tab = NewString("");
|
||||||
Printf(s_methods_tab,"static swig_lua_method swig_");
|
Printf(s_methods_tab, "static swig_lua_method swig_");
|
||||||
Printv(s_methods_tab, mangled_classname, "_methods[] = {\n", NIL);
|
Printv(s_methods_tab, mangled_classname, "_methods[] = {\n", NIL);
|
||||||
|
|
||||||
// Generate normal wrappers
|
// Generate normal wrappers
|
||||||
//return SWIG_OK;
|
//return SWIG_OK;
|
||||||
Language::classHandler(n);
|
Language::classHandler(n);
|
||||||
//return SWIG_OK;
|
//return SWIG_OK;
|
||||||
SwigType *t = Copy(Getattr(n,"name"));
|
SwigType *t = Copy(Getattr(n, "name"));
|
||||||
SwigType_add_pointer(t);
|
SwigType_add_pointer(t);
|
||||||
|
|
||||||
// Catch all: eg. a class with only static functions and/or variables will not have 'remembered'
|
// Catch all: eg. a class with only static functions and/or variables will not have 'remembered'
|
||||||
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
|
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
|
||||||
SwigType_remember_clientdata(t,wrap_class);
|
SwigType_remember_clientdata(t, wrap_class);
|
||||||
|
|
||||||
String *rt = Copy(Getattr(n,"classtype"));
|
String *rt = Copy(Getattr(n, "classtype"));
|
||||||
SwigType_add_pointer(rt);
|
SwigType_add_pointer(rt);
|
||||||
|
|
||||||
// Register the class structure with the type checker
|
// Register the class structure with the type checker
|
||||||
|
|
@ -847,39 +838,39 @@ virtual int constantWrapper(Node *n) {
|
||||||
if (have_destructor) {
|
if (have_destructor) {
|
||||||
Printv(f_wrappers, "static void swig_delete_", class_name, "(void *obj) {\n", NIL);
|
Printv(f_wrappers, "static void swig_delete_", class_name, "(void *obj) {\n", NIL);
|
||||||
if (destructor_action) {
|
if (destructor_action) {
|
||||||
Printv(f_wrappers, SwigType_str(rt,"arg1"), " = (", SwigType_str(rt,0), ") obj;\n", NIL);
|
Printv(f_wrappers, SwigType_str(rt, "arg1"), " = (", SwigType_str(rt, 0), ") obj;\n", NIL);
|
||||||
Printv(f_wrappers, destructor_action, NIL);
|
Printv(f_wrappers, destructor_action, NIL);
|
||||||
} else {
|
} else {
|
||||||
if (CPlusPlus) {
|
if (CPlusPlus) {
|
||||||
Printv(f_wrappers," delete (", SwigType_str(rt,0), ") obj;\n",NIL);
|
Printv(f_wrappers, " delete (", SwigType_str(rt, 0), ") obj;\n", NIL);
|
||||||
} else {
|
} else {
|
||||||
Printv(f_wrappers," free((char *) obj);\n",NIL);
|
Printv(f_wrappers, " free((char *) obj);\n", NIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Printf(f_wrappers,"}\n");
|
Printf(f_wrappers, "}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(s_methods_tab, " {0,0}\n};\n");
|
Printf(s_methods_tab, " {0,0}\n};\n");
|
||||||
Printv(f_wrappers,s_methods_tab,NIL);
|
Printv(f_wrappers, s_methods_tab, NIL);
|
||||||
|
|
||||||
Printf(s_attr_tab, " {0,0,0}\n};\n");
|
Printf(s_attr_tab, " {0,0,0}\n};\n");
|
||||||
Printv(f_wrappers,s_attr_tab,NIL);
|
Printv(f_wrappers, s_attr_tab, NIL);
|
||||||
|
|
||||||
Delete(s_methods_tab);
|
Delete(s_methods_tab);
|
||||||
Delete(s_attr_tab);
|
Delete(s_attr_tab);
|
||||||
|
|
||||||
// Handle inheritance
|
// Handle inheritance
|
||||||
|
|
||||||
String *base_class = NewString("");
|
String *base_class = NewString("");
|
||||||
|
|
||||||
List *baselist = Getattr(n,"bases");
|
List *baselist = Getattr(n, "bases");
|
||||||
if (baselist && Len(baselist)) {
|
if (baselist && Len(baselist)) {
|
||||||
Iterator b;
|
Iterator b;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
b = First(baselist);
|
b = First(baselist);
|
||||||
while (b.item) {
|
while (b.item) {
|
||||||
String *bname = Getattr(b.item, "name");
|
String *bname = Getattr(b.item, "name");
|
||||||
if ((!bname) || GetFlag(b.item,"feature:ignore") || (!Getattr(b.item,"module"))) {
|
if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) {
|
||||||
b = Next(b);
|
b = Next(b);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -889,15 +880,15 @@ virtual int constantWrapper(Node *n) {
|
||||||
Printv( base_class_init , " ", bname, "Ptr::constructor $ptr\n", NIL );
|
Printv( base_class_init , " ", bname, "Ptr::constructor $ptr\n", NIL );
|
||||||
}*/
|
}*/
|
||||||
String *bmangle = Swig_name_mangle(bname);
|
String *bmangle = Swig_name_mangle(bname);
|
||||||
// Printv(f_wrappers,"extern swig_class _wrap_class_", bmangle, ";\n", NIL);
|
// Printv(f_wrappers,"extern swig_class _wrap_class_", bmangle, ";\n", NIL);
|
||||||
Printf(base_class,"&_wrap_class_%s",bmangle);
|
Printf(base_class, "&_wrap_class_%s", bmangle);
|
||||||
// Put code to register base classes in init function
|
// Put code to register base classes in init function
|
||||||
|
|
||||||
// Printf(f_init,"/* Register base : %s */\n", bmangle);
|
// Printf(f_init,"/* Register base : %s */\n", bmangle);
|
||||||
// Printf(f_init,"swig_%s_bases[%d] = (swig_class *) SWIG_TypeQuery(\"%s *\")->clientdata;\n", mangled_classname, index, SwigType_namestr(bname));
|
// Printf(f_init,"swig_%s_bases[%d] = (swig_class *) SWIG_TypeQuery(\"%s *\")->clientdata;\n", mangled_classname, index, SwigType_namestr(bname));
|
||||||
b = Next(b);
|
b = Next(b);
|
||||||
index++;
|
index++;
|
||||||
Putc(',',base_class);
|
Putc(',', base_class);
|
||||||
Delete(bmangle);
|
Delete(bmangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -919,23 +910,22 @@ virtual int constantWrapper(Node *n) {
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
Printv(f_wrappers,"static swig_lua_class *swig_",mangled_classname,"_bases[] = {", base_class,"0};\n", NIL);
|
Printv(f_wrappers, "static swig_lua_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL);
|
||||||
Delete(base_class);
|
Delete(base_class);
|
||||||
|
|
||||||
Printv(f_wrappers, "swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name,
|
Printv(f_wrappers, "swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||||
"\", &SWIGTYPE", SwigType_manglestr(t), ",",NIL);
|
|
||||||
|
|
||||||
if (have_constructor) {
|
if (have_constructor) {
|
||||||
Printf(f_wrappers,"%s", Swig_name_wrapper(Swig_name_construct(class_name)));
|
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(class_name)));
|
||||||
} else {
|
} else {
|
||||||
Printf(f_wrappers,"0");
|
Printf(f_wrappers, "0");
|
||||||
}
|
}
|
||||||
if (have_destructor) {
|
if (have_destructor) {
|
||||||
Printv(f_wrappers, ", swig_delete_", class_name,NIL);
|
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||||
} else {
|
} else {
|
||||||
Printf(f_wrappers,",0");
|
Printf(f_wrappers, ",0");
|
||||||
}
|
}
|
||||||
Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname,"_bases };\n\n", NIL);
|
Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname, "_bases };\n\n", NIL);
|
||||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_", mangled_classname, "},\n", NIL);
|
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_", mangled_classname, "},\n", NIL);
|
||||||
Delete(t);
|
Delete(t);
|
||||||
Delete(mangled_classname);
|
Delete(mangled_classname);
|
||||||
|
|
@ -947,16 +937,16 @@ virtual int constantWrapper(Node *n) {
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int memberfunctionHandler(Node *n) {
|
virtual int memberfunctionHandler(Node *n) {
|
||||||
String *name = Getattr(n,"name");
|
String *name = Getattr(n, "name");
|
||||||
String *iname = GetChar(n,"sym:name");
|
String *iname = GetChar(n, "sym:name");
|
||||||
|
|
||||||
String *realname, *rname;
|
String *realname, *rname;
|
||||||
|
|
||||||
Language::memberfunctionHandler(n);
|
Language::memberfunctionHandler(n);
|
||||||
|
|
||||||
realname = iname ? iname : name;
|
realname = iname ? iname : name;
|
||||||
rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||||
if (!Getattr(n,"sym:nextSibling")) {
|
if (!Getattr(n, "sym:nextSibling")) {
|
||||||
Printv(s_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
Printv(s_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
||||||
}
|
}
|
||||||
Delete(rname);
|
Delete(rname);
|
||||||
|
|
@ -969,17 +959,17 @@ virtual int constantWrapper(Node *n) {
|
||||||
|
|
||||||
virtual int membervariableHandler(Node *n) {
|
virtual int membervariableHandler(Node *n) {
|
||||||
// REPORT("membervariableHandler",n);
|
// REPORT("membervariableHandler",n);
|
||||||
String *symname = Getattr(n,"sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
String *rname;
|
String *rname;
|
||||||
|
|
||||||
Language::membervariableHandler(n);
|
Language::membervariableHandler(n);
|
||||||
Printv(s_attr_tab, tab4, "{ \"", symname, "\",", NIL);
|
Printv(s_attr_tab, tab4, "{ \"", symname, "\",", NIL);
|
||||||
rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name,symname)));
|
rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||||
Printv(s_attr_tab, rname, ", ", NIL);
|
Printv(s_attr_tab, rname, ", ", NIL);
|
||||||
Delete(rname);
|
Delete(rname);
|
||||||
if (!GetFlag(n,"feature:immutable")) {
|
if (!GetFlag(n, "feature:immutable")) {
|
||||||
rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name,symname)));
|
rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||||
Printv(s_attr_tab, rname, "},\n",NIL);
|
Printv(s_attr_tab, rname, "},\n", NIL);
|
||||||
Delete(rname);
|
Delete(rname);
|
||||||
} else {
|
} else {
|
||||||
Printf(s_attr_tab, "0 },\n");
|
Printf(s_attr_tab, "0 },\n");
|
||||||
|
|
@ -993,7 +983,7 @@ virtual int constantWrapper(Node *n) {
|
||||||
* Method for adding C++ member constructor
|
* Method for adding C++ member constructor
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int constructorHandler(Node *n) {
|
virtual int constructorHandler(Node *n) {
|
||||||
Language::constructorHandler(n);
|
Language::constructorHandler(n);
|
||||||
have_constructor = 1;
|
have_constructor = 1;
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
@ -1006,7 +996,7 @@ virtual int constantWrapper(Node *n) {
|
||||||
virtual int destructorHandler(Node *n) {
|
virtual int destructorHandler(Node *n) {
|
||||||
Language::destructorHandler(n);
|
Language::destructorHandler(n);
|
||||||
have_destructor = 1;
|
have_destructor = 1;
|
||||||
destructor_action = Getattr(n,"wrap:action");
|
destructor_action = Getattr(n, "wrap:action");
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1043,28 +1033,28 @@ virtual int constantWrapper(Node *n) {
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
* external runtime generation
|
* external runtime generation
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* This is to support the usage
|
/* This is to support the usage
|
||||||
SWIG -external-runtime <filename>
|
SWIG -external-runtime <filename>
|
||||||
The code consists of two functions:
|
The code consists of two functions:
|
||||||
String *runtimeCode() // returns a large string with all the runtimes in
|
String *runtimeCode() // returns a large string with all the runtimes in
|
||||||
String *defaultExternalRuntimeFilename() // returns the default filename
|
String *defaultExternalRuntimeFilename() // returns the default filename
|
||||||
I am writing a generic solution, even though SWIG-Lua only has one file right now...
|
I am writing a generic solution, even though SWIG-Lua only has one file right now...
|
||||||
*/
|
*/
|
||||||
String *runtimeCode() {
|
String *runtimeCode() {
|
||||||
String *s = NewString("");
|
String *s = NewString("");
|
||||||
const char* filenames[]={"luarun.swg",0}; // must be 0 termiated
|
const char *filenames[] = { "luarun.swg", 0 }; // must be 0 termiated
|
||||||
String *sfile;
|
String *sfile;
|
||||||
for (int i=0;filenames[i]!=0;i++) {
|
for (int i = 0; filenames[i] != 0; i++) {
|
||||||
sfile = Swig_include_sys(filenames[i]);
|
sfile = Swig_include_sys(filenames[i]);
|
||||||
if (!sfile) {
|
if (!sfile) {
|
||||||
Printf(stderr, "*** Unable to open '%s'\n",filenames[i]);
|
Printf(stderr, "*** Unable to open '%s'\n", filenames[i]);
|
||||||
} else {
|
} else {
|
||||||
Append(s, sfile);
|
Append(s, sfile);
|
||||||
Delete(sfile);
|
Delete(sfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1107,8 +1097,6 @@ NEW LANGUAGE NOTE:END ************************************************/
|
||||||
* swig_lua() - Instantiate module
|
* swig_lua() - Instantiate module
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
extern "C" Language *
|
extern "C" Language *swig_lua(void) {
|
||||||
swig_lua(void) {
|
|
||||||
return new LUA();
|
return new LUA();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -12,19 +12,16 @@ char cvsroot_module_cxx[] = "$Header$";
|
||||||
#include "swigmod.h"
|
#include "swigmod.h"
|
||||||
|
|
||||||
struct Module {
|
struct Module {
|
||||||
ModuleFactory fac;
|
ModuleFactory fac;
|
||||||
char *name;
|
char *name;
|
||||||
Module *next;
|
Module *next;
|
||||||
Module(const char *n, ModuleFactory f) {
|
Module(const char *n, ModuleFactory f) {
|
||||||
fac = f;
|
fac = f;
|
||||||
name = new char[strlen(n)+1];
|
name = new char[strlen(n) + 1];
|
||||||
strcpy(name, n);
|
strcpy(name, n);
|
||||||
next = 0;
|
next = 0;
|
||||||
}
|
} ~Module() {
|
||||||
|
delete[]name;
|
||||||
~Module()
|
|
||||||
{
|
|
||||||
delete[] name;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -37,7 +34,7 @@ static Module *modules = 0;
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Swig_register_module(const char *n, ModuleFactory f) {
|
void Swig_register_module(const char *n, ModuleFactory f) {
|
||||||
Module *m = new Module(n,f);
|
Module *m = new Module(n, f);
|
||||||
m->next = modules;
|
m->next = modules;
|
||||||
modules = m;
|
modules = m;
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +48,7 @@ void Swig_register_module(const char *n, ModuleFactory f) {
|
||||||
ModuleFactory Swig_find_module(const char *name) {
|
ModuleFactory Swig_find_module(const char *name) {
|
||||||
Module *m = modules;
|
Module *m = modules;
|
||||||
while (m) {
|
while (m) {
|
||||||
if (strcmp(m->name,name) == 0) {
|
if (strcmp(m->name, name) == 0) {
|
||||||
return m->fac;
|
return m->fac;
|
||||||
}
|
}
|
||||||
m = m->next;
|
m = m->next;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -24,19 +24,19 @@
|
||||||
* address, etc. for extension objects. Should we do something here?
|
* address, etc. for extension objects. Should we do something here?
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char cvsroot_pike_cxx[] = "$Header$";
|
char cvsroot_pike_cxx[] = "$Header$";
|
||||||
|
|
||||||
#include "swigmod.h"
|
#include "swigmod.h"
|
||||||
|
|
||||||
#include <ctype.h> // for isalnum()
|
#include <ctype.h> // for isalnum()
|
||||||
|
|
||||||
static const char *usage = (char *)"\
|
static const char *usage = (char *) "\
|
||||||
Pike Options (available with -pike)\n\
|
Pike Options (available with -pike)\n\
|
||||||
[None]\n\
|
[None]\n\
|
||||||
\n";
|
\n";
|
||||||
|
|
||||||
class PIKE : public Language {
|
class PIKE:public Language {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
File *f_runtime;
|
File *f_runtime;
|
||||||
|
|
@ -47,7 +47,7 @@ private:
|
||||||
|
|
||||||
String *PrefixPlusUnderscore;
|
String *PrefixPlusUnderscore;
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
// Wrap modes
|
// Wrap modes
|
||||||
enum {
|
enum {
|
||||||
NO_CPP,
|
NO_CPP,
|
||||||
|
|
@ -68,7 +68,7 @@ public:
|
||||||
* Initialize member data
|
* Initialize member data
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
PIKE() {
|
PIKE() {
|
||||||
f_runtime = 0;
|
f_runtime = 0;
|
||||||
f_header = 0;
|
f_header = 0;
|
||||||
f_wrappers = 0;
|
f_wrappers = 0;
|
||||||
|
|
@ -83,8 +83,8 @@ public:
|
||||||
*
|
*
|
||||||
* Parse command line options and initializes variables.
|
* Parse command line options and initializes variables.
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
virtual void main(int argc, char *argv[]) {
|
virtual void main(int argc, char *argv[]) {
|
||||||
|
|
||||||
/* Set location of SWIG library */
|
/* Set location of SWIG library */
|
||||||
SWIG_library_directory("pike");
|
SWIG_library_directory("pike");
|
||||||
|
|
@ -92,8 +92,8 @@ public:
|
||||||
/* Look for certain command line options */
|
/* Look for certain command line options */
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (argv[i]) {
|
if (argv[i]) {
|
||||||
if (strcmp(argv[i],"-help") == 0) {
|
if (strcmp(argv[i], "-help") == 0) {
|
||||||
fputs(usage,stdout);
|
fputs(usage, stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -101,12 +101,12 @@ public:
|
||||||
/* Add a symbol to the parser for conditional compilation */
|
/* Add a symbol to the parser for conditional compilation */
|
||||||
Preprocessor_define("SWIGPIKE 1", 0);
|
Preprocessor_define("SWIGPIKE 1", 0);
|
||||||
|
|
||||||
/* Set language-specific configuration file */
|
/* Set language-specific configuration file */
|
||||||
SWIG_config_file("pike.swg");
|
SWIG_config_file("pike.swg");
|
||||||
|
|
||||||
/* Set typemap language */
|
/* Set typemap language */
|
||||||
SWIG_typemap_lang("pike");
|
SWIG_typemap_lang("pike");
|
||||||
|
|
||||||
/* Enable overloaded methods support */
|
/* Enable overloaded methods support */
|
||||||
allow_overloading();
|
allow_overloading();
|
||||||
}
|
}
|
||||||
|
|
@ -118,10 +118,10 @@ public:
|
||||||
virtual int top(Node *n) {
|
virtual int top(Node *n) {
|
||||||
/* Get the module name */
|
/* Get the module name */
|
||||||
String *module = Getattr(n, "name");
|
String *module = Getattr(n, "name");
|
||||||
|
|
||||||
/* Get the output file name */
|
/* Get the output file name */
|
||||||
String *outfile = Getattr(n, "outfile");
|
String *outfile = Getattr(n, "outfile");
|
||||||
|
|
||||||
/* Open the output file */
|
/* Open the output file */
|
||||||
f_runtime = NewFile(outfile, "w");
|
f_runtime = NewFile(outfile, "w");
|
||||||
if (!f_runtime) {
|
if (!f_runtime) {
|
||||||
|
|
@ -140,26 +140,26 @@ public:
|
||||||
Swig_register_filebyname("init", f_init);
|
Swig_register_filebyname("init", f_init);
|
||||||
Swig_register_filebyname("classInit", f_classInit);
|
Swig_register_filebyname("classInit", f_classInit);
|
||||||
|
|
||||||
/* Standard stuff for the SWIG runtime section */
|
/* Standard stuff for the SWIG runtime section */
|
||||||
Swig_banner(f_runtime);
|
Swig_banner(f_runtime);
|
||||||
|
|
||||||
Printf(f_header, "#define SWIG_init pike_module_init\n");
|
Printf(f_header, "#define SWIG_init pike_module_init\n");
|
||||||
Printf(f_header, "#define SWIG_name \"%s\"\n\n", module);
|
Printf(f_header, "#define SWIG_name \"%s\"\n\n", module);
|
||||||
|
|
||||||
/* Change naming scheme for constructors and destructors */
|
/* Change naming scheme for constructors and destructors */
|
||||||
Swig_name_register("construct","%c_create");
|
Swig_name_register("construct", "%c_create");
|
||||||
Swig_name_register("destroy","%c_destroy");
|
Swig_name_register("destroy", "%c_destroy");
|
||||||
|
|
||||||
/* Current wrap type */
|
/* Current wrap type */
|
||||||
current = NO_CPP;
|
current = NO_CPP;
|
||||||
|
|
||||||
/* Emit code for children */
|
/* Emit code for children */
|
||||||
Language::top(n);
|
Language::top(n);
|
||||||
|
|
||||||
/* Close the initialization function */
|
/* Close the initialization function */
|
||||||
Printf(f_init, "}\n");
|
Printf(f_init, "}\n");
|
||||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||||
|
|
||||||
/* Close all of the files */
|
/* Close all of the files */
|
||||||
Dump(f_header, f_runtime);
|
Dump(f_header, f_runtime);
|
||||||
Dump(f_wrappers, f_runtime);
|
Dump(f_wrappers, f_runtime);
|
||||||
|
|
@ -176,7 +176,7 @@ public:
|
||||||
/* Done */
|
/* Done */
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* validIdentifier()
|
* validIdentifier()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
@ -187,10 +187,12 @@ public:
|
||||||
const char *c1 = c0 + 1;
|
const char *c1 = c0 + 1;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == '`' && c == c0) {
|
if (*c == '`' && c == c0) {
|
||||||
c++; continue;
|
c++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if ((*c == '+' || *c == '-' || *c == '*' || *c == '/') && c == c1) {
|
if ((*c == '+' || *c == '-' || *c == '*' || *c == '/') && c == c1) {
|
||||||
c++; continue;
|
c++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (!(isalnum(*c) || (*c == '_')))
|
if (!(isalnum(*c) || (*c == '_')))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -198,19 +200,19 @@ public:
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* importDirective()
|
* importDirective()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int importDirective(Node *n) {
|
virtual int importDirective(Node *n) {
|
||||||
String *modname = Getattr(n,"module");
|
String *modname = Getattr(n, "module");
|
||||||
if (modname) {
|
if (modname) {
|
||||||
Printf(f_init,"pike_require(\"%s\");\n", modname);
|
Printf(f_init, "pike_require(\"%s\");\n", modname);
|
||||||
}
|
}
|
||||||
return Language::importDirective(n);
|
return Language::importDirective(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* strip()
|
* strip()
|
||||||
*
|
*
|
||||||
|
|
@ -235,26 +237,26 @@ public:
|
||||||
void add_method(const DOHString_or_char *name, const DOHString_or_char *function, const DOHString_or_char *description) {
|
void add_method(const DOHString_or_char *name, const DOHString_or_char *function, const DOHString_or_char *description) {
|
||||||
String *rename = NULL;
|
String *rename = NULL;
|
||||||
switch (current) {
|
switch (current) {
|
||||||
case NO_CPP:
|
case NO_CPP:
|
||||||
rename = NewString(name);
|
rename = NewString(name);
|
||||||
Printf(f_init, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description);
|
Printf(f_init, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description);
|
||||||
break;
|
break;
|
||||||
case STATIC_FUNC:
|
case STATIC_FUNC:
|
||||||
case STATIC_VAR:
|
case STATIC_VAR:
|
||||||
rename = NewString(name);
|
rename = NewString(name);
|
||||||
Printf(f_init, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description);
|
Printf(f_init, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description);
|
||||||
break;
|
break;
|
||||||
case CONSTRUCTOR:
|
case CONSTRUCTOR:
|
||||||
case DESTRUCTOR:
|
case DESTRUCTOR:
|
||||||
case MEMBER_FUNC:
|
case MEMBER_FUNC:
|
||||||
case MEMBER_VAR:
|
case MEMBER_VAR:
|
||||||
rename = strip(name);
|
rename = strip(name);
|
||||||
Printf(f_classInit, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description);
|
Printf(f_classInit, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description);
|
||||||
break;
|
break;
|
||||||
case CLASS_CONST:
|
case CLASS_CONST:
|
||||||
assert(false); // shouldn't have gotten here for CLASS_CONST nodes
|
assert(false); // shouldn't have gotten here for CLASS_CONST nodes
|
||||||
default:
|
default:
|
||||||
assert(false); // what is this?
|
assert(false); // what is this?
|
||||||
}
|
}
|
||||||
Delete(rename);
|
Delete(rename);
|
||||||
}
|
}
|
||||||
|
|
@ -267,83 +269,83 @@ public:
|
||||||
|
|
||||||
virtual int functionWrapper(Node *n) {
|
virtual int functionWrapper(Node *n) {
|
||||||
|
|
||||||
String *name = Getattr(n,"name");
|
String *name = Getattr(n, "name");
|
||||||
String *iname = Getattr(n,"sym:name");
|
String *iname = Getattr(n, "sym:name");
|
||||||
SwigType *d = Getattr(n,"type");
|
SwigType *d = Getattr(n, "type");
|
||||||
ParmList *l = Getattr(n,"parms");
|
ParmList *l = Getattr(n, "parms");
|
||||||
|
|
||||||
Parm *p;
|
Parm *p;
|
||||||
String *tm;
|
String *tm;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
String *overname = 0;
|
String *overname = 0;
|
||||||
if (Getattr(n,"sym:overloaded")) {
|
if (Getattr(n, "sym:overloaded")) {
|
||||||
overname = Getattr(n,"sym:overname");
|
overname = Getattr(n, "sym:overname");
|
||||||
} else {
|
} else {
|
||||||
if (!addSymbol(iname,n)) return SWIG_ERROR;
|
if (!addSymbol(iname, n))
|
||||||
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wrapper *f = NewWrapper();
|
Wrapper *f = NewWrapper();
|
||||||
|
|
||||||
/* Write code to extract function parameters. */
|
/* Write code to extract function parameters. */
|
||||||
emit_args(d, l, f);
|
emit_args(d, l, f);
|
||||||
|
|
||||||
/* Attach the standard typemaps */
|
/* Attach the standard typemaps */
|
||||||
emit_attach_parmmaps(l,f);
|
emit_attach_parmmaps(l, f);
|
||||||
Setattr(n,"wrap:parms",l);
|
Setattr(n, "wrap:parms", l);
|
||||||
|
|
||||||
/* Get number of required and total arguments */
|
/* Get number of required and total arguments */
|
||||||
int num_arguments = emit_num_arguments(l);
|
int num_arguments = emit_num_arguments(l);
|
||||||
int varargs = emit_isvarargs(l);
|
int varargs = emit_isvarargs(l);
|
||||||
|
|
||||||
/* Which input argument to start with? */
|
/* Which input argument to start with? */
|
||||||
int start = (current == MEMBER_FUNC || current == MEMBER_VAR || current == DESTRUCTOR) ? 1 : 0;
|
int start = (current == MEMBER_FUNC || current == MEMBER_VAR || current == DESTRUCTOR) ? 1 : 0;
|
||||||
|
|
||||||
/* Offset to skip over the attribute name */
|
/* Offset to skip over the attribute name */
|
||||||
// int offset = (current == MEMBER_VAR) ? 1 : 0;
|
// int offset = (current == MEMBER_VAR) ? 1 : 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
String *wname = Swig_name_wrapper(iname);
|
String *wname = Swig_name_wrapper(iname);
|
||||||
if (overname) {
|
if (overname) {
|
||||||
Append(wname,overname);
|
Append(wname, overname);
|
||||||
}
|
}
|
||||||
|
|
||||||
Printv(f->def, "static void ", wname, "(INT32 args) {", NIL);
|
Printv(f->def, "static void ", wname, "(INT32 args) {", NIL);
|
||||||
|
|
||||||
/* Generate code for argument marshalling */
|
/* Generate code for argument marshalling */
|
||||||
String *description = NewString("");
|
String *description = NewString("");
|
||||||
char source[64];
|
char source[64];
|
||||||
for (i = 0, p = l; i < num_arguments; i++) {
|
for (i = 0, p = l; i < num_arguments; i++) {
|
||||||
|
|
||||||
while (checkAttribute(p,"tmap:in:numinputs","0")) {
|
while (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *pt = Getattr(p,"type");
|
SwigType *pt = Getattr(p, "type");
|
||||||
String *ln = Getattr(p,"lname");
|
String *ln = Getattr(p, "lname");
|
||||||
|
|
||||||
if (i < start) {
|
if (i < start) {
|
||||||
String *lstr = SwigType_lstr(pt,0);
|
String *lstr = SwigType_lstr(pt, 0);
|
||||||
Printf(f->code, "%s = (%s) THIS;\n", ln, lstr);
|
Printf(f->code, "%s = (%s) THIS;\n", ln, lstr);
|
||||||
Delete(lstr);
|
Delete(lstr);
|
||||||
} else {
|
} else {
|
||||||
/* Look for an input typemap */
|
/* Look for an input typemap */
|
||||||
sprintf(source, "Pike_sp[%d-args]", i-start+offset);
|
sprintf(source, "Pike_sp[%d-args]", i - start + offset);
|
||||||
if ((tm = Getattr(p,"tmap:in"))) {
|
if ((tm = Getattr(p, "tmap:in"))) {
|
||||||
Replaceall(tm, "$source", source);
|
Replaceall(tm, "$source", source);
|
||||||
Replaceall(tm, "$target", ln);
|
Replaceall(tm, "$target", ln);
|
||||||
Replaceall(tm, "$input", source);
|
Replaceall(tm, "$input", source);
|
||||||
Setattr(p, "emit:input", source);
|
Setattr(p, "emit:input", source);
|
||||||
Printf(f->code, "%s\n", tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
String *pikedesc = Getattr(p, "tmap:in:pikedesc");
|
String *pikedesc = Getattr(p, "tmap:in:pikedesc");
|
||||||
if (pikedesc) {
|
if (pikedesc) {
|
||||||
Printv(description, pikedesc, " ", NIL);
|
Printv(description, pikedesc, " ", NIL);
|
||||||
}
|
}
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number,
|
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
|
||||||
"Unable to use type %s as a function argument.\n",SwigType_str(pt,0));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -352,30 +354,30 @@ public:
|
||||||
|
|
||||||
/* Check for trailing varargs */
|
/* Check for trailing varargs */
|
||||||
if (varargs) {
|
if (varargs) {
|
||||||
if (p && (tm = Getattr(p,"tmap:in"))) {
|
if (p && (tm = Getattr(p, "tmap:in"))) {
|
||||||
Replaceall(tm,"$input", "varargs");
|
Replaceall(tm, "$input", "varargs");
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert constraint checking code */
|
/* Insert constraint checking code */
|
||||||
for (p = l; p;) {
|
for (p = l; p;) {
|
||||||
if ((tm = Getattr(p,"tmap:check"))) {
|
if ((tm = Getattr(p, "tmap:check"))) {
|
||||||
Replaceall(tm,"$target",Getattr(p,"lname"));
|
Replaceall(tm, "$target", Getattr(p, "lname"));
|
||||||
Printv(f->code,tm,"\n",NIL);
|
Printv(f->code, tm, "\n", NIL);
|
||||||
p = Getattr(p,"tmap:check:next");
|
p = Getattr(p, "tmap:check:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert cleanup code */
|
/* Insert cleanup code */
|
||||||
String *cleanup = NewString("");
|
String *cleanup = NewString("");
|
||||||
for (p = l; p;) {
|
for (p = l; p;) {
|
||||||
if ((tm = Getattr(p,"tmap:freearg"))) {
|
if ((tm = Getattr(p, "tmap:freearg"))) {
|
||||||
Replaceall(tm,"$source",Getattr(p,"lname"));
|
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||||
Printv(cleanup,tm,"\n",NIL);
|
Printv(cleanup, tm, "\n", NIL);
|
||||||
p = Getattr(p,"tmap:freearg:next");
|
p = Getattr(p, "tmap:freearg:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
@ -384,20 +386,20 @@ public:
|
||||||
/* Insert argument output code */
|
/* Insert argument output code */
|
||||||
String *outarg = NewString("");
|
String *outarg = NewString("");
|
||||||
for (p = l; p;) {
|
for (p = l; p;) {
|
||||||
if ((tm = Getattr(p,"tmap:argout"))) {
|
if ((tm = Getattr(p, "tmap:argout"))) {
|
||||||
Replaceall(tm,"$source",Getattr(p,"lname"));
|
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||||
Replaceall(tm,"$target","resultobj");
|
Replaceall(tm, "$target", "resultobj");
|
||||||
Replaceall(tm,"$arg",Getattr(p,"emit:input"));
|
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
|
||||||
Replaceall(tm,"$input",Getattr(p,"emit:input"));
|
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||||
Printv(outarg,tm,"\n",NIL);
|
Printv(outarg, tm, "\n", NIL);
|
||||||
p = Getattr(p,"tmap:argout:next");
|
p = Getattr(p, "tmap:argout:next");
|
||||||
} else {
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit the function call */
|
/* Emit the function call */
|
||||||
emit_action(n,f);
|
emit_action(n, f);
|
||||||
|
|
||||||
/* Clear the return stack */
|
/* Clear the return stack */
|
||||||
Printf(f->code, "pop_n_elems(args);\n");
|
Printf(f->code, "pop_n_elems(args);\n");
|
||||||
|
|
@ -411,65 +413,64 @@ public:
|
||||||
} else {
|
} else {
|
||||||
// Wrapper_add_local(f, "resultobj", "struct object *resultobj");
|
// Wrapper_add_local(f, "resultobj", "struct object *resultobj");
|
||||||
Printv(description, ", ", NIL);
|
Printv(description, ", ", NIL);
|
||||||
if ((tm = Swig_typemap_lookup_new("out",n,"result",0))) {
|
if ((tm = Swig_typemap_lookup_new("out", n, "result", 0))) {
|
||||||
Replaceall(tm,"$source", "result");
|
Replaceall(tm, "$source", "result");
|
||||||
Replaceall(tm,"$target", "resultobj");
|
Replaceall(tm, "$target", "resultobj");
|
||||||
Replaceall(tm,"$result", "resultobj");
|
Replaceall(tm, "$result", "resultobj");
|
||||||
if (GetFlag(n,"feature:new")) {
|
if (GetFlag(n, "feature:new")) {
|
||||||
Replaceall(tm,"$owner","1");
|
Replaceall(tm, "$owner", "1");
|
||||||
} else {
|
} else {
|
||||||
Replaceall(tm,"$owner","0");
|
Replaceall(tm, "$owner", "0");
|
||||||
}
|
}
|
||||||
String *pikedesc = Getattr(n, "tmap:out:pikedesc");
|
String *pikedesc = Getattr(n, "tmap:out:pikedesc");
|
||||||
if (pikedesc) {
|
if (pikedesc) {
|
||||||
Printv(description, pikedesc, NIL);
|
Printv(description, pikedesc, NIL);
|
||||||
}
|
}
|
||||||
Printf(f->code,"%s\n", tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number,
|
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name);
|
||||||
"Unable to use return type %s in function %s.\n", SwigType_str(d,0), name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output argument output code */
|
/* Output argument output code */
|
||||||
Printv(f->code,outarg,NIL);
|
Printv(f->code, outarg, NIL);
|
||||||
|
|
||||||
/* Output cleanup code */
|
/* Output cleanup code */
|
||||||
Printv(f->code,cleanup,NIL);
|
Printv(f->code, cleanup, NIL);
|
||||||
|
|
||||||
/* Look to see if there is any newfree cleanup code */
|
/* Look to see if there is any newfree cleanup code */
|
||||||
if (GetFlag(n,"feature:new")) {
|
if (GetFlag(n, "feature:new")) {
|
||||||
if ((tm = Swig_typemap_lookup_new("newfree",n,"result",0))) {
|
if ((tm = Swig_typemap_lookup_new("newfree", n, "result", 0))) {
|
||||||
Replaceall(tm,"$source","result");
|
Replaceall(tm, "$source", "result");
|
||||||
Printf(f->code,"%s\n",tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if there is any return cleanup code */
|
/* See if there is any return cleanup code */
|
||||||
if ((tm = Swig_typemap_lookup_new("ret", n, "result", 0))) {
|
if ((tm = Swig_typemap_lookup_new("ret", n, "result", 0))) {
|
||||||
Replaceall(tm,"$source","result");
|
Replaceall(tm, "$source", "result");
|
||||||
Printf(f->code,"%s\n",tm);
|
Printf(f->code, "%s\n", tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the function */
|
/* Close the function */
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
|
|
||||||
/* Substitute the cleanup code */
|
/* Substitute the cleanup code */
|
||||||
Replaceall(f->code,"$cleanup",cleanup);
|
Replaceall(f->code, "$cleanup", cleanup);
|
||||||
|
|
||||||
/* Substitute the function name */
|
/* Substitute the function name */
|
||||||
Replaceall(f->code,"$symname",iname);
|
Replaceall(f->code, "$symname", iname);
|
||||||
Replaceall(f->code,"$result","resultobj");
|
Replaceall(f->code, "$result", "resultobj");
|
||||||
|
|
||||||
/* Dump the function out */
|
/* Dump the function out */
|
||||||
Wrapper_print(f,f_wrappers);
|
Wrapper_print(f, f_wrappers);
|
||||||
|
|
||||||
/* Now register the function with the interpreter. */
|
/* Now register the function with the interpreter. */
|
||||||
if (!Getattr(n,"sym:overloaded")) {
|
if (!Getattr(n, "sym:overloaded")) {
|
||||||
add_method(iname, wname, description);
|
add_method(iname, wname, description);
|
||||||
} else {
|
} else {
|
||||||
Setattr(n,"wrap:name", wname);
|
Setattr(n, "wrap:name", wname);
|
||||||
if (!Getattr(n,"sym:nextSibling")) {
|
if (!Getattr(n, "sym:nextSibling")) {
|
||||||
dispatchFunction(n);
|
dispatchFunction(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -495,32 +496,32 @@ public:
|
||||||
int maxargs;
|
int maxargs;
|
||||||
String *tmp = NewString("");
|
String *tmp = NewString("");
|
||||||
String *dispatch = Swig_overload_dispatch(n, "%s(args); return;", &maxargs);
|
String *dispatch = Swig_overload_dispatch(n, "%s(args); return;", &maxargs);
|
||||||
|
|
||||||
/* Generate a dispatch wrapper for all overloaded functions */
|
/* Generate a dispatch wrapper for all overloaded functions */
|
||||||
|
|
||||||
Wrapper *f = NewWrapper();
|
Wrapper *f = NewWrapper();
|
||||||
String *symname = Getattr(n,"sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
String *wname = Swig_name_wrapper(symname);
|
String *wname = Swig_name_wrapper(symname);
|
||||||
|
|
||||||
Printf(f->def, "static void %s(INT32 args) {", wname);
|
Printf(f->def, "static void %s(INT32 args) {", wname);
|
||||||
|
|
||||||
Wrapper_add_local(f, "argc", "INT32 argc");
|
Wrapper_add_local(f, "argc", "INT32 argc");
|
||||||
Printf(tmp, "struct svalue argv[%d]", maxargs);
|
Printf(tmp, "struct svalue argv[%d]", maxargs);
|
||||||
Wrapper_add_local(f, "argv", tmp);
|
Wrapper_add_local(f, "argv", tmp);
|
||||||
Wrapper_add_local(f, "ii", "INT32 ii");
|
Wrapper_add_local(f, "ii", "INT32 ii");
|
||||||
|
|
||||||
Printf(f->code, "argc = args;\n");
|
Printf(f->code, "argc = args;\n");
|
||||||
Printf(f->code, "for (ii = 0; (ii < argc) && (ii < %d); ii++) {\n", maxargs);
|
Printf(f->code, "for (ii = 0; (ii < argc) && (ii < %d); ii++) {\n", maxargs);
|
||||||
Printf(f->code, "argv[ii] = Pike_sp[ii-args];\n");
|
Printf(f->code, "argv[ii] = Pike_sp[ii-args];\n");
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
|
|
||||||
Replaceall(dispatch, "$args", "self, args");
|
Replaceall(dispatch, "$args", "self, args");
|
||||||
Printv(f->code, dispatch, "\n", NIL);
|
Printv(f->code, dispatch, "\n", NIL);
|
||||||
Printf(f->code, "Pike_error(\"No matching function for overloaded '%s'.\");\n", symname);
|
Printf(f->code, "Pike_error(\"No matching function for overloaded '%s'.\");\n", symname);
|
||||||
Printv(f->code, "}\n", NIL);
|
Printv(f->code, "}\n", NIL);
|
||||||
|
|
||||||
Wrapper_print(f, f_wrappers);
|
Wrapper_print(f, f_wrappers);
|
||||||
|
|
||||||
String *description = NewString("");
|
String *description = NewString("");
|
||||||
Printf(description, "tAny,");
|
Printf(description, "tAny,");
|
||||||
if (current == CONSTRUCTOR || current == DESTRUCTOR) {
|
if (current == CONSTRUCTOR || current == DESTRUCTOR) {
|
||||||
|
|
@ -553,12 +554,12 @@ public:
|
||||||
|
|
||||||
virtual int constantWrapper(Node *n) {
|
virtual int constantWrapper(Node *n) {
|
||||||
|
|
||||||
Swig_require("constantWrapper",n, "*sym:name", "type", "value", NIL);
|
Swig_require("constantWrapper", n, "*sym:name", "type", "value", NIL);
|
||||||
|
|
||||||
String *symname = Getattr(n, "sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
SwigType *type = Getattr(n, "type");
|
SwigType *type = Getattr(n, "type");
|
||||||
String *value = Getattr(n, "value");
|
String *value = Getattr(n, "value");
|
||||||
|
|
||||||
/* Special hook for member pointer */
|
/* Special hook for member pointer */
|
||||||
if (SwigType_type(type) == T_MPOINTER) {
|
if (SwigType_type(type) == T_MPOINTER) {
|
||||||
String *wname = Swig_name_wrapper(symname);
|
String *wname = Swig_name_wrapper(symname);
|
||||||
|
|
@ -575,12 +576,11 @@ public:
|
||||||
Replaceall(tm, "$value", value);
|
Replaceall(tm, "$value", value);
|
||||||
Printf(f_init, "%s\n", tm);
|
Printf(f_init, "%s\n", tm);
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number,
|
Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value %s = %s\n", SwigType_str(type, 0), value);
|
||||||
"Unsupported constant value %s = %s\n", SwigType_str(type, 0), value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Swig_restore(n);
|
Swig_restore(n);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -590,19 +590,20 @@ public:
|
||||||
|
|
||||||
virtual int nativeWrapper(Node *n) {
|
virtual int nativeWrapper(Node *n) {
|
||||||
// return Language::nativeWrapper(n);
|
// return Language::nativeWrapper(n);
|
||||||
String *name = Getattr(n,"sym:name");
|
String *name = Getattr(n, "sym:name");
|
||||||
String *wrapname = Getattr(n,"wrap:name");
|
String *wrapname = Getattr(n, "wrap:name");
|
||||||
|
|
||||||
if (!addSymbol(wrapname,n)) return SWIG_ERROR;
|
if (!addSymbol(wrapname, n))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
|
||||||
add_method(name, wrapname,0);
|
add_method(name, wrapname, 0);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* enumDeclaration()
|
* enumDeclaration()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int enumDeclaration(Node *n) {
|
virtual int enumDeclaration(Node *n) {
|
||||||
return Language::enumDeclaration(n);
|
return Language::enumDeclaration(n);
|
||||||
}
|
}
|
||||||
|
|
@ -610,7 +611,7 @@ public:
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* enumvalueDeclaration()
|
* enumvalueDeclaration()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int enumvalueDeclaration(Node *n) {
|
virtual int enumvalueDeclaration(Node *n) {
|
||||||
return Language::enumvalueDeclaration(n);
|
return Language::enumvalueDeclaration(n);
|
||||||
}
|
}
|
||||||
|
|
@ -622,7 +623,7 @@ public:
|
||||||
virtual int classDeclaration(Node *n) {
|
virtual int classDeclaration(Node *n) {
|
||||||
return Language::classDeclaration(n);
|
return Language::classDeclaration(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* classHandler()
|
* classHandler()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
@ -632,45 +633,45 @@ public:
|
||||||
String *symname = Getattr(n, "sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
if (!addSymbol(symname, n))
|
if (!addSymbol(symname, n))
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
|
|
||||||
PrefixPlusUnderscore = NewStringf("%s_", getClassPrefix());
|
PrefixPlusUnderscore = NewStringf("%s_", getClassPrefix());
|
||||||
|
|
||||||
Printf(f_classInit, "start_new_program();\n");
|
Printf(f_classInit, "start_new_program();\n");
|
||||||
|
|
||||||
/* Handle inheritance */
|
/* Handle inheritance */
|
||||||
List *baselist = Getattr(n,"bases");
|
List *baselist = Getattr(n, "bases");
|
||||||
if (baselist && Len(baselist) > 0) {
|
if (baselist && Len(baselist) > 0) {
|
||||||
Iterator base = First(baselist);
|
Iterator base = First(baselist);
|
||||||
while (base.item) {
|
while (base.item) {
|
||||||
String *basename = Getattr(base.item,"name");
|
String *basename = Getattr(base.item, "name");
|
||||||
SwigType *basetype = NewString(basename);
|
SwigType *basetype = NewString(basename);
|
||||||
SwigType_add_pointer(basetype);
|
SwigType_add_pointer(basetype);
|
||||||
SwigType_remember(basetype);
|
SwigType_remember(basetype);
|
||||||
String *basemangle = SwigType_manglestr(basetype);
|
String *basemangle = SwigType_manglestr(basetype);
|
||||||
Printf(f_classInit, "low_inherit((struct program *) SWIGTYPE%s->clientdata, 0, 0, 0, 0, 0);\n", basemangle);
|
Printf(f_classInit, "low_inherit((struct program *) SWIGTYPE%s->clientdata, 0, 0, 0, 0, 0);\n", basemangle);
|
||||||
Delete(basemangle);
|
Delete(basemangle);
|
||||||
Delete(basetype);
|
Delete(basetype);
|
||||||
base = Next(base);
|
base = Next(base);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Printf(f_classInit, "ADD_STORAGE(swig_object_wrapper);\n");
|
Printf(f_classInit, "ADD_STORAGE(swig_object_wrapper);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Language::classHandler(n);
|
Language::classHandler(n);
|
||||||
|
|
||||||
/* Accessors for member variables */
|
/* Accessors for member variables */
|
||||||
/*
|
/*
|
||||||
List *membervariables = Getattr(n,"membervariables");
|
List *membervariables = Getattr(n,"membervariables");
|
||||||
if (membervariables && Len(membervariables) > 0) {
|
if (membervariables && Len(membervariables) > 0) {
|
||||||
membervariableAccessors(membervariables);
|
membervariableAccessors(membervariables);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Done, close the class and dump its definition to the init function */
|
/* Done, close the class and dump its definition to the init function */
|
||||||
Printf(f_classInit, "add_program_constant(\"%s\", pr = end_program(), 0);\n", symname);
|
Printf(f_classInit, "add_program_constant(\"%s\", pr = end_program(), 0);\n", symname);
|
||||||
Dump(f_classInit, f_init);
|
Dump(f_classInit, f_init);
|
||||||
Clear(f_classInit);
|
Clear(f_classInit);
|
||||||
|
|
||||||
SwigType *tt = NewString(symname);
|
SwigType *tt = NewString(symname);
|
||||||
SwigType_add_pointer(tt);
|
SwigType_add_pointer(tt);
|
||||||
SwigType_remember(tt);
|
SwigType_remember(tt);
|
||||||
|
|
@ -678,8 +679,9 @@ public:
|
||||||
Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) pr);\n", tm);
|
Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) pr);\n", tm);
|
||||||
Delete(tm);
|
Delete(tm);
|
||||||
Delete(tt);
|
Delete(tt);
|
||||||
|
|
||||||
Delete(PrefixPlusUnderscore); PrefixPlusUnderscore = 0;
|
Delete(PrefixPlusUnderscore);
|
||||||
|
PrefixPlusUnderscore = 0;
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -720,7 +722,7 @@ public:
|
||||||
current = NO_CPP;
|
current = NO_CPP;
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* membervariableAccessors()
|
* membervariableAccessors()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
@ -730,18 +732,18 @@ public:
|
||||||
Iterator i;
|
Iterator i;
|
||||||
bool need_setter;
|
bool need_setter;
|
||||||
String *funcname;
|
String *funcname;
|
||||||
|
|
||||||
/* If at least one of them is mutable, we need a setter */
|
/* If at least one of them is mutable, we need a setter */
|
||||||
need_setter = false;
|
need_setter = false;
|
||||||
i = First(membervariables);
|
i = First(membervariables);
|
||||||
while (i.item) {
|
while (i.item) {
|
||||||
if (!GetFlag(i.item, "feature:immutable")) {
|
if (!GetFlag(i.item, "feature:immutable")) {
|
||||||
need_setter = true;
|
need_setter = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i = Next(i);
|
i = Next(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a function to set the values of the (mutable) variables */
|
/* Create a function to set the values of the (mutable) variables */
|
||||||
if (need_setter) {
|
if (need_setter) {
|
||||||
Wrapper *wrapper = NewWrapper();
|
Wrapper *wrapper = NewWrapper();
|
||||||
|
|
@ -749,7 +751,7 @@ public:
|
||||||
String *wname = Swig_name_wrapper(setter);
|
String *wname = Swig_name_wrapper(setter);
|
||||||
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
|
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
|
||||||
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
|
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
|
||||||
|
|
||||||
i = First(membervariables);
|
i = First(membervariables);
|
||||||
while (i.item) {
|
while (i.item) {
|
||||||
if (!GetFlag(i.item, "feature:immutable")) {
|
if (!GetFlag(i.item, "feature:immutable")) {
|
||||||
|
|
@ -770,7 +772,7 @@ public:
|
||||||
|
|
||||||
/* Dump wrapper code to the output file */
|
/* Dump wrapper code to the output file */
|
||||||
Wrapper_print(wrapper, f_wrappers);
|
Wrapper_print(wrapper, f_wrappers);
|
||||||
|
|
||||||
/* Register it with Pike */
|
/* Register it with Pike */
|
||||||
String *description = NewString("tStr tFloat, tVoid");
|
String *description = NewString("tStr tFloat, tVoid");
|
||||||
add_method("`->=", wname, description);
|
add_method("`->=", wname, description);
|
||||||
|
|
@ -781,7 +783,7 @@ public:
|
||||||
Delete(setter);
|
Delete(setter);
|
||||||
DelWrapper(wrapper);
|
DelWrapper(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a function to get the values of the (mutable) variables */
|
/* Create a function to get the values of the (mutable) variables */
|
||||||
Wrapper *wrapper = NewWrapper();
|
Wrapper *wrapper = NewWrapper();
|
||||||
String *getter = Swig_name_member(getClassPrefix(), (char *) "`->");
|
String *getter = Swig_name_member(getClassPrefix(), (char *) "`->");
|
||||||
|
|
@ -807,12 +809,12 @@ public:
|
||||||
|
|
||||||
/* Dump wrapper code to the output file */
|
/* Dump wrapper code to the output file */
|
||||||
Wrapper_print(wrapper, f_wrappers);
|
Wrapper_print(wrapper, f_wrappers);
|
||||||
|
|
||||||
/* Register it with Pike */
|
/* Register it with Pike */
|
||||||
String *description = NewString("tStr, tMix");
|
String *description = NewString("tStr, tMix");
|
||||||
add_method("`->", wname, description);
|
add_method("`->", wname, description);
|
||||||
Delete(description);
|
Delete(description);
|
||||||
|
|
||||||
/* Clean up */
|
/* Clean up */
|
||||||
Delete(wname);
|
Delete(wname);
|
||||||
Delete(getter);
|
Delete(getter);
|
||||||
|
|
@ -824,12 +826,12 @@ public:
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int membervariableHandler(Node *n) {
|
virtual int membervariableHandler(Node *n) {
|
||||||
List *membervariables = Getattr(getCurrentClass(),"membervariables");
|
List *membervariables = Getattr(getCurrentClass(), "membervariables");
|
||||||
if (!membervariables) {
|
if (!membervariables) {
|
||||||
membervariables = NewList();
|
membervariables = NewList();
|
||||||
Setattr(getCurrentClass(),"membervariables",membervariables);
|
Setattr(getCurrentClass(), "membervariables", membervariables);
|
||||||
}
|
}
|
||||||
Append(membervariables,n);
|
Append(membervariables, n);
|
||||||
current = MEMBER_VAR;
|
current = MEMBER_VAR;
|
||||||
Language::membervariableHandler(n);
|
Language::membervariableHandler(n);
|
||||||
current = NO_CPP;
|
current = NO_CPP;
|
||||||
|
|
@ -848,7 +850,7 @@ public:
|
||||||
current = NO_CPP;
|
current = NO_CPP;
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* memberconstantHandler()
|
* memberconstantHandler()
|
||||||
*
|
*
|
||||||
|
|
@ -878,9 +880,9 @@ public:
|
||||||
* swig_pike() - Instantiate module
|
* swig_pike() - Instantiate module
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static Language * new_swig_pike() {
|
static Language *new_swig_pike() {
|
||||||
return new PIKE();
|
return new PIKE();
|
||||||
}
|
}
|
||||||
extern "C" Language * swig_pike(void) {
|
extern "C" Language *swig_pike(void) {
|
||||||
return new_swig_pike();
|
return new_swig_pike();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -320,10 +320,9 @@ public:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Grab the name of the current class being processed so that we can
|
||||||
// Grab the name of the current class being processed so that we can
|
deal with members of that class. */
|
||||||
// deal with members of that class.
|
int classHandler(Node *n){
|
||||||
int classHandler(Node *n){
|
|
||||||
if(!ClassMemberTable)
|
if(!ClassMemberTable)
|
||||||
ClassMemberTable = NewHash();
|
ClassMemberTable = NewHash();
|
||||||
|
|
||||||
|
|
@ -333,6 +332,7 @@ public:
|
||||||
class_name = NULL;
|
class_name = NULL;
|
||||||
return status;
|
return status;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Not used:
|
// Not used:
|
||||||
String *runtimeCode();
|
String *runtimeCode();
|
||||||
|
|
||||||
|
|
@ -362,6 +362,7 @@ protected:
|
||||||
namespaceFunctions = NewList();
|
namespaceFunctions = NewList();
|
||||||
Append(namespaceFunctions, name);
|
Append(namespaceFunctions, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addNamespaceMethod(String *name) {
|
void addNamespaceMethod(String *name) {
|
||||||
if(!namespaceMethods)
|
if(!namespaceMethods)
|
||||||
namespaceMethods = NewList();
|
namespaceMethods = NewList();
|
||||||
|
|
@ -474,8 +475,7 @@ static int getFunctionPointerNumArgs(Node *n, SwigType *tt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void R::addSMethodInfo(String *name, String *argType, int nargs) {
|
||||||
R::addSMethodInfo(String *name, String *argType, int nargs) {
|
|
||||||
(void) argType;
|
(void) argType;
|
||||||
|
|
||||||
if(!SMethodInfo)
|
if(!SMethodInfo)
|
||||||
|
|
@ -2953,8 +2953,7 @@ void R::main(int argc, char *argv[]) {
|
||||||
Could make this work for String or File and then just store the resulting string
|
Could make this work for String or File and then just store the resulting string
|
||||||
rather than the collection of arguments and argc.
|
rather than the collection of arguments and argc.
|
||||||
*/
|
*/
|
||||||
int
|
int R::outputCommandLineArguments(File *out)
|
||||||
R::outputCommandLineArguments(File *out)
|
|
||||||
{
|
{
|
||||||
if(argc < 1 || !argv || !argv[0])
|
if(argc < 1 || !argv || !argv[0])
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
@ -2973,8 +2972,7 @@ R::outputCommandLineArguments(File *out)
|
||||||
/* How SWIG instantiates an object from this module.
|
/* How SWIG instantiates an object from this module.
|
||||||
See swigmain.cxx */
|
See swigmain.cxx */
|
||||||
extern "C"
|
extern "C"
|
||||||
Language *swig_r(void)
|
Language *swig_r(void) {
|
||||||
{
|
|
||||||
return new R();
|
return new R();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -18,32 +18,33 @@ S-Exp Options (available with -sexp)\n\
|
||||||
|
|
||||||
//static Node *view_top = 0;
|
//static Node *view_top = 0;
|
||||||
static File *out = 0;
|
static File *out = 0;
|
||||||
|
|
||||||
class Sexp : public Language {
|
class Sexp:public Language {
|
||||||
public:
|
public:
|
||||||
int indent_level;
|
int indent_level;
|
||||||
Sexp() : indent_level( 0 ) {}
|
Sexp():indent_level(0) {
|
||||||
virtual ~Sexp() {}
|
}
|
||||||
|
|
||||||
|
virtual ~ Sexp() {
|
||||||
|
}
|
||||||
|
|
||||||
virtual void main(int argc, char *argv[]) {
|
virtual void main(int argc, char *argv[]) {
|
||||||
SWIG_typemap_lang("sexp");
|
SWIG_typemap_lang("sexp");
|
||||||
for( int iX = 0; iX < argc; iX++ )
|
for (int iX = 0; iX < argc; iX++) {
|
||||||
{
|
if (strcmp(argv[iX], "-typemaplang") == 0) {
|
||||||
if( strcmp( argv[iX], "-typemaplang" ) == 0 )
|
Swig_mark_arg(iX);
|
||||||
{
|
iX++;
|
||||||
Swig_mark_arg (iX);
|
SWIG_typemap_lang(argv[iX]);
|
||||||
iX++;
|
Swig_mark_arg(iX);
|
||||||
SWIG_typemap_lang(argv[iX]);
|
continue;
|
||||||
Swig_mark_arg (iX);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if( strcmp( argv[iX], "-help" ) == 0 )
|
|
||||||
{
|
|
||||||
fputs( usage, stdout );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (strcmp(argv[iX], "-help") == 0) {
|
||||||
|
fputs(usage, stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add a symbol to the parser for conditional compilation
|
// Add a symbol to the parser for conditional compilation
|
||||||
Preprocessor_define("SWIGSEXP 1",0);
|
Preprocessor_define("SWIGSEXP 1", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DOHHash *print_circle_hash;
|
DOHHash *print_circle_hash;
|
||||||
|
|
@ -53,28 +54,25 @@ public:
|
||||||
bool need_newline;
|
bool need_newline;
|
||||||
|
|
||||||
/* Top of the parse tree */
|
/* Top of the parse tree */
|
||||||
virtual int top(Node *n)
|
virtual int top(Node *n) {
|
||||||
{
|
if (out == 0) {
|
||||||
if( out == 0 )
|
String *outfile = Getattr(n, "outfile");
|
||||||
{
|
Replaceall(outfile, "_wrap.cxx", ".lisp");
|
||||||
String *outfile = Getattr(n,"outfile");
|
Replaceall(outfile, "_wrap.c", ".lisp");
|
||||||
Replaceall(outfile,"_wrap.cxx", ".lisp");
|
out = NewFile(outfile, "w");
|
||||||
Replaceall(outfile,"_wrap.c", ".lisp");
|
if (!out) {
|
||||||
out = NewFile(outfile,"w");
|
FileErrorDisplay(outfile);
|
||||||
if (!out)
|
SWIG_exit(EXIT_FAILURE);
|
||||||
{
|
|
||||||
FileErrorDisplay(outfile);
|
|
||||||
SWIG_exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String *f_sink = NewString("");
|
String *f_sink = NewString("");
|
||||||
Swig_register_filebyname("header",f_sink);
|
Swig_register_filebyname("header", f_sink);
|
||||||
Swig_register_filebyname("wrapper",f_sink);
|
Swig_register_filebyname("wrapper", f_sink);
|
||||||
Swig_register_filebyname("runtime",f_sink);
|
Swig_register_filebyname("runtime", f_sink);
|
||||||
Swig_register_filebyname("init",f_sink);
|
Swig_register_filebyname("init", f_sink);
|
||||||
|
|
||||||
Language::top(n);
|
Language::top(n);
|
||||||
Printf( out, ";;; Lisp parse tree produced by SWIG\n" );
|
Printf(out, ";;; Lisp parse tree produced by SWIG\n");
|
||||||
print_circle_hash = DohNewHash();
|
print_circle_hash = DohNewHash();
|
||||||
print_circle_count = 0;
|
print_circle_count = 0;
|
||||||
hanging_parens = 0;
|
hanging_parens = 0;
|
||||||
|
|
@ -85,36 +83,32 @@ public:
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_indent()
|
void print_indent() {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < indent_level; i++)
|
for (i = 0; i < indent_level; i++) {
|
||||||
{
|
Printf(out, " ");
|
||||||
Printf(out, " ");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_paren(const String *oper)
|
void open_paren(const String *oper) {
|
||||||
{
|
|
||||||
flush_parens();
|
flush_parens();
|
||||||
Printf(out, "(");
|
Printf(out, "(");
|
||||||
if (oper) Printf(out, "%s ", oper);
|
if (oper)
|
||||||
|
Printf(out, "%s ", oper);
|
||||||
indent_level += 2;
|
indent_level += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void close_paren(bool neednewline = false)
|
void close_paren(bool neednewline = false) {
|
||||||
{
|
|
||||||
hanging_parens++;
|
hanging_parens++;
|
||||||
if (neednewline)
|
if (neednewline)
|
||||||
print_lazy_whitespace();
|
print_lazy_whitespace();
|
||||||
indent_level -= 2;
|
indent_level -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush_parens()
|
void flush_parens() {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
if (hanging_parens) {
|
if (hanging_parens) {
|
||||||
for (i = 0; i<hanging_parens; i++)
|
for (i = 0; i < hanging_parens; i++)
|
||||||
Printf(out, ")");
|
Printf(out, ")");
|
||||||
hanging_parens = 0;
|
hanging_parens = 0;
|
||||||
need_newline = true;
|
need_newline = true;
|
||||||
|
|
@ -125,71 +119,64 @@ public:
|
||||||
print_indent();
|
print_indent();
|
||||||
need_newline = false;
|
need_newline = false;
|
||||||
need_whitespace = false;
|
need_whitespace = false;
|
||||||
}
|
} else if (need_whitespace) {
|
||||||
else if (need_whitespace) {
|
|
||||||
Printf(out, " ");
|
Printf(out, " ");
|
||||||
need_whitespace = false;
|
need_whitespace = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_lazy_whitespace()
|
void print_lazy_whitespace() {
|
||||||
{
|
|
||||||
need_whitespace = 1;
|
need_whitespace = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_lazy_newline()
|
void print_lazy_newline() {
|
||||||
{
|
|
||||||
need_newline = 1;
|
need_newline = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool internal_key_p(DOH *key)
|
bool internal_key_p(DOH *key) {
|
||||||
{
|
return ((Cmp(key, "nodeType") == 0)
|
||||||
return ((Cmp(key,"nodeType") == 0)
|
|| (Cmp(key, "firstChild") == 0)
|
||||||
|| (Cmp(key,"firstChild") == 0)
|
|| (Cmp(key, "lastChild") == 0)
|
||||||
|| (Cmp(key,"lastChild") == 0)
|
|| (Cmp(key, "parentNode") == 0)
|
||||||
|| (Cmp(key,"parentNode") == 0)
|
|| (Cmp(key, "nextSibling") == 0)
|
||||||
|| (Cmp(key,"nextSibling") == 0)
|
|| (Cmp(key, "previousSibling") == 0)
|
||||||
|| (Cmp(key,"previousSibling") == 0)
|
|| (Cmp(key, "csym:nextSibling") == 0)
|
||||||
|| (Cmp(key,"csym:nextSibling") == 0)
|
|| (Cmp(key, "csym:previousSibling") == 0)
|
||||||
|| (Cmp(key,"csym:previousSibling") == 0)
|
|| (Cmp(key, "typepass:visit") == 0)
|
||||||
|| (Cmp(key,"typepass:visit") == 0)
|
|| (Cmp(key, "allocate:visit") == 0)
|
||||||
|| (Cmp(key,"allocate:visit") == 0)
|
|
||||||
|| (*(Char(key)) == '$'));
|
|| (*(Char(key)) == '$'));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool boolean_key_p(DOH *key)
|
bool boolean_key_p(DOH *key) {
|
||||||
{
|
return ((Cmp(key, "allocate:default_constructor") == 0)
|
||||||
return ((Cmp(key,"allocate:default_constructor") == 0)
|
|| (Cmp(key, "allocate:default_destructor") == 0)
|
||||||
|| (Cmp(key,"allocate:default_destructor") == 0)
|
|| (Cmp(key, "allows_typedef") == 0)
|
||||||
|| (Cmp(key,"allows_typedef") == 0)
|
|| (Cmp(key, "feature:immutable") == 0));
|
||||||
|| (Cmp(key,"feature:immutable") == 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool list_key_p(DOH *key)
|
bool list_key_p(DOH *key) {
|
||||||
{
|
|
||||||
return ((Cmp(key, "parms") == 0)
|
return ((Cmp(key, "parms") == 0)
|
||||||
|| (Cmp(key, "baselist") == 0));
|
|| (Cmp(key, "baselist") == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool plist_key_p(DOH *key)
|
bool plist_key_p(DOH *key)
|
||||||
// true if KEY is the name of data that is a mapping from keys to
|
// true if KEY is the name of data that is a mapping from keys to
|
||||||
// values, which should be printed as a plist.
|
// values, which should be printed as a plist.
|
||||||
{
|
{
|
||||||
return ((Cmp(key, "typescope") == 0));
|
return ((Cmp(key, "typescope") == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool maybe_plist_key_p(DOH *key)
|
bool maybe_plist_key_p(DOH *key) {
|
||||||
{
|
|
||||||
return (Strncmp(key, "tmap:", 5) == 0);
|
return (Strncmp(key, "tmap:", 5) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool print_circle(DOH *obj, bool list_p)
|
bool print_circle(DOH *obj, bool list_p)
|
||||||
// We have a complex object, which might be referenced several
|
// We have a complex object, which might be referenced several
|
||||||
// times, or even recursively. Use Lisp's reader notation for
|
// times, or even recursively. Use Lisp's reader notation for
|
||||||
// circular structures (#n#, #n=).
|
// circular structures (#n#, #n=).
|
||||||
//
|
//
|
||||||
// An object can be printed in list-mode or object-mode; LIST_P toggles.
|
// An object can be printed in list-mode or object-mode; LIST_P toggles.
|
||||||
// return TRUE if OBJ still needs to be printed
|
// return TRUE if OBJ still needs to be printed
|
||||||
{
|
{
|
||||||
flush_parens();
|
flush_parens();
|
||||||
// Following is a silly hack. It works around the limitation of
|
// Following is a silly hack. It works around the limitation of
|
||||||
|
|
@ -200,17 +187,15 @@ public:
|
||||||
if (placeholder) {
|
if (placeholder) {
|
||||||
Printv(out, placeholder, NIL);
|
Printv(out, placeholder, NIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String *placeholder = NewStringf("#%d#", ++print_circle_count);
|
String *placeholder = NewStringf("#%d#", ++print_circle_count);
|
||||||
Setattr(print_circle_hash, address, placeholder);
|
Setattr(print_circle_hash, address, placeholder);
|
||||||
Printf(out, "#%d=", print_circle_count);
|
Printf(out, "#%d=", print_circle_count);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_value_of_key(DOH *value, DOH *key)
|
void Sexp_print_value_of_key(DOH *value, DOH *key) {
|
||||||
{
|
|
||||||
if ((Cmp(key, "parms") == 0) || (Cmp(key, "wrap:parms") == 0)
|
if ((Cmp(key, "parms") == 0) || (Cmp(key, "wrap:parms") == 0)
|
||||||
|| (Cmp(key, "kwargs") == 0) || (Cmp(key, "pattern") == 0))
|
|| (Cmp(key, "kwargs") == 0) || (Cmp(key, "pattern") == 0))
|
||||||
Sexp_print_parms(value);
|
Sexp_print_parms(value);
|
||||||
|
|
@ -221,29 +206,27 @@ public:
|
||||||
Sexp_print_plist(value);
|
Sexp_print_plist(value);
|
||||||
else
|
else
|
||||||
Sexp_print_doh(value);
|
Sexp_print_doh(value);
|
||||||
}
|
} else if (list_key_p(key))
|
||||||
else if (list_key_p(key))
|
|
||||||
Sexp_print_list(value);
|
Sexp_print_list(value);
|
||||||
else if (boolean_key_p(key))
|
else if (boolean_key_p(key))
|
||||||
Sexp_print_boolean(value);
|
Sexp_print_boolean(value);
|
||||||
else
|
else
|
||||||
Sexp_print_doh(value);
|
Sexp_print_doh(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_boolean(DOH *obj)
|
void Sexp_print_boolean(DOH *obj) {
|
||||||
{
|
|
||||||
flush_parens();
|
flush_parens();
|
||||||
/* See DOH/Doh/base.c, DohGetInt() */
|
/* See DOH/Doh/base.c, DohGetInt() */
|
||||||
if (DohIsString(obj)) {
|
if (DohIsString(obj)) {
|
||||||
if (atoi(Char(obj)) != 0)
|
if (atoi(Char(obj)) != 0)
|
||||||
Printf(out, "t");
|
Printf(out, "t");
|
||||||
else Printf(out, "nil");
|
else
|
||||||
}
|
Printf(out, "nil");
|
||||||
else Printf(out, "nil");
|
} else
|
||||||
|
Printf(out, "nil");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_list(DOH *obj)
|
void Sexp_print_list(DOH *obj) {
|
||||||
{
|
|
||||||
if (print_circle(obj, true)) {
|
if (print_circle(obj, true)) {
|
||||||
open_paren(NIL);
|
open_paren(NIL);
|
||||||
for (; obj; obj = nextSibling(obj)) {
|
for (; obj; obj = nextSibling(obj)) {
|
||||||
|
|
@ -254,9 +237,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_parms(DOH *obj)
|
void Sexp_print_parms(DOH *obj) {
|
||||||
// print it as a list of plists
|
// print it as a list of plists
|
||||||
{
|
|
||||||
if (print_circle(obj, true)) {
|
if (print_circle(obj, true)) {
|
||||||
open_paren(NIL);
|
open_paren(NIL);
|
||||||
for (; obj; obj = nextSibling(obj)) {
|
for (; obj; obj = nextSibling(obj)) {
|
||||||
|
|
@ -270,33 +252,31 @@ public:
|
||||||
Sexp_print_value_of_key(value, k.key);
|
Sexp_print_value_of_key(value, k.key);
|
||||||
print_lazy_whitespace();
|
print_lazy_whitespace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close_paren(true);
|
close_paren(true);
|
||||||
}
|
} else
|
||||||
else Sexp_print_doh(obj);
|
Sexp_print_doh(obj);
|
||||||
print_lazy_whitespace();
|
print_lazy_whitespace();
|
||||||
}
|
}
|
||||||
close_paren(true);
|
close_paren(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_doh(DOH *obj)
|
void Sexp_print_doh(DOH *obj) {
|
||||||
{
|
|
||||||
flush_parens();
|
flush_parens();
|
||||||
if (DohIsString(obj)) {
|
if (DohIsString(obj)) {
|
||||||
String *o = Str(obj);
|
String *o = Str(obj);
|
||||||
Replaceall( o, "\\", "\\\\" );
|
Replaceall(o, "\\", "\\\\");
|
||||||
Replaceall( o, "\"", "\\\"" );
|
Replaceall(o, "\"", "\\\"");
|
||||||
Printf(out,"\"%s\"", o);
|
Printf(out, "\"%s\"", o);
|
||||||
Delete(o);
|
Delete(o);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (print_circle(obj, false)) {
|
if (print_circle(obj, false)) {
|
||||||
// Dispatch type
|
// Dispatch type
|
||||||
if (nodeType(obj)) {
|
if (nodeType(obj)) {
|
||||||
Sexp_print_node(obj);
|
Sexp_print_node(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (DohIsMapping(obj)) {
|
else if (DohIsMapping(obj)) {
|
||||||
Iterator k;
|
Iterator k;
|
||||||
open_paren(NIL);
|
open_paren(NIL);
|
||||||
|
|
@ -312,41 +292,37 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close_paren();
|
close_paren();
|
||||||
}
|
} else if (strcmp(ObjType(obj)->objname, "List") == 0) {
|
||||||
else if (strcmp(ObjType(obj)->objname, "List") == 0) {
|
|
||||||
int i;
|
int i;
|
||||||
open_paren(NIL);
|
open_paren(NIL);
|
||||||
for (i = 0; i<Len(obj); i++) {
|
for (i = 0; i < Len(obj); i++) {
|
||||||
DOH *item = Getitem(obj, i);
|
DOH *item = Getitem(obj, i);
|
||||||
Sexp_print_doh(item);
|
Sexp_print_doh(item);
|
||||||
}
|
}
|
||||||
close_paren();
|
close_paren();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// What is it?
|
// What is it?
|
||||||
Printf(out,"#<DOH %s %x>", ObjType(obj)->objname, obj);
|
Printf(out, "#<DOH %s %x>", ObjType(obj)->objname, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_as_keyword(const DOH *k)
|
void Sexp_print_as_keyword(const DOH *k) {
|
||||||
{
|
|
||||||
/* Print key, replacing ":" with "-" because : is CL's package prefix */
|
/* Print key, replacing ":" with "-" because : is CL's package prefix */
|
||||||
flush_parens();
|
flush_parens();
|
||||||
String *key = NewString(k);
|
String *key = NewString(k);
|
||||||
Replaceall(key, ":", "-");
|
Replaceall(key, ":", "-");
|
||||||
Replaceall(key, "_", "-");
|
Replaceall(key, "_", "-");
|
||||||
Printf(out,":%s ", key);
|
Printf(out, ":%s ", key);
|
||||||
Delete(key);
|
Delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_plist_noparens(DOH *obj)
|
void Sexp_print_plist_noparens(DOH *obj) {
|
||||||
{
|
|
||||||
/* attributes map names to objects */
|
/* attributes map names to objects */
|
||||||
Iterator k;
|
Iterator k;
|
||||||
bool first;
|
bool first;
|
||||||
for (k = First(obj), first = true; k.key; k = Next(k), first=false) {
|
for (k = First(obj), first = true; k.key; k = Next(k), first = false) {
|
||||||
if (!internal_key_p(k.key)) {
|
if (!internal_key_p(k.key)) {
|
||||||
DOH *value = Getattr(obj, k.key);
|
DOH *value = Getattr(obj, k.key);
|
||||||
flush_parens();
|
flush_parens();
|
||||||
|
|
@ -359,9 +335,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_plist(DOH *obj)
|
void Sexp_print_plist(DOH *obj) {
|
||||||
{
|
|
||||||
flush_parens();
|
flush_parens();
|
||||||
if (print_circle(obj, true)) {
|
if (print_circle(obj, true)) {
|
||||||
open_paren(NIL);
|
open_paren(NIL);
|
||||||
|
|
@ -370,14 +345,12 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_attributes(Node * obj)
|
void Sexp_print_attributes(Node *obj) {
|
||||||
{
|
|
||||||
Sexp_print_plist_noparens(obj);
|
Sexp_print_plist_noparens(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sexp_print_node(Node *obj)
|
void Sexp_print_node(Node *obj) {
|
||||||
{
|
Node *cobj;
|
||||||
Node *cobj;
|
|
||||||
open_paren(nodeType(obj));
|
open_paren(nodeType(obj));
|
||||||
/* A node has an attribute list... */
|
/* A node has an attribute list... */
|
||||||
Sexp_print_attributes(obj);
|
Sexp_print_attributes(obj);
|
||||||
|
|
@ -397,21 +370,20 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual int functionWrapper(Node *n)
|
virtual int functionWrapper(Node *n) {
|
||||||
{
|
ParmList *l = Getattr(n, "parms");
|
||||||
ParmList *l = Getattr(n,"parms");
|
|
||||||
Wrapper *f = NewWrapper();
|
Wrapper *f = NewWrapper();
|
||||||
emit_attach_parmmaps(l,f);
|
emit_attach_parmmaps(l, f);
|
||||||
Setattr(n,"wrap:parms",l);
|
Setattr(n, "wrap:parms", l);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static Language * new_swig_sexp() {
|
static Language *new_swig_sexp() {
|
||||||
return new Sexp();
|
return new Sexp();
|
||||||
}
|
}
|
||||||
extern "C" Language * swig_sexp( void ) {
|
extern "C" Language *swig_sexp(void) {
|
||||||
return new_swig_sexp();
|
return new_swig_sexp();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,41 +49,41 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct swig_module {
|
struct swig_module {
|
||||||
const char *name;
|
const char *name;
|
||||||
ModuleFactory fac;
|
ModuleFactory fac;
|
||||||
const char *help;
|
const char *help;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Association of command line options to language modules.
|
/* Association of command line options to language modules.
|
||||||
Place an entry for new language modules here, keeping the
|
Place an entry for new language modules here, keeping the
|
||||||
list sorted alphabetically. */
|
list sorted alphabetically. */
|
||||||
|
|
||||||
static swig_module modules[] = {
|
static swig_module modules[] = {
|
||||||
{"-allegrocl", swig_allegrocl, "ALLEGROCL"},
|
{"-allegrocl", swig_allegrocl, "ALLEGROCL"},
|
||||||
{"-chicken", swig_chicken, "CHICKEN"},
|
{"-chicken", swig_chicken, "CHICKEN"},
|
||||||
{"-clisp", swig_clisp, "CLISP"},
|
{"-clisp", swig_clisp, "CLISP"},
|
||||||
{"-cffi", swig_cffi, "CFFI"},
|
{"-cffi", swig_cffi, "CFFI"},
|
||||||
{"-csharp", swig_csharp, "C#"},
|
{"-csharp", swig_csharp, "C#"},
|
||||||
{"-guile", swig_guile, "Guile"},
|
{"-guile", swig_guile, "Guile"},
|
||||||
{"-java", swig_java, "Java"},
|
{"-java", swig_java, "Java"},
|
||||||
{"-lua", swig_lua, "Lua"},
|
{"-lua", swig_lua, "Lua"},
|
||||||
{"-modula3", swig_modula3, "Modula 3"},
|
{"-modula3", swig_modula3, "Modula 3"},
|
||||||
{"-mzscheme", swig_mzscheme, "Mzscheme"},
|
{"-mzscheme", swig_mzscheme, "Mzscheme"},
|
||||||
{"-ocaml", swig_ocaml, "Ocaml"},
|
{"-ocaml", swig_ocaml, "Ocaml"},
|
||||||
{"-perl", swig_perl5, "Perl"},
|
{"-perl", swig_perl5, "Perl"},
|
||||||
{"-perl5", swig_perl5, 0},
|
{"-perl5", swig_perl5, 0},
|
||||||
{"-php", swig_php4, 0},
|
{"-php", swig_php4, 0},
|
||||||
{"-php4", swig_php4, "PHP4"},
|
{"-php4", swig_php4, "PHP4"},
|
||||||
{"-php5", swig_php5, "PHP5"},
|
{"-php5", swig_php5, "PHP5"},
|
||||||
{"-pike", swig_pike, "Pike"},
|
{"-pike", swig_pike, "Pike"},
|
||||||
{"-python", swig_python, "Python"},
|
{"-python", swig_python, "Python"},
|
||||||
{"-ruby", swig_ruby, "Ruby"},
|
{"-ruby", swig_ruby, "Ruby"},
|
||||||
{"-sexp", swig_sexp, "Lisp S-Expressions"},
|
{"-sexp", swig_sexp, "Lisp S-Expressions"},
|
||||||
{"-tcl", swig_tcl, "Tcl"},
|
{"-tcl", swig_tcl, "Tcl"},
|
||||||
{"-tcl8", swig_tcl, 0},
|
{"-tcl8", swig_tcl, 0},
|
||||||
{"-uffi", swig_uffi, "Common Lisp / UFFI"},
|
{"-uffi", swig_uffi, "Common Lisp / UFFI"},
|
||||||
{"-xml", swig_xml, "XML"},
|
{"-xml", swig_xml, "XML"},
|
||||||
{"-r", swig_r, "R (aka GNU S)"},
|
{"-r", swig_r, "R (aka GNU S)"},
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -102,9 +102,7 @@ static swig_module modules[] = {
|
||||||
// Main program. Initializes the files and starts the parser.
|
// Main program. Initializes the files and starts the parser.
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
|
|
||||||
void SWIG_merge_envopt(const char *env, int oargc, char *oargv[],
|
void SWIG_merge_envopt(const char *env, int oargc, char *oargv[], int *nargc, char ***nargv) {
|
||||||
int *nargc, char ***nargv)
|
|
||||||
{
|
|
||||||
if (!env) {
|
if (!env) {
|
||||||
*nargc = oargc;
|
*nargc = oargc;
|
||||||
*nargv = oargv;
|
*nargv = oargv;
|
||||||
|
|
@ -113,13 +111,14 @@ void SWIG_merge_envopt(const char *env, int oargc, char *oargv[],
|
||||||
|
|
||||||
int argc = 1;
|
int argc = 1;
|
||||||
int arge = oargc + 1024;
|
int arge = oargc + 1024;
|
||||||
char **argv = (char **) malloc(sizeof(char*)*(arge));
|
char **argv = (char **) malloc(sizeof(char *) * (arge));
|
||||||
char *buffer = (char*) malloc(2048);
|
char *buffer = (char *) malloc(2048);
|
||||||
char *b = buffer;
|
char *b = buffer;
|
||||||
char *be = b + 1023;
|
char *be = b + 1023;
|
||||||
const char *c = env;
|
const char *c = env;
|
||||||
while ((b != be) && *c && (argc < arge)) {
|
while ((b != be) && *c && (argc < arge)) {
|
||||||
while (isspace(*c) && *c) ++c;
|
while (isspace(*c) && *c)
|
||||||
|
++c;
|
||||||
if (*c) {
|
if (*c) {
|
||||||
argv[argc] = b;
|
argv[argc] = b;
|
||||||
++argc;
|
++argc;
|
||||||
|
|
@ -159,33 +158,30 @@ int main(int margc, char **margv) {
|
||||||
Swig_register_module(modules[i].name, modules[i].fac);
|
Swig_register_module(modules[i].name, modules[i].fac);
|
||||||
}
|
}
|
||||||
|
|
||||||
Swig_init_args(argc,argv);
|
Swig_init_args(argc, argv);
|
||||||
|
|
||||||
/* Get options */
|
/* Get options */
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (argv[i]) {
|
if (argv[i]) {
|
||||||
fac = Swig_find_module(argv[i]);
|
fac = Swig_find_module(argv[i]);
|
||||||
if (fac) {
|
if (fac) {
|
||||||
dl = (fac)();
|
dl = (fac) ();
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strcmp(argv[i],"-nolang") == 0) {
|
} else if (strcmp(argv[i], "-nolang") == 0) {
|
||||||
dl = new Language;
|
dl = new Language;
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if ((strcmp(argv[i],"-dnone") == 0) ||
|
} else if ((strcmp(argv[i], "-dnone") == 0) ||
|
||||||
(strcmp(argv[i],"-dhtml") == 0) ||
|
(strcmp(argv[i], "-dhtml") == 0) ||
|
||||||
(strcmp(argv[i],"-dlatex") == 0) ||
|
(strcmp(argv[i], "-dlatex") == 0) || (strcmp(argv[i], "-dascii") == 0) || (strcmp(argv[i], "-stat") == 0)) {
|
||||||
(strcmp(argv[i],"-dascii") == 0) ||
|
Printf(stderr, "swig: Warning. %s option deprecated.\n", argv[i]);
|
||||||
(strcmp(argv[i],"-stat") == 0))
|
|
||||||
{
|
|
||||||
Printf(stderr,"swig: Warning. %s option deprecated.\n",argv[i]);
|
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if ((strcmp(argv[i],"-help") == 0) || (strcmp(argv[i],"--help") == 0)) {
|
} else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) {
|
||||||
if (strcmp(argv[i],"--help") == 0)
|
if (strcmp(argv[i], "--help") == 0)
|
||||||
strcpy(argv[i], "-help");
|
strcpy(argv[i], "-help");
|
||||||
Printf(stdout,"Target Language Options\n");
|
Printf(stdout, "Target Language Options\n");
|
||||||
for (int j = 0; modules[j].name; j++) {
|
for (int j = 0; modules[j].name; j++) {
|
||||||
if (modules[j].help) {
|
if (modules[j].help) {
|
||||||
Printf(stdout," %-15s - Generate %s wrappers\n", modules[j].name, modules[j].help);
|
Printf(stdout, " %-15s - Generate %s wrappers\n", modules[j].name, modules[j].help);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Swig_mark_arg not called as the general -help options also need to be displayed later on
|
// Swig_mark_arg not called as the general -help options also need to be displayed later on
|
||||||
|
|
@ -195,11 +191,10 @@ int main(int margc, char **margv) {
|
||||||
if (!dl) {
|
if (!dl) {
|
||||||
fac = Swig_find_module(SWIG_LANG);
|
fac = Swig_find_module(SWIG_LANG);
|
||||||
if (fac) {
|
if (fac) {
|
||||||
dl = (fac)();
|
dl = (fac) ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int res = SWIG_main(argc,argv,dl);
|
int res = SWIG_main(argc, argv, dl);
|
||||||
delete dl;
|
delete dl;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,18 +26,18 @@ typedef int bool;
|
||||||
#define PLAIN_VIRTUAL 1
|
#define PLAIN_VIRTUAL 1
|
||||||
#define PURE_VIRTUAL 2
|
#define PURE_VIRTUAL 2
|
||||||
|
|
||||||
extern char *input_file;
|
extern char *input_file;
|
||||||
extern int line_number;
|
extern int line_number;
|
||||||
extern int start_line;
|
extern int start_line;
|
||||||
extern int CPlusPlus; // C++ mode
|
extern int CPlusPlus; // C++ mode
|
||||||
extern int Extend; // Extend mode
|
extern int Extend; // Extend mode
|
||||||
extern int Verbose;
|
extern int Verbose;
|
||||||
extern int IsVirtual;
|
extern int IsVirtual;
|
||||||
extern int ImportMode;
|
extern int ImportMode;
|
||||||
extern int NoExcept; // -no_except option
|
extern int NoExcept; // -no_except option
|
||||||
extern int Abstract; // abstract base class
|
extern int Abstract; // abstract base class
|
||||||
extern int SmartPointer; // smart pointer methods being emitted
|
extern int SmartPointer; // smart pointer methods being emitted
|
||||||
extern int SwigRuntime;
|
extern int SwigRuntime;
|
||||||
|
|
||||||
/* Overload "argc" and "argv" */
|
/* Overload "argc" and "argv" */
|
||||||
extern String *argv_template_string;
|
extern String *argv_template_string;
|
||||||
|
|
@ -50,18 +50,19 @@ extern String *argc_template_string;
|
||||||
#define tab8 " "
|
#define tab8 " "
|
||||||
|
|
||||||
class Dispatcher {
|
class Dispatcher {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Dispatcher() : cplus_mode(PUBLIC) {}
|
Dispatcher ():cplus_mode(PUBLIC) {
|
||||||
virtual ~Dispatcher() {}
|
} virtual ~ Dispatcher () {
|
||||||
|
}
|
||||||
|
|
||||||
virtual int emit_one(Node *n);
|
virtual int emit_one(Node *n);
|
||||||
virtual int emit_children(Node *n);
|
virtual int emit_children(Node *n);
|
||||||
virtual int defaultHandler(Node *n);
|
virtual int defaultHandler(Node *n);
|
||||||
|
|
||||||
/* Top of the parse tree */
|
/* Top of the parse tree */
|
||||||
virtual int top(Node *n) = 0;
|
virtual int top(Node *n) = 0;
|
||||||
|
|
||||||
/* SWIG directives */
|
/* SWIG directives */
|
||||||
|
|
||||||
virtual int applyDirective(Node *n);
|
virtual int applyDirective(Node *n);
|
||||||
|
|
@ -81,7 +82,7 @@ class Dispatcher {
|
||||||
virtual int typesDirective(Node *n);
|
virtual int typesDirective(Node *n);
|
||||||
|
|
||||||
/* C/C++ parsing */
|
/* C/C++ parsing */
|
||||||
|
|
||||||
virtual int cDeclaration(Node *n);
|
virtual int cDeclaration(Node *n);
|
||||||
virtual int externDeclaration(Node *n);
|
virtual int externDeclaration(Node *n);
|
||||||
virtual int enumDeclaration(Node *n);
|
virtual int enumDeclaration(Node *n);
|
||||||
|
|
@ -110,10 +111,10 @@ protected:
|
||||||
* functions to output different types of code for different languages.
|
* functions to output different types of code for different languages.
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
class Language : public Dispatcher {
|
class Language:public Dispatcher {
|
||||||
public:
|
public:
|
||||||
Language();
|
Language ();
|
||||||
virtual ~Language();
|
virtual ~ Language ();
|
||||||
virtual int emit_one(Node *n);
|
virtual int emit_one(Node *n);
|
||||||
|
|
||||||
/* Parse command line options */
|
/* Parse command line options */
|
||||||
|
|
@ -122,10 +123,10 @@ public:
|
||||||
|
|
||||||
/* Top of the parse tree */
|
/* Top of the parse tree */
|
||||||
|
|
||||||
virtual int top(Node *n);
|
virtual int top(Node *n);
|
||||||
|
|
||||||
/* SWIG directives */
|
/* SWIG directives */
|
||||||
|
|
||||||
|
|
||||||
virtual int applyDirective(Node *n);
|
virtual int applyDirective(Node *n);
|
||||||
virtual int clearDirective(Node *n);
|
virtual int clearDirective(Node *n);
|
||||||
|
|
@ -143,7 +144,7 @@ public:
|
||||||
virtual int typesDirective(Node *n);
|
virtual int typesDirective(Node *n);
|
||||||
|
|
||||||
/* C/C++ parsing */
|
/* C/C++ parsing */
|
||||||
|
|
||||||
virtual int cDeclaration(Node *n);
|
virtual int cDeclaration(Node *n);
|
||||||
virtual int externDeclaration(Node *n);
|
virtual int externDeclaration(Node *n);
|
||||||
virtual int enumDeclaration(Node *n);
|
virtual int enumDeclaration(Node *n);
|
||||||
|
|
@ -195,12 +196,7 @@ public:
|
||||||
virtual int classDirector(Node *n);
|
virtual int classDirector(Node *n);
|
||||||
virtual int classDirectorInit(Node *n);
|
virtual int classDirectorInit(Node *n);
|
||||||
virtual int classDirectorEnd(Node *n);
|
virtual int classDirectorEnd(Node *n);
|
||||||
virtual int unrollVirtualMethods(Node *n,
|
virtual int unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_director, int &virtual_destructor, int protectedbase = 0);
|
||||||
Node *parent,
|
|
||||||
List *vm,
|
|
||||||
int default_director,
|
|
||||||
int &virtual_destructor,
|
|
||||||
int protectedbase = 0);
|
|
||||||
virtual int classDirectorConstructor(Node *n);
|
virtual int classDirectorConstructor(Node *n);
|
||||||
virtual int classDirectorDefaultConstructor(Node *n);
|
virtual int classDirectorDefaultConstructor(Node *n);
|
||||||
virtual int classDirectorMethod(Node *n, Node *parent, String *super);
|
virtual int classDirectorMethod(Node *n, Node *parent, String *super);
|
||||||
|
|
@ -210,16 +206,16 @@ public:
|
||||||
virtual int classDirectorDisown(Node *n);
|
virtual int classDirectorDisown(Node *n);
|
||||||
|
|
||||||
/* Miscellaneous */
|
/* Miscellaneous */
|
||||||
virtual int validIdentifier(String *s); /* valid identifier? */
|
virtual int validIdentifier(String *s); /* valid identifier? */
|
||||||
virtual int addSymbol(const String *s, const Node *n); /* Add symbol */
|
virtual int addSymbol(const String *s, const Node *n); /* Add symbol */
|
||||||
virtual Node *symbolLookup(String *s); /* Symbol lookup */
|
virtual Node *symbolLookup(String *s); /* Symbol lookup */
|
||||||
virtual Node *classLookup(SwigType *s); /* Class lookup */
|
virtual Node *classLookup(SwigType *s); /* Class lookup */
|
||||||
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
|
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
|
||||||
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
|
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
|
||||||
virtual int is_assignable(Node *n); /* Is variable assignable? */
|
virtual int is_assignable(Node *n); /* Is variable assignable? */
|
||||||
virtual String *runtimeCode(); /* returns the language specific runtime code */
|
virtual String *runtimeCode(); /* returns the language specific runtime code */
|
||||||
virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */
|
virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */
|
||||||
|
|
||||||
/* Allow director related code generation */
|
/* Allow director related code generation */
|
||||||
void allow_directors(int val = 1);
|
void allow_directors(int val = 1);
|
||||||
|
|
||||||
|
|
@ -227,10 +223,10 @@ public:
|
||||||
int directorsEnabled() const;
|
int directorsEnabled() const;
|
||||||
|
|
||||||
/* Allow director protected members related code generation */
|
/* Allow director protected members related code generation */
|
||||||
void allow_dirprot(int val = 1);
|
void allow_dirprot(int val = 1);
|
||||||
|
|
||||||
/* Returns the dirprot mode */
|
/* Returns the dirprot mode */
|
||||||
int dirprot_mode() const;
|
int dirprot_mode() const;
|
||||||
|
|
||||||
/* Check if the non public constructor is needed (for directors) */
|
/* Check if the non public constructor is needed (for directors) */
|
||||||
int need_nonpublic_ctor(Node *n);
|
int need_nonpublic_ctor(Node *n);
|
||||||
|
|
@ -246,10 +242,10 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* Allow multiple-input typemaps */
|
/* Allow multiple-input typemaps */
|
||||||
void allow_multiple_input(int val = 1);
|
void allow_multiple_input(int val = 1);
|
||||||
|
|
||||||
/* Allow overloaded functions */
|
/* Allow overloaded functions */
|
||||||
void allow_overloading(int val = 1);
|
void allow_overloading(int val = 1);
|
||||||
|
|
||||||
/* Wrapping class query */
|
/* Wrapping class query */
|
||||||
int is_wrapping_class();
|
int is_wrapping_class();
|
||||||
|
|
@ -281,7 +277,7 @@ protected:
|
||||||
/* Director constructor "template" code */
|
/* Director constructor "template" code */
|
||||||
String *director_ctor_code;
|
String *director_ctor_code;
|
||||||
|
|
||||||
/* Director 'protected' constructor "template" code*/
|
/* Director 'protected' constructor "template" code */
|
||||||
String *director_prot_ctor_code;
|
String *director_prot_ctor_code;
|
||||||
|
|
||||||
/* Director allows multiple inheritance */
|
/* Director allows multiple inheritance */
|
||||||
|
|
@ -291,37 +287,37 @@ protected:
|
||||||
int director_language;
|
int director_language;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Hash *symbols;
|
Hash *symbols;
|
||||||
Hash *classtypes;
|
Hash *classtypes;
|
||||||
Hash *enumtypes;
|
Hash *enumtypes;
|
||||||
int overloading;
|
int overloading;
|
||||||
int multiinput;
|
int multiinput;
|
||||||
int directors;
|
int directors;
|
||||||
};
|
};
|
||||||
|
|
||||||
int SWIG_main(int, char **, Language *);
|
int SWIG_main(int, char **, Language *);
|
||||||
void emit_args(SwigType *, ParmList *, Wrapper *f);
|
void emit_args(SwigType *, ParmList *, Wrapper *f);
|
||||||
void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
|
void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
|
||||||
void SWIG_config_file(const String_or_char *);
|
void SWIG_config_file(const String_or_char *);
|
||||||
const String *SWIG_output_directory();
|
const String *SWIG_output_directory();
|
||||||
void SWIG_config_cppext(const char *ext);
|
void SWIG_config_cppext(const char *ext);
|
||||||
|
|
||||||
void SWIG_library_directory(const char *);
|
void SWIG_library_directory(const char *);
|
||||||
int emit_num_arguments(ParmList *);
|
int emit_num_arguments(ParmList *);
|
||||||
int emit_num_required(ParmList *);
|
int emit_num_required(ParmList *);
|
||||||
int emit_isvarargs(ParmList *);
|
int emit_isvarargs(ParmList *);
|
||||||
void emit_attach_parmmaps(ParmList *, Wrapper *f);
|
void emit_attach_parmmaps(ParmList *, Wrapper *f);
|
||||||
void emit_mark_varargs(ParmList *l);
|
void emit_mark_varargs(ParmList *l);
|
||||||
void emit_action(Node *n, Wrapper *f);
|
void emit_action(Node *n, Wrapper *f);
|
||||||
int emit_action_code(Node *n, Wrapper *f, String *action);
|
int emit_action_code(Node *n, Wrapper *f, String *action);
|
||||||
void Swig_overload_check(Node *n);
|
void Swig_overload_check(Node *n);
|
||||||
String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *);
|
String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *);
|
||||||
String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *);
|
String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *);
|
||||||
String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *);
|
String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *);
|
||||||
SwigType *cplus_value_type(SwigType *t);
|
SwigType *cplus_value_type(SwigType *t);
|
||||||
|
|
||||||
/* directors.cxx start */
|
/* directors.cxx start */
|
||||||
String *Swig_csuperclass_call(String* base, String* method, ParmList* l);
|
String *Swig_csuperclass_call(String *base, String *method, ParmList *l);
|
||||||
String *Swig_class_declaration(Node *n, String *name);
|
String *Swig_class_declaration(Node *n, String *name);
|
||||||
String *Swig_class_name(Node *n);
|
String *Swig_class_name(Node *n);
|
||||||
String *Swig_method_call(String_or_char *name, ParmList *parms);
|
String *Swig_method_call(String_or_char *name, ParmList *parms);
|
||||||
|
|
@ -330,20 +326,18 @@ String *Swig_director_declaration(Node *n);
|
||||||
/* directors.cxx end */
|
/* directors.cxx end */
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void SWIG_typemap_lang(const char *);
|
void SWIG_typemap_lang(const char *);
|
||||||
typedef Language *(*ModuleFactory)(void);
|
typedef Language *(*ModuleFactory) (void);
|
||||||
}
|
} void Swig_register_module(const char *name, ModuleFactory fac);
|
||||||
|
|
||||||
void Swig_register_module(const char *name, ModuleFactory fac);
|
|
||||||
ModuleFactory Swig_find_module(const char *name);
|
ModuleFactory Swig_find_module(const char *name);
|
||||||
|
|
||||||
/* Utilities */
|
/* Utilities */
|
||||||
|
|
||||||
int is_public(Node* n);
|
int is_public(Node *n);
|
||||||
int is_private(Node* n);
|
int is_private(Node *n);
|
||||||
int is_protected(Node* n);
|
int is_protected(Node *n);
|
||||||
int is_member_director(Node* parentnode, Node* member);
|
int is_member_director(Node *parentnode, Node *member);
|
||||||
int is_member_director(Node* member);
|
int is_member_director(Node *member);
|
||||||
int use_naturalvar_mode(Node *n);
|
int use_naturalvar_mode(Node *n);
|
||||||
|
|
||||||
void Wrapper_virtual_elimination_mode_set(int);
|
void Wrapper_virtual_elimination_mode_set(int);
|
||||||
|
|
@ -360,7 +354,7 @@ void clean_overloaded(Node *n);
|
||||||
|
|
||||||
void Swig_contracts(Node *n);
|
void Swig_contracts(Node *n);
|
||||||
void Swig_contract_mode_set(int flag);
|
void Swig_contract_mode_set(int flag);
|
||||||
int Swig_contract_mode_get();
|
int Swig_contract_mode_get();
|
||||||
|
|
||||||
/* Browser */
|
/* Browser */
|
||||||
|
|
||||||
|
|
@ -370,7 +364,3 @@ void Swig_process_types(Node *n);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -13,32 +13,32 @@ char cvsroot_uffi_cxx[] = "$Header$";
|
||||||
|
|
||||||
#include "swigmod.h"
|
#include "swigmod.h"
|
||||||
|
|
||||||
class UFFI : public Language {
|
class UFFI:public Language {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void main(int argc, char *argv[]);
|
virtual void main(int argc, char *argv[]);
|
||||||
virtual int top(Node *n);
|
virtual int top(Node *n);
|
||||||
virtual int functionWrapper(Node *n);
|
virtual int functionWrapper(Node *n);
|
||||||
virtual int constantWrapper(Node *n);
|
virtual int constantWrapper(Node *n);
|
||||||
virtual int classHandler(Node *n);
|
virtual int classHandler(Node *n);
|
||||||
virtual int membervariableHandler(Node *n);
|
virtual int membervariableHandler(Node *n);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static File *f_cl=0;
|
static File *f_cl = 0;
|
||||||
static File *f_null=0;
|
static File *f_null = 0;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
int count;
|
int count;
|
||||||
String **entries;
|
String **entries;
|
||||||
} defined_foreign_types;
|
} defined_foreign_types;
|
||||||
|
|
||||||
static const char *identifier_converter="identifier-convert-null";
|
static const char *identifier_converter = "identifier-convert-null";
|
||||||
|
|
||||||
static int any_varargs(ParmList *pl) {
|
static int any_varargs(ParmList *pl) {
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
||||||
for(p=pl; p; p=nextSibling(p)) {
|
for (p = pl; p; p = nextSibling(p)) {
|
||||||
if (SwigType_isvarargs(Getattr(p, "type")))
|
if (SwigType_isvarargs(Getattr(p, "type")))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -46,83 +46,79 @@ static int any_varargs(ParmList *pl) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* utilities */
|
/* utilities */
|
||||||
/* returns new string w/ parens stripped */
|
/* returns new string w/ parens stripped */
|
||||||
static String *strip_parens(String *string) {
|
static String *strip_parens(String *string) {
|
||||||
char *s=Char(string), *p;
|
char *s = Char(string), *p;
|
||||||
int len=Len(string);
|
int len = Len(string);
|
||||||
String *res;
|
String *res;
|
||||||
|
|
||||||
if (len==0 || s[0] != '(' || s[len-1] != ')') {
|
if (len == 0 || s[0] != '(' || s[len - 1] != ')') {
|
||||||
return NewString(string);
|
return NewString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
p=(char *)malloc(len-2+1);
|
p = (char *) malloc(len - 2 + 1);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
Printf(stderr, "Malloc failed\n");
|
Printf(stderr, "Malloc failed\n");
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(p, s+1, len-1);
|
strncpy(p, s + 1, len - 1);
|
||||||
p[len-2]=0; /* null terminate */
|
p[len - 2] = 0; /* null terminate */
|
||||||
|
|
||||||
res=NewString(p);
|
res = NewString(p);
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static String *convert_literal(String *num_param, String *type) {
|
static String *convert_literal(String *num_param, String *type) {
|
||||||
String *num=strip_parens(num_param), *res;
|
String *num = strip_parens(num_param), *res;
|
||||||
char *s=Char(num);
|
char *s = Char(num);
|
||||||
|
|
||||||
/* Make sure doubles use 'd' instead of 'e' */
|
|
||||||
if (!Strcmp(type, "double")) {
|
|
||||||
String *updated=Copy(num);
|
|
||||||
if (Replace(updated, "e", "d", DOH_REPLACE_ANY) > 1) {
|
|
||||||
Printf(stderr, "Weird!! number %s looks invalid.\n", num);
|
|
||||||
SWIG_exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
Delete(num);
|
|
||||||
return updated;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SwigType_type(type) == T_CHAR) {
|
/* Make sure doubles use 'd' instead of 'e' */
|
||||||
/* Use CL syntax for character literals */
|
if (!Strcmp(type, "double")) {
|
||||||
return NewStringf("#\\%s", num_param);
|
String *updated = Copy(num);
|
||||||
}
|
if (Replace(updated, "e", "d", DOH_REPLACE_ANY) > 1) {
|
||||||
else if (SwigType_type(type) == T_STRING) {
|
Printf(stderr, "Weird!! number %s looks invalid.\n", num);
|
||||||
/* Use CL syntax for string literals */
|
SWIG_exit(EXIT_FAILURE);
|
||||||
return NewStringf("\"%s\"", num_param);
|
}
|
||||||
}
|
Delete(num);
|
||||||
|
return updated;
|
||||||
if (Len(num) < 2 || s[0] != '0') {
|
}
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* octal or hex */
|
|
||||||
|
|
||||||
res=NewStringf("#%c%s",
|
|
||||||
s[1] == 'x' ? 'x' : 'o',
|
|
||||||
s+2);
|
|
||||||
Delete(num);
|
|
||||||
|
|
||||||
return res;
|
if (SwigType_type(type) == T_CHAR) {
|
||||||
|
/* Use CL syntax for character literals */
|
||||||
|
return NewStringf("#\\%s", num_param);
|
||||||
|
} else if (SwigType_type(type) == T_STRING) {
|
||||||
|
/* Use CL syntax for string literals */
|
||||||
|
return NewStringf("\"%s\"", num_param);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Len(num) < 2 || s[0] != '0') {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* octal or hex */
|
||||||
|
|
||||||
|
res = NewStringf("#%c%s", s[1] == 'x' ? 'x' : 'o', s + 2);
|
||||||
|
Delete(num);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_defined_foreign_type(String *type) {
|
static void add_defined_foreign_type(String *type) {
|
||||||
if (!defined_foreign_types.count) {
|
if (!defined_foreign_types.count) {
|
||||||
/* Make fresh */
|
/* Make fresh */
|
||||||
defined_foreign_types.count=1;
|
defined_foreign_types.count = 1;
|
||||||
defined_foreign_types.entries=(String **)malloc(sizeof(String *));
|
defined_foreign_types.entries = (String **) malloc(sizeof(String *));
|
||||||
} else {
|
} else {
|
||||||
/* make room */
|
/* make room */
|
||||||
defined_foreign_types.count++;
|
defined_foreign_types.count++;
|
||||||
defined_foreign_types.entries=(String **)
|
defined_foreign_types.entries = (String **)
|
||||||
realloc(defined_foreign_types.entries,
|
realloc(defined_foreign_types.entries, defined_foreign_types.count * sizeof(String *));
|
||||||
defined_foreign_types.count*sizeof(String *));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined_foreign_types.entries) {
|
if (!defined_foreign_types.entries) {
|
||||||
|
|
@ -131,121 +127,110 @@ static void add_defined_foreign_type(String *type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill in the new data */
|
/* Fill in the new data */
|
||||||
defined_foreign_types.entries[defined_foreign_types.count-1]=
|
defined_foreign_types.entries[defined_foreign_types.count - 1] = Copy(type);
|
||||||
Copy(type);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
|
static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
|
||||||
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
|
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
|
||||||
if (typemap) {
|
if (typemap) {
|
||||||
String *typespec = Getattr(typemap, "code");
|
String *typespec = Getattr(typemap, "code");
|
||||||
return NewString(typespec);
|
return NewString(typespec);
|
||||||
}
|
} else {
|
||||||
else {
|
SwigType *tr = SwigType_typedef_resolve_all(ty);
|
||||||
SwigType *tr=SwigType_typedef_resolve_all(ty);
|
char *type_reduced = Char(tr);
|
||||||
char *type_reduced=Char(tr);
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
//Printf(stdout,"convert_type %s\n", ty);
|
//Printf(stdout,"convert_type %s\n", ty);
|
||||||
if (SwigType_isconst(tr)) {
|
if (SwigType_isconst(tr)) {
|
||||||
SwigType_pop(tr);
|
SwigType_pop(tr);
|
||||||
type_reduced=Char(tr);
|
type_reduced = Char(tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SwigType_ispointer(type_reduced) || SwigType_isarray(ty) ||
|
if (SwigType_ispointer(type_reduced) || SwigType_isarray(ty) || !strncmp(type_reduced, "p.f", 3)) {
|
||||||
!strncmp(type_reduced, "p.f", 3)) {
|
return NewString(":pointer-void");
|
||||||
return NewString(":pointer-void");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0; i<defined_foreign_types.count; i++) {
|
|
||||||
if (!Strcmp(ty, defined_foreign_types.entries[i])) {
|
|
||||||
return NewStringf("#.(%s \"%s\" :type :type)",
|
|
||||||
identifier_converter,
|
|
||||||
ty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Strncmp(type_reduced, "enum ", 5)) {
|
|
||||||
return NewString(":int");
|
|
||||||
}
|
|
||||||
|
|
||||||
Printf(stderr, "Unsupported data type: %s (was: %s)\n", type_reduced, ty);
|
for (i = 0; i < defined_foreign_types.count; i++) {
|
||||||
SWIG_exit(EXIT_FAILURE);
|
if (!Strcmp(ty, defined_foreign_types.entries[i])) {
|
||||||
|
return NewStringf("#.(%s \"%s\" :type :type)", identifier_converter, ty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Strncmp(type_reduced, "enum ", 5)) {
|
||||||
|
return NewString(":int");
|
||||||
|
}
|
||||||
|
|
||||||
|
Printf(stderr, "Unsupported data type: %s (was: %s)\n", type_reduced, ty);
|
||||||
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String *get_lisp_type(SwigType *ty, const String_or_char *name)
|
static String *get_lisp_type(SwigType *ty, const String_or_char *name) {
|
||||||
{
|
|
||||||
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
|
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
|
||||||
if (typemap) {
|
if (typemap) {
|
||||||
String *typespec = Getattr(typemap, "code");
|
String *typespec = Getattr(typemap, "code");
|
||||||
return NewString(typespec);
|
return NewString(typespec);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return NewString("");
|
return NewString("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UFFI :: main(int argc, char *argv[]) {
|
void UFFI::main(int argc, char *argv[]) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SWIG_library_directory("uffi");
|
SWIG_library_directory("uffi");
|
||||||
SWIG_config_file("uffi.swg");
|
SWIG_config_file("uffi.swg");
|
||||||
|
|
||||||
|
|
||||||
for(i=1; i<argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "-identifier-converter")) {
|
if (!strcmp(argv[i], "-identifier-converter")) {
|
||||||
char *conv=argv[i+1];
|
char *conv = argv[i + 1];
|
||||||
|
|
||||||
if (!conv)
|
if (!conv)
|
||||||
Swig_arg_error();
|
Swig_arg_error();
|
||||||
|
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
Swig_mark_arg(i+1);
|
Swig_mark_arg(i + 1);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
/* check for built-ins */
|
/* check for built-ins */
|
||||||
if (!strcmp(conv, "lispify")) {
|
if (!strcmp(conv, "lispify")) {
|
||||||
identifier_converter="identifier-convert-lispify";
|
identifier_converter = "identifier-convert-lispify";
|
||||||
} else if (!strcmp(conv, "null")) {
|
} else if (!strcmp(conv, "null")) {
|
||||||
identifier_converter="identifier-convert-null";
|
identifier_converter = "identifier-convert-null";
|
||||||
} else {
|
} else {
|
||||||
/* Must be user defined */
|
/* Must be user defined */
|
||||||
char *idconv = new char[strlen(conv)+1];
|
char *idconv = new char[strlen(conv) + 1];
|
||||||
strcpy(idconv, conv);
|
strcpy(idconv, conv);
|
||||||
identifier_converter=idconv;
|
identifier_converter = idconv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[i], "-help")) {
|
if (!strcmp(argv[i], "-help")) {
|
||||||
fprintf(stdout, "UFFI Options (available with -uffi)\n");
|
fprintf(stdout, "UFFI Options (available with -uffi)\n");
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
" -identifier-converter <type or funcname>\n"
|
" -identifier-converter <type or funcname>\n"
|
||||||
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
|
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
|
||||||
"\tthem to symbols. There are two built-in converters: 'null' and\n"
|
"\tthem to symbols. There are two built-in converters: 'null' and\n"
|
||||||
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
|
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
|
||||||
"\tthan one of the built-ins, then a function by that name will be\n"
|
"\tthan one of the built-ins, then a function by that name will be\n"
|
||||||
"\tcalled to convert identifiers to symbols.\n");
|
"\tcalled to convert identifiers to symbols.\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int UFFI :: top(Node *n) {
|
int UFFI::top(Node *n) {
|
||||||
String *module=Getattr(n, "name");
|
String *module = Getattr(n, "name");
|
||||||
String *output_filename=NewString("");
|
String *output_filename = NewString("");
|
||||||
String *devnull=NewString("/dev/null");
|
String *devnull = NewString("/dev/null");
|
||||||
|
|
||||||
f_null=NewFile(devnull, "w+");
|
f_null = NewFile(devnull, "w+");
|
||||||
if (!f_null) {
|
if (!f_null) {
|
||||||
FileErrorDisplay(devnull);
|
FileErrorDisplay(devnull);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
Delete(devnull);
|
Delete(devnull);
|
||||||
|
|
||||||
|
|
@ -253,166 +238,153 @@ int UFFI :: top(Node *n) {
|
||||||
Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module);
|
Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module);
|
||||||
|
|
||||||
|
|
||||||
f_cl=NewFile(output_filename, "w");
|
f_cl = NewFile(output_filename, "w");
|
||||||
if (!f_cl) {
|
if (!f_cl) {
|
||||||
FileErrorDisplay(output_filename);
|
FileErrorDisplay(output_filename);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Swig_register_filebyname("header",f_null);
|
Swig_register_filebyname("header", f_null);
|
||||||
Swig_register_filebyname("runtime",f_null);
|
Swig_register_filebyname("runtime", f_null);
|
||||||
Swig_register_filebyname("wrapper", f_cl);
|
Swig_register_filebyname("wrapper", f_cl);
|
||||||
|
|
||||||
Printf(f_cl, ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n;; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n", module, module, module);
|
Printf(f_cl,
|
||||||
|
";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n;; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n",
|
||||||
|
module, module, module);
|
||||||
Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter);
|
Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter);
|
||||||
|
|
||||||
Language::top(n);
|
Language::top(n);
|
||||||
|
|
||||||
Close(f_cl);
|
Close(f_cl);
|
||||||
Delete(f_cl); // Delete the handle, not the file
|
Delete(f_cl); // Delete the handle, not the file
|
||||||
Close(f_null);
|
Close(f_null);
|
||||||
Delete(f_null);
|
Delete(f_null);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UFFI :: functionWrapper(Node *n) {
|
int UFFI::functionWrapper(Node *n) {
|
||||||
String *funcname=Getattr(n, "sym:name");
|
String *funcname = Getattr(n, "sym:name");
|
||||||
ParmList *pl=Getattr(n, "parms");
|
ParmList *pl = Getattr(n, "parms");
|
||||||
Parm *p;
|
Parm *p;
|
||||||
int argnum=0, first=1, varargs=0;
|
int argnum = 0, first = 1, varargs = 0;
|
||||||
|
|
||||||
//Language::functionWrapper(n);
|
//Language::functionWrapper(n);
|
||||||
|
|
||||||
Printf(f_cl, "(swig-defun \"%s\"\n", funcname);
|
Printf(f_cl, "(swig-defun \"%s\"\n", funcname);
|
||||||
Printf(f_cl, " (");
|
Printf(f_cl, " (");
|
||||||
|
|
||||||
/* Special cases */
|
/* Special cases */
|
||||||
|
|
||||||
if (ParmList_len(pl) == 0) {
|
if (ParmList_len(pl) == 0) {
|
||||||
Printf(f_cl, ":void");
|
Printf(f_cl, ":void");
|
||||||
} else if (any_varargs(pl)) {
|
} else if (any_varargs(pl)) {
|
||||||
Printf(f_cl, "#| varargs |#");
|
Printf(f_cl, "#| varargs |#");
|
||||||
varargs=1;
|
varargs = 1;
|
||||||
} else {
|
} else {
|
||||||
for (p=pl; p; p=nextSibling(p), argnum++) {
|
for (p = pl; p; p = nextSibling(p), argnum++) {
|
||||||
String *argname=Getattr(p, "name");
|
String *argname = Getattr(p, "name");
|
||||||
SwigType *argtype=Getattr(p, "type");
|
SwigType *argtype = Getattr(p, "type");
|
||||||
String *ffitype=get_ffi_type(argtype, argname);
|
String *ffitype = get_ffi_type(argtype, argname);
|
||||||
String *lisptype=get_lisp_type(argtype, argname);
|
String *lisptype = get_lisp_type(argtype, argname);
|
||||||
int tempargname=0;
|
int tempargname = 0;
|
||||||
|
|
||||||
if (!argname) {
|
if (!argname) {
|
||||||
argname=NewStringf("arg%d", argnum);
|
argname = NewStringf("arg%d", argnum);
|
||||||
tempargname=1;
|
tempargname = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!first) {
|
if (!first) {
|
||||||
Printf(f_cl, "\n ");
|
Printf(f_cl, "\n ");
|
||||||
}
|
}
|
||||||
Printf(f_cl, "(%s %s %s)", argname, ffitype, lisptype);
|
Printf(f_cl, "(%s %s %s)", argname, ffitype, lisptype);
|
||||||
first=0;
|
first = 0;
|
||||||
|
|
||||||
Delete(ffitype);
|
Delete(ffitype);
|
||||||
Delete(lisptype);
|
Delete(lisptype);
|
||||||
if (tempargname)
|
if (tempargname)
|
||||||
Delete(argname);
|
Delete(argname);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Printf(f_cl, ")\n"); /* finish arg list */
|
Printf(f_cl, ")\n"); /* finish arg list */
|
||||||
Printf(f_cl, " :returning %s\n"
|
Printf(f_cl, " :returning %s\n"
|
||||||
//" :strings-convert t\n"
|
//" :strings-convert t\n"
|
||||||
//" :call-direct %s\n"
|
//" :call-direct %s\n"
|
||||||
//" :optimize-for-space t"
|
//" :optimize-for-space t"
|
||||||
")\n",
|
")\n", get_ffi_type(Getattr(n, "type"), "result")
|
||||||
get_ffi_type(Getattr(n, "type"), "result")
|
|
||||||
//,varargs ? "nil" : "t"
|
//,varargs ? "nil" : "t"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UFFI :: constantWrapper(Node *n) {
|
int UFFI::constantWrapper(Node *n) {
|
||||||
String *type=Getattr(n, "type");
|
String *type = Getattr(n, "type");
|
||||||
String *converted_value=convert_literal(Getattr(n, "value"), type);
|
String *converted_value = convert_literal(Getattr(n, "value"), type);
|
||||||
String *name=Getattr(n, "sym:name");
|
String *name = Getattr(n, "sym:name");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
Printf(stdout, "constant %s is of type %s. value: %s\n",
|
Printf(stdout, "constant %s is of type %s. value: %s\n", name, type, converted_value);
|
||||||
name, type, converted_value);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Printf(f_cl, "(swig-defconstant \"%s\" %s)\n",
|
Printf(f_cl, "(swig-defconstant \"%s\" %s)\n", name, converted_value);
|
||||||
name, converted_value);
|
|
||||||
|
|
||||||
Delete(converted_value);
|
Delete(converted_value);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Includes structs
|
// Includes structs
|
||||||
int UFFI :: classHandler(Node *n) {
|
int UFFI::classHandler(Node *n) {
|
||||||
|
|
||||||
String *name=Getattr(n, "sym:name");
|
String *name = Getattr(n, "sym:name");
|
||||||
String *kind = Getattr(n,"kind");
|
String *kind = Getattr(n, "kind");
|
||||||
Node *c;
|
Node *c;
|
||||||
|
|
||||||
if (Strcmp(kind, "struct")) {
|
if (Strcmp(kind, "struct")) {
|
||||||
Printf(stderr, "Don't know how to deal with %s kind of class yet.\n",
|
Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind);
|
||||||
kind);
|
|
||||||
Printf(stderr, " (name: %s)\n", name);
|
Printf(stderr, " (name: %s)\n", name);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(f_cl,
|
Printf(f_cl, "(swig-def-struct \"%s\"\n \n", name);
|
||||||
"(swig-def-struct \"%s\"\n \n",
|
|
||||||
name);
|
|
||||||
|
|
||||||
for (c=firstChild(n); c; c=nextSibling(c)) {
|
for (c = firstChild(n); c; c = nextSibling(c)) {
|
||||||
SwigType *type=Getattr(c, "type");
|
SwigType *type = Getattr(c, "type");
|
||||||
SwigType *decl=Getattr(c, "decl");
|
SwigType *decl = Getattr(c, "decl");
|
||||||
type = Copy(type);
|
type = Copy(type);
|
||||||
SwigType_push(type, decl);
|
SwigType_push(type, decl);
|
||||||
String *lisp_type;
|
String *lisp_type;
|
||||||
|
|
||||||
if (Strcmp(nodeType(c), "cdecl")) {
|
if (Strcmp(nodeType(c), "cdecl")) {
|
||||||
Printf(stderr, "Structure %s has a slot that we can't deal with.\n",
|
Printf(stderr, "Structure %s has a slot that we can't deal with.\n", name);
|
||||||
name);
|
Printf(stderr, "nodeType: %s, name: %s, type: %s\n", nodeType(c), Getattr(c, "name"), Getattr(c, "type"));
|
||||||
Printf(stderr, "nodeType: %s, name: %s, type: %s\n",
|
|
||||||
nodeType(c),
|
|
||||||
Getattr(c, "name"),
|
|
||||||
Getattr(c, "type"));
|
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Printf(stdout, "Converting %s in %s\n", type, name); */
|
|
||||||
lisp_type=get_ffi_type(type, Getattr(c, "sym:name"));
|
|
||||||
|
|
||||||
Printf(f_cl,
|
/* Printf(stdout, "Converting %s in %s\n", type, name); */
|
||||||
" (#.(%s \"%s\" :type :slot) %s)\n",
|
lisp_type = get_ffi_type(type, Getattr(c, "sym:name"));
|
||||||
identifier_converter,
|
|
||||||
Getattr(c, "sym:name"),
|
Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type);
|
||||||
lisp_type);
|
|
||||||
|
|
||||||
Delete(lisp_type);
|
Delete(lisp_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Language::classHandler(n);
|
// Language::classHandler(n);
|
||||||
|
|
||||||
Printf(f_cl, " )\n");
|
Printf(f_cl, " )\n");
|
||||||
|
|
||||||
/* Add this structure to the known lisp types */
|
/* Add this structure to the known lisp types */
|
||||||
//Printf(stdout, "Adding %s foreign type\n", name);
|
//Printf(stdout, "Adding %s foreign type\n", name);
|
||||||
add_defined_foreign_type(name);
|
add_defined_foreign_type(name);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UFFI :: membervariableHandler(Node *n)
|
int UFFI::membervariableHandler(Node *n) {
|
||||||
{
|
|
||||||
Language::membervariableHandler(n);
|
Language::membervariableHandler(n);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -421,7 +393,3 @@ int UFFI :: membervariableHandler(Node *n)
|
||||||
extern "C" Language *swig_uffi(void) {
|
extern "C" Language *swig_uffi(void) {
|
||||||
return new UFFI();
|
return new UFFI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,42 +11,38 @@ char cvsroot_utils_cxx[] = "$Header$";
|
||||||
|
|
||||||
#include <swigmod.h>
|
#include <swigmod.h>
|
||||||
|
|
||||||
int is_public(Node* n)
|
int is_public(Node *n) {
|
||||||
{
|
String *access = Getattr(n, "access");
|
||||||
String* access = Getattr(n, "access");
|
|
||||||
return !access || !Cmp(access, "public");
|
return !access || !Cmp(access, "public");
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_private(Node* n)
|
int is_private(Node *n) {
|
||||||
{
|
String *access = Getattr(n, "access");
|
||||||
String* access = Getattr(n, "access");
|
|
||||||
return access && !Cmp(access, "private");
|
return access && !Cmp(access, "private");
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_protected(Node* n)
|
int is_protected(Node *n) {
|
||||||
{
|
String *access = Getattr(n, "access");
|
||||||
String* access = Getattr(n, "access");
|
|
||||||
return access && !Cmp(access, "protected");
|
return access && !Cmp(access, "protected");
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_member_director(Node* parentnode, Node* member)
|
int is_member_director(Node *parentnode, Node *member) {
|
||||||
{
|
|
||||||
int director_mode = Swig_director_mode();
|
int director_mode = Swig_director_mode();
|
||||||
|
|
||||||
if (parentnode && checkAttribute(member, "storage", "virtual")) {
|
if (parentnode && checkAttribute(member, "storage", "virtual")) {
|
||||||
int parent_nodirector = GetFlag(parentnode,"feature:nodirector");
|
int parent_nodirector = GetFlag(parentnode, "feature:nodirector");
|
||||||
if (parent_nodirector) return 0;
|
if (parent_nodirector)
|
||||||
int parent_director = director_mode && GetFlag(parentnode,"feature:director");
|
return 0;
|
||||||
int cdecl_director = parent_director || GetFlag(member,"feature:director");
|
int parent_director = director_mode && GetFlag(parentnode, "feature:director");
|
||||||
int cdecl_nodirector = GetFlag(member,"feature:nodirector");
|
int cdecl_director = parent_director || GetFlag(member, "feature:director");
|
||||||
|
int cdecl_nodirector = GetFlag(member, "feature:nodirector");
|
||||||
return cdecl_director && !cdecl_nodirector && !GetFlag(member, "feature:extend");
|
return cdecl_director && !cdecl_nodirector && !GetFlag(member, "feature:extend");
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_member_director(Node* member)
|
int is_member_director(Node *member) {
|
||||||
{
|
|
||||||
return is_member_director(Getattr(member, "parentNode"), member);
|
return is_member_director(Getattr(member, "parentNode"), member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,37 +50,36 @@ int is_member_director(Node* member)
|
||||||
/* Clean overloaded list. Removes templates, ignored, and errors */
|
/* Clean overloaded list. Removes templates, ignored, and errors */
|
||||||
|
|
||||||
void clean_overloaded(Node *n) {
|
void clean_overloaded(Node *n) {
|
||||||
Node *nn = Getattr(n,"sym:overloaded");
|
Node *nn = Getattr(n, "sym:overloaded");
|
||||||
Node *first = 0;
|
Node *first = 0;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
while (nn) {
|
while (nn) {
|
||||||
String *ntype = nodeType(nn);
|
String *ntype = nodeType(nn);
|
||||||
if ((GetFlag(nn,"feature:ignore")) ||
|
if ((GetFlag(nn, "feature:ignore")) ||
|
||||||
(Getattr(nn,"error")) ||
|
(Getattr(nn, "error")) ||
|
||||||
(Strcmp(ntype,"template") == 0) ||
|
(Strcmp(ntype, "template") == 0) ||
|
||||||
((Strcmp(ntype,"cdecl") == 0) && is_protected(nn) && !is_member_director(nn)) ||
|
((Strcmp(ntype, "cdecl") == 0) && is_protected(nn) && !is_member_director(nn)) || ((Strcmp(ntype, "using") == 0) && !firstChild(nn))) {
|
||||||
((Strcmp(ntype,"using") == 0) && !firstChild(nn))) {
|
|
||||||
/* Remove from overloaded list */
|
/* Remove from overloaded list */
|
||||||
Node *ps = Getattr(nn,"sym:previousSibling");
|
Node *ps = Getattr(nn, "sym:previousSibling");
|
||||||
Node *ns = Getattr(nn,"sym:nextSibling");
|
Node *ns = Getattr(nn, "sym:nextSibling");
|
||||||
if (ps) {
|
if (ps) {
|
||||||
Setattr(ps,"sym:nextSibling",ns);
|
Setattr(ps, "sym:nextSibling", ns);
|
||||||
}
|
|
||||||
if (ns) {
|
|
||||||
Setattr(ns,"sym:previousSibling",ps);
|
|
||||||
}
|
}
|
||||||
Delattr(nn,"sym:previousSibling");
|
if (ns) {
|
||||||
Delattr(nn,"sym:nextSibling");
|
Setattr(ns, "sym:previousSibling", ps);
|
||||||
Delattr(nn,"sym:overloaded");
|
}
|
||||||
|
Delattr(nn, "sym:previousSibling");
|
||||||
|
Delattr(nn, "sym:nextSibling");
|
||||||
|
Delattr(nn, "sym:overloaded");
|
||||||
nn = ns;
|
nn = ns;
|
||||||
continue;
|
continue;
|
||||||
} else if ((Strcmp(ntype,"using") == 0)) {
|
} else if ((Strcmp(ntype, "using") == 0)) {
|
||||||
/* A possibly dangerous parse tree hack. We're going to
|
/* A possibly dangerous parse tree hack. We're going to
|
||||||
cut the parse tree node out and stick in the resolved
|
cut the parse tree node out and stick in the resolved
|
||||||
using declarations */
|
using declarations */
|
||||||
|
|
||||||
Node *ps = Getattr(nn,"sym:previousSibling");
|
Node *ps = Getattr(nn, "sym:previousSibling");
|
||||||
Node *ns = Getattr(nn,"sym:nextSibling");
|
Node *ns = Getattr(nn, "sym:nextSibling");
|
||||||
Node *un = firstChild(nn);
|
Node *un = firstChild(nn);
|
||||||
Node *pn = un;
|
Node *pn = un;
|
||||||
|
|
||||||
|
|
@ -92,32 +87,34 @@ void clean_overloaded(Node *n) {
|
||||||
first = un;
|
first = un;
|
||||||
}
|
}
|
||||||
while (pn) {
|
while (pn) {
|
||||||
Node *ppn = Getattr(pn,"sym:nextSibling");
|
Node *ppn = Getattr(pn, "sym:nextSibling");
|
||||||
Setattr(pn,"sym:overloaded",first);
|
Setattr(pn, "sym:overloaded", first);
|
||||||
Setattr(pn,"sym:overname", NewStringf("%s_%d", Getattr(nn,"sym:overname"), cnt++));
|
Setattr(pn, "sym:overname", NewStringf("%s_%d", Getattr(nn, "sym:overname"), cnt++));
|
||||||
if (ppn) pn = ppn;
|
if (ppn)
|
||||||
else break;
|
pn = ppn;
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (ps) {
|
if (ps) {
|
||||||
Setattr(ps,"sym:nextSibling",un);
|
Setattr(ps, "sym:nextSibling", un);
|
||||||
Setattr(un,"sym:previousSibling",ps);
|
Setattr(un, "sym:previousSibling", ps);
|
||||||
}
|
}
|
||||||
if (ns) {
|
if (ns) {
|
||||||
Setattr(ns,"sym:previousSibling", pn);
|
Setattr(ns, "sym:previousSibling", pn);
|
||||||
Setattr(pn,"sym:nextSibling",ns);
|
Setattr(pn, "sym:nextSibling", ns);
|
||||||
}
|
}
|
||||||
if (!first) {
|
if (!first) {
|
||||||
first = un;
|
first = un;
|
||||||
Setattr(nn,"sym:overloaded",first);
|
Setattr(nn, "sym:overloaded", first);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!first) first = nn;
|
if (!first)
|
||||||
Setattr(nn,"sym:overloaded",first);
|
first = nn;
|
||||||
|
Setattr(nn, "sym:overloaded", first);
|
||||||
}
|
}
|
||||||
nn = Getattr(nn,"sym:nextSibling");
|
nn = Getattr(nn, "sym:nextSibling");
|
||||||
}
|
}
|
||||||
if (!first || (first && !Getattr(first,"sym:nextSibling"))) {
|
if (!first || (first && !Getattr(first, "sym:nextSibling"))) {
|
||||||
Delattr(n,"sym:overloaded");
|
Delattr(n, "sym:overloaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,321 +22,266 @@ static File *out = 0;
|
||||||
static int xmllite = 0;
|
static int xmllite = 0;
|
||||||
|
|
||||||
|
|
||||||
class XML
|
class XML:public Language {
|
||||||
: public Language
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int indent_level;
|
int indent_level;
|
||||||
long id;
|
long id;
|
||||||
XML()
|
|
||||||
: indent_level( 0 )
|
|
||||||
, id( 0 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~XML()
|
XML() :indent_level(0) , id(0) {
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
virtual ~ XML() {
|
||||||
|
}
|
||||||
|
|
||||||
virtual void main(int argc, char *argv[])
|
virtual void main(int argc, char *argv[]) {
|
||||||
{
|
SWIG_typemap_lang("xml");
|
||||||
SWIG_typemap_lang("xml");
|
for (int iX = 0; iX < argc; iX++) {
|
||||||
for( int iX = 0; iX < argc; iX++ )
|
if (strcmp(argv[iX], "-xml") == 0) {
|
||||||
{
|
char *extension = 0;
|
||||||
if( strcmp( argv[iX], "-xml" ) == 0 )
|
if (iX + 1 >= argc)
|
||||||
{
|
continue;
|
||||||
char * extension = 0;
|
extension = argv[iX + 1] + strlen(argv[iX + 1]) - 4;
|
||||||
if( iX + 1 >= argc )
|
if (strcmp(extension, ".xml"))
|
||||||
continue;
|
continue;
|
||||||
extension = argv[iX+1]+strlen(argv[iX+1])-4;
|
iX++;
|
||||||
if( strcmp( extension, ".xml" ) )
|
Swig_mark_arg(iX);
|
||||||
continue;
|
String *outfile = NewString(argv[iX]);
|
||||||
iX++;
|
out = NewFile(outfile, "w");
|
||||||
Swig_mark_arg (iX);
|
if (!out) {
|
||||||
String * outfile = NewString( argv[iX] );
|
FileErrorDisplay(outfile);
|
||||||
out = NewFile(outfile,"w");
|
SWIG_exit(EXIT_FAILURE);
|
||||||
if (!out)
|
|
||||||
{
|
|
||||||
FileErrorDisplay(outfile);
|
|
||||||
SWIG_exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if( strcmp( argv[iX], "-xmllang" ) == 0 )
|
|
||||||
{
|
|
||||||
Swig_mark_arg (iX);
|
|
||||||
iX++;
|
|
||||||
SWIG_typemap_lang(argv[iX]);
|
|
||||||
Swig_mark_arg (iX);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if( strcmp( argv[iX], "-help" ) == 0 )
|
|
||||||
{
|
|
||||||
fputs( usage, stdout );
|
|
||||||
}
|
|
||||||
if( strcmp( argv[iX], "-xmllite" ) == 0 )
|
|
||||||
{
|
|
||||||
Swig_mark_arg (iX);
|
|
||||||
xmllite = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a symbol to the parser for conditional compilation
|
|
||||||
Preprocessor_define("SWIGXML 1",0);
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(argv[iX], "-xmllang") == 0) {
|
||||||
|
Swig_mark_arg(iX);
|
||||||
|
iX++;
|
||||||
|
SWIG_typemap_lang(argv[iX]);
|
||||||
|
Swig_mark_arg(iX);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(argv[iX], "-help") == 0) {
|
||||||
|
fputs(usage, stdout);
|
||||||
|
}
|
||||||
|
if (strcmp(argv[iX], "-xmllite") == 0) {
|
||||||
|
Swig_mark_arg(iX);
|
||||||
|
xmllite = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a symbol to the parser for conditional compilation
|
||||||
|
Preprocessor_define("SWIGXML 1", 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Top of the parse tree */
|
/* Top of the parse tree */
|
||||||
|
|
||||||
virtual int top(Node *n)
|
virtual int top(Node *n) {
|
||||||
{
|
if (out == 0) {
|
||||||
if( out == 0 )
|
String *outfile = Getattr(n, "outfile");
|
||||||
{
|
Replaceall(outfile, ".cxx", ".xml");
|
||||||
String *outfile = Getattr(n,"outfile");
|
Replaceall(outfile, ".cpp", ".xml");
|
||||||
Replaceall(outfile,".cxx", ".xml");
|
Replaceall(outfile, ".c", ".xml");
|
||||||
Replaceall(outfile,".cpp", ".xml");
|
out = NewFile(outfile, "w");
|
||||||
Replaceall(outfile,".c", ".xml");
|
if (!out) {
|
||||||
out = NewFile(outfile,"w");
|
FileErrorDisplay(outfile);
|
||||||
if (!out)
|
SWIG_exit(EXIT_FAILURE);
|
||||||
{
|
}
|
||||||
FileErrorDisplay(outfile);
|
}
|
||||||
SWIG_exit(EXIT_FAILURE);
|
Printf(out, "<?xml version=\"1.0\" ?> \n");
|
||||||
}
|
Xml_print_tree(n);
|
||||||
}
|
return SWIG_OK;
|
||||||
Printf( out, "<?xml version=\"1.0\" ?> \n" );
|
}
|
||||||
Xml_print_tree(n);
|
|
||||||
return SWIG_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void print_indent(int l) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < indent_level; i++) {
|
||||||
|
Printf(out, " ");
|
||||||
|
}
|
||||||
|
if (l) {
|
||||||
|
Printf(out, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Xml_print_tree(DOH *obj) {
|
||||||
|
while (obj) {
|
||||||
|
Xml_print_node(obj);
|
||||||
|
obj = nextSibling(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void print_indent(int l)
|
void Xml_print_attributes(Node *obj) {
|
||||||
{
|
String *k;
|
||||||
int i;
|
indent_level += 4;
|
||||||
for (i = 0; i < indent_level; i++)
|
print_indent(0);
|
||||||
{
|
Printf(out, "<attributelist id=\"%ld\" addr=\"%x\" >\n", ++id, obj);
|
||||||
Printf(out, " ");
|
indent_level += 4;
|
||||||
}
|
Iterator ki;
|
||||||
if (l)
|
ki = First(obj);
|
||||||
{
|
while (ki.key) {
|
||||||
Printf(out, " ");
|
k = ki.key;
|
||||||
}
|
if ((Cmp(k, "nodeType") == 0)
|
||||||
|
|| (Cmp(k, "firstChild") == 0)
|
||||||
|
|| (Cmp(k, "lastChild") == 0)
|
||||||
|
|| (Cmp(k, "parentNode") == 0)
|
||||||
|
|| (Cmp(k, "nextSibling") == 0)
|
||||||
|
|| (Cmp(k, "previousSibling") == 0)
|
||||||
|
|| (*(Char(k)) == '$')) {
|
||||||
|
/* Do nothing */
|
||||||
|
} else if (Cmp(k, "module") == 0) {
|
||||||
|
Xml_print_module(Getattr(obj, k));
|
||||||
|
} else if (Cmp(k, "baselist") == 0) {
|
||||||
|
Xml_print_baselist(Getattr(obj, k));
|
||||||
|
} else if (!xmllite && Cmp(k, "typescope") == 0) {
|
||||||
|
Xml_print_typescope(Getattr(obj, k));
|
||||||
|
} else if (!xmllite && Cmp(k, "typetab") == 0) {
|
||||||
|
Xml_print_typetab(Getattr(obj, k));
|
||||||
|
} else if (Cmp(k, "kwargs") == 0) {
|
||||||
|
Xml_print_kwargs(Getattr(obj, k));
|
||||||
|
} else if (Cmp(k, "parms") == 0 || Cmp(k, "pattern") == 0) {
|
||||||
|
Xml_print_parmlist(Getattr(obj, k));
|
||||||
|
} else {
|
||||||
|
DOH *o;
|
||||||
|
print_indent(0);
|
||||||
|
if (DohIsString(Getattr(obj, k))) {
|
||||||
|
String *ck = NewString(k);
|
||||||
|
o = Str(Getattr(obj, k));
|
||||||
|
Replaceall(ck, ":", "_");
|
||||||
|
Replaceall(ck, "<", "<");
|
||||||
|
/* Do first to avoid aliasing errors. */
|
||||||
|
Replaceall(o, "&", "&");
|
||||||
|
Replaceall(o, "<", "<");
|
||||||
|
Replaceall(o, "\"", """);
|
||||||
|
Replaceall(o, "\\", "\\\\");
|
||||||
|
Replaceall(o, "\n", " ");
|
||||||
|
Printf(out, "<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o);
|
||||||
|
Delete(o);
|
||||||
|
Delete(ck);
|
||||||
|
} else {
|
||||||
|
o = Getattr(obj, k);
|
||||||
|
String *ck = NewString(k);
|
||||||
|
Replaceall(ck, ":", "_");
|
||||||
|
Printf(out, "<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o);
|
||||||
|
Delete(ck);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
ki = Next(ki);
|
||||||
|
}
|
||||||
|
indent_level -= 4;
|
||||||
|
print_indent(0);
|
||||||
|
Printf(out, "</attributelist >\n");
|
||||||
|
indent_level -= 4;
|
||||||
|
}
|
||||||
|
|
||||||
void Xml_print_tree(DOH *obj)
|
void Xml_print_node(Node *obj) {
|
||||||
{
|
Node *cobj;
|
||||||
while (obj)
|
|
||||||
{
|
|
||||||
Xml_print_node(obj);
|
|
||||||
obj = nextSibling(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Xml_print_attributes(Node * obj)
|
print_indent(0);
|
||||||
{
|
Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", nodeType(obj), ++id, obj);
|
||||||
String *k;
|
Xml_print_attributes(obj);
|
||||||
indent_level += 4;
|
cobj = firstChild(obj);
|
||||||
print_indent(0);
|
if (cobj) {
|
||||||
Printf( out, "<attributelist id=\"%ld\" addr=\"%x\" >\n", ++id, obj );
|
indent_level += 4;
|
||||||
indent_level += 4;
|
Printf(out, "\n");
|
||||||
Iterator ki;
|
Xml_print_tree(cobj);
|
||||||
ki = First(obj);
|
indent_level -= 4;
|
||||||
while (ki.key) {
|
} else {
|
||||||
k = ki.key;
|
print_indent(1);
|
||||||
if ((Cmp(k,"nodeType") == 0)
|
Printf(out, "\n");
|
||||||
|| (Cmp(k,"firstChild") == 0)
|
}
|
||||||
|| (Cmp(k,"lastChild") == 0)
|
print_indent(0);
|
||||||
|| (Cmp(k,"parentNode") == 0)
|
Printf(out, "</%s >\n", nodeType(obj));
|
||||||
|| (Cmp(k,"nextSibling") == 0)
|
}
|
||||||
|| (Cmp(k,"previousSibling") == 0)
|
|
||||||
|| (*(Char(k)) == '$'))
|
|
||||||
{
|
|
||||||
/* Do nothing */
|
|
||||||
}
|
|
||||||
else if (Cmp(k,"module") == 0)
|
|
||||||
{
|
|
||||||
Xml_print_module( Getattr(obj,k) );
|
|
||||||
}
|
|
||||||
else if (Cmp(k,"baselist") == 0)
|
|
||||||
{
|
|
||||||
Xml_print_baselist( Getattr(obj,k) );
|
|
||||||
}
|
|
||||||
else if (!xmllite && Cmp(k,"typescope") == 0)
|
|
||||||
{
|
|
||||||
Xml_print_typescope( Getattr(obj,k) );
|
|
||||||
}
|
|
||||||
else if (!xmllite && Cmp(k,"typetab") == 0)
|
|
||||||
{
|
|
||||||
Xml_print_typetab( Getattr(obj,k) );
|
|
||||||
}
|
|
||||||
else if (Cmp(k,"kwargs") == 0)
|
|
||||||
{
|
|
||||||
Xml_print_kwargs( Getattr(obj,k) );
|
|
||||||
}
|
|
||||||
else if (Cmp(k,"parms") == 0 || Cmp(k, "pattern") == 0 )
|
|
||||||
{
|
|
||||||
Xml_print_parmlist( Getattr(obj,k) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DOH *o;
|
|
||||||
print_indent(0);
|
|
||||||
if (DohIsString(Getattr(obj,k)))
|
|
||||||
{
|
|
||||||
String *ck = NewString(k);
|
|
||||||
o = Str(Getattr(obj,k));
|
|
||||||
Replaceall( ck, ":", "_" );
|
|
||||||
Replaceall( ck, "<", "<" );
|
|
||||||
/* Do first to avoid aliasing errors. */
|
|
||||||
Replaceall( o, "&", "&" );
|
|
||||||
Replaceall( o, "<", "<" );
|
|
||||||
Replaceall( o, "\"", """ );
|
|
||||||
Replaceall( o, "\\", "\\\\" );
|
|
||||||
Replaceall( o, "\n", " " );
|
|
||||||
Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
|
|
||||||
Delete(o);
|
|
||||||
Delete(ck);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
o = Getattr(obj,k);
|
|
||||||
String *ck = NewString(k);
|
|
||||||
Replaceall( ck, ":", "_" );
|
|
||||||
Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
|
|
||||||
Delete(ck);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ki = Next(ki);
|
|
||||||
}
|
|
||||||
indent_level -= 4;
|
|
||||||
print_indent(0);
|
|
||||||
Printf( out, "</attributelist >\n" );
|
|
||||||
indent_level -= 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Xml_print_node(Node *obj)
|
|
||||||
{
|
|
||||||
Node *cobj;
|
|
||||||
|
|
||||||
print_indent(0);
|
|
||||||
Printf(out,"<%s id=\"%ld\" addr=\"%x\" >\n", nodeType(obj), ++id, obj);
|
|
||||||
Xml_print_attributes( obj );
|
|
||||||
cobj = firstChild(obj);
|
|
||||||
if (cobj)
|
|
||||||
{
|
|
||||||
indent_level += 4;
|
|
||||||
Printf(out,"\n");
|
|
||||||
Xml_print_tree(cobj);
|
|
||||||
indent_level -= 4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print_indent(1);
|
|
||||||
Printf(out,"\n");
|
|
||||||
}
|
|
||||||
print_indent(0);
|
|
||||||
Printf(out,"</%s >\n", nodeType(obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Xml_print_parmlist(ParmList *p)
|
void Xml_print_parmlist(ParmList *p) {
|
||||||
{
|
|
||||||
|
|
||||||
print_indent(0);
|
print_indent(0);
|
||||||
Printf( out, "<parmlist id=\"%ld\" addr=\"%x\" >\n", ++id, p );
|
Printf(out, "<parmlist id=\"%ld\" addr=\"%x\" >\n", ++id, p);
|
||||||
indent_level += 4;
|
indent_level += 4;
|
||||||
while(p)
|
while (p) {
|
||||||
{
|
print_indent(0);
|
||||||
print_indent(0);
|
Printf(out, "<parm id=\"%ld\">\n", ++id);
|
||||||
Printf( out, "<parm id=\"%ld\">\n", ++id );
|
Xml_print_attributes(p);
|
||||||
Xml_print_attributes( p );
|
print_indent(0);
|
||||||
print_indent(0);
|
Printf(out, "</parm >\n");
|
||||||
Printf( out, "</parm >\n" );
|
p = nextSibling(p);
|
||||||
p = nextSibling(p);
|
}
|
||||||
}
|
indent_level -= 4;
|
||||||
indent_level -= 4;
|
print_indent(0);
|
||||||
print_indent(0);
|
Printf(out, "</parmlist >\n");
|
||||||
Printf( out, "</parmlist >\n" );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Xml_print_baselist(List *p)
|
void Xml_print_baselist(List *p) {
|
||||||
{
|
|
||||||
|
|
||||||
print_indent(0);
|
print_indent(0);
|
||||||
Printf( out, "<baselist id=\"%ld\" addr=\"%x\" >\n", ++id, p );
|
Printf(out, "<baselist id=\"%ld\" addr=\"%x\" >\n", ++id, p);
|
||||||
indent_level += 4;
|
indent_level += 4;
|
||||||
Iterator s;
|
Iterator s;
|
||||||
for (s = First(p); s.item; s = Next(s))
|
for (s = First(p); s.item; s = Next(s)) {
|
||||||
{
|
print_indent(0);
|
||||||
print_indent(0);
|
String *item_name = Xml_escape_string(s.item);
|
||||||
String *item_name = Xml_escape_string(s.item);
|
Printf(out, "<base name=\"%s\" id=\"%ld\" addr=\"%x\" />\n", item_name, ++id, s.item);
|
||||||
Printf( out, "<base name=\"%s\" id=\"%ld\" addr=\"%x\" />\n", item_name, ++id, s.item );
|
Delete(item_name);
|
||||||
Delete(item_name);
|
}
|
||||||
}
|
indent_level -= 4;
|
||||||
indent_level -= 4;
|
print_indent(0);
|
||||||
print_indent(0);
|
Printf(out, "</baselist >\n");
|
||||||
Printf( out, "</baselist >\n" );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
String *Xml_escape_string(String *str) {
|
String *Xml_escape_string(String *str) {
|
||||||
String *escaped_str = 0;
|
String *escaped_str = 0;
|
||||||
if (str) {
|
if (str) {
|
||||||
escaped_str = NewString(str);
|
escaped_str = NewString(str);
|
||||||
Replaceall( escaped_str, "&", "&" );
|
Replaceall(escaped_str, "&", "&");
|
||||||
Replaceall( escaped_str, "<", "<" );
|
Replaceall(escaped_str, "<", "<");
|
||||||
Replaceall( escaped_str, "\"", """ );
|
Replaceall(escaped_str, "\"", """);
|
||||||
Replaceall( escaped_str, "\\", "\\\\" );
|
Replaceall(escaped_str, "\\", "\\\\");
|
||||||
Replaceall( escaped_str, "\n", " " );
|
Replaceall(escaped_str, "\n", " ");
|
||||||
}
|
}
|
||||||
return escaped_str;
|
return escaped_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Xml_print_module(Node *p)
|
void Xml_print_module(Node *p) {
|
||||||
{
|
|
||||||
|
|
||||||
print_indent(0);
|
print_indent(0);
|
||||||
Printf( out, "<attribute name=\"module\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", Getattr( p, "name"), ++id, p );
|
Printf(out, "<attribute name=\"module\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", Getattr(p, "name"), ++id, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Xml_print_kwargs(Hash *p)
|
void Xml_print_kwargs(Hash *p) {
|
||||||
{
|
Xml_print_hash(p, "kwargs");
|
||||||
Xml_print_hash( p, "kwargs" );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Xml_print_typescope(Hash *p)
|
void Xml_print_typescope(Hash *p) {
|
||||||
{
|
|
||||||
|
|
||||||
Xml_print_hash( p, "typescope" );
|
Xml_print_hash(p, "typescope");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Xml_print_typetab(Hash *p)
|
void Xml_print_typetab(Hash *p) {
|
||||||
{
|
|
||||||
|
|
||||||
Xml_print_hash( p, "typetab" );
|
Xml_print_hash(p, "typetab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Xml_print_hash(Hash *p, const char * markup)
|
void Xml_print_hash(Hash *p, const char *markup) {
|
||||||
{
|
|
||||||
|
|
||||||
print_indent(0);
|
print_indent(0);
|
||||||
Printf( out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p );
|
Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p);
|
||||||
Xml_print_attributes( p );
|
Xml_print_attributes(p);
|
||||||
indent_level += 4;
|
indent_level += 4;
|
||||||
Iterator n = First(p);
|
Iterator n = First(p);
|
||||||
while(n.key)
|
while (n.key) {
|
||||||
{
|
print_indent(0);
|
||||||
print_indent(0);
|
Printf(out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item);
|
||||||
Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item );
|
Xml_print_attributes(n.item);
|
||||||
Xml_print_attributes( n.item );
|
print_indent(0);
|
||||||
print_indent(0);
|
Printf(out, "</%ssitem >\n", markup);
|
||||||
Printf( out, "</%ssitem >\n", markup );
|
n = Next(n);
|
||||||
n = Next(n);
|
}
|
||||||
}
|
indent_level -= 4;
|
||||||
indent_level -= 4;
|
print_indent(0);
|
||||||
print_indent(0);
|
Printf(out, "</%s >\n", markup);
|
||||||
Printf( out, "</%s >\n", markup );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -349,29 +294,27 @@ public:
|
||||||
* up being a post-processing version of the tree.
|
* up being a post-processing version of the tree.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Swig_print_xml(DOH *obj, String* filename)
|
void Swig_print_xml(DOH *obj, String *filename) {
|
||||||
{
|
XML xml;
|
||||||
XML xml;
|
xmllite = 1;
|
||||||
xmllite = 1;
|
|
||||||
|
|
||||||
if (! filename) {
|
if (!filename) {
|
||||||
out = stdout;
|
out = stdout;
|
||||||
|
} else {
|
||||||
|
out = NewFile(filename, "w");
|
||||||
|
if (!out) {
|
||||||
|
FileErrorDisplay(filename);
|
||||||
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
out = NewFile(filename, "w");
|
|
||||||
if (!out) {
|
Printf(out, "<?xml version=\"1.0\" ?> \n");
|
||||||
FileErrorDisplay(filename);
|
xml.Xml_print_tree(obj);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Printf( out, "<?xml version=\"1.0\" ?> \n" );
|
|
||||||
xml.Xml_print_tree(obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Language * new_swig_xml() {
|
static Language *new_swig_xml() {
|
||||||
return new XML();
|
return new XML();
|
||||||
}
|
}
|
||||||
extern "C" Language * swig_xml( void ) {
|
extern "C" Language *swig_xml(void) {
|
||||||
return new_swig_xml();
|
return new_swig_xml();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -16,9 +16,9 @@ char cvsroot_expr_c[] = "$Header$";
|
||||||
static SwigScanner *scan = 0;
|
static SwigScanner *scan = 0;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int op;
|
int op;
|
||||||
long value;
|
long value;
|
||||||
String *svalue;
|
String *svalue;
|
||||||
} exprval;
|
} exprval;
|
||||||
|
|
||||||
#define EXPR_TOP 1
|
#define EXPR_TOP 1
|
||||||
|
|
@ -27,11 +27,11 @@ typedef struct {
|
||||||
#define EXPR_GROUP 4
|
#define EXPR_GROUP 4
|
||||||
#define EXPR_UMINUS 100
|
#define EXPR_UMINUS 100
|
||||||
|
|
||||||
static exprval stack[256]; /* Parsing stack */
|
static exprval stack[256]; /* Parsing stack */
|
||||||
static int sp = 0; /* Stack pointer */
|
static int sp = 0; /* Stack pointer */
|
||||||
static int prec[256]; /* Precedence rules */
|
static int prec[256]; /* Precedence rules */
|
||||||
static int expr_init = 0; /* Initialization flag */
|
static int expr_init = 0; /* Initialization flag */
|
||||||
static char *errmsg = 0; /* Parsing error */
|
static char *errmsg = 0; /* Parsing error */
|
||||||
|
|
||||||
/* Initialize the precedence table for various operators. Low values have higher precedence */
|
/* Initialize the precedence table for various operators. Low values have higher precedence */
|
||||||
static void init_precedence() {
|
static void init_precedence() {
|
||||||
|
|
@ -66,9 +66,9 @@ static void init_precedence() {
|
||||||
/* Reduce a single operator on the stack */
|
/* Reduce a single operator on the stack */
|
||||||
/* return 0 on failure, 1 on success */
|
/* return 0 on failure, 1 on success */
|
||||||
static int reduce_op() {
|
static int reduce_op() {
|
||||||
long op_token = stack[sp-1].value;
|
long op_token = stack[sp - 1].value;
|
||||||
assert(sp > 0);
|
assert(sp > 0);
|
||||||
assert(stack[sp-1].op == EXPR_OP);
|
assert(stack[sp - 1].op == EXPR_OP);
|
||||||
/* do some basic checking first: */
|
/* do some basic checking first: */
|
||||||
if (stack[sp].op != EXPR_VALUE) {
|
if (stack[sp].op != EXPR_VALUE) {
|
||||||
errmsg = "Right-hand side is not value";
|
errmsg = "Right-hand side is not value";
|
||||||
|
|
@ -90,23 +90,23 @@ static int reduce_op() {
|
||||||
errmsg = "Left-hand side of binary operator is not a value";
|
errmsg = "Left-hand side of binary operator is not a value";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((!stack[sp-2].svalue) != (!stack[sp].svalue)) {
|
if ((!stack[sp - 2].svalue) != (!stack[sp].svalue)) {
|
||||||
errmsg = "Can't mix strings and integers in expression";
|
errmsg = "Can't mix strings and integers in expression";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stack[sp].svalue) {
|
if (stack[sp].svalue) {
|
||||||
/* A binary string expression */
|
/* A binary string expression */
|
||||||
switch(stack[sp-1].value) {
|
switch (stack[sp - 1].value) {
|
||||||
case SWIG_TOKEN_EQUALTO:
|
case SWIG_TOKEN_EQUALTO:
|
||||||
stack[sp-2].value = (Strcmp(stack[sp-2].svalue,stack[sp].svalue) == 0);
|
stack[sp - 2].value = (Strcmp(stack[sp - 2].svalue, stack[sp].svalue) == 0);
|
||||||
Delete(stack[sp-2].svalue);
|
Delete(stack[sp - 2].svalue);
|
||||||
Delete(stack[sp].svalue);
|
Delete(stack[sp].svalue);
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_NOTEQUAL:
|
case SWIG_TOKEN_NOTEQUAL:
|
||||||
stack[sp-2].value = (Strcmp(stack[sp-2].svalue,stack[sp].svalue) != 0);
|
stack[sp - 2].value = (Strcmp(stack[sp - 2].svalue, stack[sp].svalue) != 0);
|
||||||
Delete(stack[sp-2].svalue);
|
Delete(stack[sp - 2].svalue);
|
||||||
Delete(stack[sp].svalue);
|
Delete(stack[sp].svalue);
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
|
|
@ -116,89 +116,89 @@ static int reduce_op() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch(op_token) {
|
switch (op_token) {
|
||||||
case SWIG_TOKEN_STAR:
|
case SWIG_TOKEN_STAR:
|
||||||
stack[sp-2].value = stack[sp-2].value * stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value * stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_EQUALTO:
|
case SWIG_TOKEN_EQUALTO:
|
||||||
stack[sp-2].value = stack[sp-2].value == stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value == stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_NOTEQUAL:
|
case SWIG_TOKEN_NOTEQUAL:
|
||||||
stack[sp-2].value = stack[sp-2].value != stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value != stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_PLUS:
|
case SWIG_TOKEN_PLUS:
|
||||||
stack[sp-2].value = stack[sp-2].value + stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value + stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_MINUS:
|
case SWIG_TOKEN_MINUS:
|
||||||
stack[sp-2].value = stack[sp-2].value - stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value - stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_AND:
|
case SWIG_TOKEN_AND:
|
||||||
stack[sp-2].value = stack[sp-2].value & stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value & stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_LAND:
|
case SWIG_TOKEN_LAND:
|
||||||
stack[sp-2].value = stack[sp-2].value && stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value && stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_OR:
|
case SWIG_TOKEN_OR:
|
||||||
stack[sp-2].value = stack[sp-2].value | stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value | stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_LOR:
|
case SWIG_TOKEN_LOR:
|
||||||
stack[sp-2].value = stack[sp-2].value || stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value || stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_XOR:
|
case SWIG_TOKEN_XOR:
|
||||||
stack[sp-2].value = stack[sp-2].value ^ stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value ^ stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_LESSTHAN:
|
case SWIG_TOKEN_LESSTHAN:
|
||||||
stack[sp-2].value = stack[sp-2].value < stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value < stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_GREATERTHAN:
|
case SWIG_TOKEN_GREATERTHAN:
|
||||||
stack[sp-2].value = stack[sp-2].value > stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value > stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_LTEQUAL:
|
case SWIG_TOKEN_LTEQUAL:
|
||||||
stack[sp-2].value = stack[sp-2].value <= stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value <= stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_GTEQUAL:
|
case SWIG_TOKEN_GTEQUAL:
|
||||||
stack[sp-2].value = stack[sp-2].value >= stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value >= stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_NOT:
|
case SWIG_TOKEN_NOT:
|
||||||
stack[sp-1].value = ~stack[sp].value;
|
stack[sp - 1].value = ~stack[sp].value;
|
||||||
sp--;
|
sp--;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_LNOT:
|
case SWIG_TOKEN_LNOT:
|
||||||
stack[sp-1].value = !stack[sp].value;
|
stack[sp - 1].value = !stack[sp].value;
|
||||||
sp--;
|
sp--;
|
||||||
break;
|
break;
|
||||||
case EXPR_UMINUS:
|
case EXPR_UMINUS:
|
||||||
stack[sp-1].value = -stack[sp].value;
|
stack[sp - 1].value = -stack[sp].value;
|
||||||
sp--;
|
sp--;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_SLASH:
|
case SWIG_TOKEN_SLASH:
|
||||||
stack[sp-2].value = stack[sp-2].value / stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value / stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_PERCENT:
|
case SWIG_TOKEN_PERCENT:
|
||||||
stack[sp-2].value = stack[sp-2].value % stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value % stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_LSHIFT:
|
case SWIG_TOKEN_LSHIFT:
|
||||||
stack[sp-2].value = stack[sp-2].value << stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value << stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_RSHIFT:
|
case SWIG_TOKEN_RSHIFT:
|
||||||
stack[sp-2].value = stack[sp-2].value >> stack[sp].value;
|
stack[sp - 2].value = stack[sp - 2].value >> stack[sp].value;
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -218,14 +218,14 @@ static int reduce_op() {
|
||||||
* Initialize the expression evaluator
|
* Initialize the expression evaluator
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Preprocessor_expr_init(void) {
|
||||||
Preprocessor_expr_init (void) {
|
if (!expr_init)
|
||||||
if (!expr_init) init_precedence();
|
init_precedence();
|
||||||
if (!scan) scan = NewSwigScanner();
|
if (!scan)
|
||||||
|
scan = NewSwigScanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Preprocessor_expr_delete(void) {
|
||||||
Preprocessor_expr_delete (void) {
|
|
||||||
SwigScanner_clear(scan);
|
SwigScanner_clear(scan);
|
||||||
DelSwigScanner(scan);
|
DelSwigScanner(scan);
|
||||||
}
|
}
|
||||||
|
|
@ -235,11 +235,12 @@ Preprocessor_expr_delete (void) {
|
||||||
* Tokenizer
|
* Tokenizer
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int expr_token(SwigScanner *s) {
|
static int expr_token(SwigScanner * s) {
|
||||||
int t;
|
int t;
|
||||||
while(1) {
|
while (1) {
|
||||||
t = SwigScanner_token(s);
|
t = SwigScanner_token(s);
|
||||||
if (!((t == SWIG_TOKEN_BACKSLASH) || (t == SWIG_TOKEN_ENDLINE))) break;
|
if (!((t == SWIG_TOKEN_BACKSLASH) || (t == SWIG_TOKEN_ENDLINE)))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
@ -250,20 +251,19 @@ static int expr_token(SwigScanner *s) {
|
||||||
* Evaluates an arithmetic expression. Returns the result and sets an error code.
|
* Evaluates an arithmetic expression. Returns the result and sets an error code.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Preprocessor_expr(DOH *s, int *error) {
|
||||||
Preprocessor_expr(DOH *s, int *error) {
|
int token = 0;
|
||||||
int token = 0;
|
int op = 0;
|
||||||
int op = 0;
|
|
||||||
|
|
||||||
sp = 0;
|
sp = 0;
|
||||||
assert(s);
|
assert(s);
|
||||||
assert(scan);
|
assert(scan);
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
/* Printf(stdout,"evaluating : '%s'\n", s); */
|
/* Printf(stdout,"evaluating : '%s'\n", s); */
|
||||||
*error = 0;
|
*error = 0;
|
||||||
SwigScanner_clear(scan);
|
SwigScanner_clear(scan);
|
||||||
SwigScanner_push(scan,s);
|
SwigScanner_push(scan, s);
|
||||||
|
|
||||||
/* Put initial state onto the stack */
|
/* Put initial state onto the stack */
|
||||||
stack[sp].op = EXPR_TOP;
|
stack[sp].op = EXPR_TOP;
|
||||||
|
|
@ -271,7 +271,7 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Look at the top of the stack */
|
/* Look at the top of the stack */
|
||||||
switch(stack[sp].op) {
|
switch (stack[sp].op) {
|
||||||
case EXPR_TOP:
|
case EXPR_TOP:
|
||||||
/* An expression. Can be a number or another expression enclosed in parens */
|
/* An expression. Can be a number or another expression enclosed in parens */
|
||||||
token = expr_token(scan);
|
token = expr_token(scan);
|
||||||
|
|
@ -283,13 +283,14 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
if ((token == SWIG_TOKEN_INT) || (token == SWIG_TOKEN_UINT) || (token == SWIG_TOKEN_LONG) || (token == SWIG_TOKEN_ULONG)) {
|
if ((token == SWIG_TOKEN_INT) || (token == SWIG_TOKEN_UINT) || (token == SWIG_TOKEN_LONG) || (token == SWIG_TOKEN_ULONG)) {
|
||||||
/* A number. Reduce EXPR_TOP to an EXPR_VALUE */
|
/* A number. Reduce EXPR_TOP to an EXPR_VALUE */
|
||||||
char *c = Char(SwigScanner_text(scan));
|
char *c = Char(SwigScanner_text(scan));
|
||||||
stack[sp].value = (long) strtol(c,0,0);
|
stack[sp].value = (long) strtol(c, 0, 0);
|
||||||
stack[sp].svalue = 0;
|
stack[sp].svalue = 0;
|
||||||
/* stack[sp].value = (long) atol(Char(SwigScanner_text(scan))); */
|
/* stack[sp].value = (long) atol(Char(SwigScanner_text(scan))); */
|
||||||
stack[sp].op = EXPR_VALUE;
|
stack[sp].op = EXPR_VALUE;
|
||||||
} else if (token == SWIG_TOKEN_PLUS) { }
|
} else if (token == SWIG_TOKEN_PLUS) {
|
||||||
else if ((token == SWIG_TOKEN_MINUS) || (token == SWIG_TOKEN_LNOT) || (token==SWIG_TOKEN_NOT)) {
|
} else if ((token == SWIG_TOKEN_MINUS) || (token == SWIG_TOKEN_LNOT) || (token == SWIG_TOKEN_NOT)) {
|
||||||
if (token == SWIG_TOKEN_MINUS) token = EXPR_UMINUS;
|
if (token == SWIG_TOKEN_MINUS)
|
||||||
|
token = EXPR_UMINUS;
|
||||||
stack[sp].value = token;
|
stack[sp].value = token;
|
||||||
stack[sp++].op = EXPR_OP;
|
stack[sp++].op = EXPR_OP;
|
||||||
stack[sp].op = EXPR_TOP;
|
stack[sp].op = EXPR_TOP;
|
||||||
|
|
@ -299,7 +300,7 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
stack[sp].op = EXPR_TOP;
|
stack[sp].op = EXPR_TOP;
|
||||||
stack[sp].value = 0;
|
stack[sp].value = 0;
|
||||||
stack[sp].svalue = 0;
|
stack[sp].svalue = 0;
|
||||||
} else if (token == SWIG_TOKEN_ENDLINE) {
|
} else if (token == SWIG_TOKEN_ENDLINE) {
|
||||||
} else if ((token == SWIG_TOKEN_STRING)) {
|
} else if ((token == SWIG_TOKEN_STRING)) {
|
||||||
stack[sp].svalue = NewString(SwigScanner_text(scan));
|
stack[sp].svalue = NewString(SwigScanner_text(scan));
|
||||||
stack[sp].op = EXPR_VALUE;
|
stack[sp].op = EXPR_VALUE;
|
||||||
|
|
@ -307,7 +308,8 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
stack[sp].value = 0;
|
stack[sp].value = 0;
|
||||||
stack[sp].svalue = 0;
|
stack[sp].svalue = 0;
|
||||||
stack[sp].op = EXPR_VALUE;
|
stack[sp].op = EXPR_VALUE;
|
||||||
} else goto syntax_error;
|
} else
|
||||||
|
goto syntax_error;
|
||||||
break;
|
break;
|
||||||
case EXPR_VALUE:
|
case EXPR_VALUE:
|
||||||
/* A value is on the stack. We may reduce or evaluate depending on what the next token is */
|
/* A value is on the stack. We may reduce or evaluate depending on what the next token is */
|
||||||
|
|
@ -315,18 +317,20 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
/* End of input. Might have to reduce if an operator is on stack */
|
/* End of input. Might have to reduce if an operator is on stack */
|
||||||
while (sp > 0) {
|
while (sp > 0) {
|
||||||
if (stack[sp-1].op == EXPR_OP) {
|
if (stack[sp - 1].op == EXPR_OP) {
|
||||||
if (!reduce_op()) goto reduce_error;
|
if (!reduce_op())
|
||||||
} else if (stack[sp-1].op == EXPR_GROUP) {
|
goto reduce_error;
|
||||||
|
} else if (stack[sp - 1].op == EXPR_GROUP) {
|
||||||
errmsg = "Missing \')\'";
|
errmsg = "Missing \')\'";
|
||||||
*error = 1;
|
*error = 1;
|
||||||
return 0;
|
return 0;
|
||||||
} else goto syntax_error;
|
} else
|
||||||
|
goto syntax_error;
|
||||||
}
|
}
|
||||||
return stack[sp].value;
|
return stack[sp].value;
|
||||||
}
|
}
|
||||||
/* Token must be an operator */
|
/* Token must be an operator */
|
||||||
switch(token) {
|
switch (token) {
|
||||||
case SWIG_TOKEN_STAR:
|
case SWIG_TOKEN_STAR:
|
||||||
case SWIG_TOKEN_EQUALTO:
|
case SWIG_TOKEN_EQUALTO:
|
||||||
case SWIG_TOKEN_NOTEQUAL:
|
case SWIG_TOKEN_NOTEQUAL:
|
||||||
|
|
@ -345,7 +349,7 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
case SWIG_TOKEN_PERCENT:
|
case SWIG_TOKEN_PERCENT:
|
||||||
case SWIG_TOKEN_LSHIFT:
|
case SWIG_TOKEN_LSHIFT:
|
||||||
case SWIG_TOKEN_RSHIFT:
|
case SWIG_TOKEN_RSHIFT:
|
||||||
if ((sp == 0) || (stack[sp-1].op == EXPR_GROUP)) {
|
if ((sp == 0) || (stack[sp - 1].op == EXPR_GROUP)) {
|
||||||
/* No possibility of reduce. Push operator and expression */
|
/* No possibility of reduce. Push operator and expression */
|
||||||
sp++;
|
sp++;
|
||||||
stack[sp].op = EXPR_OP;
|
stack[sp].op = EXPR_OP;
|
||||||
|
|
@ -354,15 +358,17 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
stack[sp].op = EXPR_TOP;
|
stack[sp].op = EXPR_TOP;
|
||||||
stack[sp].value = 0;
|
stack[sp].value = 0;
|
||||||
} else {
|
} else {
|
||||||
if (stack[sp-1].op != EXPR_OP) goto syntax_error_expected_operator;
|
if (stack[sp - 1].op != EXPR_OP)
|
||||||
op = stack[sp-1].value; /* Previous operator */
|
goto syntax_error_expected_operator;
|
||||||
|
op = stack[sp - 1].value; /* Previous operator */
|
||||||
|
|
||||||
/* Now, depending on the precedence relationship between the last operator and the current
|
/* Now, depending on the precedence relationship between the last operator and the current
|
||||||
we will reduce or push */
|
we will reduce or push */
|
||||||
|
|
||||||
if (prec[op] <= prec[token]) {
|
if (prec[op] <= prec[token]) {
|
||||||
/* Reduce the previous operator */
|
/* Reduce the previous operator */
|
||||||
if (!reduce_op()) goto reduce_error;
|
if (!reduce_op())
|
||||||
|
goto reduce_error;
|
||||||
}
|
}
|
||||||
sp++;
|
sp++;
|
||||||
stack[sp].op = EXPR_OP;
|
stack[sp].op = EXPR_OP;
|
||||||
|
|
@ -373,15 +379,18 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SWIG_TOKEN_RPAREN:
|
case SWIG_TOKEN_RPAREN:
|
||||||
if (sp == 0) goto extra_rparen;
|
if (sp == 0)
|
||||||
|
goto extra_rparen;
|
||||||
|
|
||||||
/* Might have to reduce operators first */
|
/* Might have to reduce operators first */
|
||||||
while ((sp > 0) && (stack[sp-1].op == EXPR_OP)) {
|
while ((sp > 0) && (stack[sp - 1].op == EXPR_OP)) {
|
||||||
if (!reduce_op()) goto reduce_error;
|
if (!reduce_op())
|
||||||
|
goto reduce_error;
|
||||||
}
|
}
|
||||||
if ((sp == 0) || (stack[sp-1].op != EXPR_GROUP)) goto extra_rparen;
|
if ((sp == 0) || (stack[sp - 1].op != EXPR_GROUP))
|
||||||
stack[sp-1].op = EXPR_VALUE;
|
goto extra_rparen;
|
||||||
stack[sp-1].value = stack[sp].value;
|
stack[sp - 1].op = EXPR_VALUE;
|
||||||
|
stack[sp - 1].value = stack[sp].value;
|
||||||
sp--;
|
sp--;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -391,27 +400,27 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"Internal error in expression evaluator.\n");
|
fprintf(stderr, "Internal error in expression evaluator.\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
syntax_error:
|
syntax_error:
|
||||||
errmsg = "Syntax error";
|
errmsg = "Syntax error";
|
||||||
*error = 1;
|
*error = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
syntax_error_expected_operator:
|
syntax_error_expected_operator:
|
||||||
errmsg = "Syntax error: expected operator";
|
errmsg = "Syntax error: expected operator";
|
||||||
*error = 1;
|
*error = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
reduce_error:
|
reduce_error:
|
||||||
/* errmsg has been set by reduce_op */
|
/* errmsg has been set by reduce_op */
|
||||||
*error = 1;
|
*error = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
extra_rparen:
|
extra_rparen:
|
||||||
errmsg = "Extra \')\'";
|
errmsg = "Extra \')\'";
|
||||||
*error = 1;
|
*error = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -423,14 +432,6 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
* Return error message set by the evaluator (if any)
|
* Return error message set by the evaluator (if any)
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *
|
char *Preprocessor_expr_error() {
|
||||||
Preprocessor_expr_error() {
|
|
||||||
return errmsg;
|
return errmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,27 +17,22 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
extern int Preprocessor_expr(String *s, int *error);
|
extern int Preprocessor_expr(String *s, int *error);
|
||||||
extern char *Preprocessor_expr_error(void);
|
extern char *Preprocessor_expr_error(void);
|
||||||
extern Hash *Preprocessor_define(const String_or_char *str, int swigmacro);
|
extern Hash *Preprocessor_define(const String_or_char *str, int swigmacro);
|
||||||
extern void Preprocessor_undef(const String_or_char *name);
|
extern void Preprocessor_undef(const String_or_char *name);
|
||||||
extern void Preprocessor_init(void);
|
extern void Preprocessor_init(void);
|
||||||
extern void Preprocessor_delete(void);
|
extern void Preprocessor_delete(void);
|
||||||
extern String *Preprocessor_parse(String *s);
|
extern String *Preprocessor_parse(String *s);
|
||||||
extern void Preprocessor_include_all(int);
|
extern void Preprocessor_include_all(int);
|
||||||
extern void Preprocessor_import_all(int);
|
extern void Preprocessor_import_all(int);
|
||||||
extern void Preprocessor_ignore_missing(int);
|
extern void Preprocessor_ignore_missing(int);
|
||||||
extern void Preprocessor_error_as_warning(int);
|
extern void Preprocessor_error_as_warning(int);
|
||||||
extern List *Preprocessor_depend(void);
|
extern List *Preprocessor_depend(void);
|
||||||
extern void Preprocessor_expr_init(void);
|
extern void Preprocessor_expr_init(void);
|
||||||
extern void Preprocessor_expr_delete(void);
|
extern void Preprocessor_expr_delete(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -38,8 +38,8 @@ char cvsroot_error_c[] = "$Header$";
|
||||||
# define DEFAULT_ERROR_MSG_FORMAT EMF_STANDARD
|
# define DEFAULT_ERROR_MSG_FORMAT EMF_STANDARD
|
||||||
#endif
|
#endif
|
||||||
static ErrorMessageFormat msg_format = DEFAULT_ERROR_MSG_FORMAT;
|
static ErrorMessageFormat msg_format = DEFAULT_ERROR_MSG_FORMAT;
|
||||||
static int silence = 0; /* Silent operation */
|
static int silence = 0; /* Silent operation */
|
||||||
static String *filter = 0; /* Warning filter */
|
static String *filter = 0; /* Warning filter */
|
||||||
static int warnall = 0;
|
static int warnall = 0;
|
||||||
static int nwarning = 0;
|
static int nwarning = 0;
|
||||||
static int nerrors = 0;
|
static int nerrors = 0;
|
||||||
|
|
@ -58,22 +58,23 @@ static String *format_filename(const String_or_char *filename);
|
||||||
* Issue a warning message
|
* Issue a warning message
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) {
|
||||||
Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) {
|
|
||||||
String *out;
|
String *out;
|
||||||
char *msg;
|
char *msg;
|
||||||
int wrn = 1;
|
int wrn = 1;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
if (silence) return;
|
if (silence)
|
||||||
if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
return;
|
||||||
|
if (!init_fmt)
|
||||||
|
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||||
|
|
||||||
va_start(ap,fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
out = NewStringEmpty();
|
out = NewStringEmpty();
|
||||||
vPrintf(out,fmt,ap);
|
vPrintf(out, fmt, ap);
|
||||||
|
|
||||||
msg = Char(out);
|
msg = Char(out);
|
||||||
if (isdigit((unsigned char)*msg)) {
|
if (isdigit((unsigned char) *msg)) {
|
||||||
unsigned long result = strtoul(msg, &msg, 10);
|
unsigned long result = strtoul(msg, &msg, 10);
|
||||||
if (msg != Char(out)) {
|
if (msg != Char(out)) {
|
||||||
msg++;
|
msg++;
|
||||||
|
|
@ -83,13 +84,15 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
|
||||||
|
|
||||||
/* Check in the warning filter */
|
/* Check in the warning filter */
|
||||||
if (filter) {
|
if (filter) {
|
||||||
char temp[32];
|
char temp[32];
|
||||||
char *c;
|
char *c;
|
||||||
char *f = Char(filter);
|
char *f = Char(filter);
|
||||||
sprintf(temp,"%d",wnum);
|
sprintf(temp, "%d", wnum);
|
||||||
while(*f != '\0' && (c = strstr(f,temp))) {
|
while (*f != '\0' && (c = strstr(f, temp))) {
|
||||||
if (*(c-1) == '-') wrn = 0; /* Warning disabled */
|
if (*(c - 1) == '-')
|
||||||
if (*(c-1) == '+') wrn = 1; /* Warning enabled */
|
wrn = 0; /* Warning disabled */
|
||||||
|
if (*(c - 1) == '+')
|
||||||
|
wrn = 1; /* Warning enabled */
|
||||||
f += strlen(temp);
|
f += strlen(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +103,7 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr, wrn_nnum_fmt, formatted_filename, line);
|
Printf(stderr, wrn_nnum_fmt, formatted_filename, line);
|
||||||
}
|
}
|
||||||
Printf(stderr,"%s",msg);
|
Printf(stderr, "%s", msg);
|
||||||
nwarning++;
|
nwarning++;
|
||||||
Delete(formatted_filename);
|
Delete(formatted_filename);
|
||||||
}
|
}
|
||||||
|
|
@ -114,22 +117,23 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
|
||||||
* Issue an error message
|
* Issue an error message
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
|
||||||
Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
String *formatted_filename = NULL;
|
String *formatted_filename = NULL;
|
||||||
|
|
||||||
if (silence) return;
|
if (silence)
|
||||||
if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
return;
|
||||||
|
if (!init_fmt)
|
||||||
va_start(ap,fmt);
|
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
formatted_filename = format_filename(filename);
|
formatted_filename = format_filename(filename);
|
||||||
if (line > 0) {
|
if (line > 0) {
|
||||||
Printf(stderr, err_line_fmt, formatted_filename, line);
|
Printf(stderr, err_line_fmt, formatted_filename, line);
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr, err_eof_fmt, formatted_filename);
|
Printf(stderr, err_eof_fmt, formatted_filename);
|
||||||
}
|
}
|
||||||
vPrintf(stderr,fmt,ap);
|
vPrintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
nerrors++;
|
nerrors++;
|
||||||
Delete(formatted_filename);
|
Delete(formatted_filename);
|
||||||
|
|
@ -141,8 +145,7 @@ Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
|
||||||
* Returns number of errors received.
|
* Returns number of errors received.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Swig_error_count(void) {
|
||||||
Swig_error_count(void) {
|
|
||||||
return nerrors;
|
return nerrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,8 +155,7 @@ Swig_error_count(void) {
|
||||||
* Set silent flag
|
* Set silent flag
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_error_silent(int s) {
|
||||||
Swig_error_silent(int s) {
|
|
||||||
silence = s;
|
silence = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,14 +166,14 @@ Swig_error_silent(int s) {
|
||||||
* Takes a comma separate list of warning numbers and puts in the filter.
|
* Takes a comma separate list of warning numbers and puts in the filter.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_warnfilter(const String_or_char *wlist, int add) {
|
||||||
Swig_warnfilter(const String_or_char *wlist, int add) {
|
|
||||||
char *c;
|
char *c;
|
||||||
char *cw;
|
char *cw;
|
||||||
String *s;
|
String *s;
|
||||||
|
|
||||||
if (!filter) filter = NewStringEmpty();
|
if (!filter)
|
||||||
|
filter = NewStringEmpty();
|
||||||
|
|
||||||
s = NewString("");
|
s = NewString("");
|
||||||
Clear(s);
|
Clear(s);
|
||||||
cw = Char(wlist);
|
cw = Char(wlist);
|
||||||
|
|
@ -182,31 +184,30 @@ Swig_warnfilter(const String_or_char *wlist, int add) {
|
||||||
++cw;
|
++cw;
|
||||||
}
|
}
|
||||||
c = Char(s);
|
c = Char(s);
|
||||||
c = strtok(c,", ");
|
c = strtok(c, ", ");
|
||||||
while (c) {
|
while (c) {
|
||||||
if (isdigit((int) *c) || (*c == '+') || (*c == '-')) {
|
if (isdigit((int) *c) || (*c == '+') || (*c == '-')) {
|
||||||
if (add) {
|
if (add) {
|
||||||
Insert(filter,0,c);
|
Insert(filter, 0, c);
|
||||||
if (isdigit((int) *c)) {
|
if (isdigit((int) *c)) {
|
||||||
Insert(filter,0,"-");
|
Insert(filter, 0, "-");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char temp[32];
|
char temp[32];
|
||||||
if (isdigit((int) *c)) {
|
if (isdigit((int) *c)) {
|
||||||
sprintf(temp,"-%s",c);
|
sprintf(temp, "-%s", c);
|
||||||
} else {
|
} else {
|
||||||
strcpy(temp,c);
|
strcpy(temp, c);
|
||||||
}
|
}
|
||||||
Replace(filter,temp,"", DOH_REPLACE_FIRST);
|
Replace(filter, temp, "", DOH_REPLACE_FIRST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c = strtok(NULL,", ");
|
c = strtok(NULL, ", ");
|
||||||
}
|
}
|
||||||
Delete(s);
|
Delete(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Swig_warnall(void) {
|
||||||
Swig_warnall(void) {
|
|
||||||
warnall = 1;
|
warnall = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,8 +218,7 @@ Swig_warnall(void) {
|
||||||
* Return the number of warnings
|
* Return the number of warnings
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Swig_warn_count(void) {
|
||||||
Swig_warn_count(void) {
|
|
||||||
return nwarning;
|
return nwarning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,31 +228,30 @@ Swig_warn_count(void) {
|
||||||
* Set the type of error/warning message display
|
* Set the type of error/warning message display
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_error_msg_format(ErrorMessageFormat format) {
|
||||||
Swig_error_msg_format(ErrorMessageFormat format) {
|
const char *error = "Error";
|
||||||
const char* error = "Error";
|
const char *warning = "Warning";
|
||||||
const char* warning = "Warning";
|
|
||||||
|
|
||||||
const char* fmt_eof = 0;
|
const char *fmt_eof = 0;
|
||||||
const char* fmt_line = 0;
|
const char *fmt_line = 0;
|
||||||
|
|
||||||
/* here 'format' could be directly a string instead of an enum, but
|
/* here 'format' could be directly a string instead of an enum, but
|
||||||
by now a switch is used to translated into one. */
|
by now a switch is used to translated into one. */
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case EMF_MICROSOFT:
|
case EMF_MICROSOFT:
|
||||||
fmt_line = "%s(%d)";
|
fmt_line = "%s(%d)";
|
||||||
fmt_eof = "%s(999999)"; /* Is there a special character for EOF? Just use a large number. */
|
fmt_eof = "%s(999999)"; /* Is there a special character for EOF? Just use a large number. */
|
||||||
break;
|
break;
|
||||||
case EMF_STANDARD:
|
case EMF_STANDARD:
|
||||||
default:
|
default:
|
||||||
fmt_line = "%s:%d";
|
fmt_line = "%s:%d";
|
||||||
fmt_eof = "%s:EOF";
|
fmt_eof = "%s:EOF";
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(wrn_wnum_fmt, "%s: %s(%%d): ", fmt_line, warning);
|
sprintf(wrn_wnum_fmt, "%s: %s(%%d): ", fmt_line, warning);
|
||||||
sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning);
|
sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning);
|
||||||
sprintf(err_line_fmt, "%s: %s: ", fmt_line, error);
|
sprintf(err_line_fmt, "%s: %s: ", fmt_line, error);
|
||||||
sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error);
|
sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error);
|
||||||
|
|
||||||
msg_format = format;
|
msg_format = format;
|
||||||
init_fmt = 1;
|
init_fmt = 1;
|
||||||
|
|
@ -263,12 +262,10 @@ Swig_error_msg_format(ErrorMessageFormat format) {
|
||||||
*
|
*
|
||||||
* Remove double backslashes in Windows filename paths for display
|
* Remove double backslashes in Windows filename paths for display
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
static String *
|
static String *format_filename(const String_or_char *filename) {
|
||||||
format_filename(const String_or_char *filename) {
|
|
||||||
String *formatted_filename = NewString(filename);
|
String *formatted_filename = NewString(filename);
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
Replaceall(formatted_filename,"\\\\","\\");
|
Replaceall(formatted_filename, "\\\\", "\\");
|
||||||
#endif
|
#endif
|
||||||
return formatted_filename;
|
return formatted_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,35 +30,36 @@ static int debug = 0;
|
||||||
* changed, lang.cxx doesn't nedd to be touched again.
|
* changed, lang.cxx doesn't nedd to be touched again.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_fragment_register(Node *fragment) {
|
||||||
Swig_fragment_register(Node* fragment) {
|
if (Getattr(fragment, k_emitonly)) {
|
||||||
if (Getattr(fragment,k_emitonly)) {
|
|
||||||
Swig_fragment_emit(fragment);
|
Swig_fragment_emit(fragment);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
String *name = Copy(Getattr(fragment,k_value));
|
String *name = Copy(Getattr(fragment, k_value));
|
||||||
String *type = Getattr(fragment,k_type);
|
String *type = Getattr(fragment, k_type);
|
||||||
if (type) {
|
if (type) {
|
||||||
SwigType *rtype = SwigType_typedef_resolve_all(type);
|
SwigType *rtype = SwigType_typedef_resolve_all(type);
|
||||||
String *mangle = Swig_string_mangle(type);
|
String *mangle = Swig_string_mangle(type);
|
||||||
Append(name,mangle);
|
Append(name, mangle);
|
||||||
Delete(mangle);
|
Delete(mangle);
|
||||||
Delete(rtype);
|
Delete(rtype);
|
||||||
if (debug) Printf(stdout,"register fragment %s %s\n",name,type);
|
if (debug)
|
||||||
|
Printf(stdout, "register fragment %s %s\n", name, type);
|
||||||
}
|
}
|
||||||
if (!fragments) {
|
if (!fragments) {
|
||||||
fragments = NewHash();
|
fragments = NewHash();
|
||||||
}
|
}
|
||||||
if (!Getattr(fragments,name)) {
|
if (!Getattr(fragments, name)) {
|
||||||
String *section = Copy(Getattr(fragment,k_section));
|
String *section = Copy(Getattr(fragment, k_section));
|
||||||
String *ccode = Copy(Getattr(fragment,k_code));
|
String *ccode = Copy(Getattr(fragment, k_code));
|
||||||
Hash *kwargs = Getattr(fragment,k_kwargs);
|
Hash *kwargs = Getattr(fragment, k_kwargs);
|
||||||
Setmeta(ccode,k_section,section);
|
Setmeta(ccode, k_section, section);
|
||||||
if (kwargs) {
|
if (kwargs) {
|
||||||
Setmeta(ccode,k_kwargs,kwargs);
|
Setmeta(ccode, k_kwargs, kwargs);
|
||||||
}
|
}
|
||||||
Setattr(fragments,name,ccode);
|
Setattr(fragments, name, ccode);
|
||||||
if (debug) Printf(stdout,"registering fragment %s %s\n",name,section);
|
if (debug)
|
||||||
|
Printf(stdout, "registering fragment %s %s\n", name, section);
|
||||||
Delete(section);
|
Delete(section);
|
||||||
Delete(ccode);
|
Delete(ccode);
|
||||||
}
|
}
|
||||||
|
|
@ -73,16 +74,15 @@ Swig_fragment_register(Node* fragment) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static
|
static
|
||||||
char* char_index(char* str, char c)
|
char *char_index(char *str, char c) {
|
||||||
{
|
while (*str && (c != *str))
|
||||||
while (*str && (c != *str)) ++str;
|
++str;
|
||||||
return (c == *str) ? str : 0;
|
return (c == *str) ? str : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Swig_fragment_emit(Node *n) {
|
||||||
Swig_fragment_emit(Node *n) {
|
|
||||||
String *code;
|
String *code;
|
||||||
char *pc, *tok;
|
char *pc, *tok;
|
||||||
String *t;
|
String *t;
|
||||||
String *mangle = 0;
|
String *mangle = 0;
|
||||||
String *name = 0;
|
String *name = 0;
|
||||||
|
|
@ -92,38 +92,44 @@ Swig_fragment_emit(Node *n) {
|
||||||
Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name);
|
Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
name = Getattr(n,k_value);
|
|
||||||
|
name = Getattr(n, k_value);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = n;
|
name = n;
|
||||||
}
|
}
|
||||||
type = Getattr(n,k_type);
|
type = Getattr(n, k_type);
|
||||||
if (type) {
|
if (type) {
|
||||||
mangle = Swig_string_mangle(type);
|
mangle = Swig_string_mangle(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) Printf(stdout,"looking fragment %s %s\n",name, type);
|
if (debug)
|
||||||
|
Printf(stdout, "looking fragment %s %s\n", name, type);
|
||||||
t = Copy(name);
|
t = Copy(name);
|
||||||
tok = Char(t);
|
tok = Char(t);
|
||||||
pc = char_index(tok,',');
|
pc = char_index(tok, ',');
|
||||||
if (pc) *pc = 0;
|
if (pc)
|
||||||
|
*pc = 0;
|
||||||
while (tok) {
|
while (tok) {
|
||||||
String *name = NewString(tok);
|
String *name = NewString(tok);
|
||||||
if (mangle) Append(name,mangle);
|
if (mangle)
|
||||||
if (looking_fragments && Getattr(looking_fragments,name)) {
|
Append(name, mangle);
|
||||||
|
if (looking_fragments && Getattr(looking_fragments, name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
code = Getattr(fragments,name);
|
code = Getattr(fragments, name);
|
||||||
if (debug) Printf(stdout,"looking subfragment %s\n", name);
|
if (debug)
|
||||||
if (code && (Strcmp(code,k_ignore) != 0)) {
|
Printf(stdout, "looking subfragment %s\n", name);
|
||||||
String *section = Getmeta(code,k_section);
|
if (code && (Strcmp(code, k_ignore) != 0)) {
|
||||||
Hash *nn = Getmeta(code,k_kwargs);
|
String *section = Getmeta(code, k_section);
|
||||||
if (!looking_fragments) looking_fragments = NewHash();
|
Hash *nn = Getmeta(code, k_kwargs);
|
||||||
Setattr(looking_fragments,name,"1");
|
if (!looking_fragments)
|
||||||
|
looking_fragments = NewHash();
|
||||||
|
Setattr(looking_fragments, name, "1");
|
||||||
while (nn) {
|
while (nn) {
|
||||||
if (Equal(Getattr(nn,k_name),k_fragment)) {
|
if (Equal(Getattr(nn, k_name), k_fragment)) {
|
||||||
if (debug) Printf(stdout,"emitting fragment %s %s\n",nn, type);
|
if (debug)
|
||||||
|
Printf(stdout, "emitting fragment %s %s\n", nn, type);
|
||||||
Setfile(nn, Getfile(n));
|
Setfile(nn, Getfile(n));
|
||||||
Setline(nn, Getline(n));
|
Setline(nn, Getline(n));
|
||||||
Swig_fragment_emit(nn);
|
Swig_fragment_emit(nn);
|
||||||
|
|
@ -133,23 +139,25 @@ Swig_fragment_emit(Node *n) {
|
||||||
if (section) {
|
if (section) {
|
||||||
File *f = Swig_filebyname(section);
|
File *f = Swig_filebyname(section);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
Swig_error(Getfile(code),Getline(code),
|
Swig_error(Getfile(code), Getline(code), "Bad section '%s' for code fragment '%s'\n", section, name);
|
||||||
"Bad section '%s' for code fragment '%s'\n", section,name);
|
|
||||||
} else {
|
} else {
|
||||||
if (debug) Printf(stdout,"emitting subfragment %s %s\n",name, section);
|
if (debug)
|
||||||
if (debug) Printf(f,"/* begin fragment %s */\n",name);
|
Printf(stdout, "emitting subfragment %s %s\n", name, section);
|
||||||
Printf(f,"%s\n",code);
|
if (debug)
|
||||||
if (debug) Printf(f,"/* end fragment %s */\n\n",name);
|
Printf(f, "/* begin fragment %s */\n", name);
|
||||||
Setattr(fragments,name,k_ignore);
|
Printf(f, "%s\n", code);
|
||||||
Delattr(looking_fragments,name);
|
if (debug)
|
||||||
|
Printf(f, "/* end fragment %s */\n\n", name);
|
||||||
|
Setattr(fragments, name, k_ignore);
|
||||||
|
Delattr(looking_fragments, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!code && type) {
|
} else if (!code && type) {
|
||||||
SwigType *rtype = SwigType_typedef_resolve_all(type);
|
SwigType *rtype = SwigType_typedef_resolve_all(type);
|
||||||
if (!Equal(type,rtype)) {
|
if (!Equal(type, rtype)) {
|
||||||
String *name = Copy(Getattr(n,k_value));
|
String *name = Copy(Getattr(n, k_value));
|
||||||
String *mangle = Swig_string_mangle(type);
|
String *mangle = Swig_string_mangle(type);
|
||||||
Append(name,mangle);
|
Append(name, mangle);
|
||||||
Setfile(name, Getfile(n));
|
Setfile(name, Getfile(n));
|
||||||
Setline(name, Getline(n));
|
Setline(name, Getline(n));
|
||||||
Swig_fragment_emit(name);
|
Swig_fragment_emit(name);
|
||||||
|
|
@ -158,17 +166,17 @@ Swig_fragment_emit(Node *n) {
|
||||||
}
|
}
|
||||||
Delete(rtype);
|
Delete(rtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name);
|
Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name);
|
||||||
}
|
}
|
||||||
tok = pc ? pc + 1 : 0;
|
tok = pc ? pc + 1 : 0;
|
||||||
if (tok) {
|
if (tok) {
|
||||||
pc = char_index(tok,',');
|
pc = char_index(tok, ',');
|
||||||
if (pc) *pc = 0;
|
if (pc)
|
||||||
|
*pc = 0;
|
||||||
}
|
}
|
||||||
Delete(name);
|
Delete(name);
|
||||||
}
|
}
|
||||||
Delete(t);
|
Delete(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ char cvsroot_getopt_c[] = "$Header$";
|
||||||
#include "swig.h"
|
#include "swig.h"
|
||||||
|
|
||||||
static char **args;
|
static char **args;
|
||||||
static int numargs;
|
static int numargs;
|
||||||
static int *marked;
|
static int *marked;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_init_args()
|
* Swig_init_args()
|
||||||
|
|
@ -30,8 +30,7 @@ static int *marked;
|
||||||
* Initialize the argument list handler.
|
* Initialize the argument list handler.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_init_args(int argc, char **argv) {
|
||||||
Swig_init_args(int argc, char **argv) {
|
|
||||||
int i;
|
int i;
|
||||||
assert(argc > 0);
|
assert(argc > 0);
|
||||||
assert(argv);
|
assert(argv);
|
||||||
|
|
@ -51,11 +50,10 @@ Swig_init_args(int argc, char **argv) {
|
||||||
* Marks an argument as being parsed.
|
* Marks an argument as being parsed.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_mark_arg(int n) {
|
||||||
Swig_mark_arg(int n) {
|
assert(marked);
|
||||||
assert(marked);
|
assert((n >= 0) && (n < numargs));
|
||||||
assert((n >= 0) && (n < numargs));
|
marked[n] = 1;
|
||||||
marked[n] = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -64,9 +62,8 @@ Swig_mark_arg(int n) {
|
||||||
* Checks to see if argument has been picked up.
|
* Checks to see if argument has been picked up.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Swig_check_marked(int n) {
|
||||||
Swig_check_marked(int n) {
|
assert((n >= 0) && (n < numargs));
|
||||||
assert((n>=0) && (n < numargs));
|
|
||||||
return marked[n];
|
return marked[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,27 +72,26 @@ Swig_check_marked(int n) {
|
||||||
*
|
*
|
||||||
* Checkers for unprocessed command line options and errors.
|
* Checkers for unprocessed command line options and errors.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_check_options(int check_input) {
|
||||||
Swig_check_options(int check_input) {
|
int error = 0;
|
||||||
int error = 0;
|
int i;
|
||||||
int i;
|
int max = check_input ? numargs - 1 : numargs;
|
||||||
int max = check_input ? numargs - 1 : numargs;
|
assert(marked);
|
||||||
assert(marked);
|
for (i = 1; i < max; i++) {
|
||||||
for (i = 1; i < max; i++) {
|
if (!marked[i]) {
|
||||||
if (!marked[i]) {
|
Printf(stderr, "swig error : Unrecognized option %s\n", args[i]);
|
||||||
Printf(stderr,"swig error : Unrecognized option %s\n", args[i]);
|
error = 1;
|
||||||
error=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (error) {
|
|
||||||
Printf(stderr,"Use 'swig -help' for available options.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (check_input && marked[numargs-1]) {
|
|
||||||
Printf(stderr,"Must specify an input file. Use -help for available options.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
Printf(stderr, "Use 'swig -help' for available options.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (check_input && marked[numargs - 1]) {
|
||||||
|
Printf(stderr, "Must specify an input file. Use -help for available options.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -104,13 +100,8 @@ Swig_check_options(int check_input) {
|
||||||
* Generates a generic error message and exits.
|
* Generates a generic error message and exits.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_arg_error() {
|
||||||
Swig_arg_error() {
|
Printf(stderr, "SWIG : Unable to parse command line options.\n");
|
||||||
Printf(stderr,"SWIG : Unable to parse command line options.\n");
|
Printf(stderr, "Use 'swig -help' for available options.\n");
|
||||||
Printf(stderr,"Use 'swig -help' for available options.\n");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@ char cvsroot_include_c[] = "$Header$";
|
||||||
|
|
||||||
/* Delimeter used in accessing files and directories */
|
/* Delimeter used in accessing files and directories */
|
||||||
|
|
||||||
static List *directories = 0; /* List of include directories */
|
static List *directories = 0; /* List of include directories */
|
||||||
static String *lastpath = 0; /* Last file that was included */
|
static String *lastpath = 0; /* Last file that was included */
|
||||||
static String *swiglib = 0; /* Location of SWIG library */
|
static String *swiglib = 0; /* Location of SWIG library */
|
||||||
static String *lang_config = 0; /* Language configuration file */
|
static String *lang_config = 0; /* Language configuration file */
|
||||||
static int dopush = 1; /* Whether to push directories */
|
static int dopush = 1; /* Whether to push directories */
|
||||||
|
|
||||||
/* This functions determine whether to push/pop dirs in the preprocessor */
|
/* This functions determine whether to push/pop dirs in the preprocessor */
|
||||||
void Swig_set_push_dir(int push) {
|
void Swig_set_push_dir(int push) {
|
||||||
|
|
@ -51,13 +51,11 @@ String *Swig_get_config_file() {
|
||||||
* include mechanism, but rather as a query interface for language modules.
|
* include mechanism, but rather as a query interface for language modules.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_swiglib_set(const String_or_char *sl) {
|
||||||
Swig_swiglib_set(const String_or_char *sl) {
|
|
||||||
swiglib = NewString(sl);
|
swiglib = NewString(sl);
|
||||||
}
|
}
|
||||||
|
|
||||||
String *
|
String *Swig_swiglib_get() {
|
||||||
Swig_swiglib_get() {
|
|
||||||
return swiglib;
|
return swiglib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,9 +65,9 @@ Swig_swiglib_get() {
|
||||||
* Adds a directory to the SWIG search path.
|
* Adds a directory to the SWIG search path.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
List *
|
List *Swig_add_directory(const String_or_char *dirname) {
|
||||||
Swig_add_directory(const String_or_char *dirname) {
|
if (!directories)
|
||||||
if (!directories) directories = NewList();
|
directories = NewList();
|
||||||
assert(directories);
|
assert(directories);
|
||||||
if (dirname) {
|
if (dirname) {
|
||||||
String *sdir = NewString(dirname);
|
String *sdir = NewString(dirname);
|
||||||
|
|
@ -93,21 +91,23 @@ Swig_add_directory(const String_or_char *dirname) {
|
||||||
* the preprocessor to grab files in the same directory as other included files.
|
* the preprocessor to grab files in the same directory as other included files.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_push_directory(const String_or_char *dirname) {
|
||||||
Swig_push_directory(const String_or_char *dirname) {
|
|
||||||
String *tmp = 0;
|
String *tmp = 0;
|
||||||
if (!Swig_get_push_dir()) return;
|
if (!Swig_get_push_dir())
|
||||||
if (!directories) directories = NewList();
|
return;
|
||||||
|
if (!directories)
|
||||||
|
directories = NewList();
|
||||||
assert(directories);
|
assert(directories);
|
||||||
if (!DohIsString(dirname)) {
|
if (!DohIsString(dirname)) {
|
||||||
dirname = tmp = NewString(dirname);
|
dirname = tmp = NewString(dirname);
|
||||||
assert(dirname);
|
assert(dirname);
|
||||||
}
|
}
|
||||||
if (dirname) {
|
if (dirname) {
|
||||||
Hash *dir = NewHash();
|
Hash *dir = NewHash();
|
||||||
Setattr(dir, k_name, dirname);
|
Setattr(dir, k_name, dirname);
|
||||||
Insert(directories, 0, dir);
|
Insert(directories, 0, dir);
|
||||||
if (tmp) Delete(tmp);
|
if (tmp)
|
||||||
|
Delete(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,11 +118,12 @@ Swig_push_directory(const String_or_char *dirname) {
|
||||||
* the preprocessor.
|
* the preprocessor.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_pop_directory() {
|
||||||
Swig_pop_directory() {
|
if (!Swig_get_push_dir())
|
||||||
if (!Swig_get_push_dir()) return;
|
return;
|
||||||
if (!directories) return;
|
if (!directories)
|
||||||
Delitem(directories,0);
|
return;
|
||||||
|
Delitem(directories, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -131,8 +132,7 @@ Swig_pop_directory() {
|
||||||
* Returns the full pathname of the last file opened.
|
* Returns the full pathname of the last file opened.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *Swig_last_file() {
|
||||||
Swig_last_file() {
|
|
||||||
assert(lastpath);
|
assert(lastpath);
|
||||||
return lastpath;
|
return lastpath;
|
||||||
}
|
}
|
||||||
|
|
@ -143,11 +143,10 @@ Swig_last_file() {
|
||||||
* Returns a list of the current search paths.
|
* Returns a list of the current search paths.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static List *
|
static List *Swig_search_path_any(int syspath) {
|
||||||
Swig_search_path_any(int syspath) {
|
|
||||||
String *filename;
|
String *filename;
|
||||||
String *dirname;
|
String *dirname;
|
||||||
List *slist, *llist;
|
List *slist, *llist;
|
||||||
int i, ilen;
|
int i, ilen;
|
||||||
|
|
||||||
llist = 0;
|
llist = 0;
|
||||||
|
|
@ -156,35 +155,35 @@ Swig_search_path_any(int syspath) {
|
||||||
filename = NewStringEmpty();
|
filename = NewStringEmpty();
|
||||||
assert(filename);
|
assert(filename);
|
||||||
#ifdef MACSWIG
|
#ifdef MACSWIG
|
||||||
Printf(filename,"%s",SWIG_FILE_DELIMETER);
|
Printf(filename, "%s", SWIG_FILE_DELIMETER);
|
||||||
#else
|
#else
|
||||||
Printf(filename,".%s", SWIG_FILE_DELIMETER);
|
Printf(filename, ".%s", SWIG_FILE_DELIMETER);
|
||||||
#endif
|
#endif
|
||||||
if (syspath) {
|
if (syspath) {
|
||||||
llist = NewList();
|
llist = NewList();
|
||||||
assert(llist);
|
assert(llist);
|
||||||
Append(llist,filename);
|
Append(llist, filename);
|
||||||
} else {
|
} else {
|
||||||
Append(slist,filename);
|
Append(slist, filename);
|
||||||
}
|
}
|
||||||
ilen = Len(directories);
|
ilen = Len(directories);
|
||||||
for (i = 0; i < ilen; i++) {
|
for (i = 0; i < ilen; i++) {
|
||||||
int issimple = 0;
|
int issimple = 0;
|
||||||
dirname = Getitem(directories,i);
|
dirname = Getitem(directories, i);
|
||||||
filename = NewStringEmpty();
|
filename = NewStringEmpty();
|
||||||
assert(filename);
|
assert(filename);
|
||||||
if (DohIsString(dirname)) {
|
if (DohIsString(dirname)) {
|
||||||
filename = Copy(dirname);
|
filename = Copy(dirname);
|
||||||
issimple = 1;
|
issimple = 1;
|
||||||
} else {
|
} else {
|
||||||
filename = Copy(Getattr(dirname,k_name));
|
filename = Copy(Getattr(dirname, k_name));
|
||||||
}
|
}
|
||||||
StringAppend(filename, SWIG_FILE_DELIMETER);
|
StringAppend(filename, SWIG_FILE_DELIMETER);
|
||||||
|
|
||||||
if (syspath && (issimple || !GetFlag(dirname,k_sysdir))) {
|
if (syspath && (issimple || !GetFlag(dirname, k_sysdir))) {
|
||||||
Append(llist,filename);
|
Append(llist, filename);
|
||||||
} else {
|
} else {
|
||||||
Append(slist,filename);
|
Append(slist, filename);
|
||||||
/* Insert(slist,0,filename); */
|
/* Insert(slist,0,filename); */
|
||||||
}
|
}
|
||||||
Delete(filename);
|
Delete(filename);
|
||||||
|
|
@ -192,16 +191,15 @@ Swig_search_path_any(int syspath) {
|
||||||
if (syspath) {
|
if (syspath) {
|
||||||
int ilen = Len(llist);
|
int ilen = Len(llist);
|
||||||
for (i = 0; i < ilen; i++) {
|
for (i = 0; i < ilen; i++) {
|
||||||
Append(slist,Getitem(llist,i));
|
Append(slist, Getitem(llist, i));
|
||||||
}
|
}
|
||||||
Delete(llist);
|
Delete(llist);
|
||||||
}
|
}
|
||||||
|
|
||||||
return slist;
|
return slist;
|
||||||
}
|
}
|
||||||
|
|
||||||
List *
|
List *Swig_search_path() {
|
||||||
Swig_search_path() {
|
|
||||||
return Swig_search_path_any(0);
|
return Swig_search_path_any(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,36 +211,37 @@ Swig_search_path() {
|
||||||
* Looks for a file and open it. Returns an open FILE * on success.
|
* Looks for a file and open it. Returns an open FILE * on success.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static FILE *
|
static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
|
||||||
Swig_open_any(const String_or_char *name, int sysfile) {
|
FILE *f;
|
||||||
FILE *f;
|
String *filename;
|
||||||
String *filename;
|
List *spath = 0;
|
||||||
List *spath = 0;
|
char *cname;
|
||||||
char *cname;
|
int i, ilen;
|
||||||
int i, ilen;
|
|
||||||
|
|
||||||
if (!directories) directories = NewList();
|
if (!directories)
|
||||||
|
directories = NewList();
|
||||||
assert(directories);
|
assert(directories);
|
||||||
|
|
||||||
cname = Char(name);
|
cname = Char(name);
|
||||||
filename = NewString(cname);
|
filename = NewString(cname);
|
||||||
assert(filename);
|
assert(filename);
|
||||||
f = fopen(Char(filename),"r");
|
f = fopen(Char(filename), "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
spath = Swig_search_path_any(sysfile);
|
spath = Swig_search_path_any(sysfile);
|
||||||
ilen = Len(spath);
|
ilen = Len(spath);
|
||||||
for (i = 0; i < ilen; i++) {
|
for (i = 0; i < ilen; i++) {
|
||||||
Clear(filename);
|
Clear(filename);
|
||||||
Printf(filename,"%s%s", Getitem(spath,i), cname);
|
Printf(filename, "%s%s", Getitem(spath, i), cname);
|
||||||
f = fopen(Char(filename),"r");
|
f = fopen(Char(filename), "r");
|
||||||
if (f) break;
|
if (f)
|
||||||
}
|
break;
|
||||||
Delete(spath);
|
}
|
||||||
|
Delete(spath);
|
||||||
}
|
}
|
||||||
if (f) {
|
if (f) {
|
||||||
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
|
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
|
||||||
Replaceall(filename,"\\\\","\\"); /* remove double '\' in case any already present */
|
Replaceall(filename, "\\\\", "\\"); /* remove double '\' in case any already present */
|
||||||
Replaceall(filename,"\\","\\\\");
|
Replaceall(filename, "\\", "\\\\");
|
||||||
#endif
|
#endif
|
||||||
Delete(lastpath);
|
Delete(lastpath);
|
||||||
lastpath = Copy(filename);
|
lastpath = Copy(filename);
|
||||||
|
|
@ -251,8 +250,7 @@ Swig_open_any(const String_or_char *name, int sysfile) {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
FILE *Swig_open(const String_or_char *name) {
|
||||||
Swig_open(const String_or_char *name) {
|
|
||||||
return Swig_open_any(name, 0);
|
return Swig_open_any(name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,24 +262,23 @@ Swig_open(const String_or_char *name) {
|
||||||
* Reads data from an open FILE * and returns it as a string.
|
* Reads data from an open FILE * and returns it as a string.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *Swig_read_file(FILE *f) {
|
||||||
Swig_read_file(FILE *f) {
|
int len;
|
||||||
int len;
|
char buffer[4096];
|
||||||
char buffer[4096];
|
|
||||||
String *str = NewStringEmpty();
|
String *str = NewStringEmpty();
|
||||||
|
|
||||||
assert(str);
|
assert(str);
|
||||||
while (fgets(buffer,4095,f)) {
|
while (fgets(buffer, 4095, f)) {
|
||||||
StringAppend(str,buffer);
|
StringAppend(str, buffer);
|
||||||
}
|
}
|
||||||
len = StringLen(str);
|
len = StringLen(str);
|
||||||
if (len) {
|
if (len) {
|
||||||
char *cstr = Char(str);
|
char *cstr = Char(str);
|
||||||
if (cstr[len - 1] != '\n') {
|
if (cstr[len - 1] != '\n') {
|
||||||
StringAppend(str, "\n");
|
StringAppend(str, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -291,31 +288,29 @@ Swig_read_file(FILE *f) {
|
||||||
* Opens a file and returns it as a string.
|
* Opens a file and returns it as a string.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static String *
|
static String *Swig_include_any(const String_or_char *name, int sysfile) {
|
||||||
Swig_include_any(const String_or_char *name, int sysfile) {
|
FILE *f;
|
||||||
FILE *f;
|
String *str;
|
||||||
String *str;
|
String *file;
|
||||||
String *file;
|
|
||||||
|
|
||||||
f = Swig_open_any(name, sysfile);
|
f = Swig_open_any(name, sysfile);
|
||||||
if (!f) return 0;
|
if (!f)
|
||||||
|
return 0;
|
||||||
str = Swig_read_file(f);
|
str = Swig_read_file(f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
Seek(str,0,SEEK_SET);
|
Seek(str, 0, SEEK_SET);
|
||||||
file = Copy(lastpath);
|
file = Copy(lastpath);
|
||||||
Setfile(str,file);
|
Setfile(str, file);
|
||||||
Delete(file);
|
Delete(file);
|
||||||
Setline(str,1);
|
Setline(str, 1);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
String *
|
String *Swig_include(const String_or_char *name) {
|
||||||
Swig_include(const String_or_char *name) {
|
|
||||||
return Swig_include_any(name, 0);
|
return Swig_include_any(name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
String *
|
String *Swig_include_sys(const String_or_char *name) {
|
||||||
Swig_include_sys(const String_or_char *name) {
|
|
||||||
return Swig_include_any(name, 1);
|
return Swig_include_any(name, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,15 +321,15 @@ Swig_include_sys(const String_or_char *name) {
|
||||||
* Copies the contents of a file into another file
|
* Copies the contents of a file into another file
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Swig_insert_file(const String_or_char *filename, File *outfile) {
|
||||||
Swig_insert_file(const String_or_char *filename, File *outfile) {
|
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int nbytes;
|
int nbytes;
|
||||||
FILE *f = Swig_open(filename);
|
FILE *f = Swig_open(filename);
|
||||||
|
|
||||||
if (!f) return -1;
|
if (!f)
|
||||||
while ((nbytes = Read(f,buffer,4096)) > 0) {
|
return -1;
|
||||||
Write(outfile,buffer,nbytes);
|
while ((nbytes = Read(f, buffer, 4096)) > 0) {
|
||||||
|
Write(outfile, buffer, nbytes);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -350,9 +345,9 @@ Swig_insert_file(const String_or_char *filename, File *outfile) {
|
||||||
|
|
||||||
static Hash *named_files = 0;
|
static Hash *named_files = 0;
|
||||||
|
|
||||||
void
|
void Swig_register_filebyname(const String_or_char *filename, File *outfile) {
|
||||||
Swig_register_filebyname(const String_or_char *filename, File *outfile) {
|
if (!named_files)
|
||||||
if (!named_files) named_files = NewHash();
|
named_files = NewHash();
|
||||||
Setattr(named_files, filename, outfile);
|
Setattr(named_files, filename, outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,10 +357,10 @@ Swig_register_filebyname(const String_or_char *filename, File *outfile) {
|
||||||
* Get a named file
|
* Get a named file
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
File *
|
File *Swig_filebyname(const String_or_char *filename) {
|
||||||
Swig_filebyname(const String_or_char *filename) {
|
if (!named_files)
|
||||||
if (!named_files) return 0;
|
return 0;
|
||||||
return Getattr(named_files,filename);
|
return Getattr(named_files, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -374,18 +369,18 @@ Swig_filebyname(const String_or_char *filename) {
|
||||||
* Returns the suffix of a file
|
* Returns the suffix of a file
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *
|
char *Swig_file_suffix(const String_or_char *filename) {
|
||||||
Swig_file_suffix(const String_or_char *filename) {
|
|
||||||
char *d;
|
char *d;
|
||||||
char *c = Char(filename);
|
char *c = Char(filename);
|
||||||
int len = Len(filename);
|
int len = Len(filename);
|
||||||
if (strlen(c)) {
|
if (strlen(c)) {
|
||||||
d = c + len - 1;
|
d = c + len - 1;
|
||||||
while (d != c) {
|
while (d != c) {
|
||||||
if (*d == '.') return d;
|
if (*d == '.')
|
||||||
|
return d;
|
||||||
d--;
|
d--;
|
||||||
}
|
}
|
||||||
return c+len;
|
return c + len;
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
@ -396,12 +391,10 @@ Swig_file_suffix(const String_or_char *filename) {
|
||||||
* Returns the filename with no suffix attached.
|
* Returns the filename with no suffix attached.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *
|
char *Swig_file_basename(const String_or_char *filename) {
|
||||||
Swig_file_basename(const String_or_char *filename)
|
|
||||||
{
|
|
||||||
static char tmp[1024];
|
static char tmp[1024];
|
||||||
char *c;
|
char *c;
|
||||||
strcpy(tmp,Char(filename));
|
strcpy(tmp, Char(filename));
|
||||||
c = Swig_file_suffix(tmp);
|
c = Swig_file_suffix(tmp);
|
||||||
*c = 0;
|
*c = 0;
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
@ -412,16 +405,16 @@ Swig_file_basename(const String_or_char *filename)
|
||||||
*
|
*
|
||||||
* Return the file with any leading path stripped off
|
* Return the file with any leading path stripped off
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
char *
|
char *Swig_file_filename(const String_or_char *filename) {
|
||||||
Swig_file_filename(const String_or_char *filename)
|
|
||||||
{
|
|
||||||
static char tmp[1024];
|
static char tmp[1024];
|
||||||
const char *delim = SWIG_FILE_DELIMETER;
|
const char *delim = SWIG_FILE_DELIMETER;
|
||||||
char *c;
|
char *c;
|
||||||
|
|
||||||
strcpy(tmp,Char(filename));
|
strcpy(tmp, Char(filename));
|
||||||
if ((c=strrchr(tmp,*delim))) return c+1;
|
if ((c = strrchr(tmp, *delim)))
|
||||||
else return tmp;
|
return c + 1;
|
||||||
|
else
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -429,22 +422,17 @@ Swig_file_filename(const String_or_char *filename)
|
||||||
*
|
*
|
||||||
* Return the name of the directory associated with a file
|
* Return the name of the directory associated with a file
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
char *
|
char *Swig_file_dirname(const String_or_char *filename) {
|
||||||
Swig_file_dirname(const String_or_char *filename)
|
|
||||||
{
|
|
||||||
static char tmp[1024];
|
static char tmp[1024];
|
||||||
const char *delim = SWIG_FILE_DELIMETER;
|
const char *delim = SWIG_FILE_DELIMETER;
|
||||||
char *c;
|
char *c;
|
||||||
strcpy(tmp,Char(filename));
|
strcpy(tmp, Char(filename));
|
||||||
if (!strstr(tmp,delim)) {
|
if (!strstr(tmp, delim)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
c = tmp + strlen(tmp) -1;
|
c = tmp + strlen(tmp) - 1;
|
||||||
while (*c != *delim) c--;
|
while (*c != *delim)
|
||||||
|
c--;
|
||||||
*(++c) = 0;
|
*(++c) = 0;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,11 @@ char cvsroot_misc_c[] = "$Header$";
|
||||||
* Duplicate a NULL-terminate string given as a char *.
|
* Duplicate a NULL-terminate string given as a char *.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *
|
char *Swig_copy_string(const char *s) {
|
||||||
Swig_copy_string(const char *s) {
|
|
||||||
char *c = 0;
|
char *c = 0;
|
||||||
if (s) {
|
if (s) {
|
||||||
c = (char *) malloc(strlen(s)+1);
|
c = (char *) malloc(strlen(s) + 1);
|
||||||
strcpy(c,s);
|
strcpy(c, s);
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
@ -38,10 +37,8 @@ Swig_copy_string(const char *s) {
|
||||||
* Emits the SWIG identifying banner.
|
* Emits the SWIG identifying banner.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_banner(File *f) {
|
||||||
Swig_banner(File *f) {
|
Printf(f, "/* ----------------------------------------------------------------------------\n\
|
||||||
Printf(f,
|
|
||||||
"/* ----------------------------------------------------------------------------\n\
|
|
||||||
* This file was automatically generated by SWIG (http://www.swig.org).\n\
|
* This file was automatically generated by SWIG (http://www.swig.org).\n\
|
||||||
* Version %s\n\
|
* Version %s\n\
|
||||||
* \n\
|
* \n\
|
||||||
|
|
@ -50,8 +47,7 @@ Swig_banner(File *f) {
|
||||||
* changes to this file unless you know what you are doing--modify the SWIG \n\
|
* changes to this file unless you know what you are doing--modify the SWIG \n\
|
||||||
* interface file instead. \n", PACKAGE_VERSION);
|
* interface file instead. \n", PACKAGE_VERSION);
|
||||||
/* String too long for ISO compliance */
|
/* String too long for ISO compliance */
|
||||||
Printf(f,
|
Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
|
||||||
" * ----------------------------------------------------------------------------- */\n\n");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,27 +61,28 @@ String *Swig_string_escape(String *s) {
|
||||||
String *ns;
|
String *ns;
|
||||||
int c;
|
int c;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
Printf(ns,"\\n");
|
Printf(ns, "\\n");
|
||||||
} else if (c == '\r') {
|
} else if (c == '\r') {
|
||||||
Printf(ns,"\\r");
|
Printf(ns, "\\r");
|
||||||
} else if (c == '\t') {
|
} else if (c == '\t') {
|
||||||
Printf(ns,"\\t");
|
Printf(ns, "\\t");
|
||||||
} else if (c == '\\') {
|
} else if (c == '\\') {
|
||||||
Printf(ns,"\\\\");
|
Printf(ns, "\\\\");
|
||||||
} else if (c == '\'') {
|
} else if (c == '\'') {
|
||||||
Printf(ns,"\\'");
|
Printf(ns, "\\'");
|
||||||
} else if (c == '\"') {
|
} else if (c == '\"') {
|
||||||
Printf(ns,"\\\"");
|
Printf(ns, "\\\"");
|
||||||
} else if (c == ' ') {
|
} else if (c == ' ') {
|
||||||
Putc(c,ns);
|
Putc(c, ns);
|
||||||
} else if (!isgraph(c)) {
|
} else if (!isgraph(c)) {
|
||||||
if (c < 0) c += UCHAR_MAX +1;
|
if (c < 0)
|
||||||
Printf(ns,"\\%o", c);
|
c += UCHAR_MAX + 1;
|
||||||
|
Printf(ns, "\\%o", c);
|
||||||
} else {
|
} else {
|
||||||
Putc(c,ns);
|
Putc(c, ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
|
|
@ -103,9 +100,9 @@ String *Swig_string_upper(String *s) {
|
||||||
int c;
|
int c;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
Putc(toupper(c),ns);
|
Putc(toupper(c), ns);
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
@ -121,9 +118,9 @@ String *Swig_string_lower(String *s) {
|
||||||
int c;
|
int c;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
Putc(tolower(c),ns);
|
Putc(tolower(c), ns);
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
@ -142,9 +139,9 @@ String *Swig_string_title(String *s) {
|
||||||
int c;
|
int c;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
Putc(first ? toupper(c) : tolower(c),ns);
|
Putc(first ? toupper(c) : tolower(c), ns);
|
||||||
first = 0;
|
first = 0;
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
|
|
@ -166,9 +163,9 @@ String *Swig_string_ccase(String *s) {
|
||||||
int c;
|
int c;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
if (c == '_') {
|
if (c == '_') {
|
||||||
first = 1;
|
first = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -196,7 +193,7 @@ String *Swig_string_lccase(String *s) {
|
||||||
int c;
|
int c;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
if (c == '_') {
|
if (c == '_') {
|
||||||
after_underscore = 1;
|
after_underscore = 1;
|
||||||
|
|
@ -212,6 +209,7 @@ String *Swig_string_lccase(String *s) {
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_string_ucase()
|
* Swig_string_ucase()
|
||||||
*
|
*
|
||||||
|
|
@ -224,31 +222,31 @@ String *Swig_string_ucase(String *s) {
|
||||||
String *ns;
|
String *ns;
|
||||||
int c;
|
int c;
|
||||||
int lastC = 0;
|
int lastC = 0;
|
||||||
int underscore = 0;
|
int underscore = 0;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
/* We insert a underscore when:
|
/* We insert a underscore when:
|
||||||
1. Lower case char followed by upper case char
|
1. Lower case char followed by upper case char
|
||||||
getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo
|
getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo
|
||||||
2. Number proceded by char
|
2. Number proceded by char
|
||||||
get2D > get_2d; get22D > get_22d; GET2D > get_2d */
|
get2D > get_2d; get22D > get_22d; GET2D > get_2d */
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
|
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
if (isdigit(c) && isalpha(lastC))
|
if (isdigit(c) && isalpha(lastC))
|
||||||
underscore = 1;
|
underscore = 1;
|
||||||
else if (isupper(c) && isalpha(lastC) && !isupper(lastC))
|
else if (isupper(c) && isalpha(lastC) && !isupper(lastC))
|
||||||
underscore = 1;
|
underscore = 1;
|
||||||
|
|
||||||
lastC = c;
|
lastC = c;
|
||||||
|
|
||||||
if (underscore) {
|
if (underscore) {
|
||||||
Putc('_',ns);
|
Putc('_', ns);
|
||||||
underscore = 0;
|
underscore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Putc(tolower(c),ns);
|
Putc(tolower(c), ns);
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
@ -268,7 +266,7 @@ String *Swig_string_first_upper(String *s) {
|
||||||
String *ns = NewStringEmpty();
|
String *ns = NewStringEmpty();
|
||||||
char *cs = Char(s);
|
char *cs = Char(s);
|
||||||
if (cs && cs[0] != 0) {
|
if (cs && cs[0] != 0) {
|
||||||
Putc(toupper(cs[0]),ns);
|
Putc(toupper(cs[0]), ns);
|
||||||
Append(ns, cs + 1);
|
Append(ns, cs + 1);
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
|
|
@ -289,7 +287,7 @@ String *Swig_string_first_lower(String *s) {
|
||||||
String *ns = NewStringEmpty();
|
String *ns = NewStringEmpty();
|
||||||
char *cs = Char(s);
|
char *cs = Char(s);
|
||||||
if (cs && cs[0] != 0) {
|
if (cs && cs[0] != 0) {
|
||||||
Putc(tolower(cs[0]),ns);
|
Putc(tolower(cs[0]), ns);
|
||||||
Append(ns, cs + 1);
|
Append(ns, cs + 1);
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
|
|
@ -327,30 +325,33 @@ String *Swig_string_typecode(String *s) {
|
||||||
String *str = 0;
|
String *str = 0;
|
||||||
tc = NewStringEmpty();
|
tc = NewStringEmpty();
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
if (c == '`') break;
|
if (c == '`')
|
||||||
Putc(c,tc);
|
break;
|
||||||
|
Putc(c, tc);
|
||||||
}
|
}
|
||||||
str = SwigType_str(tc,0);
|
str = SwigType_str(tc, 0);
|
||||||
Append(ns,str);
|
Append(ns, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
} else {
|
} else {
|
||||||
Putc(c,ns);
|
Putc(c, ns);
|
||||||
if (c == '\'') {
|
if (c == '\'') {
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
Putc(c,ns);
|
Putc(c, ns);
|
||||||
if (c == '\'') break;
|
if (c == '\'')
|
||||||
|
break;
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
c = Getc(s);
|
c = Getc(s);
|
||||||
Putc(c,ns);
|
Putc(c, ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (c == '\"') {
|
} else if (c == '\"') {
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
Putc(c,ns);
|
Putc(c, ns);
|
||||||
if (c == '\"') break;
|
if (c == '\"')
|
||||||
|
break;
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
c = Getc(s);
|
c = Getc(s);
|
||||||
Putc(c,ns);
|
Putc(c, ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -358,7 +359,7 @@ String *Swig_string_typecode(String *s) {
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_string_mangle()
|
* Swig_string_mangle()
|
||||||
*
|
*
|
||||||
|
|
@ -382,12 +383,13 @@ String *Swig_string_typecode(String *s) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *Swig_string_mangle(const String *s) {
|
String *Swig_string_mangle(const String *s) {
|
||||||
#if 0
|
#if 0
|
||||||
/* old mangling, not suitable for using in macros */
|
/* old mangling, not suitable for using in macros */
|
||||||
String *t = Copy(s);
|
String *t = Copy(s);
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (!isalnum(*c)) *c = '_';
|
if (!isalnum(*c))
|
||||||
|
*c = '_';
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
|
@ -399,26 +401,26 @@ String *Swig_string_mangle(const String *s) {
|
||||||
String *b = Copy(s);
|
String *b = Copy(s);
|
||||||
if (SwigType_istemplate(b)) {
|
if (SwigType_istemplate(b)) {
|
||||||
String *st = Swig_symbol_template_deftype(b, 0);
|
String *st = Swig_symbol_template_deftype(b, 0);
|
||||||
String *sq = Swig_symbol_type_qualify(st,0);
|
String *sq = Swig_symbol_type_qualify(st, 0);
|
||||||
String *t = SwigType_namestr(sq);
|
String *t = SwigType_namestr(sq);
|
||||||
Delete(st);
|
Delete(st);
|
||||||
Delete(sq);
|
Delete(sq);
|
||||||
Delete(b);
|
Delete(b);
|
||||||
b = t ;
|
b = t;
|
||||||
}
|
}
|
||||||
pc = cb = StringChar(b);
|
pc = cb = StringChar(b);
|
||||||
while (*pc) {
|
while (*pc) {
|
||||||
char c = *pc;
|
char c = *pc;
|
||||||
if (isalnum((int)c) || (c == '_')) {
|
if (isalnum((int) c) || (c == '_')) {
|
||||||
state = 1;
|
state = 1;
|
||||||
if (space && (space == state)) {
|
if (space && (space == state)) {
|
||||||
StringAppend(result,"_SS_");
|
StringAppend(result, "_SS_");
|
||||||
}
|
}
|
||||||
space = 0;
|
space = 0;
|
||||||
Printf(result,"%c",(int)c);
|
Printf(result, "%c", (int) c);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (isspace((int)c)) {
|
if (isspace((int) c)) {
|
||||||
space = state;
|
space = state;
|
||||||
++pc;
|
++pc;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -426,10 +428,10 @@ String *Swig_string_mangle(const String *s) {
|
||||||
state = 3;
|
state = 3;
|
||||||
space = 0;
|
space = 0;
|
||||||
}
|
}
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case '.':
|
case '.':
|
||||||
if ((cb != pc) && (*(pc - 1) == 'p')) {
|
if ((cb != pc) && (*(pc - 1) == 'p')) {
|
||||||
StringAppend(result,"_");
|
StringAppend(result, "_");
|
||||||
++pc;
|
++pc;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -438,8 +440,9 @@ String *Swig_string_mangle(const String *s) {
|
||||||
break;
|
break;
|
||||||
case ':':
|
case ':':
|
||||||
if (*(pc + 1) == ':') {
|
if (*(pc + 1) == ':') {
|
||||||
StringAppend(result,"_");
|
StringAppend(result, "_");
|
||||||
++pc; ++pc;
|
++pc;
|
||||||
|
++pc;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -503,10 +506,10 @@ String *Swig_string_mangle(const String *s) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isalpha((int)c)) {
|
if (isalpha((int) c)) {
|
||||||
Printf(result,"_S%c_",(int)c);
|
Printf(result, "_S%c_", (int) c);
|
||||||
} else{
|
} else {
|
||||||
Printf(result,"_S%02X_",(int)c);
|
Printf(result, "_S%02X_", (int) c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++pc;
|
++pc;
|
||||||
|
|
@ -528,18 +531,17 @@ String *Swig_string_emangle(String *s) {
|
||||||
* In this case, "A::B". Returns NULL if there is no base.
|
* In this case, "A::B". Returns NULL if there is no base.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_scopename_split(String *s, String **rprefix, String **rlast) {
|
||||||
Swig_scopename_split(String *s, String **rprefix, String **rlast) {
|
|
||||||
char *tmp = Char(s);
|
char *tmp = Char(s);
|
||||||
char *c = tmp;
|
char *c = tmp;
|
||||||
char *cc = c;
|
char *cc = c;
|
||||||
char *co = 0;
|
char *co = 0;
|
||||||
if (!strstr(c,"::")) {
|
if (!strstr(c, "::")) {
|
||||||
*rprefix = 0;
|
*rprefix = 0;
|
||||||
*rlast = Copy(s);
|
*rlast = Copy(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((co = strstr(cc,"operator "))) {
|
if ((co = strstr(cc, "operator "))) {
|
||||||
if (co == cc) {
|
if (co == cc) {
|
||||||
*rprefix = 0;
|
*rprefix = 0;
|
||||||
*rlast = Copy(s);
|
*rlast = Copy(s);
|
||||||
|
|
@ -551,7 +553,7 @@ Swig_scopename_split(String *s, String **rprefix, String **rlast) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if ((*c == ':') && (*(c+1) == ':')) {
|
if ((*c == ':') && (*(c + 1) == ':')) {
|
||||||
cc = c;
|
cc = c;
|
||||||
c += 2;
|
c += 2;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -559,8 +561,10 @@ Swig_scopename_split(String *s, String **rprefix, String **rlast) {
|
||||||
int level = 1;
|
int level = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c && level) {
|
while (*c && level) {
|
||||||
if (*c == '<') level++;
|
if (*c == '<')
|
||||||
if (*c == '>') level--;
|
level++;
|
||||||
|
if (*c == '>')
|
||||||
|
level--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -580,14 +584,14 @@ Swig_scopename_split(String *s, String **rprefix, String **rlast) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String *
|
String *Swig_scopename_prefix(String *s) {
|
||||||
Swig_scopename_prefix(String *s) {
|
|
||||||
char *tmp = Char(s);
|
char *tmp = Char(s);
|
||||||
char *c = tmp;
|
char *c = tmp;
|
||||||
char *cc = c;
|
char *cc = c;
|
||||||
char *co = 0;
|
char *co = 0;
|
||||||
if (!strstr(c,"::")) return 0;
|
if (!strstr(c, "::"))
|
||||||
if ((co = strstr(cc,"operator "))) {
|
return 0;
|
||||||
|
if ((co = strstr(cc, "operator "))) {
|
||||||
if (co == cc) {
|
if (co == cc) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -596,7 +600,7 @@ Swig_scopename_prefix(String *s) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if ((*c == ':') && (*(c+1) == ':')) {
|
if ((*c == ':') && (*(c + 1) == ':')) {
|
||||||
cc = c;
|
cc = c;
|
||||||
c += 2;
|
c += 2;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -604,8 +608,10 @@ Swig_scopename_prefix(String *s) {
|
||||||
int level = 1;
|
int level = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c && level) {
|
while (*c && level) {
|
||||||
if (*c == '<') level++;
|
if (*c == '<')
|
||||||
if (*c == '>') level--;
|
level++;
|
||||||
|
if (*c == '>')
|
||||||
|
level--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -628,21 +634,21 @@ Swig_scopename_prefix(String *s) {
|
||||||
* case, "C".
|
* case, "C".
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *Swig_scopename_last(String *s) {
|
||||||
Swig_scopename_last(String *s) {
|
|
||||||
char *tmp = Char(s);
|
char *tmp = Char(s);
|
||||||
char *c = tmp;
|
char *c = tmp;
|
||||||
char *cc = c;
|
char *cc = c;
|
||||||
char *co = 0;
|
char *co = 0;
|
||||||
if (!strstr(c,"::")) return NewString(s);
|
if (!strstr(c, "::"))
|
||||||
|
return NewString(s);
|
||||||
|
|
||||||
if ((co = strstr(cc,"operator "))) {
|
if ((co = strstr(cc, "operator "))) {
|
||||||
return NewString(co);
|
return NewString(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if ((*c == ':') && (*(c+1) == ':')) {
|
if ((*c == ':') && (*(c + 1) == ':')) {
|
||||||
cc = c;
|
cc = c;
|
||||||
c += 2;
|
c += 2;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -650,8 +656,10 @@ Swig_scopename_last(String *s) {
|
||||||
int level = 1;
|
int level = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c && level) {
|
while (*c && level) {
|
||||||
if (*c == '<') level++;
|
if (*c == '<')
|
||||||
if (*c == '>') level--;
|
level++;
|
||||||
|
if (*c == '>')
|
||||||
|
level--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -659,7 +667,7 @@ Swig_scopename_last(String *s) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NewString(cc+2);
|
return NewString(cc + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -669,30 +677,32 @@ Swig_scopename_last(String *s) {
|
||||||
* In this case, "A". Returns NULL if there is no base.
|
* In this case, "A". Returns NULL if there is no base.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *Swig_scopename_first(String *s) {
|
||||||
Swig_scopename_first(String *s) {
|
|
||||||
char *tmp = Char(s);
|
char *tmp = Char(s);
|
||||||
char *c = tmp;
|
char *c = tmp;
|
||||||
char *co = 0;
|
char *co = 0;
|
||||||
if (!strstr(c,"::")) return 0;
|
if (!strstr(c, "::"))
|
||||||
if ((co = strstr(c,"operator "))) {
|
return 0;
|
||||||
|
if ((co = strstr(c, "operator "))) {
|
||||||
if (co == c) {
|
if (co == c) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
co = c + Len(s);
|
co = c + Len(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*c && (c != co)) {
|
while (*c && (c != co)) {
|
||||||
if ((*c == ':') && (*(c+1) == ':')) {
|
if ((*c == ':') && (*(c + 1) == ':')) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (*c == '<') {
|
if (*c == '<') {
|
||||||
int level = 1;
|
int level = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c && level) {
|
while (*c && level) {
|
||||||
if (*c == '<') level++;
|
if (*c == '<')
|
||||||
if (*c == '>') level--;
|
level++;
|
||||||
|
if (*c == '>')
|
||||||
|
level--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -715,25 +725,28 @@ Swig_scopename_first(String *s) {
|
||||||
* In this case, "B::C". Returns NULL if there is no suffix.
|
* In this case, "B::C". Returns NULL if there is no suffix.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *Swig_scopename_suffix(String *s) {
|
||||||
Swig_scopename_suffix(String *s) {
|
|
||||||
char *tmp = Char(s);
|
char *tmp = Char(s);
|
||||||
char *c = tmp;
|
char *c = tmp;
|
||||||
char *co = 0;
|
char *co = 0;
|
||||||
if (!strstr(c,"::")) return 0;
|
if (!strstr(c, "::"))
|
||||||
if ((co = strstr(c,"operator "))) {
|
return 0;
|
||||||
if (co == c) return 0;
|
if ((co = strstr(c, "operator "))) {
|
||||||
|
if (co == c)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if ((*c == ':') && (*(c+1) == ':')) {
|
if ((*c == ':') && (*(c + 1) == ':')) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (*c == '<') {
|
if (*c == '<') {
|
||||||
int level = 1;
|
int level = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c && level) {
|
while (*c && level) {
|
||||||
if (*c == '<') level++;
|
if (*c == '<')
|
||||||
if (*c == '>') level--;
|
level++;
|
||||||
|
if (*c == '>')
|
||||||
|
level--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -742,11 +755,12 @@ Swig_scopename_suffix(String *s) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*c && (c != tmp)) {
|
if (*c && (c != tmp)) {
|
||||||
return NewString(c+2);
|
return NewString(c + 2);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_scopename_check()
|
* Swig_scopename_check()
|
||||||
*
|
*
|
||||||
|
|
@ -756,20 +770,24 @@ Swig_scopename_suffix(String *s) {
|
||||||
int Swig_scopename_check(String *s) {
|
int Swig_scopename_check(String *s) {
|
||||||
char *c = Char(s);
|
char *c = Char(s);
|
||||||
char *co = 0;
|
char *co = 0;
|
||||||
if ((co = strstr(c,"operator "))) {
|
if ((co = strstr(c, "operator "))) {
|
||||||
if (co == c) return 0;
|
if (co == c)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strstr(c,"::")) return 0;
|
if (!strstr(c, "::"))
|
||||||
|
return 0;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if ((*c == ':') && (*(c+1) == ':')) {
|
if ((*c == ':') && (*(c + 1) == ':')) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
if (*c == '<') {
|
if (*c == '<') {
|
||||||
int level = 1;
|
int level = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c && level) {
|
while (*c && level) {
|
||||||
if (*c == '<') level++;
|
if (*c == '<')
|
||||||
if (*c == '>') level--;
|
level++;
|
||||||
|
if (*c == '>')
|
||||||
|
level--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -809,15 +827,15 @@ String *Swig_string_command(String *s) {
|
||||||
#if defined(HAVE_POPEN)
|
#if defined(HAVE_POPEN)
|
||||||
if (Len(s)) {
|
if (Len(s)) {
|
||||||
char *command = Char(s);
|
char *command = Char(s);
|
||||||
FILE *fp = popen(command,"r");
|
FILE *fp = popen(command, "r");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
char buffer[1025];
|
char buffer[1025];
|
||||||
while(fscanf(fp,"%1024s",buffer) != EOF) {
|
while (fscanf(fp, "%1024s", buffer) != EOF) {
|
||||||
Append(res,buffer);
|
Append(res, buffer);
|
||||||
}
|
}
|
||||||
pclose(fp);
|
pclose(fp);
|
||||||
} else {
|
} else {
|
||||||
Swig_error("SWIG",Getline(s), "Command encoder fails attempting '%s'.\n", s);
|
Swig_error("SWIG", Getline(s), "Command encoder fails attempting '%s'.\n", s);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -839,8 +857,7 @@ String *Swig_string_command(String *s) {
|
||||||
#define USE_RXSPENCER
|
#define USE_RXSPENCER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *skip_delim(char pb, char pe, const char *ce)
|
const char *skip_delim(char pb, char pe, const char *ce) {
|
||||||
{
|
|
||||||
int end = 0;
|
int end = 0;
|
||||||
int lb = 0;
|
int lb = 0;
|
||||||
while (!end && *ce != '\0') {
|
while (!end && *ce != '\0') {
|
||||||
|
|
@ -872,45 +889,45 @@ String *Swig_string_rxspencer(String *s) {
|
||||||
int retval;
|
int retval;
|
||||||
regex_t compiled;
|
regex_t compiled;
|
||||||
cb = ++cs;
|
cb = ++cs;
|
||||||
ce = skip_delim('[',']', cb);
|
ce = skip_delim('[', ']', cb);
|
||||||
if (ce) {
|
if (ce) {
|
||||||
char bregexp[512];
|
char bregexp[512];
|
||||||
strncpy(bregexp, cb, ce - cb);
|
strncpy(bregexp, cb, ce - cb);
|
||||||
bregexp[ce - cb] = '\0';
|
bregexp[ce - cb] = '\0';
|
||||||
++ce;
|
++ce;
|
||||||
retval = regcomp(&compiled, bregexp, REG_EXTENDED);
|
retval = regcomp(&compiled, bregexp, REG_EXTENDED);
|
||||||
if(retval == 0) {
|
if (retval == 0) {
|
||||||
cs = ce;
|
cs = ce;
|
||||||
if (*cs == '[') {
|
if (*cs == '[') {
|
||||||
cb = ++cs;
|
cb = ++cs;
|
||||||
ce = skip_delim('[',']', cb) ;
|
ce = skip_delim('[', ']', cb);
|
||||||
if (ce) {
|
if (ce) {
|
||||||
const char *cvalue = ce + 1;
|
const char *cvalue = ce + 1;
|
||||||
int nsub = (int) compiled.re_nsub+1;
|
int nsub = (int) compiled.re_nsub + 1;
|
||||||
regmatch_t *pmatch = (regmatch_t *)malloc(sizeof(regmatch_t)*(nsub));
|
regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
|
||||||
retval = regexec(&compiled,cvalue,nsub,pmatch,0);
|
retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
|
||||||
if (retval != REG_NOMATCH) {
|
if (retval != REG_NOMATCH) {
|
||||||
char *spos = 0;
|
char *spos = 0;
|
||||||
res = NewStringWithSize(cb, ce - cb);
|
res = NewStringWithSize(cb, ce - cb);
|
||||||
spos = Strchr(res,'@');
|
spos = Strchr(res, '@');
|
||||||
while (spos) {
|
while (spos) {
|
||||||
char cd = *(++spos);
|
char cd = *(++spos);
|
||||||
if (isdigit(cd)) {
|
if (isdigit(cd)) {
|
||||||
char arg[8];
|
char arg[8];
|
||||||
size_t len;
|
size_t len;
|
||||||
int i = cd - '0';
|
int i = cd - '0';
|
||||||
sprintf(arg,"@%d", i);
|
sprintf(arg, "@%d", i);
|
||||||
if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
|
if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
|
||||||
char value[256];
|
char value[256];
|
||||||
strncpy(value,cvalue + pmatch[i].rm_so, len);
|
strncpy(value, cvalue + pmatch[i].rm_so, len);
|
||||||
value[len] = 0;
|
value[len] = 0;
|
||||||
Replaceall(res,arg,value);
|
Replaceall(res, arg, value);
|
||||||
} else {
|
} else {
|
||||||
Replaceall(res,arg,"");
|
Replaceall(res, arg, "");
|
||||||
}
|
}
|
||||||
spos = Strchr(res,'@');
|
spos = Strchr(res, '@');
|
||||||
} else if (cd == '@') {
|
} else if (cd == '@') {
|
||||||
spos = strchr(spos + 1,'@');
|
spos = strchr(spos + 1, '@');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -922,12 +939,13 @@ String *Swig_string_rxspencer(String *s) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!res) res = NewStringEmpty();
|
if (!res)
|
||||||
|
res = NewStringEmpty();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
String *Swig_string_rxspencer(String *s) {
|
String *Swig_string_rxspencer(String *s) {
|
||||||
(void)s;
|
(void) s;
|
||||||
return NewStringEmpty();
|
return NewStringEmpty();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -939,8 +957,7 @@ String *Swig_string_rxspencer(String *s) {
|
||||||
* Initialize the SWIG core
|
* Initialize the SWIG core
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_init() {
|
||||||
Swig_init() {
|
|
||||||
/* Set some useful string encoding methods */
|
/* Set some useful string encoding methods */
|
||||||
DohEncoding("escape", Swig_string_escape);
|
DohEncoding("escape", Swig_string_escape);
|
||||||
DohEncoding("upper", Swig_string_upper);
|
DohEncoding("upper", Swig_string_upper);
|
||||||
|
|
@ -949,7 +966,7 @@ Swig_init() {
|
||||||
DohEncoding("ctitle", Swig_string_ccase);
|
DohEncoding("ctitle", Swig_string_ccase);
|
||||||
DohEncoding("lctitle", Swig_string_lccase);
|
DohEncoding("lctitle", Swig_string_lccase);
|
||||||
DohEncoding("utitle", Swig_string_ucase);
|
DohEncoding("utitle", Swig_string_ucase);
|
||||||
DohEncoding("typecode",Swig_string_typecode);
|
DohEncoding("typecode", Swig_string_typecode);
|
||||||
DohEncoding("mangle", Swig_string_emangle);
|
DohEncoding("mangle", Swig_string_emangle);
|
||||||
DohEncoding("command", Swig_string_command);
|
DohEncoding("command", Swig_string_command);
|
||||||
DohEncoding("rxspencer", Swig_string_rxspencer);
|
DohEncoding("rxspencer", Swig_string_rxspencer);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -20,13 +20,13 @@ char cvsroot_parms_c[] = "$Header$";
|
||||||
|
|
||||||
Parm *NewParm(SwigType *type, const String_or_char *name) {
|
Parm *NewParm(SwigType *type, const String_or_char *name) {
|
||||||
Parm *p = NewHash();
|
Parm *p = NewHash();
|
||||||
Setattr(p,k_nodetype,k_parm);
|
Setattr(p, k_nodetype, k_parm);
|
||||||
if (type) {
|
if (type) {
|
||||||
SwigType *ntype = Copy(type);
|
SwigType *ntype = Copy(type);
|
||||||
Setattr(p,k_type,ntype);
|
Setattr(p, k_type, ntype);
|
||||||
Delete(ntype);
|
Delete(ntype);
|
||||||
}
|
}
|
||||||
Setattr(p,k_name,name);
|
Setattr(p, k_name, name);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) {
|
||||||
Parm *p = NewParm(type, name);
|
Parm *p = NewParm(type, name);
|
||||||
Setfile(p, Getfile(n));
|
Setfile(p, Getfile(n));
|
||||||
Setline(p, Getline(n));
|
Setline(p, Getline(n));
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,45 +51,45 @@ Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) {
|
||||||
* ------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
Parm *CopyParm(Parm *p) {
|
Parm *CopyParm(Parm *p) {
|
||||||
Parm *np = NewHash();
|
Parm *np = NewHash();
|
||||||
SwigType *t = HashGetAttr(p,k_type);
|
SwigType *t = HashGetAttr(p, k_type);
|
||||||
String *name = HashGetAttr(p,k_name);
|
String *name = HashGetAttr(p, k_name);
|
||||||
String *lname = HashGetAttr(p,k_lname);
|
String *lname = HashGetAttr(p, k_lname);
|
||||||
String *value = HashGetAttr(p,k_value);
|
String *value = HashGetAttr(p, k_value);
|
||||||
String *ignore = HashGetAttr(p,k_ignore);
|
String *ignore = HashGetAttr(p, k_ignore);
|
||||||
String *alttype = HashGetAttr(p,k_alttype);
|
String *alttype = HashGetAttr(p, k_alttype);
|
||||||
String *byname = HashGetAttr(p, k_argbyname);
|
String *byname = HashGetAttr(p, k_argbyname);
|
||||||
String *compactdefargs = HashGetAttr(p, k_compactdefargs);
|
String *compactdefargs = HashGetAttr(p, k_compactdefargs);
|
||||||
String *self = HashGetAttr(p, k_self);
|
String *self = HashGetAttr(p, k_self);
|
||||||
|
|
||||||
if (t) {
|
if (t) {
|
||||||
SwigType *nt = Copy(t);
|
SwigType *nt = Copy(t);
|
||||||
Setattr(np,k_type,nt);
|
Setattr(np, k_type, nt);
|
||||||
Delete(nt);
|
Delete(nt);
|
||||||
}
|
}
|
||||||
if (name) {
|
if (name) {
|
||||||
String *str = Copy(name);
|
String *str = Copy(name);
|
||||||
Setattr(np,k_name,str);
|
Setattr(np, k_name, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
if (lname) {
|
if (lname) {
|
||||||
String *str = Copy(lname);
|
String *str = Copy(lname);
|
||||||
Setattr(np,k_lname, str);
|
Setattr(np, k_lname, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
String *str = Copy(value);
|
String *str = Copy(value);
|
||||||
Setattr(np,k_value, str);
|
Setattr(np, k_value, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
if (ignore) {
|
if (ignore) {
|
||||||
String *str = Copy(ignore);
|
String *str = Copy(ignore);
|
||||||
Setattr(np,k_ignore, str);
|
Setattr(np, k_ignore, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
if (alttype) {
|
if (alttype) {
|
||||||
String *str = Copy(alttype);
|
String *str = Copy(alttype);
|
||||||
Setattr(np,k_alttype, str);
|
Setattr(np, k_alttype, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
if (byname) {
|
if (byname) {
|
||||||
|
|
@ -98,7 +98,7 @@ Parm *CopyParm(Parm *p) {
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
if (compactdefargs) {
|
if (compactdefargs) {
|
||||||
String *str = Copy(compactdefargs);
|
String *str = Copy(compactdefargs);
|
||||||
Setattr(np, k_compactdefargs, str);
|
Setattr(np, k_compactdefargs, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
|
|
@ -107,9 +107,9 @@ Parm *CopyParm(Parm *p) {
|
||||||
Setattr(np, k_self, str);
|
Setattr(np, k_self, str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
Setfile(np,Getfile(p));
|
Setfile(np, Getfile(p));
|
||||||
Setline(np,Getline(p));
|
Setline(np, Getline(p));
|
||||||
|
|
||||||
return np;
|
return np;
|
||||||
}
|
}
|
||||||
|
|
@ -118,19 +118,19 @@ Parm *CopyParm(Parm *p) {
|
||||||
* CopyParmList()
|
* CopyParmList()
|
||||||
* ------------------------------------------------------------------ */
|
* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
ParmList *
|
ParmList *CopyParmList(ParmList *p) {
|
||||||
CopyParmList(ParmList *p) {
|
|
||||||
Parm *np;
|
Parm *np;
|
||||||
Parm *pp = 0;
|
Parm *pp = 0;
|
||||||
Parm *fp = 0;
|
Parm *fp = 0;
|
||||||
|
|
||||||
if (!p) return 0;
|
if (!p)
|
||||||
|
return 0;
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
np = CopyParm(p);
|
np = CopyParm(p);
|
||||||
if (pp) {
|
if (pp) {
|
||||||
set_nextSibling(pp,np);
|
set_nextSibling(pp, np);
|
||||||
Delete(np);
|
Delete(np);
|
||||||
} else {
|
} else {
|
||||||
fp = np;
|
fp = np;
|
||||||
}
|
}
|
||||||
|
|
@ -145,9 +145,10 @@ CopyParmList(ParmList *p) {
|
||||||
* ------------------------------------------------------------------ */
|
* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
int ParmList_numarg(ParmList *p) {
|
int ParmList_numarg(ParmList *p) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (p) {
|
while (p) {
|
||||||
if (!HashGetAttr(p,k_ignore)) n++;
|
if (!HashGetAttr(p, k_ignore))
|
||||||
|
n++;
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
|
@ -160,11 +161,14 @@ int ParmList_numarg(ParmList *p) {
|
||||||
int ParmList_numrequired(ParmList *p) {
|
int ParmList_numrequired(ParmList *p) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (p) {
|
while (p) {
|
||||||
SwigType *t = HashGetAttr(p,k_type);
|
SwigType *t = HashGetAttr(p, k_type);
|
||||||
String *value = HashGetAttr(p,k_value);
|
String *value = HashGetAttr(p, k_value);
|
||||||
if (value) return i;
|
if (value)
|
||||||
if (!(SwigType_type(t) == T_VOID)) i++;
|
return i;
|
||||||
else break;
|
if (!(SwigType_type(t) == T_VOID))
|
||||||
|
i++;
|
||||||
|
else
|
||||||
|
break;
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
|
@ -191,12 +195,12 @@ int ParmList_len(ParmList *p) {
|
||||||
|
|
||||||
String *ParmList_str(ParmList *p) {
|
String *ParmList_str(ParmList *p) {
|
||||||
String *out = NewStringEmpty();
|
String *out = NewStringEmpty();
|
||||||
while(p) {
|
while (p) {
|
||||||
String *pstr = SwigType_str(HashGetAttr(p,k_type), HashGetAttr(p,k_name));
|
String *pstr = SwigType_str(HashGetAttr(p, k_type), HashGetAttr(p, k_name));
|
||||||
StringAppend(out,pstr);
|
StringAppend(out, pstr);
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
if (p) {
|
if (p) {
|
||||||
StringAppend(out,",");
|
StringAppend(out, ",");
|
||||||
}
|
}
|
||||||
Delete(pstr);
|
Delete(pstr);
|
||||||
}
|
}
|
||||||
|
|
@ -211,18 +215,18 @@ String *ParmList_str(ParmList *p) {
|
||||||
|
|
||||||
String *ParmList_str_defaultargs(ParmList *p) {
|
String *ParmList_str_defaultargs(ParmList *p) {
|
||||||
String *out = NewStringEmpty();
|
String *out = NewStringEmpty();
|
||||||
while(p) {
|
while (p) {
|
||||||
String *value = HashGetAttr(p,k_value);
|
String *value = HashGetAttr(p, k_value);
|
||||||
String *pstr = SwigType_str(HashGetAttr(p,k_type), HashGetAttr(p,k_name));
|
String *pstr = SwigType_str(HashGetAttr(p, k_type), HashGetAttr(p, k_name));
|
||||||
StringAppend(out,pstr);
|
StringAppend(out, pstr);
|
||||||
if (value) {
|
if (value) {
|
||||||
Printf(out,"=%s", value);
|
Printf(out, "=%s", value);
|
||||||
}
|
}
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
if (p) {
|
if (p) {
|
||||||
StringAppend(out,",");
|
StringAppend(out, ",");
|
||||||
}
|
}
|
||||||
Delete(pstr);
|
Delete(pstr);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
@ -235,15 +239,15 @@ String *ParmList_str_defaultargs(ParmList *p) {
|
||||||
|
|
||||||
String *ParmList_protostr(ParmList *p) {
|
String *ParmList_protostr(ParmList *p) {
|
||||||
String *out = NewStringEmpty();
|
String *out = NewStringEmpty();
|
||||||
while(p) {
|
while (p) {
|
||||||
if (HashGetAttr(p,k_hidden)) {
|
if (HashGetAttr(p, k_hidden)) {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
} else {
|
} else {
|
||||||
String *pstr = SwigType_str(HashGetAttr(p,k_type), 0);
|
String *pstr = SwigType_str(HashGetAttr(p, k_type), 0);
|
||||||
StringAppend(out,pstr);
|
StringAppend(out, pstr);
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
if (p) {
|
if (p) {
|
||||||
StringAppend(out,",");
|
StringAppend(out, ",");
|
||||||
}
|
}
|
||||||
Delete(pstr);
|
Delete(pstr);
|
||||||
}
|
}
|
||||||
|
|
@ -260,16 +264,16 @@ String *ParmList_protostr(ParmList *p) {
|
||||||
|
|
||||||
int ParmList_is_compactdefargs(ParmList *p) {
|
int ParmList_is_compactdefargs(ParmList *p) {
|
||||||
int compactdefargs = 0;
|
int compactdefargs = 0;
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
compactdefargs = HashGetAttr(p,k_compactdefargs) ? 1 : 0;
|
compactdefargs = HashGetAttr(p, k_compactdefargs) ? 1 : 0;
|
||||||
|
|
||||||
/* The "compactdefargs" attribute should only be set on the first parameter in the list.
|
/* The "compactdefargs" attribute should only be set on the first parameter in the list.
|
||||||
* However, sometimes an extra parameter is inserted at the beginning of the parameter list,
|
* However, sometimes an extra parameter is inserted at the beginning of the parameter list,
|
||||||
* so we check the 2nd parameter too. */
|
* so we check the 2nd parameter too. */
|
||||||
if (!compactdefargs) {
|
if (!compactdefargs) {
|
||||||
Parm *nextparm = nextSibling(p);
|
Parm *nextparm = nextSibling(p);
|
||||||
compactdefargs = (nextparm && HashGetAttr(nextparm,k_compactdefargs)) ? 1 : 0;
|
compactdefargs = (nextparm && HashGetAttr(nextparm, k_compactdefargs)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -285,15 +289,15 @@ int ParmList_is_compactdefargs(ParmList *p) {
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
int ParmList_has_defaultargs(ParmList *p) {
|
int ParmList_has_defaultargs(ParmList *p) {
|
||||||
int default_args = 0;
|
int default_args = 0;
|
||||||
while (p) {
|
while (p) {
|
||||||
if (HashGetAttr(p, k_value)) {
|
if (HashGetAttr(p, k_value)) {
|
||||||
default_args = 1;
|
default_args = 1;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
p = nextSibling(p);
|
|
||||||
}
|
}
|
||||||
return default_args;
|
p = nextSibling(p);
|
||||||
|
}
|
||||||
|
return default_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
|
|
@ -304,14 +308,14 @@ int ParmList_has_defaultargs(ParmList *p) {
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
ParmList *ParmList_copy_all_except_last_parm(ParmList *p) {
|
ParmList *ParmList_copy_all_except_last_parm(ParmList *p) {
|
||||||
ParmList* newparms = 0;
|
ParmList *newparms = 0;
|
||||||
Parm *newparm = 0;
|
Parm *newparm = 0;
|
||||||
Parm *pp = 0;
|
Parm *pp = 0;
|
||||||
Parm *fp = 0;
|
Parm *fp = 0;
|
||||||
while (nextSibling(p)) {
|
while (nextSibling(p)) {
|
||||||
newparm = CopyParm(p);
|
newparm = CopyParm(p);
|
||||||
if (pp) {
|
if (pp) {
|
||||||
set_nextSibling(pp,newparm);
|
set_nextSibling(pp, newparm);
|
||||||
Delete(newparm);
|
Delete(newparm);
|
||||||
} else {
|
} else {
|
||||||
fp = newparm;
|
fp = newparm;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -86,7 +86,7 @@ char cvsroot_stype_c[] = "$Header$";
|
||||||
|
|
||||||
|
|
||||||
SwigType *NewSwigType(int t) {
|
SwigType *NewSwigType(int t) {
|
||||||
switch(t) {
|
switch (t) {
|
||||||
case T_BOOL:
|
case T_BOOL:
|
||||||
return NewString("bool");
|
return NewString("bool");
|
||||||
break;
|
break;
|
||||||
|
|
@ -102,7 +102,7 @@ SwigType *NewSwigType(int t) {
|
||||||
case T_USHORT:
|
case T_USHORT:
|
||||||
return NewString("unsigned short");
|
return NewString("unsigned short");
|
||||||
break;
|
break;
|
||||||
case T_LONG:
|
case T_LONG:
|
||||||
return NewString("long");
|
return NewString("long");
|
||||||
break;
|
break;
|
||||||
case T_ULONG:
|
case T_ULONG:
|
||||||
|
|
@ -126,12 +126,12 @@ SwigType *NewSwigType(int t) {
|
||||||
case T_UCHAR:
|
case T_UCHAR:
|
||||||
return NewString("unsigned char");
|
return NewString("unsigned char");
|
||||||
break;
|
break;
|
||||||
case T_STRING: {
|
case T_STRING:{
|
||||||
SwigType *t = NewString("char");
|
SwigType *t = NewString("char");
|
||||||
SwigType_add_pointer(t);
|
SwigType_add_pointer(t);
|
||||||
return t;
|
return t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case T_LONGLONG:
|
case T_LONGLONG:
|
||||||
return NewString("long long");
|
return NewString("long long");
|
||||||
break;
|
break;
|
||||||
|
|
@ -141,7 +141,7 @@ SwigType *NewSwigType(int t) {
|
||||||
case T_VOID:
|
case T_VOID:
|
||||||
return NewString("void");
|
return NewString("void");
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return NewStringEmpty();
|
return NewStringEmpty();
|
||||||
|
|
@ -153,17 +153,18 @@ SwigType *NewSwigType(int t) {
|
||||||
* Push a type constructor onto the type
|
* Push a type constructor onto the type
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void SwigType_push(SwigType *t, String *cons)
|
void SwigType_push(SwigType *t, String *cons) {
|
||||||
{
|
if (!cons)
|
||||||
if (!cons) return;
|
return;
|
||||||
if (!Len(cons)) return;
|
if (!Len(cons))
|
||||||
|
return;
|
||||||
|
|
||||||
if (Len(t)) {
|
if (Len(t)) {
|
||||||
char *c = Char(cons);
|
char *c = Char(cons);
|
||||||
if (c[strlen(c)-1] != '.')
|
if (c[strlen(c) - 1] != '.')
|
||||||
Insert(t,0,".");
|
Insert(t, 0, ".");
|
||||||
}
|
}
|
||||||
Insert(t,0,cons);
|
Insert(t, 0, cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -178,36 +179,39 @@ void SwigType_push(SwigType *t, String *cons)
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int SwigType_ispointer_return(SwigType *t) {
|
int SwigType_ispointer_return(SwigType *t) {
|
||||||
char* c;
|
char *c;
|
||||||
int idx;
|
int idx;
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
idx = strlen(c)-4;
|
idx = strlen(c) - 4;
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
return (strcmp(c+idx, ").p.") == 0);
|
return (strcmp(c + idx, ").p.") == 0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SwigType_isreference_return(SwigType *t) {
|
int SwigType_isreference_return(SwigType *t) {
|
||||||
char* c;
|
char *c;
|
||||||
int idx;
|
int idx;
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
idx = strlen(c)-4;
|
idx = strlen(c) - 4;
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
return (strcmp(c+idx, ").r.") == 0);
|
return (strcmp(c + idx, ").r.") == 0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SwigType_isconst(SwigType *t) {
|
int SwigType_isconst(SwigType *t) {
|
||||||
char *c;
|
char *c;
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
if (strncmp(c,"q(",2) == 0) {
|
if (strncmp(c, "q(", 2) == 0) {
|
||||||
String *q = SwigType_parm(t);
|
String *q = SwigType_parm(t);
|
||||||
if (strstr(Char(q),"const")) {
|
if (strstr(Char(q), "const")) {
|
||||||
Delete(q);
|
Delete(q);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -239,8 +243,9 @@ int SwigType_ismutable(SwigType *t) {
|
||||||
|
|
||||||
int SwigType_isenum(SwigType *t) {
|
int SwigType_isenum(SwigType *t) {
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
if (strncmp(c,"enum ",5) == 0) {
|
return 0;
|
||||||
|
if (strncmp(c, "enum ", 5) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -248,19 +253,23 @@ int SwigType_isenum(SwigType *t) {
|
||||||
|
|
||||||
int SwigType_issimple(SwigType *t) {
|
int SwigType_issimple(SwigType *t) {
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == '<') {
|
if (*c == '<') {
|
||||||
int nest = 1;
|
int nest = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c && nest) {
|
while (*c && nest) {
|
||||||
if (*c == '<') nest++;
|
if (*c == '<')
|
||||||
if (*c == '>') nest--;
|
nest++;
|
||||||
|
if (*c == '>')
|
||||||
|
nest--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
if (*c == '.') return 0;
|
if (*c == '.')
|
||||||
|
return 0;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -319,14 +328,13 @@ static Hash *default_cache = 0;
|
||||||
p.SWIGTYPE -> SWIGTYPE
|
p.SWIGTYPE -> SWIGTYPE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static
|
static
|
||||||
void SwigType_add_default(String *def, SwigType *nr)
|
void SwigType_add_default(String *def, SwigType *nr) {
|
||||||
{
|
if (Strcmp(nr, "SWIGTYPE") == 0) {
|
||||||
if (Strcmp(nr,"SWIGTYPE") == 0) {
|
StringAppend(def, "SWIGTYPE");
|
||||||
StringAppend(def,"SWIGTYPE");
|
|
||||||
} else {
|
} else {
|
||||||
String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
|
String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
|
||||||
if (q && strstr(Char(nr),"SWIGTYPE")) {
|
if (q && strstr(Char(nr), "SWIGTYPE")) {
|
||||||
StringAppend(def, nr);
|
StringAppend(def, nr);
|
||||||
} else {
|
} else {
|
||||||
String *nd = SwigType_default(nr);
|
String *nd = SwigType_default(nr);
|
||||||
|
|
@ -334,17 +342,17 @@ void SwigType_add_default(String *def, SwigType *nr)
|
||||||
String *bdef = nd;
|
String *bdef = nd;
|
||||||
if (q) {
|
if (q) {
|
||||||
bdef = NewStringf("%s%s", q, nd);
|
bdef = NewStringf("%s%s", q, nd);
|
||||||
if ((Strcmp(nr,bdef) == 0)) {
|
if ((Strcmp(nr, bdef) == 0)) {
|
||||||
Delete(bdef);
|
Delete(bdef);
|
||||||
bdef = nd;
|
bdef = nd;
|
||||||
} else {
|
} else {
|
||||||
Delete(nd);
|
Delete(nd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringAppend(def,bdef);
|
StringAppend(def, bdef);
|
||||||
Delete(bdef);
|
Delete(bdef);
|
||||||
} else {
|
} else {
|
||||||
StringAppend(def,nr);
|
StringAppend(def, nr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Delete(q);
|
Delete(q);
|
||||||
|
|
@ -358,28 +366,31 @@ SwigType *SwigType_default(SwigType *t) {
|
||||||
char *cr;
|
char *cr;
|
||||||
|
|
||||||
#ifdef SWIG_DEFAULT_CACHE
|
#ifdef SWIG_DEFAULT_CACHE
|
||||||
if (!default_cache) default_cache = NewHash();
|
if (!default_cache)
|
||||||
|
default_cache = NewHash();
|
||||||
r = Getattr(default_cache,t);
|
|
||||||
|
r = Getattr(default_cache, t);
|
||||||
if (r) {
|
if (r) {
|
||||||
return Copy(r);
|
return Copy(r);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SwigType_isvarargs(t)) {
|
if (SwigType_isvarargs(t)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = t;
|
r = t;
|
||||||
while ((r1 = SwigType_typedef_resolve(r))) {
|
while ((r1 = SwigType_typedef_resolve(r))) {
|
||||||
if (r != t) Delete(r);
|
if (r != t)
|
||||||
|
Delete(r);
|
||||||
r = r1;
|
r = r1;
|
||||||
}
|
}
|
||||||
if (SwigType_isqualifier(r)) {
|
if (SwigType_isqualifier(r)) {
|
||||||
String *q;
|
String *q;
|
||||||
if (r == t) r = Copy(t);
|
if (r == t)
|
||||||
|
r = Copy(t);
|
||||||
q = SwigType_pop(r);
|
q = SwigType_pop(r);
|
||||||
if (strstr(Char(r),"SWIGTYPE")) {
|
if (strstr(Char(r), "SWIGTYPE")) {
|
||||||
Delete(q);
|
Delete(q);
|
||||||
def = r;
|
def = r;
|
||||||
return def;
|
return def;
|
||||||
|
|
@ -387,20 +398,19 @@ SwigType *SwigType_default(SwigType *t) {
|
||||||
Delete(q);
|
Delete(q);
|
||||||
}
|
}
|
||||||
cr = Char(r);
|
cr = Char(r);
|
||||||
if (strcmp(cr,"p.SWIGTYPE") == 0) {
|
if (strcmp(cr, "p.SWIGTYPE") == 0) {
|
||||||
def = NewString("SWIGTYPE");
|
def = NewString("SWIGTYPE");
|
||||||
} else if (SwigType_ispointer(r)) {
|
} else if (SwigType_ispointer(r)) {
|
||||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||||
SwigType *nr = Copy(r);
|
SwigType *nr = Copy(r);
|
||||||
SwigType_del_pointer(nr);
|
SwigType_del_pointer(nr);
|
||||||
def = SwigType_isfunction(nr) ?
|
def = SwigType_isfunction(nr) ? NewStringEmpty() : NewString("p.");
|
||||||
NewStringEmpty() : NewString("p.");
|
|
||||||
SwigType_add_default(def, nr);
|
SwigType_add_default(def, nr);
|
||||||
Delete(nr);
|
Delete(nr);
|
||||||
#else
|
#else
|
||||||
def = NewString("p.SWIGTYPE");
|
def = NewString("p.SWIGTYPE");
|
||||||
#endif
|
#endif
|
||||||
} else if (strcmp(cr,"r.SWIGTYPE") == 0) {
|
} else if (strcmp(cr, "r.SWIGTYPE") == 0) {
|
||||||
def = NewString("SWIGTYPE");
|
def = NewString("SWIGTYPE");
|
||||||
} else if (SwigType_isreference(r)) {
|
} else if (SwigType_isreference(r)) {
|
||||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||||
|
|
@ -413,19 +423,19 @@ SwigType *SwigType_default(SwigType *t) {
|
||||||
def = NewString("r.SWIGTYPE");
|
def = NewString("r.SWIGTYPE");
|
||||||
#endif
|
#endif
|
||||||
} else if (SwigType_isarray(r)) {
|
} else if (SwigType_isarray(r)) {
|
||||||
if (strcmp(cr,"a().SWIGTYPE") == 0) {
|
if (strcmp(cr, "a().SWIGTYPE") == 0) {
|
||||||
def = NewString("p.SWIGTYPE");
|
def = NewString("p.SWIGTYPE");
|
||||||
} else if (strcmp(cr,"a(ANY).SWIGTYPE") == 0) {
|
} else if (strcmp(cr, "a(ANY).SWIGTYPE") == 0) {
|
||||||
def = NewString("a().SWIGTYPE");
|
def = NewString("a().SWIGTYPE");
|
||||||
} else {
|
} else {
|
||||||
int i, empty = 0;
|
int i, empty = 0;
|
||||||
int ndim = SwigType_array_ndim(r);
|
int ndim = SwigType_array_ndim(r);
|
||||||
SwigType *nr = Copy(r);
|
SwigType *nr = Copy(r);
|
||||||
for (i = 0; i < ndim; i++) {
|
for (i = 0; i < ndim; i++) {
|
||||||
String *dim = SwigType_array_getdim(r,i);
|
String *dim = SwigType_array_getdim(r, i);
|
||||||
if (!Len(dim)) {
|
if (!Len(dim)) {
|
||||||
char *c = Char(nr);
|
char *c = Char(nr);
|
||||||
empty = strstr(c,"a(ANY).") != c;
|
empty = strstr(c, "a(ANY).") != c;
|
||||||
}
|
}
|
||||||
Delete(dim);
|
Delete(dim);
|
||||||
}
|
}
|
||||||
|
|
@ -438,24 +448,24 @@ SwigType *SwigType_default(SwigType *t) {
|
||||||
SwigType_del_array(nr);
|
SwigType_del_array(nr);
|
||||||
SwigType_add_default(def, nr);
|
SwigType_add_default(def, nr);
|
||||||
#else
|
#else
|
||||||
StringAppend(def,"SWIGTYPE");
|
StringAppend(def, "SWIGTYPE");
|
||||||
#endif
|
#endif
|
||||||
Delete(nr);
|
Delete(nr);
|
||||||
}
|
}
|
||||||
} else if (SwigType_ismemberpointer(r)) {
|
} else if (SwigType_ismemberpointer(r)) {
|
||||||
if (strcmp(cr,"m(CLASS).SWIGTYPE") == 0) {
|
if (strcmp(cr, "m(CLASS).SWIGTYPE") == 0) {
|
||||||
def = NewString("p.SWIGTYPE");
|
def = NewString("p.SWIGTYPE");
|
||||||
} else {
|
} else {
|
||||||
def = NewString("m(CLASS).SWIGTYPE");
|
def = NewString("m(CLASS).SWIGTYPE");
|
||||||
}
|
}
|
||||||
} else if (SwigType_isenum(r)) {
|
} else if (SwigType_isenum(r)) {
|
||||||
if (strcmp(cr,"enum SWIGTYPE") == 0) {
|
if (strcmp(cr, "enum SWIGTYPE") == 0) {
|
||||||
def = NewString("SWIGTYPE");
|
def = NewString("SWIGTYPE");
|
||||||
} else {
|
} else {
|
||||||
def = NewString("enum SWIGTYPE");
|
def = NewString("enum SWIGTYPE");
|
||||||
}
|
}
|
||||||
} else if (SwigType_isfunction(r)) {
|
} else if (SwigType_isfunction(r)) {
|
||||||
if (strcmp(cr,"f(ANY).SWIGTYPE") == 0) {
|
if (strcmp(cr, "f(ANY).SWIGTYPE") == 0) {
|
||||||
def = NewString("p.SWIGTYPE");
|
def = NewString("p.SWIGTYPE");
|
||||||
} else {
|
} else {
|
||||||
def = NewString("p.f(ANY).SWIGTYPE");
|
def = NewString("p.f(ANY).SWIGTYPE");
|
||||||
|
|
@ -463,17 +473,17 @@ SwigType *SwigType_default(SwigType *t) {
|
||||||
} else {
|
} else {
|
||||||
def = NewString("SWIGTYPE");
|
def = NewString("SWIGTYPE");
|
||||||
}
|
}
|
||||||
if (r != t) Delete(r);
|
if (r != t)
|
||||||
if (StringEqual(def,t)) {
|
Delete(r);
|
||||||
|
if (StringEqual(def, t)) {
|
||||||
Delete(def);
|
Delete(def);
|
||||||
def = 0;
|
def = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SWIG_DEFAULT_CACHE
|
#ifdef SWIG_DEFAULT_CACHE
|
||||||
/* The cache produces strange results, see enum_template.i case */
|
/* The cache produces strange results, see enum_template.i case */
|
||||||
if (def) {
|
if (def) {
|
||||||
String *cdef = Copy(def);
|
String *cdef = Copy(def);
|
||||||
Setattr(default_cache,t, cdef);
|
Setattr(default_cache, t, cdef);
|
||||||
Delete(cdef);
|
Delete(cdef);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -489,35 +499,38 @@ SwigType *SwigType_default(SwigType *t) {
|
||||||
* Returns a string of the base type. Takes care of template expansions
|
* Returns a string of the base type. Takes care of template expansions
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *SwigType_namestr(const SwigType *t) {
|
||||||
SwigType_namestr(const SwigType *t) {
|
|
||||||
String *r;
|
String *r;
|
||||||
String *suffix;
|
String *suffix;
|
||||||
List *p;
|
List *p;
|
||||||
int i, sz;
|
int i, sz;
|
||||||
char *d = Char(t);
|
char *d = Char(t);
|
||||||
char *c = strstr(d,"<(");
|
char *c = strstr(d, "<(");
|
||||||
|
|
||||||
if (!c || !strstr(c+2,")>")) return NewString(t);
|
if (!c || !strstr(c + 2, ")>"))
|
||||||
|
return NewString(t);
|
||||||
|
|
||||||
r = NewStringWithSize(d, c - d);
|
r = NewStringWithSize(d, c - d);
|
||||||
if (*(c - 1) == '<') Putc(' ',r);
|
if (*(c - 1) == '<')
|
||||||
Putc('<',r);
|
Putc(' ', r);
|
||||||
|
Putc('<', r);
|
||||||
p = SwigType_parmlist(c+1);
|
|
||||||
|
p = SwigType_parmlist(c + 1);
|
||||||
sz = Len(p);
|
sz = Len(p);
|
||||||
for (i = 0; i < sz; i++) {
|
for (i = 0; i < sz; i++) {
|
||||||
String *str = SwigType_str(Getitem(p,i),0);
|
String *str = SwigType_str(Getitem(p, i), 0);
|
||||||
/* Avoid creating a <: token, which is the same as [ in C++. */
|
/* Avoid creating a <: token, which is the same as [ in C++. */
|
||||||
if (i == 0 && Len(str) && *Char(str) == ':') Putc(' ', r);
|
if (i == 0 && Len(str) && *Char(str) == ':')
|
||||||
StringAppend(r,str);
|
Putc(' ', r);
|
||||||
if ((i+1) < sz) Putc(',',r);
|
StringAppend(r, str);
|
||||||
|
if ((i + 1) < sz)
|
||||||
|
Putc(',', r);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
Putc(' ',r);
|
Putc(' ', r);
|
||||||
Putc('>',r);
|
Putc('>', r);
|
||||||
suffix = SwigType_templatesuffix(t);
|
suffix = SwigType_templatesuffix(t);
|
||||||
StringAppend(r,suffix);
|
StringAppend(r, suffix);
|
||||||
Delete(suffix);
|
Delete(suffix);
|
||||||
Delete(p);
|
Delete(p);
|
||||||
return r;
|
return r;
|
||||||
|
|
@ -529,9 +542,7 @@ SwigType_namestr(const SwigType *t) {
|
||||||
* Create a C string representation of a datatype.
|
* Create a C string representation of a datatype.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *SwigType_str(SwigType *s, const String_or_char *id) {
|
||||||
SwigType_str(SwigType *s, const String_or_char *id)
|
|
||||||
{
|
|
||||||
String *result;
|
String *result;
|
||||||
String *element = 0, *nextelement;
|
String *element = 0, *nextelement;
|
||||||
List *elements;
|
List *elements;
|
||||||
|
|
@ -547,71 +558,71 @@ SwigType_str(SwigType *s, const String_or_char *id)
|
||||||
nelements = Len(elements);
|
nelements = Len(elements);
|
||||||
|
|
||||||
if (nelements > 0) {
|
if (nelements > 0) {
|
||||||
element = Getitem(elements,0);
|
element = Getitem(elements, 0);
|
||||||
}
|
}
|
||||||
/* Now, walk the type list and start emitting */
|
/* Now, walk the type list and start emitting */
|
||||||
for (i = 0; i < nelements; i++) {
|
for (i = 0; i < nelements; i++) {
|
||||||
if (i < (nelements - 1)) {
|
if (i < (nelements - 1)) {
|
||||||
nextelement = Getitem(elements,i+1);
|
nextelement = Getitem(elements, i + 1);
|
||||||
} else {
|
} else {
|
||||||
nextelement = 0;
|
nextelement = 0;
|
||||||
}
|
}
|
||||||
if (SwigType_isqualifier(element)) {
|
if (SwigType_isqualifier(element)) {
|
||||||
DOH *q = 0;
|
DOH *q = 0;
|
||||||
q = SwigType_parm(element);
|
q = SwigType_parm(element);
|
||||||
Insert(result,0," ");
|
Insert(result, 0, " ");
|
||||||
Insert(result,0,q);
|
Insert(result, 0, q);
|
||||||
Delete(q);
|
Delete(q);
|
||||||
} else if (SwigType_ispointer(element)) {
|
} else if (SwigType_ispointer(element)) {
|
||||||
Insert(result,0,"*");
|
Insert(result, 0, "*");
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result,0,"(");
|
Insert(result, 0, "(");
|
||||||
StringAppend(result,")");
|
StringAppend(result, ")");
|
||||||
}
|
}
|
||||||
} else if (SwigType_ismemberpointer(element)) {
|
} else if (SwigType_ismemberpointer(element)) {
|
||||||
String *q;
|
String *q;
|
||||||
q = SwigType_parm(element);
|
q = SwigType_parm(element);
|
||||||
Insert(result,0,"::*");
|
Insert(result, 0, "::*");
|
||||||
Insert(result,0,q);
|
Insert(result, 0, q);
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result,0,"(");
|
Insert(result, 0, "(");
|
||||||
StringAppend(result,")");
|
StringAppend(result, ")");
|
||||||
}
|
}
|
||||||
Delete(q);
|
Delete(q);
|
||||||
}
|
} else if (SwigType_isreference(element)) {
|
||||||
else if (SwigType_isreference(element)) {
|
Insert(result, 0, "&");
|
||||||
Insert(result,0,"&");
|
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result,0,"(");
|
Insert(result, 0, "(");
|
||||||
StringAppend(result,")");
|
StringAppend(result, ")");
|
||||||
}
|
}
|
||||||
} else if (SwigType_isarray(element)) {
|
} else if (SwigType_isarray(element)) {
|
||||||
DOH *size;
|
DOH *size;
|
||||||
StringAppend(result,"[");
|
StringAppend(result, "[");
|
||||||
size = SwigType_parm(element);
|
size = SwigType_parm(element);
|
||||||
StringAppend(result,size);
|
StringAppend(result, size);
|
||||||
StringAppend(result,"]");
|
StringAppend(result, "]");
|
||||||
Delete(size);
|
Delete(size);
|
||||||
} else if (SwigType_isfunction(element)) {
|
} else if (SwigType_isfunction(element)) {
|
||||||
DOH *parms, *p;
|
DOH *parms, *p;
|
||||||
int j, plen;
|
int j, plen;
|
||||||
StringAppend(result,"(");
|
StringAppend(result, "(");
|
||||||
parms = SwigType_parmlist(element);
|
parms = SwigType_parmlist(element);
|
||||||
plen = Len(parms);
|
plen = Len(parms);
|
||||||
for (j = 0; j < plen; j++) {
|
for (j = 0; j < plen; j++) {
|
||||||
p = SwigType_str(Getitem(parms,j),0);
|
p = SwigType_str(Getitem(parms, j), 0);
|
||||||
StringAppend(result,p);
|
StringAppend(result, p);
|
||||||
if (j < (plen-1)) StringAppend(result,",");
|
if (j < (plen - 1))
|
||||||
|
StringAppend(result, ",");
|
||||||
}
|
}
|
||||||
StringAppend(result,")");
|
StringAppend(result, ")");
|
||||||
Delete(parms);
|
Delete(parms);
|
||||||
} else {
|
} else {
|
||||||
if (strcmp(Char(element),"v(...)") == 0) {
|
if (strcmp(Char(element), "v(...)") == 0) {
|
||||||
Insert(result,0,"...");
|
Insert(result, 0, "...");
|
||||||
} else {
|
} else {
|
||||||
String *bs = SwigType_namestr(element);
|
String *bs = SwigType_namestr(element);
|
||||||
Insert(result,0," ");
|
Insert(result, 0, " ");
|
||||||
Insert(result,0,bs);
|
Insert(result, 0, bs);
|
||||||
Delete(bs);
|
Delete(bs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -628,8 +639,7 @@ SwigType_str(SwigType *s, const String_or_char *id)
|
||||||
* Create a locally assignable type
|
* Create a locally assignable type
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_ltype(SwigType *s) {
|
||||||
SwigType_ltype(SwigType *s) {
|
|
||||||
String *result;
|
String *result;
|
||||||
String *element;
|
String *element;
|
||||||
SwigType *td, *tc = 0;
|
SwigType *td, *tc = 0;
|
||||||
|
|
@ -646,9 +656,9 @@ SwigType_ltype(SwigType *s) {
|
||||||
}
|
}
|
||||||
if (SwigType_issimple(tc)) {
|
if (SwigType_issimple(tc)) {
|
||||||
/* Resolve any typedef definitions */
|
/* Resolve any typedef definitions */
|
||||||
SwigType *tt = Copy(tc);
|
SwigType *tt = Copy(tc);
|
||||||
td = 0;
|
td = 0;
|
||||||
while ((td = SwigType_typedef_resolve(tt))) {
|
while ((td = SwigType_typedef_resolve(tt))) {
|
||||||
if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) {
|
if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) {
|
||||||
/* We need to use the typedef type */
|
/* We need to use the typedef type */
|
||||||
Delete(tt);
|
Delete(tt);
|
||||||
|
|
@ -661,7 +671,7 @@ SwigType_ltype(SwigType *s) {
|
||||||
}
|
}
|
||||||
if (td) {
|
if (td) {
|
||||||
Delete(tc);
|
Delete(tc);
|
||||||
tc = td;
|
tc = td;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elements = SwigType_split(tc);
|
elements = SwigType_split(tc);
|
||||||
|
|
@ -669,7 +679,7 @@ SwigType_ltype(SwigType *s) {
|
||||||
|
|
||||||
/* Now, walk the type list and start emitting */
|
/* Now, walk the type list and start emitting */
|
||||||
for (i = 0; i < nelements; i++) {
|
for (i = 0; i < nelements; i++) {
|
||||||
element = Getitem(elements,i);
|
element = Getitem(elements, i);
|
||||||
/* when we see a function, we need to preserve the following types */
|
/* when we see a function, we need to preserve the following types */
|
||||||
if (SwigType_isfunction(element)) {
|
if (SwigType_isfunction(element)) {
|
||||||
notypeconv = 1;
|
notypeconv = 1;
|
||||||
|
|
@ -677,34 +687,34 @@ SwigType_ltype(SwigType *s) {
|
||||||
if (SwigType_isqualifier(element)) {
|
if (SwigType_isqualifier(element)) {
|
||||||
/* Do nothing. Ignore */
|
/* Do nothing. Ignore */
|
||||||
} else if (SwigType_ispointer(element)) {
|
} else if (SwigType_ispointer(element)) {
|
||||||
StringAppend(result,element);
|
StringAppend(result, element);
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
} else if (SwigType_ismemberpointer(element)) {
|
} else if (SwigType_ismemberpointer(element)) {
|
||||||
StringAppend(result,element);
|
StringAppend(result, element);
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
} else if (SwigType_isreference(element)) {
|
} else if (SwigType_isreference(element)) {
|
||||||
if (notypeconv) {
|
if (notypeconv) {
|
||||||
StringAppend(result,element);
|
StringAppend(result, element);
|
||||||
} else {
|
} else {
|
||||||
StringAppend(result,"p.");
|
StringAppend(result, "p.");
|
||||||
}
|
}
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
} else if (SwigType_isarray(element) && firstarray) {
|
} else if (SwigType_isarray(element) && firstarray) {
|
||||||
if (notypeconv) {
|
if (notypeconv) {
|
||||||
StringAppend(result,element);
|
StringAppend(result, element);
|
||||||
} else {
|
} else {
|
||||||
StringAppend(result,"p.");
|
StringAppend(result, "p.");
|
||||||
}
|
}
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
} else if (SwigType_isenum(element)) {
|
} else if (SwigType_isenum(element)) {
|
||||||
int anonymous_enum = (Cmp(element,"enum ") == 0);
|
int anonymous_enum = (Cmp(element, "enum ") == 0);
|
||||||
if (notypeconv || !anonymous_enum) {
|
if (notypeconv || !anonymous_enum) {
|
||||||
StringAppend(result,element);
|
StringAppend(result, element);
|
||||||
} else {
|
} else {
|
||||||
StringAppend(result,"int");
|
StringAppend(result, "int");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StringAppend(result,element);
|
StringAppend(result, element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Delete(elements);
|
Delete(elements);
|
||||||
|
|
@ -727,14 +737,12 @@ SwigType_ltype(SwigType *s) {
|
||||||
* with an equivalent assignable version.
|
* with an equivalent assignable version.
|
||||||
* -------------------------------------------------------------------- */
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *SwigType_lstr(SwigType *s, const String_or_char *id) {
|
||||||
SwigType_lstr(SwigType *s, const String_or_char *id)
|
|
||||||
{
|
|
||||||
String *result;
|
String *result;
|
||||||
SwigType *tc;
|
SwigType *tc;
|
||||||
|
|
||||||
tc = SwigType_ltype(s);
|
tc = SwigType_ltype(s);
|
||||||
result = SwigType_str(tc,id);
|
result = SwigType_str(tc, id);
|
||||||
Delete(tc);
|
Delete(tc);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -751,11 +759,11 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
||||||
String *element = 0, *nextelement;
|
String *element = 0, *nextelement;
|
||||||
SwigType *td, *rs, *tc = 0;
|
SwigType *td, *rs, *tc = 0;
|
||||||
List *elements;
|
List *elements;
|
||||||
int nelements, i;
|
int nelements, i;
|
||||||
int clear = 1;
|
int clear = 1;
|
||||||
int firstarray = 1;
|
int firstarray = 1;
|
||||||
int isreference = 0;
|
int isreference = 0;
|
||||||
int isarray = 0;
|
int isarray = 0;
|
||||||
|
|
||||||
result = NewStringEmpty();
|
result = NewStringEmpty();
|
||||||
|
|
||||||
|
|
@ -772,70 +780,70 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
||||||
} else {
|
} else {
|
||||||
td = SwigType_typedef_resolve(rs);
|
td = SwigType_typedef_resolve(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (td) {
|
if (td) {
|
||||||
if ((SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) {
|
if ((SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) {
|
||||||
elements = SwigType_split(td);
|
elements = SwigType_split(td);
|
||||||
} else {
|
} else {
|
||||||
elements = SwigType_split(rs);
|
elements = SwigType_split(rs);
|
||||||
}
|
}
|
||||||
Delete(td);
|
Delete(td);
|
||||||
} else {
|
} else {
|
||||||
elements = SwigType_split(rs);
|
elements = SwigType_split(rs);
|
||||||
}
|
}
|
||||||
nelements = Len(elements);
|
nelements = Len(elements);
|
||||||
if (nelements > 0) {
|
if (nelements > 0) {
|
||||||
element = Getitem(elements,0);
|
element = Getitem(elements, 0);
|
||||||
}
|
}
|
||||||
/* Now, walk the type list and start emitting */
|
/* Now, walk the type list and start emitting */
|
||||||
for (i = 0; i < nelements; i++) {
|
for (i = 0; i < nelements; i++) {
|
||||||
if (i < (nelements - 1)) {
|
if (i < (nelements - 1)) {
|
||||||
nextelement = Getitem(elements,i+1);
|
nextelement = Getitem(elements, i + 1);
|
||||||
} else {
|
} else {
|
||||||
nextelement = 0;
|
nextelement = 0;
|
||||||
}
|
}
|
||||||
if (SwigType_isqualifier(element)) {
|
if (SwigType_isqualifier(element)) {
|
||||||
DOH *q = 0;
|
DOH *q = 0;
|
||||||
q = SwigType_parm(element);
|
q = SwigType_parm(element);
|
||||||
Insert(result,0," ");
|
Insert(result, 0, " ");
|
||||||
Insert(result,0,q);
|
Insert(result, 0, q);
|
||||||
Delete(q);
|
Delete(q);
|
||||||
clear = 0;
|
clear = 0;
|
||||||
} else if (SwigType_ispointer(element)) {
|
} else if (SwigType_ispointer(element)) {
|
||||||
Insert(result,0,"*");
|
Insert(result, 0, "*");
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result,0,"(");
|
Insert(result, 0, "(");
|
||||||
StringAppend(result,")");
|
StringAppend(result, ")");
|
||||||
}
|
}
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
} else if (SwigType_ismemberpointer(element)) {
|
} else if (SwigType_ismemberpointer(element)) {
|
||||||
String *q;
|
String *q;
|
||||||
Insert(result,0,"::*");
|
Insert(result, 0, "::*");
|
||||||
q = SwigType_parm(element);
|
q = SwigType_parm(element);
|
||||||
Insert(result,0,q);
|
Insert(result, 0, q);
|
||||||
Delete(q);
|
Delete(q);
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result,0,"(");
|
Insert(result, 0, "(");
|
||||||
StringAppend(result,")");
|
StringAppend(result, ")");
|
||||||
}
|
}
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
} else if (SwigType_isreference(element)) {
|
} else if (SwigType_isreference(element)) {
|
||||||
Insert(result,0,"&");
|
Insert(result, 0, "&");
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result,0,"(");
|
Insert(result, 0, "(");
|
||||||
StringAppend(result,")");
|
StringAppend(result, ")");
|
||||||
}
|
}
|
||||||
isreference = 1;
|
isreference = 1;
|
||||||
} else if (SwigType_isarray(element)) {
|
} else if (SwigType_isarray(element)) {
|
||||||
DOH *size;
|
DOH *size;
|
||||||
if (firstarray && !isreference) {
|
if (firstarray && !isreference) {
|
||||||
StringAppend(result,"(*)");
|
StringAppend(result, "(*)");
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
} else {
|
} else {
|
||||||
StringAppend(result,"[");
|
StringAppend(result, "[");
|
||||||
size = SwigType_parm(element);
|
size = SwigType_parm(element);
|
||||||
StringAppend(result,size);
|
StringAppend(result, size);
|
||||||
StringAppend(result,"]");
|
StringAppend(result, "]");
|
||||||
Delete(size);
|
Delete(size);
|
||||||
clear = 0;
|
clear = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -843,21 +851,22 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
||||||
} else if (SwigType_isfunction(element)) {
|
} else if (SwigType_isfunction(element)) {
|
||||||
DOH *parms, *p;
|
DOH *parms, *p;
|
||||||
int j, plen;
|
int j, plen;
|
||||||
StringAppend(result,"(");
|
StringAppend(result, "(");
|
||||||
parms = SwigType_parmlist(element);
|
parms = SwigType_parmlist(element);
|
||||||
plen = Len(parms);
|
plen = Len(parms);
|
||||||
for (j = 0; j < plen; j++) {
|
for (j = 0; j < plen; j++) {
|
||||||
p = SwigType_str(Getitem(parms,j),0);
|
p = SwigType_str(Getitem(parms, j), 0);
|
||||||
StringAppend(result,p);
|
StringAppend(result, p);
|
||||||
Delete(p);
|
Delete(p);
|
||||||
if (j < (plen-1)) StringAppend(result,",");
|
if (j < (plen - 1))
|
||||||
|
StringAppend(result, ",");
|
||||||
}
|
}
|
||||||
StringAppend(result,")");
|
StringAppend(result, ")");
|
||||||
Delete(parms);
|
Delete(parms);
|
||||||
} else {
|
} else {
|
||||||
String *bs = SwigType_namestr(element);
|
String *bs = SwigType_namestr(element);
|
||||||
Insert(result,0," ");
|
Insert(result, 0, " ");
|
||||||
Insert(result,0,bs);
|
Insert(result, 0, bs);
|
||||||
Delete(bs);
|
Delete(bs);
|
||||||
}
|
}
|
||||||
element = nextelement;
|
element = nextelement;
|
||||||
|
|
@ -866,14 +875,15 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
||||||
if (clear) {
|
if (clear) {
|
||||||
cast = NewStringEmpty();
|
cast = NewStringEmpty();
|
||||||
} else {
|
} else {
|
||||||
cast = NewStringf("(%s)",result);
|
cast = NewStringf("(%s)", result);
|
||||||
}
|
}
|
||||||
if (name) {
|
if (name) {
|
||||||
if (isreference) {
|
if (isreference) {
|
||||||
if (isarray) Clear(cast);
|
if (isarray)
|
||||||
StringAppend(cast,"*");
|
Clear(cast);
|
||||||
|
StringAppend(cast, "*");
|
||||||
}
|
}
|
||||||
StringAppend(cast,name);
|
StringAppend(cast, name);
|
||||||
}
|
}
|
||||||
Delete(result);
|
Delete(result);
|
||||||
Delete(tc);
|
Delete(tc);
|
||||||
|
|
@ -893,22 +903,22 @@ String *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
|
||||||
result = NewStringEmpty();
|
result = NewStringEmpty();
|
||||||
|
|
||||||
if (SwigType_isarray(s)) {
|
if (SwigType_isarray(s)) {
|
||||||
String *lstr = SwigType_lstr(s,0);
|
String *lstr = SwigType_lstr(s, 0);
|
||||||
Printf(result,"(%s)%s", lstr,name);
|
Printf(result, "(%s)%s", lstr, name);
|
||||||
Delete(lstr);
|
Delete(lstr);
|
||||||
} else if (SwigType_isreference(s)) {
|
} else if (SwigType_isreference(s)) {
|
||||||
String *str = SwigType_str(s,0);
|
String *str = SwigType_str(s, 0);
|
||||||
Printf(result,"(%s)", str);
|
Printf(result, "(%s)", str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
if (name)
|
if (name)
|
||||||
StringAppend(result,name);
|
StringAppend(result, name);
|
||||||
} else if (SwigType_isqualifier(s)) {
|
} else if (SwigType_isqualifier(s)) {
|
||||||
String *lstr = SwigType_lstr(s,0);
|
String *lstr = SwigType_lstr(s, 0);
|
||||||
Printf(result,"(%s)%s", lstr,name);
|
Printf(result, "(%s)%s", lstr, name);
|
||||||
Delete(lstr);
|
Delete(lstr);
|
||||||
} else {
|
} else {
|
||||||
if (name)
|
if (name)
|
||||||
StringAppend(result,name);
|
StringAppend(result, name);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -922,11 +932,11 @@ String *SwigType_manglestr_default(SwigType *s) {
|
||||||
SwigType *lt;
|
SwigType *lt;
|
||||||
SwigType *sr = SwigType_typedef_qualified(s);
|
SwigType *sr = SwigType_typedef_qualified(s);
|
||||||
SwigType *ss = SwigType_typedef_resolve_all(sr);
|
SwigType *ss = SwigType_typedef_resolve_all(sr);
|
||||||
|
|
||||||
s = ss;
|
s = ss;
|
||||||
|
|
||||||
if (SwigType_istemplate(ss)) {
|
if (SwigType_istemplate(ss)) {
|
||||||
SwigType *ty = Swig_symbol_template_deftype(ss,0);
|
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
|
||||||
Delete(ss);
|
Delete(ss);
|
||||||
ss = ty;
|
ss = ty;
|
||||||
s = ss;
|
s = ss;
|
||||||
|
|
@ -939,7 +949,8 @@ String *SwigType_manglestr_default(SwigType *s) {
|
||||||
|
|
||||||
c = Char(result);
|
c = Char(result);
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (!isalnum((int)*c)) *c = '_';
|
if (!isalnum((int) *c))
|
||||||
|
*c = '_';
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
if (SwigType_istemplate(base)) {
|
if (SwigType_istemplate(base)) {
|
||||||
|
|
@ -948,29 +959,39 @@ String *SwigType_manglestr_default(SwigType *s) {
|
||||||
base = b;
|
base = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
Replace(base,"struct ","", DOH_REPLACE_ANY); /* This might be problematic */
|
Replace(base, "struct ", "", DOH_REPLACE_ANY); /* This might be problematic */
|
||||||
Replace(base,"class ","", DOH_REPLACE_ANY);
|
Replace(base, "class ", "", DOH_REPLACE_ANY);
|
||||||
Replace(base,"union ","", DOH_REPLACE_ANY);
|
Replace(base, "union ", "", DOH_REPLACE_ANY);
|
||||||
Replace(base,"enum ","", DOH_REPLACE_ANY);
|
Replace(base, "enum ", "", DOH_REPLACE_ANY);
|
||||||
|
|
||||||
c = Char(base);
|
c = Char(base);
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == '<') *c = 'T';
|
if (*c == '<')
|
||||||
else if (*c == '>') *c = 't';
|
*c = 'T';
|
||||||
else if (*c == '*') *c = 'p';
|
else if (*c == '>')
|
||||||
else if (*c == '[') *c = 'a';
|
*c = 't';
|
||||||
else if (*c == ']') *c = 'A';
|
else if (*c == '*')
|
||||||
else if (*c == '&') *c = 'R';
|
*c = 'p';
|
||||||
else if (*c == '(') *c = 'f';
|
else if (*c == '[')
|
||||||
else if (*c == ')') *c = 'F';
|
*c = 'a';
|
||||||
else if (!isalnum((int)*c)) *c = '_';
|
else if (*c == ']')
|
||||||
|
*c = 'A';
|
||||||
|
else if (*c == '&')
|
||||||
|
*c = 'R';
|
||||||
|
else if (*c == '(')
|
||||||
|
*c = 'f';
|
||||||
|
else if (*c == ')')
|
||||||
|
*c = 'F';
|
||||||
|
else if (!isalnum((int) *c))
|
||||||
|
*c = '_';
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
StringAppend(result,base);
|
StringAppend(result, base);
|
||||||
Insert(result,0,"_");
|
Insert(result, 0, "_");
|
||||||
Delete(lt);
|
Delete(lt);
|
||||||
Delete(base);
|
Delete(base);
|
||||||
if (ss) Delete(ss);
|
if (ss)
|
||||||
|
Delete(ss);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -984,51 +1005,52 @@ String *SwigType_manglestr(SwigType *s) {
|
||||||
* Replaces a typename in a type with something else. Needed for templates.
|
* Replaces a typename in a type with something else. Needed for templates.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
||||||
SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
|
||||||
String *nt;
|
String *nt;
|
||||||
int i, ilen;
|
int i, ilen;
|
||||||
List *elem;
|
List *elem;
|
||||||
|
|
||||||
if (!Strstr(t,pat)) return;
|
if (!Strstr(t, pat))
|
||||||
|
return;
|
||||||
|
|
||||||
if (StringEqual(t,pat)) {
|
if (StringEqual(t, pat)) {
|
||||||
Replace(t,pat,rep,DOH_REPLACE_ANY);
|
Replace(t, pat, rep, DOH_REPLACE_ANY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nt = NewStringEmpty();
|
nt = NewStringEmpty();
|
||||||
elem = SwigType_split(t);
|
elem = SwigType_split(t);
|
||||||
ilen = Len(elem);
|
ilen = Len(elem);
|
||||||
for (i = 0; i < ilen; i++) {
|
for (i = 0; i < ilen; i++) {
|
||||||
String *e = Getitem(elem,i);
|
String *e = Getitem(elem, i);
|
||||||
if (SwigType_issimple(e)) {
|
if (SwigType_issimple(e)) {
|
||||||
if (StringEqual(e,pat)) {
|
if (StringEqual(e, pat)) {
|
||||||
/* Replaces a type of the form 'pat' with 'rep<args>' */
|
/* Replaces a type of the form 'pat' with 'rep<args>' */
|
||||||
Replace(e,pat,rep,DOH_REPLACE_ANY);
|
Replace(e, pat, rep, DOH_REPLACE_ANY);
|
||||||
} else if (SwigType_istemplate(e)) {
|
} else if (SwigType_istemplate(e)) {
|
||||||
/* Replaces a type of the form 'pat<args>' with 'rep' */
|
/* Replaces a type of the form 'pat<args>' with 'rep' */
|
||||||
if (StringEqual(e,pat)) {
|
if (StringEqual(e, pat)) {
|
||||||
String *repbase = SwigType_templateprefix(rep);
|
String *repbase = SwigType_templateprefix(rep);
|
||||||
Replace(e,pat,repbase,DOH_REPLACE_ID | DOH_REPLACE_FIRST);
|
Replace(e, pat, repbase, DOH_REPLACE_ID | DOH_REPLACE_FIRST);
|
||||||
Delete(repbase);
|
Delete(repbase);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
String *tsuffix;
|
String *tsuffix;
|
||||||
List *tparms = SwigType_parmlist(e);
|
List *tparms = SwigType_parmlist(e);
|
||||||
int j, jlen;
|
int j, jlen;
|
||||||
String *nt = SwigType_templateprefix(e);
|
String *nt = SwigType_templateprefix(e);
|
||||||
StringAppend(nt,"<(");
|
StringAppend(nt, "<(");
|
||||||
jlen = Len(tparms);
|
jlen = Len(tparms);
|
||||||
for (j = 0; j < jlen; j++) {
|
for (j = 0; j < jlen; j++) {
|
||||||
SwigType_typename_replace(Getitem(tparms,j), pat, rep);
|
SwigType_typename_replace(Getitem(tparms, j), pat, rep);
|
||||||
StringAppend(nt,Getitem(tparms,j));
|
StringAppend(nt, Getitem(tparms, j));
|
||||||
if (j < (jlen-1)) Putc(',',nt);
|
if (j < (jlen - 1))
|
||||||
|
Putc(',', nt);
|
||||||
}
|
}
|
||||||
tsuffix = SwigType_templatesuffix(e);
|
tsuffix = SwigType_templatesuffix(e);
|
||||||
Printf(nt,")>%s", tsuffix);
|
Printf(nt, ")>%s", tsuffix);
|
||||||
Delete(tsuffix);
|
Delete(tsuffix);
|
||||||
Clear(e);
|
Clear(e);
|
||||||
StringAppend(e,nt);
|
StringAppend(e, nt);
|
||||||
Delete(nt);
|
Delete(nt);
|
||||||
Delete(tparms);
|
Delete(tparms);
|
||||||
}
|
}
|
||||||
|
|
@ -1036,10 +1058,10 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
||||||
String *first, *rest;
|
String *first, *rest;
|
||||||
first = Swig_scopename_first(e);
|
first = Swig_scopename_first(e);
|
||||||
rest = Swig_scopename_suffix(e);
|
rest = Swig_scopename_suffix(e);
|
||||||
SwigType_typename_replace(rest,pat,rep);
|
SwigType_typename_replace(rest, pat, rep);
|
||||||
SwigType_typename_replace(first,pat,rep);
|
SwigType_typename_replace(first, pat, rep);
|
||||||
Clear(e);
|
Clear(e);
|
||||||
Printv(e,first,"::",rest,NIL);
|
Printv(e, first, "::", rest, NIL);
|
||||||
Delete(first);
|
Delete(first);
|
||||||
Delete(rest);
|
Delete(rest);
|
||||||
}
|
}
|
||||||
|
|
@ -1047,22 +1069,23 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
||||||
int j, jlen;
|
int j, jlen;
|
||||||
List *fparms = SwigType_parmlist(e);
|
List *fparms = SwigType_parmlist(e);
|
||||||
Clear(e);
|
Clear(e);
|
||||||
StringAppend(e,"f(");
|
StringAppend(e, "f(");
|
||||||
jlen = Len(fparms);
|
jlen = Len(fparms);
|
||||||
for (j = 0; j < jlen; j++) {
|
for (j = 0; j < jlen; j++) {
|
||||||
SwigType_typename_replace(Getitem(fparms,j), pat, rep);
|
SwigType_typename_replace(Getitem(fparms, j), pat, rep);
|
||||||
StringAppend(e,Getitem(fparms,j));
|
StringAppend(e, Getitem(fparms, j));
|
||||||
if (j < (jlen-1)) Putc(',',e);
|
if (j < (jlen - 1))
|
||||||
|
Putc(',', e);
|
||||||
}
|
}
|
||||||
StringAppend(e,").");
|
StringAppend(e, ").");
|
||||||
Delete(fparms);
|
Delete(fparms);
|
||||||
} else if (SwigType_isarray(e)) {
|
} else if (SwigType_isarray(e)) {
|
||||||
Replace(e,pat,rep, DOH_REPLACE_ID);
|
Replace(e, pat, rep, DOH_REPLACE_ID);
|
||||||
}
|
}
|
||||||
StringAppend(nt,e);
|
StringAppend(nt, e);
|
||||||
}
|
}
|
||||||
Clear(t);
|
Clear(t);
|
||||||
StringAppend(t,nt);
|
StringAppend(t, nt);
|
||||||
Delete(nt);
|
Delete(nt);
|
||||||
Delete(elem);
|
Delete(elem);
|
||||||
}
|
}
|
||||||
|
|
@ -1073,14 +1096,13 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
||||||
* Checks type declarators for a match
|
* Checks type declarators for a match
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int SwigType_check_decl(SwigType *ty, const SwigType *decl) {
|
||||||
SwigType_check_decl(SwigType *ty, const SwigType *decl) {
|
SwigType *t, *t1, *t2;
|
||||||
SwigType *t,*t1,*t2;
|
|
||||||
int r;
|
int r;
|
||||||
t = SwigType_typedef_resolve_all(ty);
|
t = SwigType_typedef_resolve_all(ty);
|
||||||
t1 = SwigType_strip_qualifiers(t);
|
t1 = SwigType_strip_qualifiers(t);
|
||||||
t2 = SwigType_prefix(t1);
|
t2 = SwigType_prefix(t1);
|
||||||
r = Equal(t2,decl);
|
r = Equal(t2, decl);
|
||||||
Delete(t);
|
Delete(t);
|
||||||
Delete(t1);
|
Delete(t1);
|
||||||
Delete(t2);
|
Delete(t2);
|
||||||
|
|
|
||||||
|
|
@ -35,17 +35,17 @@ extern "C" {
|
||||||
|
|
||||||
/* Short names for common data types */
|
/* Short names for common data types */
|
||||||
|
|
||||||
typedef DOH String;
|
typedef DOH String;
|
||||||
typedef DOH Hash;
|
typedef DOH Hash;
|
||||||
typedef DOH List;
|
typedef DOH List;
|
||||||
typedef DOH String_or_char;
|
typedef DOH String_or_char;
|
||||||
typedef DOH File;
|
typedef DOH File;
|
||||||
typedef DOH Parm;
|
typedef DOH Parm;
|
||||||
typedef DOH ParmList;
|
typedef DOH ParmList;
|
||||||
typedef DOH Node;
|
typedef DOH Node;
|
||||||
typedef DOH Symtab;
|
typedef DOH Symtab;
|
||||||
typedef DOH Typetab;
|
typedef DOH Typetab;
|
||||||
typedef DOH SwigType;
|
typedef DOH SwigType;
|
||||||
|
|
||||||
/* --- Legacy DataType interface. These type codes are provided solely
|
/* --- Legacy DataType interface. These type codes are provided solely
|
||||||
for backwards compatibility with older modules --- */
|
for backwards compatibility with older modules --- */
|
||||||
|
|
@ -94,28 +94,28 @@ typedef DOH SwigType;
|
||||||
|
|
||||||
/* --- File interface --- */
|
/* --- File interface --- */
|
||||||
|
|
||||||
extern List *Swig_add_directory(const String_or_char *dirname);
|
extern List *Swig_add_directory(const String_or_char *dirname);
|
||||||
extern void Swig_push_directory(const String_or_char *dirname);
|
extern void Swig_push_directory(const String_or_char *dirname);
|
||||||
extern void Swig_pop_directory();
|
extern void Swig_pop_directory();
|
||||||
extern String *Swig_last_file();
|
extern String *Swig_last_file();
|
||||||
extern List *Swig_search_path();
|
extern List *Swig_search_path();
|
||||||
extern FILE *Swig_open(const String_or_char *name);
|
extern FILE *Swig_open(const String_or_char *name);
|
||||||
extern String *Swig_read_file(FILE *f);
|
extern String *Swig_read_file(FILE *f);
|
||||||
extern String *Swig_include(const String_or_char *name);
|
extern String *Swig_include(const String_or_char *name);
|
||||||
extern String *Swig_include_sys(const String_or_char *name);
|
extern String *Swig_include_sys(const String_or_char *name);
|
||||||
extern int Swig_insert_file(const String_or_char *name, File *outfile);
|
extern int Swig_insert_file(const String_or_char *name, File *outfile);
|
||||||
extern void Swig_set_config_file(const String_or_char *filename);
|
extern void Swig_set_config_file(const String_or_char *filename);
|
||||||
extern String *Swig_get_config_file(void);
|
extern String *Swig_get_config_file(void);
|
||||||
extern void Swig_set_push_dir(int dopush);
|
extern void Swig_set_push_dir(int dopush);
|
||||||
extern int Swig_get_push_dir(void);
|
extern int Swig_get_push_dir(void);
|
||||||
extern void Swig_swiglib_set(const String_or_char *);
|
extern void Swig_swiglib_set(const String_or_char *);
|
||||||
extern String *Swig_swiglib_get();
|
extern String *Swig_swiglib_get();
|
||||||
extern void Swig_register_filebyname(const String_or_char *filename, File *outfile);
|
extern void Swig_register_filebyname(const String_or_char *filename, File *outfile);
|
||||||
extern File *Swig_filebyname(const String_or_char *filename);
|
extern File *Swig_filebyname(const String_or_char *filename);
|
||||||
extern char *Swig_file_suffix(const String_or_char *filename);
|
extern char *Swig_file_suffix(const String_or_char *filename);
|
||||||
extern char *Swig_file_basename(const String_or_char *filename);
|
extern char *Swig_file_basename(const String_or_char *filename);
|
||||||
extern char *Swig_file_filename(const String_or_char *filename);
|
extern char *Swig_file_filename(const String_or_char *filename);
|
||||||
extern char *Swig_file_dirname(const String_or_char *filename);
|
extern char *Swig_file_dirname(const String_or_char *filename);
|
||||||
|
|
||||||
#if defined(MACSWIG)
|
#if defined(MACSWIG)
|
||||||
# define SWIG_FILE_DELIMETER ":"
|
# define SWIG_FILE_DELIMETER ":"
|
||||||
|
|
@ -127,32 +127,32 @@ extern char *Swig_file_dirname(const String_or_char *filename);
|
||||||
|
|
||||||
/* --- Command line parsing --- */
|
/* --- Command line parsing --- */
|
||||||
|
|
||||||
extern void Swig_init_args(int argc, char **argv);
|
extern void Swig_init_args(int argc, char **argv);
|
||||||
extern void Swig_mark_arg(int n);
|
extern void Swig_mark_arg(int n);
|
||||||
extern int Swig_check_marked(int n);
|
extern int Swig_check_marked(int n);
|
||||||
extern void Swig_check_options(int check_input);
|
extern void Swig_check_options(int check_input);
|
||||||
extern void Swig_arg_error();
|
extern void Swig_arg_error();
|
||||||
|
|
||||||
/* --- Scanner Interface --- */
|
/* --- Scanner Interface --- */
|
||||||
|
|
||||||
typedef struct SwigScanner SwigScanner;
|
typedef struct SwigScanner SwigScanner;
|
||||||
|
|
||||||
extern SwigScanner *NewSwigScanner();
|
extern SwigScanner *NewSwigScanner();
|
||||||
extern void DelSwigScanner(SwigScanner *);
|
extern void DelSwigScanner(SwigScanner *);
|
||||||
extern void SwigScanner_clear(SwigScanner *);
|
extern void SwigScanner_clear(SwigScanner *);
|
||||||
extern void SwigScanner_push(SwigScanner *, String *);
|
extern void SwigScanner_push(SwigScanner *, String *);
|
||||||
extern void SwigScanner_pushtoken(SwigScanner *, int);
|
extern void SwigScanner_pushtoken(SwigScanner *, int);
|
||||||
extern int SwigScanner_token(SwigScanner *);
|
extern int SwigScanner_token(SwigScanner *);
|
||||||
extern String *SwigScanner_text(SwigScanner *);
|
extern String *SwigScanner_text(SwigScanner *);
|
||||||
extern void SwigScanner_skip_line(SwigScanner *);
|
extern void SwigScanner_skip_line(SwigScanner *);
|
||||||
extern int SwigScanner_skip_balanced(SwigScanner *, int startchar, int endchar);
|
extern int SwigScanner_skip_balanced(SwigScanner *, int startchar, int endchar);
|
||||||
extern void SwigScanner_set_location(SwigScanner *, String *file, int line);
|
extern void SwigScanner_set_location(SwigScanner *, String *file, int line);
|
||||||
extern String *SwigScanner_get_file(SwigScanner *);
|
extern String *SwigScanner_get_file(SwigScanner *);
|
||||||
extern int SwigScanner_get_line(SwigScanner *);
|
extern int SwigScanner_get_line(SwigScanner *);
|
||||||
extern void SwigScanner_idstart(SwigScanner *, char *idchar);
|
extern void SwigScanner_idstart(SwigScanner *, char *idchar);
|
||||||
|
|
||||||
#define SWIG_MAXTOKENS 512
|
#define SWIG_MAXTOKENS 512
|
||||||
#define SWIG_TOKEN_LPAREN 1
|
#define SWIG_TOKEN_LPAREN 1
|
||||||
#define SWIG_TOKEN_RPAREN 2
|
#define SWIG_TOKEN_RPAREN 2
|
||||||
#define SWIG_TOKEN_SEMI 3
|
#define SWIG_TOKEN_SEMI 3
|
||||||
#define SWIG_TOKEN_COMMA 4
|
#define SWIG_TOKEN_COMMA 4
|
||||||
|
|
@ -203,146 +203,146 @@ extern void SwigScanner_idstart(SwigScanner *, char *idchar);
|
||||||
#define SWIG_TOKEN_LONGLONG 49
|
#define SWIG_TOKEN_LONGLONG 49
|
||||||
#define SWIG_TOKEN_ULONGLONG 50
|
#define SWIG_TOKEN_ULONGLONG 50
|
||||||
#define SWIG_TOKEN_ILLEGAL 98
|
#define SWIG_TOKEN_ILLEGAL 98
|
||||||
#define SWIG_TOKEN_LAST 99
|
#define SWIG_TOKEN_LAST 99
|
||||||
|
|
||||||
/* --- Functions for manipulating the string-based type encoding --- */
|
/* --- Functions for manipulating the string-based type encoding --- */
|
||||||
|
|
||||||
extern SwigType *NewSwigType(int typecode);
|
extern SwigType *NewSwigType(int typecode);
|
||||||
extern SwigType *SwigType_del_element(SwigType *t);
|
extern SwigType *SwigType_del_element(SwigType *t);
|
||||||
extern SwigType *SwigType_add_pointer(SwigType *t);
|
extern SwigType *SwigType_add_pointer(SwigType *t);
|
||||||
extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual);
|
extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual);
|
||||||
extern SwigType *SwigType_del_pointer(SwigType *t);
|
extern SwigType *SwigType_del_pointer(SwigType *t);
|
||||||
extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size);
|
extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size);
|
||||||
extern SwigType *SwigType_del_array(SwigType *t);
|
extern SwigType *SwigType_del_array(SwigType *t);
|
||||||
extern SwigType *SwigType_pop_arrays(SwigType *t);
|
extern SwigType *SwigType_pop_arrays(SwigType *t);
|
||||||
extern SwigType *SwigType_add_reference(SwigType *t);
|
extern SwigType *SwigType_add_reference(SwigType *t);
|
||||||
extern SwigType *SwigType_del_reference(SwigType *t);
|
extern SwigType *SwigType_del_reference(SwigType *t);
|
||||||
extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual);
|
extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual);
|
||||||
extern SwigType *SwigType_del_qualifier(SwigType *t);
|
extern SwigType *SwigType_del_qualifier(SwigType *t);
|
||||||
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
|
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
|
||||||
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
|
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
|
||||||
extern SwigType *SwigType_pop_function(SwigType *t);
|
extern SwigType *SwigType_pop_function(SwigType *t);
|
||||||
extern ParmList *SwigType_function_parms(SwigType *t);
|
extern ParmList *SwigType_function_parms(SwigType *t);
|
||||||
extern List *SwigType_split(const SwigType *t);
|
extern List *SwigType_split(const SwigType *t);
|
||||||
extern String *SwigType_pop(SwigType *t);
|
extern String *SwigType_pop(SwigType *t);
|
||||||
extern void SwigType_push(SwigType *t, SwigType *s);
|
extern void SwigType_push(SwigType *t, SwigType *s);
|
||||||
extern List *SwigType_parmlist(const SwigType *p);
|
extern List *SwigType_parmlist(const SwigType *p);
|
||||||
extern String *SwigType_parm(String *p);
|
extern String *SwigType_parm(String *p);
|
||||||
extern String *SwigType_str(SwigType *s, const String_or_char *id);
|
extern String *SwigType_str(SwigType *s, const String_or_char *id);
|
||||||
extern String *SwigType_lstr(SwigType *s, const String_or_char *id);
|
extern String *SwigType_lstr(SwigType *s, const String_or_char *id);
|
||||||
extern String *SwigType_rcaststr(SwigType *s, const String_or_char *id);
|
extern String *SwigType_rcaststr(SwigType *s, const String_or_char *id);
|
||||||
extern String *SwigType_lcaststr(SwigType *s, const String_or_char *id);
|
extern String *SwigType_lcaststr(SwigType *s, const String_or_char *id);
|
||||||
extern String *SwigType_manglestr(SwigType *t);
|
extern String *SwigType_manglestr(SwigType *t);
|
||||||
extern SwigType *SwigType_ltype(SwigType *t);
|
extern SwigType *SwigType_ltype(SwigType *t);
|
||||||
extern int SwigType_ispointer(SwigType *t);
|
extern int SwigType_ispointer(SwigType *t);
|
||||||
extern int SwigType_ispointer_return(SwigType *t);
|
extern int SwigType_ispointer_return(SwigType *t);
|
||||||
extern int SwigType_ismemberpointer(SwigType *t);
|
extern int SwigType_ismemberpointer(SwigType *t);
|
||||||
extern int SwigType_isreference(SwigType *t);
|
extern int SwigType_isreference(SwigType *t);
|
||||||
extern int SwigType_isreference_return(SwigType *t);
|
extern int SwigType_isreference_return(SwigType *t);
|
||||||
extern int SwigType_isarray(SwigType *t);
|
extern int SwigType_isarray(SwigType *t);
|
||||||
extern int SwigType_isfunction(SwigType *t);
|
extern int SwigType_isfunction(SwigType *t);
|
||||||
extern int SwigType_isqualifier(SwigType *t);
|
extern int SwigType_isqualifier(SwigType *t);
|
||||||
extern int SwigType_isconst(SwigType *t);
|
extern int SwigType_isconst(SwigType *t);
|
||||||
extern int SwigType_issimple(SwigType *t);
|
extern int SwigType_issimple(SwigType *t);
|
||||||
extern int SwigType_ismutable(SwigType *t);
|
extern int SwigType_ismutable(SwigType *t);
|
||||||
extern int SwigType_isvarargs(const SwigType *t);
|
extern int SwigType_isvarargs(const SwigType *t);
|
||||||
extern int SwigType_istemplate(const SwigType *t);
|
extern int SwigType_istemplate(const SwigType *t);
|
||||||
extern int SwigType_isenum(SwigType *t);
|
extern int SwigType_isenum(SwigType *t);
|
||||||
extern int SwigType_check_decl(SwigType *t, const String_or_char *decl);
|
extern int SwigType_check_decl(SwigType *t, const String_or_char *decl);
|
||||||
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
|
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
|
||||||
extern String *SwigType_base(const SwigType *t);
|
extern String *SwigType_base(const SwigType *t);
|
||||||
extern String *SwigType_namestr(const SwigType *t);
|
extern String *SwigType_namestr(const SwigType *t);
|
||||||
extern String *SwigType_templateprefix(const SwigType *t);
|
extern String *SwigType_templateprefix(const SwigType *t);
|
||||||
extern String *SwigType_templatesuffix(const SwigType *t);
|
extern String *SwigType_templatesuffix(const SwigType *t);
|
||||||
extern String *SwigType_templateargs(const SwigType *t);
|
extern String *SwigType_templateargs(const SwigType *t);
|
||||||
extern String *SwigType_prefix(const SwigType *t);
|
extern String *SwigType_prefix(const SwigType *t);
|
||||||
extern int SwigType_array_ndim(SwigType *t);
|
extern int SwigType_array_ndim(SwigType *t);
|
||||||
extern String *SwigType_array_getdim(SwigType *t, int n);
|
extern String *SwigType_array_getdim(SwigType *t, int n);
|
||||||
extern void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep);
|
extern void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep);
|
||||||
extern SwigType *SwigType_array_type(SwigType *t);
|
extern SwigType *SwigType_array_type(SwigType *t);
|
||||||
extern String *SwigType_default(SwigType *t);
|
extern String *SwigType_default(SwigType *t);
|
||||||
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
|
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
|
||||||
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
|
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
|
||||||
|
|
||||||
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||||
extern SwigType* SwigType_template_deftype(const SwigType *type, Symtab *tscope);
|
extern SwigType *SwigType_template_deftype(const SwigType *type, Symtab *tscope);
|
||||||
|
|
||||||
/* --- Type-system managment --- */
|
/* --- Type-system managment --- */
|
||||||
extern void SwigType_typesystem_init();
|
extern void SwigType_typesystem_init();
|
||||||
extern int SwigType_typedef(SwigType *type, String_or_char *name);
|
extern int SwigType_typedef(SwigType *type, String_or_char *name);
|
||||||
extern int SwigType_typedef_class(String_or_char *name);
|
extern int SwigType_typedef_class(String_or_char *name);
|
||||||
extern int SwigType_typedef_using(String_or_char *qname);
|
extern int SwigType_typedef_using(String_or_char *qname);
|
||||||
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast);
|
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast);
|
||||||
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
|
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
|
||||||
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
|
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
|
||||||
extern void SwigType_using_scope(Typetab *t);
|
extern void SwigType_using_scope(Typetab *t);
|
||||||
extern void SwigType_new_scope(const String_or_char *name);
|
extern void SwigType_new_scope(const String_or_char *name);
|
||||||
extern void SwigType_inherit_scope(Typetab *scope);
|
extern void SwigType_inherit_scope(Typetab *scope);
|
||||||
extern Typetab *SwigType_pop_scope();
|
extern Typetab *SwigType_pop_scope();
|
||||||
extern Typetab *SwigType_set_scope(Typetab *h);
|
extern Typetab *SwigType_set_scope(Typetab *h);
|
||||||
extern void SwigType_print_scope(Typetab *t);
|
extern void SwigType_print_scope(Typetab *t);
|
||||||
extern SwigType *SwigType_typedef_resolve(SwigType *t);
|
extern SwigType *SwigType_typedef_resolve(SwigType *t);
|
||||||
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
|
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
|
||||||
extern SwigType *SwigType_typedef_qualified(SwigType *t);
|
extern SwigType *SwigType_typedef_qualified(SwigType *t);
|
||||||
extern int SwigType_istypedef(SwigType *t);
|
extern int SwigType_istypedef(SwigType *t);
|
||||||
extern int SwigType_isclass(SwigType *t);
|
extern int SwigType_isclass(SwigType *t);
|
||||||
extern void SwigType_attach_symtab(Symtab *syms);
|
extern void SwigType_attach_symtab(Symtab *syms);
|
||||||
extern void SwigType_remember(SwigType *t);
|
extern void SwigType_remember(SwigType *t);
|
||||||
extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata);
|
extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata);
|
||||||
extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata);
|
extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata);
|
||||||
extern void (*SwigType_remember_trace(void (*tf)(SwigType *, String *, String *)))(SwigType *, String *, String *);
|
extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
|
||||||
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
||||||
extern int SwigType_type(SwigType *t);
|
extern int SwigType_type(SwigType *t);
|
||||||
|
|
||||||
/* --- Symbol table module --- */
|
/* --- Symbol table module --- */
|
||||||
|
|
||||||
extern void Swig_symbol_init();
|
extern void Swig_symbol_init();
|
||||||
extern void Swig_symbol_setscopename(const String_or_char *name);
|
extern void Swig_symbol_setscopename(const String_or_char *name);
|
||||||
extern String *Swig_symbol_getscopename();
|
extern String *Swig_symbol_getscopename();
|
||||||
extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
|
extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
|
||||||
extern Symtab *Swig_symbol_newscope();
|
extern Symtab *Swig_symbol_newscope();
|
||||||
extern Symtab *Swig_symbol_setscope(Symtab *);
|
extern Symtab *Swig_symbol_setscope(Symtab *);
|
||||||
extern Symtab *Swig_symbol_getscope(const String_or_char *symname);
|
extern Symtab *Swig_symbol_getscope(const String_or_char *symname);
|
||||||
extern Symtab *Swig_symbol_current();
|
extern Symtab *Swig_symbol_current();
|
||||||
extern Symtab *Swig_symbol_popscope();
|
extern Symtab *Swig_symbol_popscope();
|
||||||
extern Node *Swig_symbol_add(String_or_char *symname, Node *node);
|
extern Node *Swig_symbol_add(String_or_char *symname, Node *node);
|
||||||
extern void Swig_symbol_cadd(String_or_char *symname, Node *node);
|
extern void Swig_symbol_cadd(String_or_char *symname, Node *node);
|
||||||
extern Node *Swig_symbol_clookup(String_or_char *symname, Symtab *tab);
|
extern Node *Swig_symbol_clookup(String_or_char *symname, Symtab *tab);
|
||||||
extern Node *Swig_symbol_clookup_check(String_or_char *symname, Symtab *tab, int (*check)(Node *));
|
extern Node *Swig_symbol_clookup_check(String_or_char *symname, Symtab *tab, int (*check) (Node *));
|
||||||
extern Symtab *Swig_symbol_cscope(String_or_char *symname, Symtab *tab);
|
extern Symtab *Swig_symbol_cscope(String_or_char *symname, Symtab *tab);
|
||||||
extern Node *Swig_symbol_clookup_local(String_or_char *symname, Symtab *tab);
|
extern Node *Swig_symbol_clookup_local(String_or_char *symname, Symtab *tab);
|
||||||
extern Node *Swig_symbol_clookup_local_check(String_or_char *symname, Symtab *tab, int (*check)(Node *));
|
extern Node *Swig_symbol_clookup_local_check(String_or_char *symname, Symtab *tab, int (*check) (Node *));
|
||||||
extern String *Swig_symbol_qualified(Node *node);
|
extern String *Swig_symbol_qualified(Node *node);
|
||||||
extern Node *Swig_symbol_isoverloaded(Node *node);
|
extern Node *Swig_symbol_isoverloaded(Node *node);
|
||||||
extern void Swig_symbol_remove(Node *node);
|
extern void Swig_symbol_remove(Node *node);
|
||||||
extern void Swig_symbol_alias(String_or_char *aliasname, Symtab *tab);
|
extern void Swig_symbol_alias(String_or_char *aliasname, Symtab *tab);
|
||||||
extern void Swig_symbol_inherit(Symtab *tab);
|
extern void Swig_symbol_inherit(Symtab *tab);
|
||||||
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
|
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
|
||||||
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
|
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
|
||||||
extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
|
extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
|
||||||
|
|
||||||
extern void Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
extern void Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||||
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
|
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
|
||||||
extern SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab);
|
extern SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab);
|
||||||
|
|
||||||
/* --- Parameters and Parameter Lists --- */
|
/* --- Parameters and Parameter Lists --- */
|
||||||
|
|
||||||
/* Parameters are really just hidden behind a DOH object. The following
|
/* Parameters are really just hidden behind a DOH object. The following
|
||||||
interface will probably be simplified even further. */
|
interface will probably be simplified even further. */
|
||||||
|
|
||||||
extern Parm *NewParm(SwigType *type, const String_or_char *name);
|
extern Parm *NewParm(SwigType *type, const String_or_char *name);
|
||||||
extern Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n);
|
extern Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n);
|
||||||
extern Parm *CopyParm(Parm *p);
|
extern Parm *CopyParm(Parm *p);
|
||||||
extern ParmList *CopyParmList(ParmList *);
|
extern ParmList *CopyParmList(ParmList *);
|
||||||
extern int ParmList_len(ParmList *);
|
extern int ParmList_len(ParmList *);
|
||||||
extern int ParmList_numarg(ParmList *);
|
extern int ParmList_numarg(ParmList *);
|
||||||
extern int ParmList_numrequired(ParmList *);
|
extern int ParmList_numrequired(ParmList *);
|
||||||
extern String *ParmList_str(ParmList *);
|
extern String *ParmList_str(ParmList *);
|
||||||
extern String *ParmList_str_defaultargs(ParmList *);
|
extern String *ParmList_str_defaultargs(ParmList *);
|
||||||
extern String *ParmList_protostr(ParmList *);
|
extern String *ParmList_protostr(ParmList *);
|
||||||
extern int ParmList_is_compactdefargs(ParmList *p);
|
extern int ParmList_is_compactdefargs(ParmList *p);
|
||||||
extern int ParmList_has_defaultargs(ParmList *p);
|
extern int ParmList_has_defaultargs(ParmList *p);
|
||||||
extern ParmList *ParmList_copy_all_except_last_parm(ParmList *p);
|
extern ParmList *ParmList_copy_all_except_last_parm(ParmList *p);
|
||||||
|
|
||||||
/* --- Parse tree support --- */
|
/* --- Parse tree support --- */
|
||||||
|
|
||||||
|
|
@ -354,7 +354,7 @@ extern ParmList *ParmList_copy_all_except_last_parm(ParmList *p);
|
||||||
#define nextSibling(x) Getattr(x,k_nextsibling)
|
#define nextSibling(x) Getattr(x,k_nextsibling)
|
||||||
#define firstChild(x) Getattr(x,k_firstchild)
|
#define firstChild(x) Getattr(x,k_firstchild)
|
||||||
#define lastChild(x) Getattr(x,k_lastchild)
|
#define lastChild(x) Getattr(x,k_lastchild)
|
||||||
extern int checkAttribute(Node *obj, const String_or_char *name, const String_or_char *value);
|
extern int checkAttribute(Node *obj, const String_or_char *name, const String_or_char *value);
|
||||||
|
|
||||||
/* Macros to set up the DOM tree (mostly used by the parser) */
|
/* Macros to set up the DOM tree (mostly used by the parser) */
|
||||||
|
|
||||||
|
|
@ -365,145 +365,142 @@ extern int checkAttribute(Node *obj, const String_or_char *name, const String_or
|
||||||
#define set_firstChild(x,v) Setattr(x,"firstChild",v)
|
#define set_firstChild(x,v) Setattr(x,"firstChild",v)
|
||||||
#define set_lastChild(x,v) Setattr(x,"lastChild",v)
|
#define set_lastChild(x,v) Setattr(x,"lastChild",v)
|
||||||
|
|
||||||
extern void appendChild(Node *node, Node *child);
|
extern void appendChild(Node *node, Node *child);
|
||||||
extern void preppendChild(Node *node, Node *child);
|
extern void preppendChild(Node *node, Node *child);
|
||||||
extern void deleteNode(Node *node);
|
extern void deleteNode(Node *node);
|
||||||
extern Node *copyNode(Node *node);
|
extern Node *copyNode(Node *node);
|
||||||
|
|
||||||
extern void Swig_tag_nodes(Node *node, const String_or_char *attrname, DOH *value);
|
extern void Swig_tag_nodes(Node *node, const String_or_char *attrname, DOH *value);
|
||||||
|
|
||||||
extern int Swig_require(const char *ns, Node *node, ...);
|
extern int Swig_require(const char *ns, Node *node, ...);
|
||||||
extern int Swig_save(const char *ns, Node *node,...);
|
extern int Swig_save(const char *ns, Node *node, ...);
|
||||||
extern void Swig_restore(Node *node);
|
extern void Swig_restore(Node *node);
|
||||||
|
|
||||||
/* Debugging of parse trees */
|
/* Debugging of parse trees */
|
||||||
extern void Swig_print_tags(File *obj, Node *root);
|
extern void Swig_print_tags(File *obj, Node *root);
|
||||||
extern void Swig_print_tree(Node *obj);
|
extern void Swig_print_tree(Node *obj);
|
||||||
extern void Swig_print_node(Node *obj);
|
extern void Swig_print_node(Node *obj);
|
||||||
|
|
||||||
extern void Swig_print_xml(Node *obj, String* filename);
|
extern void Swig_print_xml(Node *obj, String *filename);
|
||||||
|
|
||||||
/* -- Wrapper function Object */
|
/* -- Wrapper function Object */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Hash *localh;
|
Hash *localh;
|
||||||
String *def;
|
String *def;
|
||||||
String *locals;
|
String *locals;
|
||||||
String *code;
|
String *code;
|
||||||
} Wrapper;
|
} Wrapper;
|
||||||
|
|
||||||
extern Wrapper *NewWrapper();
|
extern Wrapper *NewWrapper();
|
||||||
extern void DelWrapper(Wrapper *w);
|
extern void DelWrapper(Wrapper *w);
|
||||||
extern void Wrapper_compact_print_mode_set(int flag);
|
extern void Wrapper_compact_print_mode_set(int flag);
|
||||||
extern void Wrapper_pretty_print(String *str, File *f);
|
extern void Wrapper_pretty_print(String *str, File *f);
|
||||||
extern void Wrapper_compact_print(String *str, File *f);
|
extern void Wrapper_compact_print(String *str, File *f);
|
||||||
extern void Wrapper_print(Wrapper *w, File *f);
|
extern void Wrapper_print(Wrapper *w, File *f);
|
||||||
extern int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
|
extern int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
|
||||||
extern int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...);
|
extern int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...);
|
||||||
extern int Wrapper_check_local(Wrapper *w, const String_or_char *name);
|
extern int Wrapper_check_local(Wrapper *w, const String_or_char *name);
|
||||||
extern char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
|
extern char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
|
||||||
extern char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...);
|
extern char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...);
|
||||||
|
|
||||||
/* --- Naming functions --- */
|
/* --- Naming functions --- */
|
||||||
|
|
||||||
extern void Swig_name_register(const String_or_char *method, const String_or_char *format);
|
extern void Swig_name_register(const String_or_char *method, const String_or_char *format);
|
||||||
extern void Swig_name_unregister(const String_or_char *method);
|
extern void Swig_name_unregister(const String_or_char *method);
|
||||||
extern String *Swig_name_mangle(const String_or_char *s);
|
extern String *Swig_name_mangle(const String_or_char *s);
|
||||||
extern String *Swig_name_wrapper(const String_or_char *fname);
|
extern String *Swig_name_wrapper(const String_or_char *fname);
|
||||||
extern String *Swig_name_member(const String_or_char *classname, const String_or_char *mname);
|
extern String *Swig_name_member(const String_or_char *classname, const String_or_char *mname);
|
||||||
extern String *Swig_name_get(const String_or_char *vname);
|
extern String *Swig_name_get(const String_or_char *vname);
|
||||||
extern String *Swig_name_set(const String_or_char *vname);
|
extern String *Swig_name_set(const String_or_char *vname);
|
||||||
extern String *Swig_name_construct(const String_or_char *classname);
|
extern String *Swig_name_construct(const String_or_char *classname);
|
||||||
extern String *Swig_name_copyconstructor(const String_or_char *classname);
|
extern String *Swig_name_copyconstructor(const String_or_char *classname);
|
||||||
extern String *Swig_name_destroy(const String_or_char *classname);
|
extern String *Swig_name_destroy(const String_or_char *classname);
|
||||||
extern String *Swig_name_disown(const String_or_char *classname);
|
extern String *Swig_name_disown(const String_or_char *classname);
|
||||||
|
|
||||||
extern void Swig_naming_init();
|
extern void Swig_naming_init();
|
||||||
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
|
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
|
||||||
extern Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name,SwigType *decl);
|
extern Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl);
|
||||||
extern void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *namewrn, ParmList *declaratorparms);
|
extern void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *namewrn, ParmList *declaratorparms);
|
||||||
extern void Swig_name_inherit(String *base, String *derived);
|
extern void Swig_name_inherit(String *base, String *derived);
|
||||||
extern int Swig_need_protected(Node *n);
|
extern int Swig_need_protected(Node *n);
|
||||||
extern int Swig_need_name_warning(Node *n);
|
extern int Swig_need_name_warning(Node *n);
|
||||||
extern int Swig_need_redefined_warn(Node* a, Node* b, int InClass);
|
extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass);
|
||||||
|
|
||||||
extern String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname);
|
extern String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname);
|
||||||
extern String *Swig_name_warning(Node *n, String *prefix, String *name,SwigType *decl);
|
extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl);
|
||||||
|
|
||||||
/* --- parameterized rename functions --- */
|
/* --- parameterized rename functions --- */
|
||||||
|
|
||||||
extern void Swig_name_object_set(Hash *namehash, String_or_char *name, SwigType *decl, DOH *object);
|
extern void Swig_name_object_set(Hash *namehash, String_or_char *name, SwigType *decl, DOH *object);
|
||||||
extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl);
|
extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl);
|
||||||
extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived);
|
extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived);
|
||||||
extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n);
|
extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n);
|
||||||
extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs);
|
extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value,
|
||||||
|
Hash *featureattribs);
|
||||||
|
|
||||||
/* --- Misc --- */
|
/* --- Misc --- */
|
||||||
extern char *Swig_copy_string(const char *c);
|
extern char *Swig_copy_string(const char *c);
|
||||||
extern void Swig_banner(File *f);
|
extern void Swig_banner(File *f);
|
||||||
extern String *Swig_string_escape(String *s);
|
extern String *Swig_string_escape(String *s);
|
||||||
extern String *Swig_string_mangle(const String *s);
|
extern String *Swig_string_mangle(const String *s);
|
||||||
extern void Swig_scopename_split(String *s, String **prefix, String **last);
|
extern void Swig_scopename_split(String *s, String **prefix, String **last);
|
||||||
extern String *Swig_scopename_prefix(String *s);
|
extern String *Swig_scopename_prefix(String *s);
|
||||||
extern String *Swig_scopename_last(String *s);
|
extern String *Swig_scopename_last(String *s);
|
||||||
extern String *Swig_scopename_first(String *s);
|
extern String *Swig_scopename_first(String *s);
|
||||||
extern String *Swig_scopename_suffix(String *s);
|
extern String *Swig_scopename_suffix(String *s);
|
||||||
extern int Swig_scopename_check(String *s);
|
extern int Swig_scopename_check(String *s);
|
||||||
extern String *Swig_string_lower(String *s);
|
extern String *Swig_string_lower(String *s);
|
||||||
extern String *Swig_string_upper(String *s);
|
extern String *Swig_string_upper(String *s);
|
||||||
extern String *Swig_string_title(String *s);
|
extern String *Swig_string_title(String *s);
|
||||||
|
|
||||||
extern void Swig_init();
|
extern void Swig_init();
|
||||||
extern void Swig_warn(const char *filename, int line, const char *msg);
|
extern void Swig_warn(const char *filename, int line, const char *msg);
|
||||||
|
|
||||||
extern int Swig_value_wrapper_mode(int mode);
|
extern int Swig_value_wrapper_mode(int mode);
|
||||||
|
|
||||||
|
|
||||||
#define WARNING(msg) Swig_warn(__FILE__,__LINE__,msg)
|
#define WARNING(msg) Swig_warn(__FILE__,__LINE__,msg)
|
||||||
|
|
||||||
typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
|
typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
|
||||||
|
|
||||||
extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...);
|
extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...);
|
||||||
extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...);
|
extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...);
|
||||||
extern int Swig_error_count(void);
|
extern int Swig_error_count(void);
|
||||||
extern void Swig_error_silent(int s);
|
extern void Swig_error_silent(int s);
|
||||||
extern void Swig_warnfilter(const String_or_char *wlist, int val);
|
extern void Swig_warnfilter(const String_or_char *wlist, int val);
|
||||||
extern void Swig_warnall(void);
|
extern void Swig_warnall(void);
|
||||||
extern int Swig_warn_count(void);
|
extern int Swig_warn_count(void);
|
||||||
extern void Swig_error_msg_format(ErrorMessageFormat format);
|
extern void Swig_error_msg_format(ErrorMessageFormat format);
|
||||||
|
|
||||||
/* --- C Wrappers --- */
|
/* --- C Wrappers --- */
|
||||||
extern String *Swig_cparm_name(Parm *p, int i);
|
extern String *Swig_cparm_name(Parm *p, int i);
|
||||||
extern String *Swig_wrapped_var_type(SwigType *t, int varcref);
|
extern String *Swig_wrapped_var_type(SwigType *t, int varcref);
|
||||||
extern int Swig_cargs(Wrapper *w, ParmList *l);
|
extern int Swig_cargs(Wrapper *w, ParmList *l);
|
||||||
extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl);
|
extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl);
|
||||||
|
|
||||||
extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms);
|
extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms);
|
||||||
extern String *Swig_cconstructor_call(String_or_char *name);
|
extern String *Swig_cconstructor_call(String_or_char *name);
|
||||||
extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms);
|
extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms);
|
||||||
extern String *Swig_unref_call(Node *n);
|
extern String *Swig_unref_call(Node *n);
|
||||||
extern String *Swig_ref_call(Node *n, const String* lname);
|
extern String *Swig_ref_call(Node *n, const String *lname);
|
||||||
extern String *Swig_cdestructor_call(Node *n);
|
extern String *Swig_cdestructor_call(Node *n);
|
||||||
extern String *Swig_cppdestructor_call(Node *n);
|
extern String *Swig_cppdestructor_call(Node *n);
|
||||||
extern String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref);
|
extern String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref);
|
||||||
extern String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref);
|
extern String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref);
|
||||||
|
|
||||||
extern String *Swig_extension_code(const String *function_name,
|
extern String *Swig_extension_code(const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus);
|
||||||
ParmList *parms, SwigType* return_type, const String *code, int cplusplus);
|
extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus);
|
||||||
extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType* return_type, const String *code, int cplusplus);
|
|
||||||
|
|
||||||
/* --- Transformations --- */
|
/* --- Transformations --- */
|
||||||
|
|
||||||
extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
|
extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
|
||||||
extern int Swig_ConstructorToFunction(Node *n, String *classname,
|
extern int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
|
||||||
String *none_comparison,
|
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
|
||||||
String *director_ctor,
|
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
|
||||||
int cplus, int flags);
|
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
|
||||||
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
|
extern int Swig_VargetToFunction(Node *n, int flags);
|
||||||
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
|
extern int Swig_VarsetToFunction(Node *n, int flags);
|
||||||
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
|
|
||||||
extern int Swig_VargetToFunction(Node *n, int flags);
|
|
||||||
extern int Swig_VarsetToFunction(Node *n, int flags);
|
|
||||||
|
|
||||||
#define CWRAP_EXTEND 0x01
|
#define CWRAP_EXTEND 0x01
|
||||||
#define CWRAP_SMART_POINTER 0x02
|
#define CWRAP_SMART_POINTER 0x02
|
||||||
|
|
@ -512,49 +509,47 @@ extern int Swig_VarsetToFunction(Node *n, int flags);
|
||||||
#define CWRAP_DIRECTOR_TWO_CALLS 0x10
|
#define CWRAP_DIRECTOR_TWO_CALLS 0x10
|
||||||
|
|
||||||
/* --- Director Helpers --- */
|
/* --- Director Helpers --- */
|
||||||
extern Node *Swig_methodclass(Node *n);
|
extern Node *Swig_methodclass(Node *n);
|
||||||
extern int Swig_directorclass(Node *n);
|
extern int Swig_directorclass(Node *n);
|
||||||
extern Node *Swig_directormap(Node *n, String *type);
|
extern Node *Swig_directormap(Node *n, String *type);
|
||||||
|
|
||||||
/* --- Legacy Typemap API (somewhat simplified, ha!) --- */
|
/* --- Legacy Typemap API (somewhat simplified, ha!) --- */
|
||||||
|
|
||||||
extern void Swig_typemap_init();
|
extern void Swig_typemap_init();
|
||||||
extern void Swig_typemap_register(const String_or_char *op, ParmList *pattern, String_or_char *code, ParmList *locals, ParmList *kwargs);
|
extern void Swig_typemap_register(const String_or_char *op, ParmList *pattern, String_or_char *code, ParmList *locals, ParmList *kwargs);
|
||||||
extern int Swig_typemap_copy(const String_or_char *op, ParmList *srcpattern, ParmList *pattern);
|
extern int Swig_typemap_copy(const String_or_char *op, ParmList *srcpattern, ParmList *pattern);
|
||||||
extern void Swig_typemap_clear(const String_or_char *op, ParmList *pattern);
|
extern void Swig_typemap_clear(const String_or_char *op, ParmList *pattern);
|
||||||
extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
|
extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
|
||||||
extern void Swig_typemap_clear_apply(ParmList *pattern);
|
extern void Swig_typemap_clear_apply(ParmList *pattern);
|
||||||
extern void Swig_typemap_debug();
|
extern void Swig_typemap_debug();
|
||||||
|
|
||||||
extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *pname, SwigType **matchtype);
|
extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *pname, SwigType **matchtype);
|
||||||
extern Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch);
|
extern Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch);
|
||||||
extern String *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *lname,
|
extern String *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *lname,
|
||||||
String_or_char *source, String_or_char *target, Wrapper *f);
|
String_or_char *source, String_or_char *target, Wrapper *f);
|
||||||
|
|
||||||
extern String *Swig_typemap_lookup_new(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f);
|
extern String *Swig_typemap_lookup_new(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f);
|
||||||
extern void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p);
|
extern void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p);
|
||||||
extern void Swig_typemap_new_scope();
|
extern void Swig_typemap_new_scope();
|
||||||
extern Hash *Swig_typemap_pop_scope();
|
extern Hash *Swig_typemap_pop_scope();
|
||||||
|
|
||||||
extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f);
|
extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f);
|
||||||
|
|
||||||
/* --- Code fragment support --- */
|
/* --- Code fragment support --- */
|
||||||
|
|
||||||
extern void Swig_fragment_register(Node* fragment);
|
extern void Swig_fragment_register(Node *fragment);
|
||||||
extern void Swig_fragment_emit(String *name);
|
extern void Swig_fragment_emit(String *name);
|
||||||
|
|
||||||
/* hacks defined in C++ ! */
|
/* hacks defined in C++ ! */
|
||||||
extern int Swig_director_mode();
|
extern int Swig_director_mode();
|
||||||
extern void Wrapper_director_mode_set(int);
|
extern void Wrapper_director_mode_set(int);
|
||||||
|
|
||||||
|
|
||||||
/* -- template init -- */
|
/* -- template init -- */
|
||||||
extern void SwigType_template_init();
|
extern void SwigType_template_init();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,6 @@ void Swig_keys_init() {
|
||||||
|
|
||||||
k_previoussibling = NewString("previousSibling");
|
k_previoussibling = NewString("previousSibling");
|
||||||
k_nextsibling = NewString("nextSibling");
|
k_nextsibling = NewString("nextSibling");
|
||||||
k_firstchild = NewString("firstChild");
|
k_firstchild = NewString("firstChild");
|
||||||
k_lastchild = NewString("lastChild");
|
k_lastchild = NewString("lastChild");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,4 +140,4 @@ extern String *k_previoussibling;
|
||||||
extern String *k_nextsibling;
|
extern String *k_nextsibling;
|
||||||
extern String *k_firstchild;
|
extern String *k_firstchild;
|
||||||
extern String *k_lastchild;
|
extern String *k_lastchild;
|
||||||
#endif /* SWIG_SWIGKEYS_H_ */
|
#endif /* SWIG_SWIGKEYS_H_ */
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -21,20 +21,21 @@ char cvsroot_tree_c[] = "$Header$";
|
||||||
* Dump the tag structure of a parse tree to standard output
|
* Dump the tag structure of a parse tree to standard output
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_print_tags(DOH *obj, DOH *root) {
|
||||||
Swig_print_tags(DOH *obj, DOH *root) {
|
|
||||||
DOH *croot, *newroot;
|
DOH *croot, *newroot;
|
||||||
DOH *cobj;
|
DOH *cobj;
|
||||||
|
|
||||||
if (!root) croot = NewStringEmpty();
|
if (!root)
|
||||||
else croot = root;
|
croot = NewStringEmpty();
|
||||||
|
else
|
||||||
|
croot = root;
|
||||||
|
|
||||||
while (obj) {
|
while (obj) {
|
||||||
Printf(stdout,"%s . %s (%s:%d)\n", croot, nodeType(obj), Getfile(obj), Getline(obj));
|
Printf(stdout, "%s . %s (%s:%d)\n", croot, nodeType(obj), Getfile(obj), Getline(obj));
|
||||||
cobj = firstChild(obj);
|
cobj = firstChild(obj);
|
||||||
if (cobj) {
|
if (cobj) {
|
||||||
newroot = NewStringf("%s . %s",croot,nodeType(obj));
|
newroot = NewStringf("%s . %s", croot, nodeType(obj));
|
||||||
Swig_print_tags(cobj,newroot);
|
Swig_print_tags(cobj, newroot);
|
||||||
Delete(newroot);
|
Delete(newroot);
|
||||||
}
|
}
|
||||||
obj = nextSibling(obj);
|
obj = nextSibling(obj);
|
||||||
|
|
@ -61,36 +62,34 @@ static void print_indent(int l) {
|
||||||
* Swig_print_node(Node *n)
|
* Swig_print_node(Node *n)
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_print_node(Node *obj) {
|
||||||
Swig_print_node(Node *obj) {
|
|
||||||
Iterator ki;
|
Iterator ki;
|
||||||
Node *cobj;
|
Node *cobj;
|
||||||
|
|
||||||
print_indent(0);
|
print_indent(0);
|
||||||
Printf(stdout,"+++ %s ----------------------------------------\n", nodeType(obj));
|
Printf(stdout, "+++ %s ----------------------------------------\n", nodeType(obj));
|
||||||
ki = First(obj);
|
ki = First(obj);
|
||||||
while (ki.key) {
|
while (ki.key) {
|
||||||
String *k = ki.key;
|
String *k = ki.key;
|
||||||
if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
|
if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) ||
|
||||||
(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
|
(Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) {
|
||||||
(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
|
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
} else if (Cmp(k,"parms") == 0) {
|
} else if (Cmp(k, "parms") == 0) {
|
||||||
print_indent(2);
|
print_indent(2);
|
||||||
Printf(stdout,"%-12s - %s\n", k, ParmList_protostr(Getattr(obj,k)));
|
Printf(stdout, "%-12s - %s\n", k, ParmList_protostr(Getattr(obj, k)));
|
||||||
} else {
|
} else {
|
||||||
DOH *o;
|
DOH *o;
|
||||||
char *trunc = "";
|
char *trunc = "";
|
||||||
print_indent(2);
|
print_indent(2);
|
||||||
if (DohIsString(Getattr(obj,k))) {
|
if (DohIsString(Getattr(obj, k))) {
|
||||||
o = Str(Getattr(obj,k));
|
o = Str(Getattr(obj, k));
|
||||||
if (Len(o) > 40) {
|
if (Len(o) > 40) {
|
||||||
trunc = "...";
|
trunc = "...";
|
||||||
}
|
}
|
||||||
Printf(stdout,"%-12s - \"%(escape)-0.40s%s\"\n", k, o, trunc);
|
Printf(stdout, "%-12s - \"%(escape)-0.40s%s\"\n", k, o, trunc);
|
||||||
Delete(o);
|
Delete(o);
|
||||||
} else {
|
} else {
|
||||||
Printf(stdout,"%-12s - 0x%x\n", k, Getattr(obj,k));
|
Printf(stdout, "%-12s - 0x%x\n", k, Getattr(obj, k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ki = Next(ki);
|
ki = Next(ki);
|
||||||
|
|
@ -98,12 +97,12 @@ Swig_print_node(Node *obj) {
|
||||||
cobj = firstChild(obj);
|
cobj = firstChild(obj);
|
||||||
if (cobj) {
|
if (cobj) {
|
||||||
indent_level += 6;
|
indent_level += 6;
|
||||||
Printf(stdout,"\n");
|
Printf(stdout, "\n");
|
||||||
Swig_print_tree(cobj);
|
Swig_print_tree(cobj);
|
||||||
indent_level -= 6;
|
indent_level -= 6;
|
||||||
} else {
|
} else {
|
||||||
print_indent(1);
|
print_indent(1);
|
||||||
Printf(stdout,"\n");
|
Printf(stdout, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,8 +112,7 @@ Swig_print_node(Node *obj) {
|
||||||
* Dump the tree structure of a parse tree to standard output
|
* Dump the tree structure of a parse tree to standard output
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_print_tree(DOH *obj) {
|
||||||
Swig_print_tree(DOH *obj) {
|
|
||||||
while (obj) {
|
while (obj) {
|
||||||
Swig_print_node(obj);
|
Swig_print_node(obj);
|
||||||
obj = nextSibling(obj);
|
obj = nextSibling(obj);
|
||||||
|
|
@ -127,25 +125,25 @@ Swig_print_tree(DOH *obj) {
|
||||||
* Appends a new child to a node
|
* Appends a new child to a node
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void appendChild(Node *node, Node *chd) {
|
||||||
appendChild(Node *node, Node *chd) {
|
|
||||||
Node *lc;
|
Node *lc;
|
||||||
|
|
||||||
if (!chd) return;
|
if (!chd)
|
||||||
|
return;
|
||||||
|
|
||||||
lc = lastChild(node);
|
lc = lastChild(node);
|
||||||
if (!lc) {
|
if (!lc) {
|
||||||
set_firstChild(node,chd);
|
set_firstChild(node, chd);
|
||||||
} else {
|
} else {
|
||||||
set_nextSibling(lc,chd);
|
set_nextSibling(lc, chd);
|
||||||
set_previousSibling(chd,lc);
|
set_previousSibling(chd, lc);
|
||||||
}
|
}
|
||||||
while (chd) {
|
while (chd) {
|
||||||
lc = chd;
|
lc = chd;
|
||||||
set_parentNode(chd,node);
|
set_parentNode(chd, node);
|
||||||
chd = nextSibling(chd);
|
chd = nextSibling(chd);
|
||||||
}
|
}
|
||||||
set_lastChild(node,lc);
|
set_lastChild(node, lc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -154,20 +152,20 @@ appendChild(Node *node, Node *chd) {
|
||||||
* Preppends a new child to a node
|
* Preppends a new child to a node
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void preppendChild(Node *node, Node *chd) {
|
||||||
preppendChild(Node *node, Node *chd) {
|
|
||||||
Node *fc;
|
Node *fc;
|
||||||
|
|
||||||
if (!chd) return;
|
if (!chd)
|
||||||
|
return;
|
||||||
|
|
||||||
fc = firstChild(node);
|
fc = firstChild(node);
|
||||||
if (fc) {
|
if (fc) {
|
||||||
set_nextSibling(chd,fc);
|
set_nextSibling(chd, fc);
|
||||||
set_previousSibling(fc,chd);
|
set_previousSibling(fc, chd);
|
||||||
}
|
}
|
||||||
set_firstChild(node,chd);
|
set_firstChild(node, chd);
|
||||||
while (chd) {
|
while (chd) {
|
||||||
set_parentNode(chd,node);
|
set_parentNode(chd, node);
|
||||||
chd = nextSibling(chd);
|
chd = nextSibling(chd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -178,8 +176,7 @@ preppendChild(Node *node, Node *chd) {
|
||||||
* Deletes a node.
|
* Deletes a node.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void deleteNode(Node *n) {
|
||||||
deleteNode(Node *n) {
|
|
||||||
Node *parent;
|
Node *parent;
|
||||||
Node *prev;
|
Node *prev;
|
||||||
Node *next;
|
Node *next;
|
||||||
|
|
@ -188,17 +185,17 @@ deleteNode(Node *n) {
|
||||||
prev = previousSibling(n);
|
prev = previousSibling(n);
|
||||||
next = nextSibling(n);
|
next = nextSibling(n);
|
||||||
if (prev) {
|
if (prev) {
|
||||||
set_nextSibling(prev,next);
|
set_nextSibling(prev, next);
|
||||||
} else {
|
} else {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
set_firstChild(parent,next);
|
set_firstChild(parent, next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (next) {
|
if (next) {
|
||||||
set_previousSibling(next,prev);
|
set_previousSibling(next, prev);
|
||||||
} else {
|
} else {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
set_lastChild(parent,prev);
|
set_lastChild(parent, prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -209,17 +206,16 @@ deleteNode(Node *n) {
|
||||||
* Copies a node, but only copies simple attributes (no lists, hashes).
|
* Copies a node, but only copies simple attributes (no lists, hashes).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
Node *
|
Node *copyNode(Node *n) {
|
||||||
copyNode(Node *n) {
|
|
||||||
Iterator ki;
|
Iterator ki;
|
||||||
Node *c = NewHash();
|
Node *c = NewHash();
|
||||||
for (ki = First(n); ki.key; ki = Next(ki)) {
|
for (ki = First(n); ki.key; ki = Next(ki)) {
|
||||||
if (DohIsString(ki.item)) {
|
if (DohIsString(ki.item)) {
|
||||||
Setattr(c,ki.key,Copy(ki.item));
|
Setattr(c, ki.key, Copy(ki.item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Setfile(c,Getfile(n));
|
Setfile(c, Getfile(n));
|
||||||
Setline(c,Getline(n));
|
Setline(c, Getline(n));
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,11 +226,10 @@ copyNode(Node *n) {
|
||||||
* subtypes with extra information.
|
* subtypes with extra information.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
|
||||||
Swig_tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
|
|
||||||
while (n) {
|
while (n) {
|
||||||
Setattr(n,attrname,value);
|
Setattr(n, attrname, value);
|
||||||
Swig_tag_nodes(firstChild(n),attrname, value);
|
Swig_tag_nodes(firstChild(n), attrname, value);
|
||||||
n = nextSibling(n);
|
n = nextSibling(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,10 +238,9 @@ Swig_tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
|
||||||
* checkAttribute()
|
* checkAttribute()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) {
|
||||||
checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) {
|
String *v = Getattr(n, name);
|
||||||
String *v = Getattr(n,name);
|
return v ? Equal(v, value) : 0;
|
||||||
return v ? Equal(v,value) : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -263,8 +257,7 @@ checkAttribute(Node *n, const String_or_char *name, const String_or_char *value)
|
||||||
* This function can be called more than once with different namespaces.
|
* This function can be called more than once with different namespaces.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Swig_require(const char *ns, Node *n, ...) {
|
||||||
Swig_require(const char *ns, Node *n, ...) {
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *name;
|
char *name;
|
||||||
DOH *obj;
|
DOH *obj;
|
||||||
|
|
@ -282,13 +275,13 @@ Swig_require(const char *ns, Node *n, ...) {
|
||||||
opt = 1;
|
opt = 1;
|
||||||
name++;
|
name++;
|
||||||
}
|
}
|
||||||
obj = Getattr(n,name);
|
obj = Getattr(n, name);
|
||||||
if (!opt && !obj) {
|
if (!opt && !obj) {
|
||||||
Printf(stderr,"%s:%d. Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n",
|
Printf(stderr, "%s:%d. Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", Getfile(n), Getline(n), name, nodeType(n));
|
||||||
Getfile(n), Getline(n), name, nodeType(n));
|
|
||||||
assert(obj);
|
assert(obj);
|
||||||
}
|
}
|
||||||
if (!obj) obj = DohNone;
|
if (!obj)
|
||||||
|
obj = DohNone;
|
||||||
if (newref) {
|
if (newref) {
|
||||||
/* Save a copy of the attribute */
|
/* Save a copy of the attribute */
|
||||||
Setattr(n, NewStringf("%s:%s", ns, name), obj);
|
Setattr(n, NewStringf("%s:%s", ns, name), obj);
|
||||||
|
|
@ -299,14 +292,14 @@ Swig_require(const char *ns, Node *n, ...) {
|
||||||
|
|
||||||
/* Save the view */
|
/* Save the view */
|
||||||
{
|
{
|
||||||
String *view = Getattr(n,k_view);
|
String *view = Getattr(n, k_view);
|
||||||
if (view) {
|
if (view) {
|
||||||
if (Strcmp(view,ns) != 0) {
|
if (Strcmp(view, ns) != 0) {
|
||||||
Setattr(n, NewStringf("%s:view", ns), view);
|
Setattr(n, NewStringf("%s:view", ns), view);
|
||||||
Setattr(n,k_view,ns);
|
Setattr(n, k_view, ns);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Setattr(n,k_view,ns);
|
Setattr(n, k_view, ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,8 +313,7 @@ Swig_require(const char *ns, Node *n, ...) {
|
||||||
* are saved, ie behaves as if all the attribute names were prefixed by ?.
|
* are saved, ie behaves as if all the attribute names were prefixed by ?.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Swig_save(const char *ns, Node *n, ...) {
|
||||||
Swig_save(const char *ns, Node *n, ...) {
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *name;
|
char *name;
|
||||||
DOH *obj;
|
DOH *obj;
|
||||||
|
|
@ -334,12 +326,13 @@ Swig_save(const char *ns, Node *n, ...) {
|
||||||
} else if (*name == '?') {
|
} else if (*name == '?') {
|
||||||
name++;
|
name++;
|
||||||
}
|
}
|
||||||
obj = Getattr(n,name);
|
obj = Getattr(n, name);
|
||||||
if (!obj) obj = DohNone;
|
if (!obj)
|
||||||
|
obj = DohNone;
|
||||||
|
|
||||||
/* Save a copy of the attribute */
|
/* Save a copy of the attribute */
|
||||||
if (Setattr(n, NewStringf("%s:%s", ns, name), obj)) {
|
if (Setattr(n, NewStringf("%s:%s", ns, name), obj)) {
|
||||||
Printf(stderr,"Swig_save('%s','%s'): Warning, attribute '%s' was already saved.\n", ns, nodeType(n), name);
|
Printf(stderr, "Swig_save('%s','%s'): Warning, attribute '%s' was already saved.\n", ns, nodeType(n), name);
|
||||||
}
|
}
|
||||||
name = va_arg(ap, char *);
|
name = va_arg(ap, char *);
|
||||||
}
|
}
|
||||||
|
|
@ -347,14 +340,14 @@ Swig_save(const char *ns, Node *n, ...) {
|
||||||
|
|
||||||
/* Save the view */
|
/* Save the view */
|
||||||
{
|
{
|
||||||
String *view = Getattr(n,k_view);
|
String *view = Getattr(n, k_view);
|
||||||
if (view) {
|
if (view) {
|
||||||
if (Strcmp(view,ns) != 0) {
|
if (Strcmp(view, ns) != 0) {
|
||||||
Setattr(n, NewStringf("%s:view", ns), view);
|
Setattr(n, NewStringf("%s:view", ns), view);
|
||||||
Setattr(n,k_view,ns);
|
Setattr(n, k_view, ns);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Setattr(n,k_view,ns);
|
Setattr(n, k_view, ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,15 +359,14 @@ Swig_save(const char *ns, Node *n, ...) {
|
||||||
* Restores attributes saved by a previous call to Swig_require() or Swig_save().
|
* Restores attributes saved by a previous call to Swig_require() or Swig_save().
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_restore(Node *n) {
|
||||||
Swig_restore(Node *n) {
|
|
||||||
String *temp;
|
String *temp;
|
||||||
int len;
|
int len;
|
||||||
List *l;
|
List *l;
|
||||||
String *ns;
|
String *ns;
|
||||||
Iterator ki;
|
Iterator ki;
|
||||||
|
|
||||||
ns = Getattr(n,k_view);
|
ns = Getattr(n, k_view);
|
||||||
assert(ns);
|
assert(ns);
|
||||||
|
|
||||||
l = NewList();
|
l = NewList();
|
||||||
|
|
@ -384,16 +376,14 @@ Swig_restore(Node *n) {
|
||||||
|
|
||||||
for (ki = First(n); ki.key; ki = Next(ki)) {
|
for (ki = First(n); ki.key; ki = Next(ki)) {
|
||||||
if (Strncmp(temp, ki.key, len) == 0) {
|
if (Strncmp(temp, ki.key, len) == 0) {
|
||||||
Append(l,ki.key);
|
Append(l, ki.key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ki = First(l); ki.item; ki = Next(ki)) {
|
for (ki = First(l); ki.item; ki = Next(ki)) {
|
||||||
DOH *obj = Getattr(n,ki.item);
|
DOH *obj = Getattr(n, ki.item);
|
||||||
Setattr(n,Char(ki.item)+len,obj);
|
Setattr(n, Char(ki.item) + len, obj);
|
||||||
Delattr(n,ki.item);
|
Delattr(n, ki.item);
|
||||||
}
|
}
|
||||||
Delete(l);
|
Delete(l);
|
||||||
Delete(temp);
|
Delete(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -111,8 +111,7 @@ char cvsroot_typeobj_c[] = "$Header$";
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef NEW
|
#ifdef NEW
|
||||||
SwigType *
|
SwigType *NewSwigType(const String_or_char *initial) {
|
||||||
NewSwigType(const String_or_char *initial) {
|
|
||||||
return NewString(initial);
|
return NewString(initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,8 +131,7 @@ NewSwigType(const String_or_char *initial) {
|
||||||
* substring, to chop the element off, or for other purposes).
|
* substring, to chop the element off, or for other purposes).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int element_size(char *c) {
|
||||||
element_size(char *c) {
|
|
||||||
int nparen;
|
int nparen;
|
||||||
char *s = c;
|
char *s = c;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
|
|
@ -144,15 +142,18 @@ element_size(char *c) {
|
||||||
nparen = 1;
|
nparen = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == '(') nparen++;
|
if (*c == '(')
|
||||||
|
nparen++;
|
||||||
if (*c == ')') {
|
if (*c == ')') {
|
||||||
nparen--;
|
nparen--;
|
||||||
if (nparen == 0) break;
|
if (nparen == 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*c) c++;
|
if (*c)
|
||||||
|
c++;
|
||||||
}
|
}
|
||||||
return (int) (c - s);
|
return (int) (c - s);
|
||||||
}
|
}
|
||||||
|
|
@ -163,10 +164,9 @@ element_size(char *c) {
|
||||||
* Deletes one type element from the type.
|
* Deletes one type element from the type.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_del_element(SwigType *t) {
|
||||||
SwigType_del_element(SwigType *t) {
|
|
||||||
int sz = element_size(Char(t));
|
int sz = element_size(Char(t));
|
||||||
Delslice(t,0,sz);
|
Delslice(t, 0, sz);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,21 +176,21 @@ SwigType_del_element(SwigType *t) {
|
||||||
* Pop one type element off the type.
|
* Pop one type element off the type.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_pop(SwigType *t) {
|
||||||
SwigType_pop(SwigType *t) {
|
SwigType *result;
|
||||||
SwigType *result;
|
char *c;
|
||||||
char *c;
|
int sz;
|
||||||
int sz;
|
|
||||||
|
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
if (!*c) return 0;
|
if (!*c)
|
||||||
|
return 0;
|
||||||
|
|
||||||
sz = element_size(c);
|
sz = element_size(c);
|
||||||
result = NewStringWithSize(c,sz);
|
result = NewStringWithSize(c, sz);
|
||||||
Delslice(t,0,sz);
|
Delslice(t, 0, sz);
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
if (*c == '.') {
|
if (*c == '.') {
|
||||||
Delitem(t,0);
|
Delitem(t, 0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -201,26 +201,28 @@ SwigType_pop(SwigType *t) {
|
||||||
* Returns the parameter of an operator as a string
|
* Returns the parameter of an operator as a string
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *SwigType_parm(SwigType *t) {
|
||||||
SwigType_parm(SwigType *t) {
|
|
||||||
char *start, *c;
|
char *start, *c;
|
||||||
int nparens = 0;
|
int nparens = 0;
|
||||||
|
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
while (*c && (*c != '(') && (*c != '.')) c++;
|
while (*c && (*c != '(') && (*c != '.'))
|
||||||
if (!*c || (*c == '.')) return 0;
|
c++;
|
||||||
|
if (!*c || (*c == '.'))
|
||||||
|
return 0;
|
||||||
c++;
|
c++;
|
||||||
start = c;
|
start = c;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == ')') {
|
if (*c == ')') {
|
||||||
if (nparens == 0) break;
|
if (nparens == 0)
|
||||||
|
break;
|
||||||
nparens--;
|
nparens--;
|
||||||
} else if (*c == '(') {
|
} else if (*c == '(') {
|
||||||
nparens++;
|
nparens++;
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
return NewStringWithSize(start, (int) (c-start));
|
return NewStringWithSize(start, (int) (c - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -230,20 +232,21 @@ SwigType_parm(SwigType *t) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
List *SwigType_split(const SwigType *t) {
|
List *SwigType_split(const SwigType *t) {
|
||||||
DOH *item;
|
DOH *item;
|
||||||
List *list;
|
List *list;
|
||||||
char *c;
|
char *c;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
list = NewList();
|
list = NewList();
|
||||||
while (*c) {
|
while (*c) {
|
||||||
len = element_size(c);
|
len = element_size(c);
|
||||||
item = NewStringWithSize(c,len);
|
item = NewStringWithSize(c, len);
|
||||||
Append(list,item);
|
Append(list, item);
|
||||||
Delete(item);
|
Delete(item);
|
||||||
c = c + len;
|
c = c + len;
|
||||||
if (*c == '.') c++;
|
if (*c == '.')
|
||||||
|
c++;
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
@ -255,40 +258,45 @@ List *SwigType_split(const SwigType *t) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
List *SwigType_parmlist(const String *p) {
|
List *SwigType_parmlist(const String *p) {
|
||||||
DOH *item;
|
DOH *item;
|
||||||
List *list;
|
List *list;
|
||||||
char *c, *itemstart;
|
char *c, *itemstart;
|
||||||
|
|
||||||
c = Char(p);
|
c = Char(p);
|
||||||
while (*c && (*c != '(') && (*c != '.')) c++;
|
while (*c && (*c != '(') && (*c != '.'))
|
||||||
if (!*c || (*c == '.')) return 0;
|
c++;
|
||||||
|
if (!*c || (*c == '.'))
|
||||||
|
return 0;
|
||||||
c++;
|
c++;
|
||||||
list = NewList();
|
list = NewList();
|
||||||
itemstart = c;
|
itemstart = c;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == ',') {
|
if (*c == ',') {
|
||||||
item = NewStringWithSize(itemstart, (int) (c - itemstart));
|
item = NewStringWithSize(itemstart, (int) (c - itemstart));
|
||||||
Append(list,item);
|
Append(list, item);
|
||||||
Delete(item);
|
Delete(item);
|
||||||
itemstart = c+1;
|
itemstart = c + 1;
|
||||||
} else if (*c == '(') {
|
} else if (*c == '(') {
|
||||||
int nparens = 1;
|
int nparens = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == '(') nparens++;
|
if (*c == '(')
|
||||||
|
nparens++;
|
||||||
if (*c == ')') {
|
if (*c == ')') {
|
||||||
nparens--;
|
nparens--;
|
||||||
if (nparens == 0) break;
|
if (nparens == 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
} else if (*c == ')') {
|
} else if (*c == ')') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*c) c++;
|
if (*c)
|
||||||
|
c++;
|
||||||
}
|
}
|
||||||
item = NewStringWithSize(itemstart,(int) (c - itemstart));
|
item = NewStringWithSize(itemstart, (int) (c - itemstart));
|
||||||
Append(list,item);
|
Append(list, item);
|
||||||
Delete(item);
|
Delete(item);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
@ -304,43 +312,42 @@ List *SwigType_parmlist(const String *p) {
|
||||||
* functions take into account qualifiers (if any).
|
* functions take into account qualifiers (if any).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_add_pointer(SwigType *t) {
|
||||||
SwigType_add_pointer(SwigType *t) {
|
Insert(t, 0, "p.");
|
||||||
Insert(t,0,"p.");
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_del_pointer(SwigType *t) {
|
||||||
SwigType_del_pointer(SwigType *t) {
|
|
||||||
char *c, *s;
|
char *c, *s;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
s = c;
|
s = c;
|
||||||
/* Skip qualifiers, if any */
|
/* Skip qualifiers, if any */
|
||||||
if (strncmp(c,"q(",2) == 0) {
|
if (strncmp(c, "q(", 2) == 0) {
|
||||||
c = strchr(c,'.');
|
c = strchr(c, '.');
|
||||||
assert(c);
|
assert(c);
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
if (strncmp(c,"p.",2)) {
|
if (strncmp(c, "p.", 2)) {
|
||||||
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
|
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
Delslice(t,0,(c-s)+2);
|
Delslice(t, 0, (c - s) + 2);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int SwigType_ispointer(SwigType *t) {
|
||||||
SwigType_ispointer(SwigType *t) {
|
|
||||||
char *c;
|
char *c;
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
/* Skip qualifiers, if any */
|
/* Skip qualifiers, if any */
|
||||||
if (strncmp(c,"q(",2) == 0) {
|
if (strncmp(c, "q(", 2) == 0) {
|
||||||
c = strchr(c,'.');
|
c = strchr(c, '.');
|
||||||
if (!c) return 0;
|
if (!c)
|
||||||
|
return 0;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
if (strncmp(c,"p.",2) == 0) {
|
if (strncmp(c, "p.", 2) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -357,29 +364,27 @@ SwigType_ispointer(SwigType *t) {
|
||||||
* functions take into account qualifiers (if any).
|
* functions take into account qualifiers (if any).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_add_reference(SwigType *t) {
|
||||||
SwigType_add_reference(SwigType *t) {
|
Insert(t, 0, "r.");
|
||||||
Insert(t,0,"r.");
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
SwigType *
|
|
||||||
SwigType_del_reference(SwigType *t) {
|
|
||||||
char *c = Char(t);
|
|
||||||
int check = strncmp(c,"r.",2);
|
|
||||||
assert(check == 0);
|
|
||||||
Delslice(t,0,2);
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
SwigType *SwigType_del_reference(SwigType *t) {
|
||||||
SwigType_isreference(SwigType *t) {
|
char *c = Char(t);
|
||||||
|
int check = strncmp(c, "r.", 2);
|
||||||
|
assert(check == 0);
|
||||||
|
Delslice(t, 0, 2);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SwigType_isreference(SwigType *t) {
|
||||||
char *c;
|
char *c;
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
if (strncmp(c,"r.",2) == 0) {
|
if (strncmp(c, "r.", 2) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -397,20 +402,19 @@ SwigType_isreference(SwigType *t) {
|
||||||
* stored in exactly the same way as "q(const volatile)".
|
* stored in exactly the same way as "q(const volatile)".
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
|
||||||
SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
|
|
||||||
char temp[256], newq[256];
|
char temp[256], newq[256];
|
||||||
int sz, added = 0;
|
int sz, added = 0;
|
||||||
char *q, *cqual;
|
char *q, *cqual;
|
||||||
|
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
cqual = Char(qual);
|
cqual = Char(qual);
|
||||||
|
|
||||||
if (!(strncmp(c,"q(",2) == 0)) {
|
if (!(strncmp(c, "q(", 2) == 0)) {
|
||||||
sprintf(temp,"q(%s).",cqual);
|
sprintf(temp, "q(%s).", cqual);
|
||||||
Insert(t,0,temp);
|
Insert(t, 0, temp);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The type already has a qualifier on it. In this case, we first check to
|
/* The type already has a qualifier on it. In this case, we first check to
|
||||||
see if the qualifier is already specified. In that case do nothing.
|
see if the qualifier is already specified. In that case do nothing.
|
||||||
|
|
@ -418,58 +422,57 @@ SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
|
||||||
order */
|
order */
|
||||||
|
|
||||||
sz = element_size(c);
|
sz = element_size(c);
|
||||||
strncpy(temp,c, (sz < 256) ? sz : 256);
|
strncpy(temp, c, (sz < 256) ? sz : 256);
|
||||||
|
|
||||||
if (strstr(temp,cqual)) {
|
if (strstr(temp, cqual)) {
|
||||||
/* Qualifier already added */
|
/* Qualifier already added */
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the qualifier to the existing list. */
|
/* Add the qualifier to the existing list. */
|
||||||
|
|
||||||
strcpy(newq,"q(");
|
strcpy(newq, "q(");
|
||||||
q = temp+2;
|
q = temp + 2;
|
||||||
q = strtok(q," ).");
|
q = strtok(q, " ).");
|
||||||
while (q) {
|
while (q) {
|
||||||
if (strcmp(cqual,q) < 0) {
|
if (strcmp(cqual, q) < 0) {
|
||||||
/* New qualifier is less that current qualifier. We need to insert it */
|
/* New qualifier is less that current qualifier. We need to insert it */
|
||||||
strcat(newq,cqual);
|
strcat(newq, cqual);
|
||||||
strcat(newq," ");
|
strcat(newq, " ");
|
||||||
strcat(newq,q);
|
strcat(newq, q);
|
||||||
added = 1;
|
added = 1;
|
||||||
} else {
|
} else {
|
||||||
strcat(newq,q);
|
strcat(newq, q);
|
||||||
}
|
}
|
||||||
q = strtok(NULL," ).");
|
q = strtok(NULL, " ).");
|
||||||
if (q) {
|
if (q) {
|
||||||
strcat(newq," ");
|
strcat(newq, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!added) {
|
if (!added) {
|
||||||
strcat(newq," ");
|
strcat(newq, " ");
|
||||||
strcat(newq,cqual);
|
strcat(newq, cqual);
|
||||||
}
|
}
|
||||||
strcat(newq,").");
|
strcat(newq, ").");
|
||||||
Delslice(t,0,sz);
|
Delslice(t, 0, sz);
|
||||||
Insert(t,0,newq);
|
Insert(t, 0, newq);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_del_qualifier(SwigType *t) {
|
||||||
SwigType_del_qualifier(SwigType *t) {
|
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
int check = strncmp(c,"q(",2);
|
int check = strncmp(c, "q(", 2);
|
||||||
assert(check == 0);
|
assert(check == 0);
|
||||||
Delslice(t,0,element_size(c));
|
Delslice(t, 0, element_size(c));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int SwigType_isqualifier(SwigType *t) {
|
||||||
SwigType_isqualifier(SwigType *t) {
|
|
||||||
char *c;
|
char *c;
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
if (strncmp(c,"q(",2) == 0) {
|
if (strncmp(c, "q(", 2) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -485,29 +488,27 @@ SwigType_isqualifier(SwigType *t) {
|
||||||
* Add, remove, and test for C++ pointer to members.
|
* Add, remove, and test for C++ pointer to members.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *name) {
|
||||||
SwigType_add_memberpointer(SwigType *t, const String_or_char *name) {
|
|
||||||
String *temp = NewStringf("m(%s).", name);
|
String *temp = NewStringf("m(%s).", name);
|
||||||
Insert(t,0,temp);
|
Insert(t, 0, temp);
|
||||||
Delete(temp);
|
Delete(temp);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_del_memberpointer(SwigType *t) {
|
||||||
SwigType_del_memberpointer(SwigType *t) {
|
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
int check = strncmp(c,"m(",2);
|
int check = strncmp(c, "m(", 2);
|
||||||
assert(check == 0);
|
assert(check == 0);
|
||||||
Delslice(t,0,element_size(c));
|
Delslice(t, 0, element_size(c));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int SwigType_ismemberpointer(SwigType *t) {
|
||||||
SwigType_ismemberpointer(SwigType *t) {
|
|
||||||
char *c;
|
char *c;
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
if (strncmp(c,"m(",2) == 0) {
|
if (strncmp(c, "m(", 2) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -529,57 +530,54 @@ SwigType_ismemberpointer(SwigType *t) {
|
||||||
* SwigType_pop_arrays() - Remove all arrays
|
* SwigType_pop_arrays() - Remove all arrays
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_add_array(SwigType *t, const String_or_char *size) {
|
||||||
SwigType_add_array(SwigType *t, const String_or_char *size) {
|
|
||||||
char temp[512];
|
char temp[512];
|
||||||
strcpy(temp,"a(");
|
strcpy(temp, "a(");
|
||||||
strcat(temp,Char(size));
|
strcat(temp, Char(size));
|
||||||
strcat(temp,").");
|
strcat(temp, ").");
|
||||||
Insert(t,0,temp);
|
Insert(t, 0, temp);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_del_array(SwigType *t) {
|
||||||
SwigType_del_array(SwigType *t) {
|
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
int check = strncmp(c,"a(",2);
|
int check = strncmp(c, "a(", 2);
|
||||||
assert(check == 0);
|
assert(check == 0);
|
||||||
Delslice(t,0,element_size(c));
|
Delslice(t, 0, element_size(c));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SwigType_isarray(SwigType *t) {
|
int SwigType_isarray(SwigType *t) {
|
||||||
char *c;
|
char *c;
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
if (strncmp(c,"a(",2) == 0) {
|
if (strncmp(c, "a(", 2) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove all arrays */
|
/* Remove all arrays */
|
||||||
SwigType *
|
SwigType *SwigType_pop_arrays(SwigType *t) {
|
||||||
SwigType_pop_arrays(SwigType *t) {
|
|
||||||
String *ta;
|
String *ta;
|
||||||
assert(SwigType_isarray(t));
|
assert(SwigType_isarray(t));
|
||||||
ta = NewStringEmpty();
|
ta = NewStringEmpty();
|
||||||
while (SwigType_isarray(t)) {
|
while (SwigType_isarray(t)) {
|
||||||
SwigType *td = SwigType_pop(t);
|
SwigType *td = SwigType_pop(t);
|
||||||
Append(ta,td);
|
Append(ta, td);
|
||||||
Delete(td);
|
Delete(td);
|
||||||
}
|
}
|
||||||
return ta;
|
return ta;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return number of array dimensions */
|
/* Return number of array dimensions */
|
||||||
int
|
int SwigType_array_ndim(SwigType *t) {
|
||||||
SwigType_array_ndim(SwigType *t) {
|
|
||||||
int ndim = 0;
|
int ndim = 0;
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
|
|
||||||
while (c && (strncmp(c,"a(",2) == 0)) {
|
while (c && (strncmp(c, "a(", 2) == 0)) {
|
||||||
c = strchr(c,'.');
|
c = strchr(c, '.');
|
||||||
c++;
|
c++;
|
||||||
ndim++;
|
ndim++;
|
||||||
}
|
}
|
||||||
|
|
@ -587,25 +585,24 @@ SwigType_array_ndim(SwigType *t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get nth array dimension */
|
/* Get nth array dimension */
|
||||||
String *
|
String *SwigType_array_getdim(SwigType *t, int n) {
|
||||||
SwigType_array_getdim(SwigType *t, int n) {
|
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
while (c && (strncmp(c,"a(",2) == 0) && (n > 0)) {
|
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
|
||||||
c = strchr(c,'.');
|
c = strchr(c, '.');
|
||||||
c++;
|
c++;
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
String *dim = SwigType_parm(c);
|
String *dim = SwigType_parm(c);
|
||||||
if (SwigType_istemplate(dim)) {
|
if (SwigType_istemplate(dim)) {
|
||||||
String *ndim = SwigType_namestr(dim);
|
String *ndim = SwigType_namestr(dim);
|
||||||
Delete(dim);
|
Delete(dim);
|
||||||
dim = ndim;
|
dim = ndim;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dim;
|
return dim;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -617,10 +614,11 @@ void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) {
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
|
|
||||||
start = c;
|
start = c;
|
||||||
if (strncmp(c,"a(",2)) abort();
|
if (strncmp(c, "a(", 2))
|
||||||
|
abort();
|
||||||
|
|
||||||
while (c && (strncmp(c,"a(",2) == 0) && (n > 0)) {
|
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
|
||||||
c = strchr(c,'.');
|
c = strchr(c, '.');
|
||||||
c++;
|
c++;
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
|
|
@ -628,19 +626,18 @@ void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) {
|
||||||
temp = *c;
|
temp = *c;
|
||||||
*c = 0;
|
*c = 0;
|
||||||
result = NewString(start);
|
result = NewString(start);
|
||||||
Printf(result,"a(%s)",rep);
|
Printf(result, "a(%s)", rep);
|
||||||
*c = temp;
|
*c = temp;
|
||||||
c = strchr(c,'.');
|
c = strchr(c, '.');
|
||||||
Append(result,c);
|
Append(result, c);
|
||||||
}
|
}
|
||||||
Clear(t);
|
Clear(t);
|
||||||
Append(t,result);
|
Append(t, result);
|
||||||
Delete(result);
|
Delete(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return base type of an array */
|
/* Return base type of an array */
|
||||||
SwigType *
|
SwigType *SwigType_array_type(SwigType *ty) {
|
||||||
SwigType_array_type(SwigType *ty) {
|
|
||||||
SwigType *t;
|
SwigType *t;
|
||||||
t = Copy(ty);
|
t = Copy(ty);
|
||||||
while (SwigType_isarray(t)) {
|
while (SwigType_isarray(t)) {
|
||||||
|
|
@ -662,72 +659,73 @@ SwigType_array_type(SwigType *ty) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Returns the function type, t, constructed from the parameters, parms */
|
/* Returns the function type, t, constructed from the parameters, parms */
|
||||||
SwigType *
|
SwigType *SwigType_add_function(SwigType *t, ParmList *parms) {
|
||||||
SwigType_add_function(SwigType *t, ParmList *parms) {
|
|
||||||
String *pstr;
|
String *pstr;
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
||||||
Insert(t,0,").");
|
Insert(t, 0, ").");
|
||||||
pstr = NewString("f(");
|
pstr = NewString("f(");
|
||||||
p = parms;
|
p = parms;
|
||||||
for (p = parms; p; p = nextSibling(p)) {
|
for (p = parms; p; p = nextSibling(p)) {
|
||||||
if (p != parms) Putc(',',pstr);
|
if (p != parms)
|
||||||
Append(pstr, Getattr(p,k_type));
|
Putc(',', pstr);
|
||||||
|
Append(pstr, Getattr(p, k_type));
|
||||||
}
|
}
|
||||||
Insert(t,0,pstr);
|
Insert(t, 0, pstr);
|
||||||
Delete(pstr);
|
Delete(pstr);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_pop_function(SwigType *t) {
|
||||||
SwigType_pop_function(SwigType *t) {
|
|
||||||
SwigType *f = 0;
|
SwigType *f = 0;
|
||||||
SwigType *g = 0;
|
SwigType *g = 0;
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
if (strncmp(c,"q(",2) == 0) {
|
if (strncmp(c, "q(", 2) == 0) {
|
||||||
f = SwigType_pop(t);
|
f = SwigType_pop(t);
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
}
|
}
|
||||||
if (strncmp(c,"f(",2)) {
|
if (strncmp(c, "f(", 2)) {
|
||||||
printf("Fatal error. SwigType_pop_function applied to non-function.\n");
|
printf("Fatal error. SwigType_pop_function applied to non-function.\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
g = SwigType_pop(t);
|
g = SwigType_pop(t);
|
||||||
if (f) SwigType_push(g,f);
|
if (f)
|
||||||
|
SwigType_push(g, f);
|
||||||
Delete(f);
|
Delete(f);
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int SwigType_isfunction(SwigType *t) {
|
||||||
SwigType_isfunction(SwigType *t) {
|
|
||||||
char *c;
|
char *c;
|
||||||
if (!t) {
|
if (!t) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
if (strncmp(c,"q(",2) == 0) {
|
if (strncmp(c, "q(", 2) == 0) {
|
||||||
/* Might be a 'const' function. Try to skip over the 'const' */
|
/* Might be a 'const' function. Try to skip over the 'const' */
|
||||||
c = strchr(c,'.');
|
c = strchr(c, '.');
|
||||||
if (c) c++;
|
if (c)
|
||||||
else return 0;
|
c++;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
if (strncmp(c,"f(",2) == 0) {
|
if (strncmp(c, "f(", 2) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParmList *
|
ParmList *SwigType_function_parms(SwigType *t) {
|
||||||
SwigType_function_parms(SwigType *t) {
|
|
||||||
List *l = SwigType_parmlist(t);
|
List *l = SwigType_parmlist(t);
|
||||||
Hash *p, *pp = 0, *firstp = 0;
|
Hash *p, *pp = 0, *firstp = 0;
|
||||||
Iterator o;
|
Iterator o;
|
||||||
|
|
||||||
for (o = First(l); o.item; o = Next(o)) {
|
for (o = First(l); o.item; o = Next(o)) {
|
||||||
p = NewParm(o.item,0);
|
p = NewParm(o.item, 0);
|
||||||
if (!firstp) firstp = p;
|
if (!firstp)
|
||||||
|
firstp = p;
|
||||||
if (pp) {
|
if (pp) {
|
||||||
set_nextSibling(pp,p);
|
set_nextSibling(pp, p);
|
||||||
Delete(p);
|
Delete(p);
|
||||||
}
|
}
|
||||||
pp = p;
|
pp = p;
|
||||||
|
|
@ -737,7 +735,8 @@ SwigType_function_parms(SwigType *t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int SwigType_isvarargs(const SwigType *t) {
|
int SwigType_isvarargs(const SwigType *t) {
|
||||||
if (Strcmp(t,"v(...)") == 0) return 1;
|
if (Strcmp(t, "v(...)") == 0)
|
||||||
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -758,24 +757,25 @@ int SwigType_isvarargs(const SwigType *t) {
|
||||||
* vector<int *> ----> "vector<(p.int)>"
|
* vector<int *> ----> "vector<(p.int)>"
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_add_template(SwigType *t, ParmList *parms) {
|
||||||
SwigType_add_template(SwigType *t, ParmList *parms) {
|
Parm *p;
|
||||||
Parm *p;
|
|
||||||
|
|
||||||
Append(t,"<(");
|
Append(t, "<(");
|
||||||
p = parms;
|
p = parms;
|
||||||
for (p = parms; p; p = nextSibling(p)) {
|
for (p = parms; p; p = nextSibling(p)) {
|
||||||
String *v;
|
String *v;
|
||||||
if (Getattr(p,k_default)) continue;
|
if (Getattr(p, k_default))
|
||||||
if (p != parms) Append(t,",");
|
continue;
|
||||||
v = Getattr(p,k_value);
|
if (p != parms)
|
||||||
|
Append(t, ",");
|
||||||
|
v = Getattr(p, k_value);
|
||||||
if (v) {
|
if (v) {
|
||||||
Append(t,v);
|
Append(t, v);
|
||||||
} else {
|
} else {
|
||||||
Append(t,Getattr(p,k_type));
|
Append(t, Getattr(p, k_type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Append(t,")>");
|
Append(t, ")>");
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -791,11 +791,10 @@ SwigType_add_template(SwigType *t, ParmList *parms) {
|
||||||
* Results in "Foo"
|
* Results in "Foo"
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *SwigType_templateprefix(const SwigType *t) {
|
||||||
SwigType_templateprefix(const SwigType *t) {
|
|
||||||
const char *s = Char(t);
|
const char *s = Char(t);
|
||||||
const char *c = strstr(s,"<(");
|
const char *c = strstr(s, "<(");
|
||||||
return c ? NewStringWithSize(s, c-s) : NewString(s);
|
return c ? NewStringWithSize(s, c - s) : NewString(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -809,17 +808,18 @@ SwigType_templateprefix(const SwigType *t) {
|
||||||
* returns "::bar"
|
* returns "::bar"
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *SwigType_templatesuffix(const SwigType *t) {
|
||||||
SwigType_templatesuffix(const SwigType *t) {
|
|
||||||
const char *c;
|
const char *c;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if ((*c == '<') && (*(c+1) == '(')) {
|
if ((*c == '<') && (*(c + 1) == '(')) {
|
||||||
int nest = 1;
|
int nest = 1;
|
||||||
c++;
|
c++;
|
||||||
while (*c && nest) {
|
while (*c && nest) {
|
||||||
if (*c == '<') nest++;
|
if (*c == '<')
|
||||||
if (*c == '>') nest--;
|
nest++;
|
||||||
|
if (*c == '>')
|
||||||
|
nest--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
return NewString(c);
|
return NewString(c);
|
||||||
|
|
@ -835,22 +835,23 @@ SwigType_templatesuffix(const SwigType *t) {
|
||||||
* Returns the template part
|
* Returns the template part
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *SwigType_templateargs(const SwigType *t) {
|
||||||
SwigType_templateargs(const SwigType *t) {
|
|
||||||
const char *c;
|
const char *c;
|
||||||
const char *start;
|
const char *start;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if ((*c == '<') && (*(c+1) == '(')) {
|
if ((*c == '<') && (*(c + 1) == '(')) {
|
||||||
int nest = 1;
|
int nest = 1;
|
||||||
start = c;
|
start = c;
|
||||||
c++;
|
c++;
|
||||||
while (*c && nest) {
|
while (*c && nest) {
|
||||||
if (*c == '<') nest++;
|
if (*c == '<')
|
||||||
if (*c == '>') nest--;
|
nest++;
|
||||||
|
if (*c == '>')
|
||||||
|
nest--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
return NewStringWithSize(start,c-start);
|
return NewStringWithSize(start, c - start);
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
@ -863,10 +864,10 @@ SwigType_templateargs(const SwigType *t) {
|
||||||
* Tests a type to see if it includes template parameters
|
* Tests a type to see if it includes template parameters
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int SwigType_istemplate(const SwigType *t) {
|
||||||
SwigType_istemplate(const SwigType *t) {
|
|
||||||
char *ct = Char(t);
|
char *ct = Char(t);
|
||||||
if ((ct = strstr(ct,"<(")) && (strstr(ct + 2,")>"))) return 1;
|
if ((ct = strstr(ct, "<(")) && (strstr(ct + 2, ")>")))
|
||||||
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -877,8 +878,7 @@ SwigType_istemplate(const SwigType *t) {
|
||||||
* type "p.p.int", the function would return "int".
|
* type "p.p.int", the function would return "int".
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_base(const SwigType *t) {
|
||||||
SwigType_base(const SwigType *t) {
|
|
||||||
char *c;
|
char *c;
|
||||||
char *lastop = 0;
|
char *lastop = 0;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
|
|
@ -888,8 +888,8 @@ SwigType_base(const SwigType *t) {
|
||||||
/* Search for the last type constructor separator '.' */
|
/* Search for the last type constructor separator '.' */
|
||||||
while (*c) {
|
while (*c) {
|
||||||
if (*c == '.') {
|
if (*c == '.') {
|
||||||
if (*(c+1)) {
|
if (*(c + 1)) {
|
||||||
lastop = c+1;
|
lastop = c + 1;
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -899,11 +899,14 @@ SwigType_base(const SwigType *t) {
|
||||||
int ntemp = 1;
|
int ntemp = 1;
|
||||||
c++;
|
c++;
|
||||||
while ((*c) && (ntemp > 0)) {
|
while ((*c) && (ntemp > 0)) {
|
||||||
if (*c == '>') ntemp--;
|
if (*c == '>')
|
||||||
else if (*c == '<') ntemp++;
|
ntemp--;
|
||||||
|
else if (*c == '<')
|
||||||
|
ntemp++;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
if (ntemp) break;
|
if (ntemp)
|
||||||
|
break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (*c == '(') {
|
if (*c == '(') {
|
||||||
|
|
@ -911,11 +914,14 @@ SwigType_base(const SwigType *t) {
|
||||||
int nparen = 1;
|
int nparen = 1;
|
||||||
c++;
|
c++;
|
||||||
while ((*c) && (nparen > 0)) {
|
while ((*c) && (nparen > 0)) {
|
||||||
if (*c == '(') nparen++;
|
if (*c == '(')
|
||||||
else if (*c == ')') nparen--;
|
nparen++;
|
||||||
|
else if (*c == ')')
|
||||||
|
nparen--;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
if (nparen) break;
|
if (nparen)
|
||||||
|
break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
c++;
|
c++;
|
||||||
|
|
@ -930,8 +936,7 @@ SwigType_base(const SwigType *t) {
|
||||||
* type "p.p.int" is "p.p.".
|
* type "p.p.int" is "p.p.".
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *SwigType_prefix(const SwigType *t) {
|
||||||
SwigType_prefix(const SwigType *t) {
|
|
||||||
char *c, *d;
|
char *c, *d;
|
||||||
String *r = 0;
|
String *r = 0;
|
||||||
|
|
||||||
|
|
@ -939,7 +944,8 @@ SwigType_prefix(const SwigType *t) {
|
||||||
d = c + strlen(c);
|
d = c + strlen(c);
|
||||||
|
|
||||||
/* Check for a type constructor */
|
/* Check for a type constructor */
|
||||||
if ((d > c) && (*(d-1) == '.')) d--;
|
if ((d > c) && (*(d - 1) == '.'))
|
||||||
|
d--;
|
||||||
|
|
||||||
while (d > c) {
|
while (d > c) {
|
||||||
d--;
|
d--;
|
||||||
|
|
@ -947,8 +953,10 @@ SwigType_prefix(const SwigType *t) {
|
||||||
int nest = 1;
|
int nest = 1;
|
||||||
d--;
|
d--;
|
||||||
while ((d > c) && (nest)) {
|
while ((d > c) && (nest)) {
|
||||||
if (*d == '>') nest++;
|
if (*d == '>')
|
||||||
if (*d == '<') nest--;
|
nest++;
|
||||||
|
if (*d == '<')
|
||||||
|
nest--;
|
||||||
d--;
|
d--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -957,17 +965,19 @@ SwigType_prefix(const SwigType *t) {
|
||||||
int nparen = 1;
|
int nparen = 1;
|
||||||
d--;
|
d--;
|
||||||
while ((d > c) && (nparen)) {
|
while ((d > c) && (nparen)) {
|
||||||
if (*d == ')') nparen++;
|
if (*d == ')')
|
||||||
if (*d == '(') nparen--;
|
nparen++;
|
||||||
|
if (*d == '(')
|
||||||
|
nparen--;
|
||||||
d--;
|
d--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*d == '.') {
|
if (*d == '.') {
|
||||||
char t = *(d+1);
|
char t = *(d + 1);
|
||||||
*(d+1) = 0;
|
*(d + 1) = 0;
|
||||||
r = NewString(c);
|
r = NewString(c);
|
||||||
*(d+1) = t;
|
*(d + 1) = t;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -980,34 +990,34 @@ SwigType_prefix(const SwigType *t) {
|
||||||
* Strip all qualifiers from a type and return a new type
|
* Strip all qualifiers from a type and return a new type
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *
|
SwigType *SwigType_strip_qualifiers(SwigType *t) {
|
||||||
SwigType_strip_qualifiers(SwigType *t) {
|
|
||||||
static Hash *memoize_stripped = 0;
|
static Hash *memoize_stripped = 0;
|
||||||
SwigType *r;
|
SwigType *r;
|
||||||
List *l;
|
List *l;
|
||||||
Iterator ei;
|
Iterator ei;
|
||||||
|
|
||||||
|
if (!memoize_stripped)
|
||||||
|
memoize_stripped = NewHash();
|
||||||
|
r = Getattr(memoize_stripped, t);
|
||||||
|
if (r)
|
||||||
|
return Copy(r);
|
||||||
|
|
||||||
if (!memoize_stripped) memoize_stripped = NewHash();
|
|
||||||
r = Getattr(memoize_stripped,t);
|
|
||||||
if (r) return Copy(r);
|
|
||||||
|
|
||||||
l = SwigType_split(t);
|
l = SwigType_split(t);
|
||||||
r = NewStringEmpty();
|
r = NewStringEmpty();
|
||||||
|
|
||||||
for (ei = First(l);ei.item; ei = Next(ei)) {
|
for (ei = First(l); ei.item; ei = Next(ei)) {
|
||||||
if (SwigType_isqualifier(ei.item)) continue;
|
if (SwigType_isqualifier(ei.item))
|
||||||
Append(r,ei.item);
|
continue;
|
||||||
|
Append(r, ei.item);
|
||||||
}
|
}
|
||||||
Delete(l);
|
Delete(l);
|
||||||
{
|
{
|
||||||
String *key, *value;
|
String *key, *value;
|
||||||
key = Copy(t);
|
key = Copy(t);
|
||||||
value = Copy(r);
|
value = Copy(r);
|
||||||
Setattr(memoize_stripped,key,value);
|
Setattr(memoize_stripped, key, value);
|
||||||
Delete(key);
|
Delete(key);
|
||||||
Delete(value);
|
Delete(value);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -20,21 +20,15 @@ static Hash *warnings = 0;
|
||||||
* Issue a warning
|
* Issue a warning
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Swig_warn(const char *filename, int line, const char *msg) {
|
||||||
Swig_warn(const char *filename, int line, const char *msg) {
|
|
||||||
String *key;
|
String *key;
|
||||||
if (!warnings) {
|
if (!warnings) {
|
||||||
warnings = NewHash();
|
warnings = NewHash();
|
||||||
}
|
}
|
||||||
key = NewStringf("%s:%d", filename,line);
|
key = NewStringf("%s:%d", filename, line);
|
||||||
if (!Getattr(warnings,key)) {
|
if (!Getattr(warnings, key)) {
|
||||||
Printf(stderr,"swig-dev warning:%s:%d:%s\n", filename, line, msg);
|
Printf(stderr, "swig-dev warning:%s:%d:%s\n", filename, line, msg);
|
||||||
Setattr(warnings,key,key);
|
Setattr(warnings, key, key);
|
||||||
}
|
}
|
||||||
Delete(key);
|
Delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ char cvsroot_wrapfunc_c[] = "$Header$";
|
||||||
#include "swig.h"
|
#include "swig.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static int Compact_mode = 0; /* set to 0 on default */
|
static int Compact_mode = 0; /* set to 0 on default */
|
||||||
static int Max_line_size = 128;
|
static int Max_line_size = 128;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -23,8 +23,7 @@ static int Max_line_size = 128;
|
||||||
* Create a new wrapper function object.
|
* Create a new wrapper function object.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
Wrapper *
|
Wrapper *NewWrapper() {
|
||||||
NewWrapper() {
|
|
||||||
Wrapper *w;
|
Wrapper *w;
|
||||||
w = (Wrapper *) malloc(sizeof(Wrapper));
|
w = (Wrapper *) malloc(sizeof(Wrapper));
|
||||||
w->localh = NewHash();
|
w->localh = NewHash();
|
||||||
|
|
@ -40,8 +39,7 @@ NewWrapper() {
|
||||||
* Delete a wrapper function object.
|
* Delete a wrapper function object.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void DelWrapper(Wrapper *w) {
|
||||||
DelWrapper(Wrapper *w) {
|
|
||||||
Delete(w->localh);
|
Delete(w->localh);
|
||||||
Delete(w->locals);
|
Delete(w->locals);
|
||||||
Delete(w->code);
|
Delete(w->code);
|
||||||
|
|
@ -55,8 +53,7 @@ DelWrapper(Wrapper *w) {
|
||||||
* Set compact_mode.
|
* Set compact_mode.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Wrapper_compact_print_mode_set(int flag) {
|
||||||
Wrapper_compact_print_mode_set(int flag) {
|
|
||||||
Compact_mode = flag;
|
Compact_mode = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,8 +63,7 @@ Wrapper_compact_print_mode_set(int flag) {
|
||||||
* Formats a wrapper function and fixes up the indentation.
|
* Formats a wrapper function and fixes up the indentation.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Wrapper_pretty_print(String *str, File *f) {
|
||||||
Wrapper_pretty_print(String *str, File *f) {
|
|
||||||
String *ts;
|
String *ts;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
int c, i;
|
int c, i;
|
||||||
|
|
@ -77,127 +73,132 @@ Wrapper_pretty_print(String *str, File *f) {
|
||||||
int label = 0;
|
int label = 0;
|
||||||
|
|
||||||
ts = NewStringEmpty();
|
ts = NewStringEmpty();
|
||||||
Seek(str,0, SEEK_SET);
|
Seek(str, 0, SEEK_SET);
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (c == '\"') {
|
if (c == '\"') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
c = Getc(str);
|
c = Getc(str);
|
||||||
}
|
}
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
if (c == '\"') break;
|
if (c == '\"')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
empty = 0;
|
empty = 0;
|
||||||
} else if (c == '\'') {
|
} else if (c == '\'') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
c = Getc(str);
|
c = Getc(str);
|
||||||
}
|
}
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
if (c == '\'') break;
|
if (c == '\'')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
empty = 0;
|
empty = 0;
|
||||||
} else if (c == ':') {
|
} else if (c == ':') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
if ((c = Getc(str)) == '\n') {
|
if ((c = Getc(str)) == '\n') {
|
||||||
if (!empty && !strchr(Char(ts),'?')) label = 1;
|
if (!empty && !strchr(Char(ts), '?'))
|
||||||
|
label = 1;
|
||||||
}
|
}
|
||||||
Ungetc(c,str);
|
Ungetc(c, str);
|
||||||
} else if (c == '(') {
|
} else if (c == '(') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
plevel+=indent;
|
plevel += indent;
|
||||||
empty = 0;
|
empty = 0;
|
||||||
} else if (c == ')') {
|
} else if (c == ')') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
plevel-=indent;
|
plevel -= indent;
|
||||||
empty = 0;
|
empty = 0;
|
||||||
} else if (c == '{') {
|
} else if (c == '{') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
Putc('\n',ts);
|
Putc('\n', ts);
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',f);
|
Putc(' ', f);
|
||||||
Printf(f,"%s", ts);
|
Printf(f, "%s", ts);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
level+=indent;
|
level += indent;
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (!isspace(c)) {
|
if (!isspace(c)) {
|
||||||
Ungetc(c,str);
|
Ungetc(c, str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
empty = 0;
|
empty = 0;
|
||||||
} else if (c == '}') {
|
} else if (c == '}') {
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
Putc('\n',ts);
|
Putc('\n', ts);
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',f);
|
Putc(' ', f);
|
||||||
Printf(f,"%s",ts);
|
Printf(f, "%s", ts);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
}
|
}
|
||||||
level-=indent;
|
level -= indent;
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
empty = 0;
|
empty = 0;
|
||||||
} else if (c == '\n') {
|
} else if (c == '\n') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
empty = 0;
|
empty = 0;
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
int slevel = level;
|
int slevel = level;
|
||||||
if (label && (slevel >= indent)) slevel -= indent;
|
if (label && (slevel >= indent))
|
||||||
|
slevel -= indent;
|
||||||
if ((Char(ts))[0] != '#') {
|
if ((Char(ts))[0] != '#') {
|
||||||
for (i = 0; i < slevel; i++)
|
for (i = 0; i < slevel; i++)
|
||||||
Putc(' ',f);
|
Putc(' ', f);
|
||||||
}
|
}
|
||||||
Printf(f,"%s",ts);
|
Printf(f, "%s", ts);
|
||||||
for (i = 0; i < plevel; i++)
|
for (i = 0; i < plevel; i++)
|
||||||
Putc(' ',f);
|
Putc(' ', f);
|
||||||
}
|
}
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
label = 0;
|
label = 0;
|
||||||
empty = 1;
|
empty = 1;
|
||||||
} else if (c == '/') {
|
} else if (c == '/') {
|
||||||
empty = 0;
|
empty = 0;
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
c = Getc(str);
|
c = Getc(str);
|
||||||
if (c != EOF) {
|
if (c != EOF) {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
if (c == '/') { /* C++ comment */
|
if (c == '/') { /* C++ comment */
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
Ungetc(c,str);
|
Ungetc(c, str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
}
|
}
|
||||||
} else if (c == '*') { /* C comment */
|
} else if (c == '*') { /* C comment */
|
||||||
int endstar = 0;
|
int endstar = 0;
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (endstar && c == '/') { /* end of C comment */
|
if (endstar && c == '/') { /* end of C comment */
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
endstar = (c == '*');
|
endstar = (c == '*');
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
if (c == '\n') { /* multi-line C comment. Could be improved slightly. */
|
if (c == '\n') { /* multi-line C comment. Could be improved slightly. */
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',ts);
|
Putc(' ', ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!empty || !isspace(c)) {
|
if (!empty || !isspace(c)) {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
empty = 0;
|
empty = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty) Printf(f,"%s",ts);
|
if (!empty)
|
||||||
|
Printf(f, "%s", ts);
|
||||||
Delete(ts);
|
Delete(ts);
|
||||||
Printf(f,"\n");
|
Printf(f, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -207,9 +208,8 @@ Wrapper_pretty_print(String *str, File *f) {
|
||||||
* Print out in compact format, with Compact enabled.
|
* Print out in compact format, with Compact enabled.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Wrapper_compact_print(String *str, File *f) {
|
||||||
Wrapper_compact_print(String *str, File *f) {
|
String *ts, *tf; /*temp string & temp file */
|
||||||
String *ts, *tf; /*temp string & temp file */
|
|
||||||
int level = 0;
|
int level = 0;
|
||||||
int c, i;
|
int c, i;
|
||||||
int empty = 1;
|
int empty = 1;
|
||||||
|
|
@ -217,163 +217,165 @@ Wrapper_compact_print(String *str, File *f) {
|
||||||
|
|
||||||
ts = NewStringEmpty();
|
ts = NewStringEmpty();
|
||||||
tf = NewStringEmpty();
|
tf = NewStringEmpty();
|
||||||
Seek(str,0, SEEK_SET);
|
Seek(str, 0, SEEK_SET);
|
||||||
|
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (c == '\"') { /* string 1 */
|
if (c == '\"') { /* string 1 */
|
||||||
empty = 0;
|
empty = 0;
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
c = Getc(str);
|
c = Getc(str);
|
||||||
}
|
}
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
if (c == '\"') break;
|
if (c == '\"')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (c == '\'') { /* string 2 */
|
} else if (c == '\'') { /* string 2 */
|
||||||
empty = 0;
|
empty = 0;
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
c = Getc(str);
|
c = Getc(str);
|
||||||
}
|
}
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
if (c == '\'') break;
|
if (c == '\'')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (c == '{') { /* start of {...} */
|
} else if (c == '{') { /* start of {...} */
|
||||||
empty = 0;
|
empty = 0;
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
if (Len(tf) == 0) {
|
if (Len(tf) == 0) {
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
|
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
} else {
|
} else {
|
||||||
Putc('\n',tf);
|
Putc('\n', tf);
|
||||||
Printf(f,"%s", tf);
|
Printf(f, "%s", tf);
|
||||||
Clear(tf);
|
Clear(tf);
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
}
|
}
|
||||||
Append(tf,ts);
|
Append(tf, ts);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
level+=indent;
|
level += indent;
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (!isspace(c)) {
|
if (!isspace(c)) {
|
||||||
Ungetc(c,str);
|
Ungetc(c, str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (c == '}') { /* end of {...} */
|
} else if (c == '}') { /* end of {...} */
|
||||||
empty = 0;
|
empty = 0;
|
||||||
if (Len(tf) == 0) {
|
if (Len(tf) == 0) {
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
|
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
} else {
|
} else {
|
||||||
Putc('\n',tf);
|
Putc('\n', tf);
|
||||||
Printf(f,"%s", tf);
|
Printf(f, "%s", tf);
|
||||||
Clear(tf);
|
Clear(tf);
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
}
|
}
|
||||||
Append(tf, ts);
|
Append(tf, ts);
|
||||||
Putc(c, tf);
|
Putc(c, tf);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
level-=indent;
|
level -= indent;
|
||||||
} else if (c == '\n') { /* line end */
|
} else if (c == '\n') { /* line end */
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (!isspace(c))
|
if (!isspace(c))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (c == '#'){
|
if (c == '#') {
|
||||||
Putc('\n',ts);
|
Putc('\n', ts);
|
||||||
} else if (c == '}') {
|
} else if (c == '}') {
|
||||||
Putc(' ',ts);
|
Putc(' ', ts);
|
||||||
} else if ( (c != EOF) || (Len(ts)!=0) ){
|
} else if ((c != EOF) || (Len(ts) != 0)) {
|
||||||
if (Len(tf) == 0) {
|
if (Len(tf) == 0) {
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
|
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
} else {
|
} else {
|
||||||
Putc('\n',tf);
|
Putc('\n', tf);
|
||||||
Printf(f,"%s", tf);
|
Printf(f, "%s", tf);
|
||||||
Clear(tf);
|
Clear(tf);
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
}
|
}
|
||||||
Append(tf,ts);
|
Append(tf, ts);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
}
|
}
|
||||||
Ungetc(c,str);
|
Ungetc(c, str);
|
||||||
|
|
||||||
empty = 1;
|
empty = 1;
|
||||||
} else if (c == '/') { /* comment */
|
} else if (c == '/') { /* comment */
|
||||||
empty = 0;
|
empty = 0;
|
||||||
c = Getc(str);
|
c = Getc(str);
|
||||||
if (c != EOF) {
|
if (c != EOF) {
|
||||||
if (c == '/') { /* C++ comment */
|
if (c == '/') { /* C++ comment */
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
Ungetc(c,str);
|
Ungetc(c, str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (c == '*') { /* C comment */
|
} else if (c == '*') { /* C comment */
|
||||||
int endstar = 0;
|
int endstar = 0;
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
if (endstar && c == '/') { /* end of C comment */
|
if (endstar && c == '/') { /* end of C comment */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
endstar = (c == '*');
|
endstar = (c == '*');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Putc('/',ts);
|
Putc('/', ts);
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (c == '#') { /* Preprocessor line */
|
} else if (c == '#') { /* Preprocessor line */
|
||||||
Putc('#', ts);
|
Putc('#', ts);
|
||||||
while ((c = Getc(str)) != EOF) {
|
while ((c = Getc(str)) != EOF) {
|
||||||
Putc(c, ts);
|
Putc(c, ts);
|
||||||
if (c == '\\') { /* Continued line of the same PP */
|
if (c == '\\') { /* Continued line of the same PP */
|
||||||
c = Getc(str);
|
c = Getc(str);
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
Putc(c, ts);
|
Putc(c, ts);
|
||||||
else
|
else
|
||||||
Ungetc(c, str);
|
Ungetc(c, str);
|
||||||
} else if (c == '\n')
|
} else if (c == '\n')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
Append(tf,"\n");
|
Append(tf, "\n");
|
||||||
}
|
}
|
||||||
Append(tf,ts);
|
Append(tf, ts);
|
||||||
Printf(f, "%s", tf);
|
Printf(f, "%s", tf);
|
||||||
Clear(tf);
|
Clear(tf);
|
||||||
Clear(ts);
|
Clear(ts);
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
Putc(' ',tf);
|
Putc(' ', tf);
|
||||||
empty = 1;
|
empty = 1;
|
||||||
} else {
|
} else {
|
||||||
if (!empty || !isspace(c)) {
|
if (!empty || !isspace(c)) {
|
||||||
Putc(c,ts);
|
Putc(c, ts);
|
||||||
empty = 0;
|
empty = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
Append(tf,ts);
|
Append(tf, ts);
|
||||||
}
|
}
|
||||||
if (Len(tf) != 0)
|
if (Len(tf) != 0)
|
||||||
Printf(f,"%s",tf);
|
Printf(f, "%s", tf);
|
||||||
Delete(ts);
|
Delete(ts);
|
||||||
Delete(tf);
|
Delete(tf);
|
||||||
Printf(f,"\n");
|
Printf(f, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -382,18 +384,17 @@ Wrapper_compact_print(String *str, File *f) {
|
||||||
* Print out a wrapper function. Does pretty or compact printing as well.
|
* Print out a wrapper function. Does pretty or compact printing as well.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void Wrapper_print(Wrapper *w, File *f) {
|
||||||
Wrapper_print(Wrapper *w, File *f) {
|
|
||||||
String *str;
|
String *str;
|
||||||
|
|
||||||
str = NewStringEmpty();
|
str = NewStringEmpty();
|
||||||
Printf(str,"%s\n", w->def);
|
Printf(str, "%s\n", w->def);
|
||||||
Printf(str,"%s\n", w->locals);
|
Printf(str, "%s\n", w->locals);
|
||||||
Printf(str,"%s\n", w->code);
|
Printf(str, "%s\n", w->code);
|
||||||
if (Compact_mode == 1)
|
if (Compact_mode == 1)
|
||||||
Wrapper_compact_print(str,f);
|
Wrapper_compact_print(str, f);
|
||||||
else
|
else
|
||||||
Wrapper_pretty_print(str,f);
|
Wrapper_pretty_print(str, f);
|
||||||
|
|
||||||
Delete(str);
|
Delete(str);
|
||||||
}
|
}
|
||||||
|
|
@ -405,14 +406,13 @@ Wrapper_print(Wrapper *w, File *f) {
|
||||||
* present (which may or may not be okay to the caller).
|
* present (which may or may not be okay to the caller).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
|
||||||
Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
|
|
||||||
/* See if the local has already been declared */
|
/* See if the local has already been declared */
|
||||||
if (Getattr(w->localh,name)) {
|
if (Getattr(w->localh, name)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Setattr(w->localh,name,decl);
|
Setattr(w->localh, name, decl);
|
||||||
Printf(w->locals,"%s;\n", decl);
|
Printf(w->locals, "%s;\n", decl);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -424,24 +424,23 @@ Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *
|
||||||
* to manually construct the 'decl' string before calling.
|
* to manually construct the 'decl' string before calling.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
|
||||||
Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret;
|
int ret;
|
||||||
String *decl;
|
String *decl;
|
||||||
DOH *obj;
|
DOH *obj;
|
||||||
decl = NewStringEmpty();
|
decl = NewStringEmpty();
|
||||||
va_start(ap,name);
|
va_start(ap, name);
|
||||||
|
|
||||||
obj = va_arg(ap,void *);
|
obj = va_arg(ap, void *);
|
||||||
while (obj) {
|
while (obj) {
|
||||||
Append(decl,obj);
|
Append(decl, obj);
|
||||||
Putc(' ', decl);
|
Putc(' ', decl);
|
||||||
obj = va_arg(ap, void *);
|
obj = va_arg(ap, void *);
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
ret = Wrapper_add_local(w,name,decl);
|
ret = Wrapper_add_local(w, name, decl);
|
||||||
Delete(decl);
|
Delete(decl);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -452,9 +451,8 @@ Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
|
||||||
* Check to see if a local name has already been declared
|
* Check to see if a local name has already been declared
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int Wrapper_check_local(Wrapper *w, const String_or_char *name) {
|
||||||
Wrapper_check_local(Wrapper *w, const String_or_char *name) {
|
if (Getattr(w->localh, name)) {
|
||||||
if (Getattr(w->localh,name)) {
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -467,27 +465,26 @@ Wrapper_check_local(Wrapper *w, const String_or_char *name) {
|
||||||
* used. Returns the name that was actually selected.
|
* used. Returns the name that was actually selected.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *
|
char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
|
||||||
Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
|
|
||||||
int i;
|
int i;
|
||||||
String *nname = NewString(name);
|
String *nname = NewString(name);
|
||||||
String *ndecl = NewString(decl);
|
String *ndecl = NewString(decl);
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
while (Wrapper_check_local(w,nname)) {
|
while (Wrapper_check_local(w, nname)) {
|
||||||
Clear(nname);
|
Clear(nname);
|
||||||
Printf(nname,"%s%d",name,i);
|
Printf(nname, "%s%d", name, i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
Replace(ndecl, name, nname, DOH_REPLACE_ID);
|
Replace(ndecl, name, nname, DOH_REPLACE_ID);
|
||||||
Setattr(w->localh,nname,ndecl);
|
Setattr(w->localh, nname, ndecl);
|
||||||
Printf(w->locals,"%s;\n", ndecl);
|
Printf(w->locals, "%s;\n", ndecl);
|
||||||
ret = Char(nname);
|
ret = Char(nname);
|
||||||
Delete(nname);
|
Delete(nname);
|
||||||
Delete(ndecl);
|
Delete(ndecl);
|
||||||
return ret; /* Note: nname should still exists in the w->localh hash */
|
return ret; /* Note: nname should still exists in the w->localh hash */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -499,30 +496,23 @@ Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *
|
||||||
* to manually construct the 'decl' string before calling.
|
* to manually construct the 'decl' string before calling.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char *
|
char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) {
|
||||||
Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) {
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *ret;
|
char *ret;
|
||||||
String *decl;
|
String *decl;
|
||||||
DOH *obj;
|
DOH *obj;
|
||||||
decl = NewStringEmpty();
|
decl = NewStringEmpty();
|
||||||
va_start(ap,name);
|
va_start(ap, name);
|
||||||
|
|
||||||
obj = va_arg(ap,void *);
|
obj = va_arg(ap, void *);
|
||||||
while (obj) {
|
while (obj) {
|
||||||
Append(decl,obj);
|
Append(decl, obj);
|
||||||
Putc(' ',decl);
|
Putc(' ', decl);
|
||||||
obj = va_arg(ap, void *);
|
obj = va_arg(ap, void *);
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
ret = Wrapper_new_local(w,name,decl);
|
ret = Wrapper_new_local(w, name, decl);
|
||||||
Delete(decl);
|
Delete(decl);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue