Beispiel #1
0
        internal object AnyTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef)
        {
            var type = getValueApi.GetJsValueType(isolate, value, isByRef);

            switch (type)
            {
            case JsValueType.BigInt:
                return(getValueApi.GetBigInt(isolate, value, isByRef));

            case JsValueType.Boolean:
                return(getValueApi.GetBoolean(isolate, value, isByRef));

            case JsValueType.Date:
                return(DateTranslator(isolate, getValueApi, value, isByRef));

            case JsValueType.ArrayBuffer:
                return(getValueApi.GetArrayBuffer(isolate, value, isByRef));

            case JsValueType.Function:
                return(getValueApi.GetFunction(isolate, value, isByRef));

            case JsValueType.JsObject:
                return(getValueApi.GetJSObject(isolate, value, isByRef));

            case JsValueType.NativeObject:
                var typeId = getValueApi.GetTypeId(isolate, value, isByRef);
                if (!typeRegister.IsArray(typeId))
                {
                    var objType = typeRegister.GetType(typeId);
                    if (objType != typeof(object) && generalGetterMap.ContainsKey(objType))
                    {
                        return(generalGetterMap[objType](isolate, getValueApi, value, isByRef));
                    }
                }
                var objPtr = getValueApi.GetNativeObject(isolate, value, isByRef);
                var result = objectPool.Get(objPtr.ToInt32());

                var typedValueResult = result as TypedValue;
                if (typedValueResult != null)
                {
                    return(typedValueResult.Target);
                }

                return(result);

            case JsValueType.Number:
                return(getValueApi.GetNumber(isolate, value, isByRef));

            case JsValueType.String:
                return(getValueApi.GetString(isolate, value, isByRef));

            default:
                return(null);
            }
        }
Beispiel #2
0
        private object JSObjectTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef)
        {
            var jsValueType = getValueApi.GetJsValueType(isolate, value, isByRef);

            if (jsValueType == JsValueType.JsObject)
            {
                IntPtr DLLJSObjectPtr = getValueApi.GetJSObject(isolate, value, isByRef);
                return(jsEnv.jsObjectFactory.GetOrCreateJSObject(DLLJSObjectPtr, jsEnv));
            }
            else
            {
                return(AnyTranslator(isolate, getValueApi, value, isByRef));
            }
        }
Beispiel #3
0
        private object JSObjectTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef)
        {
            IntPtr DLLJSObjectPtr = getValueApi.GetJSObject(isolate, value, isByRef);

            return(jsEnv.jsObjectFactory.GetOrCreateJSObject(DLLJSObjectPtr, jsEnv));
        }