Browse Source

Adding support for quoted strings to JSBind

Josh Engebretson 9 years ago
parent
commit
7098c213cb

+ 4 - 2
Source/ToolCore/JSBind/JSBHeaderVisitor.h

@@ -311,8 +311,10 @@ public:
                     if (arg->hasInitializer())
                     {
                         ftype->initializer_ = arg->initializer()->chars();
-                        if (ftype->initializer_.StartsWith("\\"))
+
+                        if (arg->initializer()->_quotedString)
                             ftype->initializer_ = "\"" + ftype->initializer_ + "\"";
+
                     }
 
                     jfunction->AddParameter(ftype);
@@ -425,7 +427,7 @@ public:
         }
 
         if (type->isIntegerType() || _unsigned)
-        {            
+        {
             module_->RegisterConstant(getNameString(decl->name()).CString(), value, JSBPrimitiveType::Int, _unsigned);
         }
         else

+ 4 - 0
Source/ToolCore/JSBind/cplusplus/Lexer.cpp

@@ -773,7 +773,11 @@ void Lexer::scanUntilQuote(Token *tok, unsigned char quote)
         yyinp();
 
     if (control())
+    {
         tok->string = control()->stringLiteral(yytext, yylen);
+        if (quote == '"')
+            ((StringLiteral *)tok->string)->_quotedString = true;
+    }
 }
 
 void Lexer::scanNumericLiteral(Token *tok)

+ 5 - 1
Source/ToolCore/JSBind/cplusplus/Literals.h

@@ -67,8 +67,12 @@ class CPLUSPLUS_EXPORT StringLiteral: public Literal
 {
 public:
     StringLiteral(const char *chars, unsigned size)
-        : Literal(chars, size)
+        : Literal(chars, size), _quotedString(false)
     { }
+
+    // ATOMIC BEGIN
+    bool _quotedString;
+    // ATOMIC END
 };
 
 class CPLUSPLUS_EXPORT NumericLiteral: public Literal