The dirprot feature is now disabled by default. Added dirprot option and ruby runtime examples.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5510 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2003-12-09 02:52:08 +00:00
commit 634b973f31
11 changed files with 154 additions and 41 deletions

View file

@ -268,6 +268,9 @@ class JAVA : public Language {
if (Getattr(optionsnode, "directors")) {
allow_directors();
}
if (Getattr(optionsnode, "dirprot")) {
allow_dirprot();
}
}
/* Initialize all of the output files */

View file

@ -1720,41 +1720,43 @@ int Language::classHandler(Node *n) {
classDirectorDisown(n);
/* emit all the protected virtual members as needed */
Node *vtable = Getattr(n, "vtable");
String* symname = Getattr(n, "sym:name");
Node *item;
Iterator k;
int old_mode = cplus_mode;
cplus_mode = CPLUS_PROTECTED;
for (k = First(vtable); k.key; k = Next(k)) {
item = k.item;
String* director = Getattr(item,"director");
Node *method = Getattr(item, "methodNode");
Node* parentnode = Getattr(method, "parentNode");
String* methodname = Getattr(method,"sym:name");
String* wrapname = NewStringf("%s_%s", symname,methodname);
if (!Getattr(symbols,wrapname)
&& !Cmp(director,"1")
&& (n != parentnode)
&& is_protected(method)) {
Node* m = Copy(method);
String* mdecl = Getattr(m,"decl");
Setattr(m,"parentNode", n);
/* ugly trick, to avoid an uglier one later on emit. We take
the 'const' out from calling method to avoid the ugly const
casting latter. The casting from 'non-const' to 'const' is not
needed here, but it prevents the simple replacement of
arg1 by darg on emit.cxx.
*/
if (Strncmp(mdecl, "q(const).", 9)== 0)
Replace(mdecl,"q(const).","", DOH_REPLACE_FIRST);
cDeclaration(m);
Delete(m);
if (director_protected_mode) {
Node *vtable = Getattr(n, "vtable");
String* symname = Getattr(n, "sym:name");
Node *item;
Iterator k;
int old_mode = cplus_mode;
cplus_mode = CPLUS_PROTECTED;
for (k = First(vtable); k.key; k = Next(k)) {
item = k.item;
String* director = Getattr(item,"director");
Node *method = Getattr(item, "methodNode");
Node* parentnode = Getattr(method, "parentNode");
String* methodname = Getattr(method,"sym:name");
String* wrapname = NewStringf("%s_%s", symname,methodname);
if (!Getattr(symbols,wrapname)
&& !Cmp(director,"1")
&& (n != parentnode)
&& is_protected(method)) {
Node* m = Copy(method);
String* mdecl = Getattr(m,"decl");
Setattr(m,"parentNode", n);
/* ugly trick, to avoid an uglier one later on emit. We
take the 'const' out from calling method to avoid the
ugly const casting latter. The casting from 'non-const'
to 'const' is not needed here, but it prevents the simple
replacement of arg1 by darg on emit.cxx.
*/
if (Strncmp(mdecl, "q(const).", 9)== 0)
Replace(mdecl,"q(const).","", DOH_REPLACE_FIRST);
cDeclaration(m);
Delete(m);
}
Delete(wrapname);
}
Delete(wrapname);
cplus_mode = old_mode;
}
cplus_mode = old_mode;
}
return SWIG_OK;
@ -2184,6 +2186,14 @@ void Language::allow_directors(int val) {
directors = val;
}
/* -----------------------------------------------------------------------------
* Language::allow_dirprot()
* ----------------------------------------------------------------------------- */
void Language::allow_dirprot(int val) {
director_protected_mode = val;
}
/* -----------------------------------------------------------------------------
* Language::directorsEnabled()
* ----------------------------------------------------------------------------- */

View file

@ -196,6 +196,9 @@ public:
if (Getattr(options, "directors")) {
allow_directors();
}
if (Getattr(options, "dirprot")) {
allow_dirprot();
}
if (Getattr(options, "sizeof")) {
generate_sizeof = 1;
}

View file

@ -159,6 +159,9 @@ public:
if (Getattr(options, "directors")) {
allow_directors();
}
if (Getattr(options, "dirprot")) {
allow_dirprot();
}
}
}
}

View file

@ -335,6 +335,9 @@ public:
if (Getattr(options, "directors")) {
allow_directors();
}
if (Getattr(options, "dirprot")) {
allow_dirprot();
}
if (Getattr(options, "ruby_globalmodule")) {
useGlobalModule = true;
}

View file

@ -213,6 +213,9 @@ public:
/* Allow director related code generation */
void allow_directors(int val = 1);
/* Allow director protected members related code generation */
void allow_dirprot(int val = 1);
/* Return true if directors are enabled */
int directorsEnabled() const;