Fix Javascript generator to use %renamed variable names.

This commit is contained in:
Oliver Buchtala 2013-09-09 15:05:11 +03:00
commit b6c9c97b96
2 changed files with 12 additions and 2 deletions

View file

@ -44,7 +44,6 @@ CPP_TEST_CASES = \
cpp_static \
director_alternating \
enum_template \
infinity \
namespace_virtual_method \
overload_copy \
rename1 \
@ -68,6 +67,7 @@ CPP_TEST_CASES = \
javascript_unicode
BROKEN_TEST_CASES = \
infinity \
preproc_include
SKIP_CPP_CASES = @SKIP_CPP_CASES@

View file

@ -793,8 +793,18 @@ int JSEmitter::enterFunction(Node *n) {
int JSEmitter::enterVariable(Node *n) {
// reset the state information for variables.
state.variable(true);
state.variable(NAME, Swig_scopename_last(Getattr(n, "name")));
// Retrieve a pure symbol name. Using 'sym:name' as a basis, as it considers %renamings.
if (Equal(Getattr(n, "view"), "memberconstantHandler")) {
// Note: this is kind of hacky/experimental
// For constants/enums 'sym:name' contains e.g., 'Foo_Hello' instead of 'Hello'
state.variable(NAME, Getattr(n, "memberconstantHandler:sym:name"));
} else {
state.variable(NAME, Swig_scopename_last(Getattr(n, "sym:name")));
}
if(Equal(Getattr(n, "storage"), "static")) {
SetFlag(state.variable(), IS_STATIC);