git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6839 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-12-06 22:53:09 +00:00
commit 347f342fab
5 changed files with 34 additions and 44 deletions

View file

@ -60,8 +60,6 @@ static int check_implemented(Node *n) {
class Allocate : public Dispatcher {
Node *inclass;
enum AccessMode { PUBLIC, PRIVATE, PROTECTED };
AccessMode cplus_mode;
int extendmode;
/* Checks if a virtual function is the same as inherited from the bases */
@ -368,6 +366,10 @@ class Allocate : public Dispatcher {
}
public:
Allocate() :
inclass(NULL),
extendmode(0) {}
virtual int top(Node *n) {
cplus_mode = PUBLIC;
inclass = 0;

View file

@ -17,11 +17,6 @@ char cvsroot_csharp_cxx[] = "$Header$";
#include <ctype.h>
// temporary hack start
#define CPLUS_PUBLIC 0
extern int cplus_mode;
// temporary hack end
class CSHARP : public Language {
static const char *usage;
const String *empty_string;
@ -821,7 +816,7 @@ class CSHARP : public Language {
virtual int enumDeclaration(Node *n) {
if (!ImportMode) {
if (getCurrentClass() && (cplus_mode != CPLUS_PUBLIC)) return SWIG_NOWRAP;
if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP;
enum_code = NewString("");
String *symname = Getattr(n,"sym:name");
@ -933,7 +928,7 @@ class CSHARP : public Language {
* ---------------------------------------------------------------------- */
virtual int enumvalueDeclaration(Node *n) {
if (getCurrentClass() && (cplus_mode != CPLUS_PUBLIC)) return SWIG_NOWRAP;
if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP;
Swig_require("enumvalueDeclaration",n,"*name", "?value",NIL);
String *symname = Getattr(n,"sym:name");

View file

@ -19,11 +19,6 @@ char cvsroot_java_cxx[] = "$Header$";
/* Hash type used for JNI upcall data */
typedef DOH UpcallData;
// temporary hack start
#define CPLUS_PUBLIC 0
extern int cplus_mode;
// temporary hack end
class JAVA : public Language {
static const char *usage;
const String *empty_string;
@ -1060,7 +1055,7 @@ class JAVA : public Language {
virtual int enumDeclaration(Node *n) {
if (!ImportMode) {
if (getCurrentClass() && (cplus_mode != CPLUS_PUBLIC)) return SWIG_NOWRAP;
if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP;
enum_code = NewString("");
String *symname = Getattr(n,"sym:name");
@ -1177,7 +1172,7 @@ class JAVA : public Language {
* ---------------------------------------------------------------------- */
virtual int enumvalueDeclaration(Node *n) {
if (getCurrentClass() && (cplus_mode != CPLUS_PUBLIC)) return SWIG_NOWRAP;
if (getCurrentClass() && (cplus_mode != PUBLIC)) return SWIG_NOWRAP;
Swig_require("enumvalueDeclaration",n,"*name", "?value",NIL);
String *symname = Getattr(n,"sym:name");

View file

@ -65,7 +65,6 @@ int ImportMode = 0;
int IsVirtual = 0;
static String *AttributeFunctionGet = 0;
static String *AttributeFunctionSet = 0;
int cplus_mode = 0;
static Node *CurrentClass = 0;
int line_number = 0;
char *input_file = 0;
@ -80,12 +79,6 @@ extern int NoExtern;
#define IMPORT_MODE 1
#define IMPORT_MODULE 2
/* C++ access modes */
#define CPLUS_PUBLIC 0
#define CPLUS_PROTECTED 1
#define CPLUS_PRIVATE 2
/* ----------------------------------------------------------------------
* Dispatcher::emit_one()
*
@ -398,9 +391,9 @@ int Language::top(Node *n) {
int Language::extendDirective(Node *n) {
int oldam = Extend;
int oldmode = cplus_mode;
AccessMode oldmode = cplus_mode;
Extend = CWRAP_EXTEND;
cplus_mode = CPLUS_PUBLIC;
cplus_mode = PUBLIC;
emit_children(n);
@ -451,7 +444,7 @@ int Language::clearDirective(Node *n) {
int Language::constantDirective(Node *n) {
if (CurrentClass && (cplus_mode != CPLUS_PUBLIC)) return SWIG_NOWRAP;
if (CurrentClass && (cplus_mode != PUBLIC)) return SWIG_NOWRAP;
if (!ImportMode) {
Swig_require("constantDirective",n,"name", "?value",NIL);
@ -726,7 +719,7 @@ int Language::cDeclaration(Node *n) {
SwigType *ty, *fullty;
/* discarts nodes following the access control rules */
if (cplus_mode != CPLUS_PUBLIC || !is_public(n)) {
if (cplus_mode != PUBLIC || !is_public(n)) {
/* except for friends, they are not affected by access control */
int isfriend = storage && (Cmp(storage,"friend") == 0);
if (!isfriend ) {
@ -1390,7 +1383,7 @@ int Language::enumDeclaration(Node *n) {
* ---------------------------------------------------------------------- */
int Language::enumvalueDeclaration(Node *n) {
if (CurrentClass && (cplus_mode != CPLUS_PUBLIC)) return SWIG_NOWRAP;
if (CurrentClass && (cplus_mode != PUBLIC)) return SWIG_NOWRAP;
Swig_require("enumvalueDeclaration",n,"*name", "?value",NIL);
String *value = Getattr(n,"value");
@ -1922,9 +1915,9 @@ int Language::classDeclaration(Node *n) {
Setattr(n,"name",classname);
if (Cmp(kind,"class") == 0) {
cplus_mode = CPLUS_PRIVATE;
cplus_mode = PRIVATE;
} else {
cplus_mode = CPLUS_PUBLIC;
cplus_mode = PUBLIC;
}
ClassName = NewString(classname);
@ -2028,7 +2021,7 @@ int Language::classHandler(Node *n) {
/* Look for smart pointer handling */
if (Getattr(n,"allocate:smartpointer")) {
List *methods = Getattr(n,"allocate:smartpointer");
cplus_mode = CPLUS_PUBLIC;
cplus_mode = PUBLIC;
SmartPointer = CWRAP_SMART_POINTER;
Iterator c;
for (c = First(methods); c.item; c= Next(c)) {
@ -2037,7 +2030,7 @@ int Language::classHandler(Node *n) {
SmartPointer = 0;
}
cplus_mode = CPLUS_PUBLIC;
cplus_mode = PUBLIC;
if (!ImportMode && (GenerateDefault && !Getattr(n,"feature:nodefault"))) {
if (!Getattr(n,"has_constructor") && !Getattr(n,"allocate:has_constructor") && (Getattr(n,"allocate:default_constructor"))) {
/* Note: will need to change this to support different kinds of classes */
@ -2064,8 +2057,8 @@ int Language::classHandler(Node *n) {
String* symname = Getattr(n, "sym:name");
Node *item;
Iterator k;
int old_mode = cplus_mode;
cplus_mode = CPLUS_PROTECTED;
AccessMode old_mode = cplus_mode;
cplus_mode = PROTECTED;
for (k = First(vtable); k.key; k = Next(k)) {
item = k.item;
Node *method = Getattr(item, "methodNode");
@ -2128,7 +2121,7 @@ int Language::constructorDeclaration(Node *n) {
Setattr(CurrentClass,"sym:cleanconstructor","1");
}
if ((cplus_mode != CPLUS_PUBLIC)) {
if ((cplus_mode != PUBLIC)) {
/* check only for director classes */
if (!Swig_directorclass(CurrentClass) || !need_nonpublic_ctor(n))
return SWIG_NOWRAP;
@ -2270,7 +2263,7 @@ Language::copyconstructorHandler(Node *n) {
int Language::destructorDeclaration(Node *n) {
if (!CurrentClass) return SWIG_NOWRAP;
if (cplus_mode != CPLUS_PUBLIC) return SWIG_NOWRAP;
if (cplus_mode != PUBLIC) return SWIG_NOWRAP;
if (ImportMode) return SWIG_NOWRAP;
Swig_save("destructorDeclaration",n,"name", "sym:name",NIL);
@ -2327,11 +2320,11 @@ int Language::destructorHandler(Node *n) {
int Language::accessDeclaration(Node *n) {
String *kind = Getattr(n,"kind");
if (Cmp(kind,"public") == 0) {
cplus_mode = CPLUS_PUBLIC;
cplus_mode = PUBLIC;
} else if (Cmp(kind,"private") == 0) {
cplus_mode = CPLUS_PRIVATE;
cplus_mode = PRIVATE;
} else if (Cmp(kind,"protected") == 0) {
cplus_mode = CPLUS_PROTECTED;
cplus_mode = PROTECTED;
}
return SWIG_OK;
}
@ -2361,7 +2354,7 @@ int Language::validIdentifier(String *s) {
* ----------------------------------------------------------------------------- */
int Language::usingDeclaration(Node *n) {
if ((cplus_mode == CPLUS_PUBLIC)) {
if ((cplus_mode == PUBLIC)) {
Node* np = Copy(n);
Node *c;
for (c = firstChild(np); c; c = nextSibling(c)) {

View file

@ -60,7 +60,8 @@ extern String *argc_template_string;
class Dispatcher {
public:
Dispatcher() : cplus_mode(PUBLIC) {}
virtual int emit_one(Node *n);
virtual int emit_children(Node *n);
virtual int defaultHandler(Node *n);
@ -101,6 +102,11 @@ class Dispatcher {
virtual int usingDeclaration(Node *n);
virtual int namespaceDeclaration(Node *n);
virtual int templateDeclaration(Node *n);
enum AccessMode { PUBLIC, PRIVATE, PROTECTED };
protected:
AccessMode cplus_mode;
};
/************************************************************************
@ -243,7 +249,7 @@ public:
/* Set overload variable templates argc and argv */
void setOverloadResolutionTemplates(String *argc, String *argv);
protected:
protected:
/* Allow multiple-input typemaps */
void allow_multiple_input(int val = 1);
@ -286,14 +292,13 @@ public:
/* Director language module */
int director_language;
private:
private:
Hash *symbols;
Hash *classtypes;
Hash *enumtypes;
int overloading;
int multiinput;
int directors;
};
int SWIG_main(int, char **, Language *);