Browse Source

review feedback

Yong Qu 9 years ago
parent
commit
b3bec2183c
5 changed files with 20 additions and 11 deletions
  1. 8 10
      bin/ch/WScriptJsrt.cpp
  2. 0 1
      bin/ch/stdafx.h
  3. 4 0
      test/es6/exportmodule.js
  4. 4 0
      test/es6/moduletest1.js
  5. 4 0
      test/es6/passmodule.js

+ 8 - 10
bin/ch/WScriptJsrt.cpp

@@ -217,7 +217,7 @@ JsValueRef WScriptJsrt::LoadScriptHelper(JsValueRef callee, bool isConstructCall
     else
     {
         AutoString fileContent;
-        char* fileName = nullptr;
+        char* fileNameNarrow = nullptr;
         bool freeFileName = false;
         AutoString scriptInjectType;
         size_t fileContentLength;
@@ -233,7 +233,7 @@ JsValueRef WScriptJsrt::LoadScriptHelper(JsValueRef callee, bool isConstructCall
             if (argumentCount > 3)
             {
                 size_t unused;
-                IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointerUtf8Copy(arguments[3], &fileName, &unused));
+                IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointerUtf8Copy(arguments[3], &fileNameNarrow, &unused));
                 freeFileName = true;
             }
         }
@@ -241,17 +241,17 @@ JsValueRef WScriptJsrt::LoadScriptHelper(JsValueRef callee, bool isConstructCall
         if (!freeFileName)
         {
             sprintf_s(fileNameBuffer, "script%i.js", (int)sourceContext);
-            fileName = fileNameBuffer;
+            fileNameNarrow = fileNameBuffer;
         }
 
         if (*fileContent)
         {
             // TODO: This is CESU-8. How to tell the engine?
             // TODO: How to handle this source (script) life time?
-            returnValue = LoadScript(callee, fileName, *fileContent, *scriptInjectType ? *scriptInjectType : "self", isSourceModule);
+            returnValue = LoadScript(callee, fileNameNarrow, *fileContent, *scriptInjectType ? *scriptInjectType : "self", isSourceModule);
             if (freeFileName)
             {
-                ChakraRTInterface::JsStringFree(fileName);
+                ChakraRTInterface::JsStringFree(fileNameNarrow);
             }
         }
     }
@@ -287,7 +287,8 @@ JsErrorCode WScriptJsrt::InitializeModuleInfo(JsValueRef specifier, JsModuleReco
     {
         errorCode = ChakraRTInterface::JsSetModuleHostInfo(moduleRecord, JsModuleHostInfo_HostDefined, specifier);
     }
-    return errorCode;
+    IfJsrtErrorFailLogAndRetErrorCode(errorCode);
+    return JsNoError;
 }
 
 JsErrorCode WScriptJsrt::LoadModuleFromString(LPCSTR fileName, LPCSTR fileContent)
@@ -318,10 +319,7 @@ JsErrorCode WScriptJsrt::LoadModuleFromString(LPCSTR fileName, LPCSTR fileConten
     {
         requestModule = moduleRecordEntry->second;
     }
-    if (errorCode != JsNoError)
-    {
-        return errorCode;
-    }
+    IfJsrtErrorFailLogAndRetErrorCode(errorCode);
     JsValueRef errorObject = JS_INVALID_REFERENCE;
 
     // ParseModuleSource is sync, while additional fetch & evaluation are async.

+ 0 - 1
bin/ch/stdafx.h

@@ -63,7 +63,6 @@
 #if defined(DBG)
 
 #define _STRINGIZE_(x) #x
-//#define _STRINGIZE(x) _STRINGIZE_(x)
 
 #define AssertMsg(exp, comment)   \
 do { \

+ 4 - 0
test/es6/exportmodule.js

@@ -1,2 +1,6 @@
+//-------------------------------------------------------------------------------------------------------
+// Copyright (C) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//-------------------------------------------------------------------------------------------------------
 export var x;
 x = 'Pass';

+ 4 - 0
test/es6/moduletest1.js

@@ -1 +1,5 @@
+//-------------------------------------------------------------------------------------------------------
+// Copyright (C) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//-------------------------------------------------------------------------------------------------------
 WScript.LoadScriptFile("passModule.JS", "module");

+ 4 - 0
test/es6/passmodule.js

@@ -1,2 +1,6 @@
+//-------------------------------------------------------------------------------------------------------
+// Copyright (C) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//-------------------------------------------------------------------------------------------------------
 import { x } from 'exportmodule.js';
 WScript.Echo(x);