Nested classes support
Closes #89 Squash merge branch 'master' of https://github.com/wkalinin/swig into wkalinin-nested By Vladimir Kalinin * 'master' of https://github.com/wkalinin/swig: CPlusPlusOut mode for Octave nested class illustration fixed "Abstract" flag for nested classes added an example enabled anonymous nested structs runtime test porting warnings disabled porting fixes java runtime tests ported nested class closing bracket offset fixed removed double nested template (not supported by %template parsing) template_nested test extended parent field made public property access fixed replaced tabs with spaces warning W-reorder deprecated warnings removed, derived_nested runtime test added optimized string indenting Nested classes indenting nested classes docs fixed the order in which flattened inner classes are added after the outer Private nested classes were getting into the type table. Java getProxyName() fix for nested classes fixes the case when nested classes is forward declared Fix for a case when a nested class inherits from the same base as the outer. (Base class constructor declaration is found first in this case) merge fix nested C struct first immediate declaration incorrectly renamed sample fixed tests updated to reflect nested classes support Java nested classes support (1) flattening should remove the link to the outer class access mode correctly set/restored for nested classes nested templates should be skipped while flattening (template nodes themselves, not expanded versions) also non-public nested classes should be ignored If nested classes are not supported, default behaviour is flattening, not ignoring flag "nested" is preserved, so, the nested classes can be ignored by user nested workaround test updated template instantiated within a class is marked as nested for ignoring purposes %ignore not applied to the nested classed, because "nested" flag is set too late typedef name takes precedence over the real name (reason?) unnamed structs should be processed for all the languages nested C struct instances are wrapped as "immutable" tree building typedef declaration for unnamed C structures fixed nested classes "flattening" fixed %ignoring nested classes renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface tree iteration fix dirclassname variable names unified memory issue fixed merge error ignore unnamed structs for C++ unnamed nested C structs naming & unnesting class added to classes hash under typedef name private nested classes skipped test updated due to nested templates support anonymous structs with inheritance fixed nested_class test to allow anonymous structs w/o declarator tests updated: nested workaround removed from namespace_class.i propagated nested template declaration to the C++ file injected members scope nested tempplates fixes, nested structures in "C" mode parsing added utility function "appendSibling" (like "appendChild") nested unnamed structures parsing fixes, access mode restored on nested class end, tdname is properly patched with outer class name prefix memory management fixes nested templates (1) Nested unnamed structs Nested class support (1) Nested class support (1)
This commit is contained in:
parent
fcd0480364
commit
b63c4839fe
39 changed files with 1449 additions and 1111 deletions
|
|
@ -1545,7 +1545,110 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
Delete(locator);
|
||||
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)
|
||||
{
|
||||
String* result = 0;
|
||||
char c;
|
||||
int old_line = s->line;
|
||||
String* old_text = Copy(s->text);
|
||||
int position = Tell(s->str);
|
||||
|
||||
int num_levels = 1;
|
||||
int state = 0;
|
||||
char temp[2] = { 0, 0 };
|
||||
temp[0] = (char) startchar;
|
||||
Clear(s->text);
|
||||
Setfile(s->text, Getfile(s->str));
|
||||
Setline(s->text, s->line);
|
||||
Append(s->text, temp);
|
||||
while (num_levels > 0) {
|
||||
if ((c = nextchar(s)) == 0) {
|
||||
Clear(s->text);
|
||||
Append(s->text, old_text);
|
||||
Delete(old_text);
|
||||
s->line = old_line;
|
||||
return 0;
|
||||
}
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (c == startchar)
|
||||
num_levels++;
|
||||
else if (c == endchar)
|
||||
num_levels--;
|
||||
else if (c == '/')
|
||||
state = 10;
|
||||
else if (c == '\"')
|
||||
state = 20;
|
||||
else if (c == '\'')
|
||||
state = 30;
|
||||
break;
|
||||
case 10:
|
||||
if (c == '/')
|
||||
state = 11;
|
||||
else if (c == '*')
|
||||
state = 12;
|
||||
else if (c == startchar) {
|
||||
state = 0;
|
||||
num_levels++;
|
||||
}
|
||||
else
|
||||
state = 0;
|
||||
break;
|
||||
case 11:
|
||||
if (c == '\n')
|
||||
state = 0;
|
||||
else
|
||||
state = 11;
|
||||
break;
|
||||
case 12: /* first character inside C comment */
|
||||
if (c == '*')
|
||||
state = 14;
|
||||
else
|
||||
state = 13;
|
||||
break;
|
||||
case 13:
|
||||
if (c == '*')
|
||||
state = 14;
|
||||
break;
|
||||
case 14: /* possible end of C comment */
|
||||
if (c == '*')
|
||||
state = 14;
|
||||
else if (c == '/')
|
||||
state = 0;
|
||||
else
|
||||
state = 13;
|
||||
break;
|
||||
case 20:
|
||||
if (c == '\"')
|
||||
state = 0;
|
||||
else if (c == '\\')
|
||||
state = 21;
|
||||
break;
|
||||
case 21:
|
||||
state = 20;
|
||||
break;
|
||||
case 30:
|
||||
if (c == '\'')
|
||||
state = 0;
|
||||
else if (c == '\\')
|
||||
state = 31;
|
||||
break;
|
||||
case 31:
|
||||
state = 30;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Seek(s->str, position, SEEK_SET);
|
||||
result = Copy(s->text);
|
||||
Clear(s->text);
|
||||
Append(s->text, old_text);
|
||||
Delete(old_text);
|
||||
s->line = old_line;
|
||||
return result;
|
||||
}
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Scanner_isoperator()
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue