From b6c9c97b96bc3039ccb291d76a64d009fc81fbb7 Mon Sep 17 00:00:00 2001 From: Oliver Buchtala Date: Mon, 9 Sep 2013 15:05:11 +0300 Subject: [PATCH] Fix Javascript generator to use %renamed variable names. --- Examples/test-suite/javascript/Makefile.in | 2 +- Source/Modules/javascript.cxx | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index 5d7fba02e..49dd18054 100755 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -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@ diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index 54135d852..5bd22f710 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -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);