Cosmetics/code beautification of nested class support
This commit is contained in:
parent
b63c4839fe
commit
44a883a057
13 changed files with 249 additions and 241 deletions
|
|
@ -118,6 +118,12 @@ void skip_balanced(int startchar, int endchar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* get_raw_text_balanced()
|
||||||
|
*
|
||||||
|
* Returns raw text between 2 braces
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *get_raw_text_balanced(int startchar, int endchar) {
|
String *get_raw_text_balanced(int startchar, int endchar) {
|
||||||
return Scanner_get_raw_text_balanced(scan, startchar, endchar);
|
return Scanner_get_raw_text_balanced(scan, startchar, endchar);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -799,8 +799,8 @@ static String *make_class_name(String *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use typedef name as class name */
|
/* Use typedef name as class name */
|
||||||
void add_typedef_name(Node* n, Node* decl, String* oldName, Symtab *cscope, String* scpname)
|
|
||||||
{
|
void add_typedef_name(Node *n, Node *decl, String *oldName, Symtab *cscope, String *scpname) {
|
||||||
String *class_rename = 0;
|
String *class_rename = 0;
|
||||||
SwigType *decltype = Getattr(decl, "decl");
|
SwigType *decltype = Getattr(decl, "decl");
|
||||||
if (!decltype || !Len(decltype)) {
|
if (!decltype || !Len(decltype)) {
|
||||||
|
|
@ -1432,7 +1432,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
||||||
%type <node> cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl cpp_alternate_rettype;
|
%type <node> cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl cpp_alternate_rettype;
|
||||||
%type <node> cpp_members cpp_member;
|
%type <node> cpp_members cpp_member;
|
||||||
%type <node> cpp_constructor_decl cpp_destructor_decl cpp_protection_decl cpp_conversion_operator cpp_static_assert;
|
%type <node> cpp_constructor_decl cpp_destructor_decl cpp_protection_decl cpp_conversion_operator cpp_static_assert;
|
||||||
%type <node> cpp_swig_directive cpp_temp_possible /*cpp_nested*/ cpp_opt_declarators ;
|
%type <node> cpp_swig_directive cpp_temp_possible cpp_opt_declarators ;
|
||||||
%type <node> cpp_using_decl cpp_namespace_decl cpp_catch_decl cpp_lambda_decl;
|
%type <node> cpp_using_decl cpp_namespace_decl cpp_catch_decl cpp_lambda_decl;
|
||||||
%type <node> kwargs options;
|
%type <node> kwargs options;
|
||||||
|
|
||||||
|
|
@ -3447,7 +3447,8 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
||||||
Delete(prefix);
|
Delete(prefix);
|
||||||
inclass = 1;
|
inclass = 1;
|
||||||
currentOuterClass = $<node>$;
|
currentOuterClass = $<node>$;
|
||||||
if (CPlusPlusOut) { /* save the structure declaration to declare it in global scope for C++ to see*/
|
if (CPlusPlusOut) {
|
||||||
|
/* save the structure declaration to declare it in global scope for C++ to see */
|
||||||
code = get_raw_text_balanced('{', '}');
|
code = get_raw_text_balanced('{', '}');
|
||||||
Setattr($<node>$, "code", code);
|
Setattr($<node>$, "code", code);
|
||||||
Delete(code);
|
Delete(code);
|
||||||
|
|
@ -4286,7 +4287,6 @@ cpp_member : c_declaration { $$ = $1; }
|
||||||
| cpp_conversion_operator { $$ = $1; }
|
| cpp_conversion_operator { $$ = $1; }
|
||||||
| cpp_forward_class_decl { $$ = $1; }
|
| cpp_forward_class_decl { $$ = $1; }
|
||||||
| cpp_class_decl { $$ = $1; }
|
| cpp_class_decl { $$ = $1; }
|
||||||
/* | cpp_nested { $$ = $1; }*/
|
|
||||||
| storage_class idcolon SEMI { $$ = 0; }
|
| storage_class idcolon SEMI { $$ = 0; }
|
||||||
| cpp_using_decl { $$ = $1; }
|
| cpp_using_decl { $$ = $1; }
|
||||||
| cpp_template_decl { $$ = $1; }
|
| cpp_template_decl { $$ = $1; }
|
||||||
|
|
|
||||||
|
|
@ -4134,7 +4134,9 @@ public:
|
||||||
String *old_director_delegate_instances = director_delegate_instances;
|
String *old_director_delegate_instances = director_delegate_instances;
|
||||||
String *old_director_method_types = director_method_types;
|
String *old_director_method_types = director_method_types;
|
||||||
String *old_director_connect_parms = director_connect_parms;
|
String *old_director_connect_parms = director_connect_parms;
|
||||||
|
|
||||||
int ret = Language::classDeclaration(n);
|
int ret = Language::classDeclaration(n);
|
||||||
|
|
||||||
// these variables are deleted in emitProxyClassDefAndCPPCasts, hence no Delete here
|
// these variables are deleted in emitProxyClassDefAndCPPCasts, hence no Delete here
|
||||||
director_callback_typedefs = old_director_callback_typedefs;
|
director_callback_typedefs = old_director_callback_typedefs;
|
||||||
director_callbacks = old_director_callbacks;
|
director_callbacks = old_director_callbacks;
|
||||||
|
|
@ -4143,6 +4145,7 @@ public:
|
||||||
director_delegate_instances = old_director_delegate_instances;
|
director_delegate_instances = old_director_delegate_instances;
|
||||||
director_method_types = old_director_method_types;
|
director_method_types = old_director_method_types;
|
||||||
director_connect_parms = old_director_connect_parms;
|
director_connect_parms = old_director_connect_parms;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ static Language *lang = 0; // Language method
|
||||||
int CPlusPlus = 0;
|
int CPlusPlus = 0;
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
int CPlusPlusOut = 0; // generate C++ declarations for C code
|
int CPlusPlusOut = 0; // Generate C++ compatible code when wrapping C code
|
||||||
};
|
}
|
||||||
int Extend = 0; // Extend flag
|
int Extend = 0; // Extend flag
|
||||||
int ForceExtern = 0; // Force extern mode
|
int ForceExtern = 0; // Force extern mode
|
||||||
int GenerateDefault = 1; // Generate default constructors
|
int GenerateDefault = 1; // Generate default constructors
|
||||||
|
|
@ -870,18 +870,6 @@ void Swig_flatten_nested() {
|
||||||
Delete(fname);
|
Delete(fname);
|
||||||
Delete(name);
|
Delete(name);
|
||||||
Delete(val);
|
Delete(val);
|
||||||
/*
|
|
||||||
String* name = NewStringEmpty();
|
|
||||||
Hash* newname = NewHash();
|
|
||||||
Setattr(newname, "name", "$ignore");
|
|
||||||
Hash* match = NewHash();
|
|
||||||
Setattr(match, "name", "match$nested");
|
|
||||||
Setattr(match, "value", "1");
|
|
||||||
set_nextSibling(newname, match);
|
|
||||||
Swig_name_rename_add(0, name, 0, newname, 0);
|
|
||||||
Delete(name);
|
|
||||||
Delete(match);
|
|
||||||
Delete(newname);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -476,7 +476,6 @@ class TypePass:private Dispatcher {
|
||||||
if (unnamed && tdname && (Cmp(storage, "typedef") == 0)) {
|
if (unnamed && tdname && (Cmp(storage, "typedef") == 0)) {
|
||||||
SwigType_typedef(unnamed, tdname);
|
SwigType_typedef(unnamed, tdname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// name of the outer class should already be patched to contain it's outer classes names, but not to contain namespaces
|
// name of the outer class should already be patched to contain it's outer classes names, but not to contain namespaces
|
||||||
// namespace name (if present) is added after processing child nodes
|
// namespace name (if present) is added after processing child nodes
|
||||||
if (Getattr(n, "nested:outer") && name) {
|
if (Getattr(n, "nested:outer") && name) {
|
||||||
|
|
@ -1116,8 +1115,7 @@ class TypePass:private Dispatcher {
|
||||||
* list of overloaded methods we have just added in as child nodes to the "using" node.
|
* list of overloaded methods we have just added in as child nodes to the "using" node.
|
||||||
* The node will still exist, it is just the symbol table linked list of overloaded methods
|
* The node will still exist, it is just the symbol table linked list of overloaded methods
|
||||||
* which is hacked. */
|
* which is hacked. */
|
||||||
if (Getattr(n, "sym:overloaded"))
|
if (Getattr(n, "sym:overloaded")) {
|
||||||
{
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
#ifdef DEBUG_OVERLOADED
|
#ifdef DEBUG_OVERLOADED
|
||||||
Node *debugnode = n;
|
Node *debugnode = n;
|
||||||
|
|
@ -1299,7 +1297,8 @@ static String *make_name(Node *n, String *name,SwigType *decl) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!name) return 0;
|
if (!name)
|
||||||
|
return 0;
|
||||||
return Swig_name_make(n, 0, name, decl, 0);
|
return Swig_name_make(n, 0, name, decl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1341,7 +1340,8 @@ static void add_symbols_c(Node *n) {
|
||||||
SetFlag(n, "hasconsttype");
|
SetFlag(n, "hasconsttype");
|
||||||
SetFlag(n, "feature:immutable");
|
SetFlag(n, "feature:immutable");
|
||||||
}
|
}
|
||||||
if (tmp) Delete(tmp);
|
if (tmp)
|
||||||
|
Delete(tmp);
|
||||||
}
|
}
|
||||||
if (!type) {
|
if (!type) {
|
||||||
Printf(stderr, "notype name %s\n", name);
|
Printf(stderr, "notype name %s\n", name);
|
||||||
|
|
@ -1440,8 +1440,7 @@ static void add_symbols_c(Node *n) {
|
||||||
Swig_warning(WARN_PARSE_REDUNDANT, Getfile(c), Getline(c), "%s\n", ec);
|
Swig_warning(WARN_PARSE_REDUNDANT, Getfile(c), Getline(c), "%s\n", ec);
|
||||||
}
|
}
|
||||||
SWIG_WARN_NODE_END(n);
|
SWIG_WARN_NODE_END(n);
|
||||||
Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(n),Getline(n),en,
|
Printf(e, "%s:%d:%s\n%s:%d:%s\n", Getfile(n), Getline(n), en, Getfile(c), Getline(c), ec);
|
||||||
Getfile(c),Getline(c),ec);
|
|
||||||
Setattr(n, "error", e);
|
Setattr(n, "error", e);
|
||||||
Delete(e);
|
Delete(e);
|
||||||
Delete(en);
|
Delete(en);
|
||||||
|
|
@ -1454,7 +1453,8 @@ static void add_symbols_c(Node *n) {
|
||||||
|
|
||||||
/* Strips C-style and C++-style comments from string in-place. */
|
/* Strips C-style and C++-style comments from string in-place. */
|
||||||
static void strip_comments(char *string) {
|
static void strip_comments(char *string) {
|
||||||
int state = 0; /*
|
int state = 0;
|
||||||
|
/*
|
||||||
* 0 - not in comment
|
* 0 - not in comment
|
||||||
* 1 - in c-style comment
|
* 1 - in c-style comment
|
||||||
* 2 - in c++-style comment
|
* 2 - in c++-style comment
|
||||||
|
|
@ -1516,8 +1516,7 @@ static void strip_comments(char *string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an %insert with a typedef to make a new name visible to C
|
// Create a %insert with a typedef to make a new name visible to C
|
||||||
// the code is moved from parser.y, dump_nested() function with minor changes
|
|
||||||
static Node *create_insert(Node *n, bool noTypedef = false) {
|
static Node *create_insert(Node *n, bool noTypedef = false) {
|
||||||
// format a typedef
|
// format a typedef
|
||||||
String *ccode = Getattr(n, "code");
|
String *ccode = Getattr(n, "code");
|
||||||
|
|
@ -1534,7 +1533,6 @@ static Node* create_insert(Node* n, bool noTypedef = false) {
|
||||||
}
|
}
|
||||||
Append(ccode, ";");
|
Append(ccode, ";");
|
||||||
|
|
||||||
|
|
||||||
/* Strip comments - further code may break in presence of comments. */
|
/* Strip comments - further code may break in presence of comments. */
|
||||||
strip_comments(Char(ccode));
|
strip_comments(Char(ccode));
|
||||||
|
|
||||||
|
|
@ -1590,8 +1588,7 @@ static Node* create_insert(Node* n, bool noTypedef = false) {
|
||||||
return newnode;
|
return newnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void insertNodeAfter(Node *n, Node* c)
|
static void insertNodeAfter(Node *n, Node *c) {
|
||||||
{
|
|
||||||
Node *g = parentNode(n);
|
Node *g = parentNode(n);
|
||||||
set_parentNode(c, g);
|
set_parentNode(c, g);
|
||||||
Node *ns = nextSibling(n);
|
Node *ns = nextSibling(n);
|
||||||
|
|
@ -1603,8 +1600,7 @@ static void insertNodeAfter(Node *n, Node* c)
|
||||||
}
|
}
|
||||||
if (!ns) {
|
if (!ns) {
|
||||||
set_lastChild(g, c);
|
set_lastChild(g, c);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
set_nextSibling(c, ns);
|
set_nextSibling(c, ns);
|
||||||
set_previousSibling(ns, c);
|
set_previousSibling(ns, c);
|
||||||
}
|
}
|
||||||
|
|
@ -1686,8 +1682,8 @@ void Swig_name_unnamed_c_structs(Node *n) {
|
||||||
c = next;
|
c = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void remove_outer_class_reference(Node *n)
|
|
||||||
{
|
static void remove_outer_class_reference(Node *n) {
|
||||||
for (Node *c = firstChild(n); c; c = nextSibling(c)) {
|
for (Node *c = firstChild(n); c; c = nextSibling(c)) {
|
||||||
if (GetFlag(c, "feature:flatnested")) {
|
if (GetFlag(c, "feature:flatnested")) {
|
||||||
Delattr(c, "nested:outer");
|
Delattr(c, "nested:outer");
|
||||||
|
|
@ -1695,6 +1691,7 @@ static void remove_outer_class_reference(Node *n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Swig_process_nested_classes(Node *n) {
|
void Swig_process_nested_classes(Node *n) {
|
||||||
Node *c = firstChild(n);
|
Node *c = firstChild(n);
|
||||||
while (c) {
|
while (c) {
|
||||||
|
|
|
||||||
|
|
@ -1648,6 +1648,10 @@ void Swig_name_inherit(String *base, String *derived) {
|
||||||
Swig_name_object_inherit(Swig_cparse_features(), base, derived);
|
Swig_name_object_inherit(Swig_cparse_features(), base, derived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_inherit_base_symbols()
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Swig_inherit_base_symbols(List *bases) {
|
void Swig_inherit_base_symbols(List *bases) {
|
||||||
if (bases) {
|
if (bases) {
|
||||||
Iterator s;
|
Iterator s;
|
||||||
|
|
@ -1663,13 +1667,19 @@ void Swig_inherit_base_symbols(List* bases) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_make_inherit_list()
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
List *Swig_make_inherit_list(String *clsname, List *names, String *Namespaceprefix) {
|
List *Swig_make_inherit_list(String *clsname, List *names, String *Namespaceprefix) {
|
||||||
int i, ilen;
|
int i, ilen;
|
||||||
String *derived;
|
String *derived;
|
||||||
List *bases = NewList();
|
List *bases = NewList();
|
||||||
|
|
||||||
if (Namespaceprefix) derived = NewStringf("%s::%s", Namespaceprefix,clsname);
|
if (Namespaceprefix)
|
||||||
else derived = NewString(clsname);
|
derived = NewStringf("%s::%s", Namespaceprefix, clsname);
|
||||||
|
else
|
||||||
|
derived = NewString(clsname);
|
||||||
|
|
||||||
ilen = Len(names);
|
ilen = Len(names);
|
||||||
for (i = 0; i < ilen; i++) {
|
for (i = 0; i < ilen; i++) {
|
||||||
|
|
|
||||||
|
|
@ -1545,9 +1545,14 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
||||||
Delete(locator);
|
Delete(locator);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* returns raw text between 2 braces, does not change scanner state in any way*/
|
|
||||||
String* Scanner_get_raw_text_balanced(Scanner* s, int startchar, int endchar)
|
/* -----------------------------------------------------------------------------
|
||||||
{
|
* Scanner_get_raw_text_balanced()
|
||||||
|
*
|
||||||
|
* Returns raw text between 2 braces, does not change scanner state in any way
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
String *Scanner_get_raw_text_balanced(Scanner *s, int startchar, int endchar) {
|
||||||
String *result = 0;
|
String *result = 0;
|
||||||
char c;
|
char c;
|
||||||
int old_line = s->line;
|
int old_line = s->line;
|
||||||
|
|
|
||||||
|
|
@ -171,8 +171,7 @@ void prependChild(Node *node, Node *chd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendSibling(Node *node, Node *chd)
|
void appendSibling(Node *node, Node *chd) {
|
||||||
{
|
|
||||||
Node *parent;
|
Node *parent;
|
||||||
Node *lc = node;
|
Node *lc = node;
|
||||||
while (nextSibling(lc))
|
while (nextSibling(lc))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue