Java directors implementation contributed by Scott Michel.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5075 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
029cd11a67
commit
f87e2f574a
6 changed files with 1211 additions and 35 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -202,6 +202,16 @@ Language::Language() {
|
||||||
symbols = NewHash();
|
symbols = NewHash();
|
||||||
classtypes = NewHash();
|
classtypes = NewHash();
|
||||||
none_comparison = NewString("$arg != 0");
|
none_comparison = NewString("$arg != 0");
|
||||||
|
director_ctor_code = NewString("");
|
||||||
|
|
||||||
|
/* Default director constructor code, passed to Swig_ConstructorToFunction */
|
||||||
|
Printv(director_ctor_code,
|
||||||
|
"if ( $comparison ) { /*subclassed */\n",
|
||||||
|
" $director_new \n",
|
||||||
|
"} else {\n",
|
||||||
|
" $nondirector_new \n",
|
||||||
|
"}\n", NIL);
|
||||||
|
|
||||||
overloading = 0;
|
overloading = 0;
|
||||||
multiinput = 0;
|
multiinput = 0;
|
||||||
directors = 0;
|
directors = 0;
|
||||||
|
|
@ -1609,11 +1619,7 @@ int Language::classDeclaration(Node *n) {
|
||||||
InClass = 1;
|
InClass = 1;
|
||||||
CurrentClass = n;
|
CurrentClass = n;
|
||||||
|
|
||||||
if (Getattr(n,"abstract")) {
|
Abstract = (Getattr(n,"abstract") ? 1 : 0);
|
||||||
Abstract = 1;
|
|
||||||
} else {
|
|
||||||
Abstract = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Call classHandler() here */
|
/* Call classHandler() here */
|
||||||
if (!ImportMode) {
|
if (!ImportMode) {
|
||||||
|
|
@ -1767,7 +1773,7 @@ Language::constructorHandler(Node *n) {
|
||||||
|
|
||||||
mrename = Swig_name_construct(symname);
|
mrename = Swig_name_construct(symname);
|
||||||
if (CPlusPlus) patch_parms(parms);
|
if (CPlusPlus) patch_parms(parms);
|
||||||
Swig_ConstructorToFunction(n, ClassType, none_comparison, CPlusPlus, Getattr(n, "template") ? 0 :Extend);
|
Swig_ConstructorToFunction(n, ClassType, none_comparison, director_ctor_code, CPlusPlus, Getattr(n, "template") ? 0 :Extend);
|
||||||
Setattr(n,"sym:name", mrename);
|
Setattr(n,"sym:name", mrename);
|
||||||
functionWrapper(n);
|
functionWrapper(n);
|
||||||
Delete(mrename);
|
Delete(mrename);
|
||||||
|
|
@ -1787,7 +1793,7 @@ Language::copyconstructorHandler(Node *n) {
|
||||||
Parm *parms = Getattr(n,"parms");
|
Parm *parms = Getattr(n,"parms");
|
||||||
if (CPlusPlus) patch_parms(parms);
|
if (CPlusPlus) patch_parms(parms);
|
||||||
mrename = Swig_name_copyconstructor(symname);
|
mrename = Swig_name_copyconstructor(symname);
|
||||||
Swig_ConstructorToFunction(n,ClassType, none_comparison,
|
Swig_ConstructorToFunction(n,ClassType, none_comparison, director_ctor_code,
|
||||||
CPlusPlus, Getattr(n,"template") ? 0 : Extend);
|
CPlusPlus, Getattr(n,"template") ? 0 : Extend);
|
||||||
Setattr(n,"sym:name", mrename);
|
Setattr(n,"sym:name", mrename);
|
||||||
functionWrapper(n);
|
functionWrapper(n);
|
||||||
|
|
|
||||||
|
|
@ -1826,6 +1826,9 @@ public:
|
||||||
|
|
||||||
p = NewParm(NewString("int"), NewString("__disown"));
|
p = NewParm(NewString("int"), NewString("__disown"));
|
||||||
Setattr(p, "CAML_VALUE", "1");
|
Setattr(p, "CAML_VALUE", "1");
|
||||||
|
Setattr(n, "director:postfix_args", p);
|
||||||
|
Setattr(p, "args:byname", "1");
|
||||||
|
Setattr(p, "value", "0");
|
||||||
set_nextSibling(ip, p);
|
set_nextSibling(ip, p);
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,6 @@ public:
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int top(Node *n) {
|
virtual int top(Node *n) {
|
||||||
|
|
||||||
/* check if directors are enabled for this module. note: this
|
/* check if directors are enabled for this module. note: this
|
||||||
* is a "master" switch, without which no director code will be
|
* is a "master" switch, without which no director code will be
|
||||||
* emitted. %feature("director") statements are also required
|
* emitted. %feature("director") statements are also required
|
||||||
|
|
@ -444,7 +443,7 @@ public:
|
||||||
Printf(f_runtime,"#define SWIG_DIRECTORS\n");
|
Printf(f_runtime,"#define SWIG_DIRECTORS\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set module name */
|
/* Set module name */
|
||||||
module = Copy(Getattr(n,"name"));
|
module = Copy(Getattr(n,"name"));
|
||||||
mainmodule = Getattr(n,"name");
|
mainmodule = Getattr(n,"name");
|
||||||
|
|
||||||
|
|
@ -1629,7 +1628,9 @@ public:
|
||||||
parms = p;
|
parms = p;
|
||||||
for (ip = parms; nextSibling(ip); ) ip = nextSibling(ip);
|
for (ip = parms; nextSibling(ip); ) ip = nextSibling(ip);
|
||||||
p = NewParm(NewString("int"), NewString("__disown"));
|
p = NewParm(NewString("int"), NewString("__disown"));
|
||||||
Setattr(p, "value", "1");
|
Setattr(p, "arg:byname", "1");
|
||||||
|
Setattr(n, "director:postfix_args", p);
|
||||||
|
Setattr(p, "value", "0");
|
||||||
set_nextSibling(ip, p);
|
set_nextSibling(ip, p);
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
|
|
|
||||||
|
|
@ -2088,7 +2088,9 @@ public:
|
||||||
parms = p;
|
parms = p;
|
||||||
for (ip = parms; nextSibling(ip); ) ip = nextSibling(ip);
|
for (ip = parms; nextSibling(ip); ) ip = nextSibling(ip);
|
||||||
p = NewParm(NewString("int"), NewString("__disown"));
|
p = NewParm(NewString("int"), NewString("__disown"));
|
||||||
Setattr(p, "value", "1");
|
Setattr(p, "arg:byname", "1");
|
||||||
|
Setattr(n, "director:postfix_args", p);
|
||||||
|
Setattr(p, "value", "0");
|
||||||
set_nextSibling(ip, p);
|
set_nextSibling(ip, p);
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ 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 SmartPointer; // smart pointer methods being emitted
|
||||||
|
|
||||||
/* Miscellaneous stuff */
|
/* Miscellaneous stuff */
|
||||||
|
|
||||||
|
|
@ -238,10 +240,15 @@ public:
|
||||||
/* Return true if the current method is part of a smart-pointer */
|
/* Return true if the current method is part of a smart-pointer */
|
||||||
int is_smart_pointer() const;
|
int is_smart_pointer() const;
|
||||||
|
|
||||||
|
/* Director subclass comparison test */
|
||||||
|
String *none_comparison;
|
||||||
|
|
||||||
|
/* Director constructor "template" code */
|
||||||
|
String *director_ctor_code;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Hash *symbols;
|
Hash *symbols;
|
||||||
Hash *classtypes;
|
Hash *classtypes;
|
||||||
String *none_comparison;
|
|
||||||
int overloading;
|
int overloading;
|
||||||
int multiinput;
|
int multiinput;
|
||||||
int directors;
|
int directors;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue