From fe3f00837c6186e0cee033e81e29ffdec82f8d7f Mon Sep 17 00:00:00 2001 From: Oliver Buchtala Date: Wed, 23 Apr 2014 03:46:46 +0200 Subject: [PATCH] Fix regression in Javascript generator for enums. --- Source/Modules/javascript.cxx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index be73e4d1d..7d4d6f7d6 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -48,6 +48,7 @@ bool js_template_enable_debug = false; #define STATIC_FUNCTIONS "static_functions" #define STATIC_VARIABLES "static_variables" #define HAS_TEMPLATES "has_templates" +#define FORCE_CPP "force_cpp" #define RESET true @@ -1110,19 +1111,11 @@ int JSEmitter::emitConstant(Node *n) { String *iname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(name); String *rawval = Getattr(n, "rawval"); - String *value; + String *value = rawval ? rawval : Getattr(n, "value"); - // HACK: there are several cases. - // - rawval is set for numerical constants as - // #define MS_NOOVERRIDE -1111 - // - value is set for - // - cppvalue needs to be used for c++ - if (rawval) { - value = rawval; - } else if (Getattr(n, "cppvalue")) { + // HACK: forcing usage of cppvalue for v8 (which turned out to fix typdef_struct.i, et. al) + if (State::IsSet(state.global (FORCE_CPP)) && Getattr(n, "cppvalue") != NULL) { value = Getattr(n, "cppvalue"); - } else { - value = Getattr(n, "value"); } Template t_getter(getTemplate("js_getter")); @@ -1919,6 +1912,8 @@ int V8Emitter::initialize(Node *n) { Swig_register_filebyname("init", f_init); Swig_register_filebyname("post-init", f_post_init); + state.global(FORCE_CPP, NewString("1")); + return SWIG_OK; }