public static bool evaluate(string jsScriptName)
    {
        if (evaluatedScript.ContainsKey(jsScriptName))
        {
            return(true);
        }
        // add even failed
        evaluatedScript.Add(jsScriptName, true);

        string fullName = JSMgr.getJSFullName(jsScriptName);

        byte[] bytes = jsLoader.LoadJSSync(fullName);
        if (bytes == null)
        {
            Debug.LogError(jsScriptName + "file bytes is null");
            return(false);
        }
        else if (bytes.Length == 0)
        {
            Debug.LogError(jsScriptName + "file bytes length = 0");
            return(false);
        }

        bool ret = (1 == JSApi.evaluate(bytes, (uint)bytes.Length, fullName));

        return(ret);
    }
Beispiel #2
0
    public static bool evaluate(string jsScriptName)
    {
        if (evaluatedScript.ContainsKey(jsScriptName))
        {
            return(true);
        }
        // add even failed
        evaluatedScript.Add(jsScriptName, true);

        string fullName = JSMgr.getJSFullName(jsScriptName);

        byte[] bytes;

        bool   jsc         = false;
        string jscFullName = fullName.Replace(JSBindingSettings.jsDir, JSBindingSettings.jscDir).Replace(JSBindingSettings.jsExtension, JSBindingSettings.jscExtension);

//         if (File.Exists(jscFullName))
//         {
//             jsc = true;
//             bytes = jsLoader.LoadJSSync(jscFullName);
//         }
//         else
        {
            bytes = jsLoader.LoadJSSync(fullName);
        }

        if (bytes == null)
        {
            Debug.LogError(jsScriptName + "file content is null");
            return(false);
        }
        else if (bytes.Length == 0)
        {
            Debug.LogError(jsScriptName + "file content length = 0");
            return(false);
        }

        bool ret = jsc ? (1 == JSApi.evaluate_jsc(bytes, (uint)bytes.Length, jscFullName))
            : (1 == JSApi.evaluate(bytes, (uint)bytes.Length, fullName));

        return(ret);
    }