Exemplo n.º 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);
            }
        }
Exemplo n.º 2
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.Function:
            //case JsValueType.JsObject:
            case JsValueType.NativeObject:
                var typeId  = getValueApi.GetTypeId(isolate, value, isByRef);
                var objType = typeRegister.GetType(typeId);
                if (objType != typeof(object) && generalGetterMap.ContainsKey(objType))
                {
                    return(generalGetterMap[objType](isolate, getValueApi, value, isByRef));
                }
                var objPtr = getValueApi.GetObject(isolate, value, isByRef);
                return(objectPool.Get(objPtr.ToInt32()));

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

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

            default:
                return(null);
            }
        }
Exemplo n.º 3
0
 public static uint GetUInt32(int jsEnvIdx, IntPtr isolate, IGetValueFromJs getValueApi, IntPtr holder, bool isByRef)
 {
     return (uint)getValueApi.GetNumber(isolate, holder, isByRef);
 }
Exemplo n.º 4
0
 public static sbyte GetSByte(int jsEnvIdx, IntPtr isolate, IGetValueFromJs getValueApi, IntPtr holder, bool isByRef)
 {
     return (sbyte)getValueApi.GetNumber(isolate, holder, isByRef);
 }
Exemplo n.º 5
0
 public static short GetInt16(int jsEnvIdx, IntPtr isolate, IGetValueFromJs getValueApi, IntPtr holder, bool isByRef)
 {
     return (short)getValueApi.GetNumber(isolate, holder, isByRef);
 }
Exemplo n.º 6
0
 public static float GetFloat(int jsEnvIdx, IntPtr isolate, IGetValueFromJs getValueApi, IntPtr holder, bool isByRef)
 {
     return (float)getValueApi.GetNumber(isolate, holder, isByRef);
 }
Exemplo n.º 7
0
 public static double GetDouble(int jsEnvIdx, IntPtr isolate, IGetValueFromJs getValueApi, IntPtr holder, bool isByRef)
 {
     return getValueApi.GetNumber(isolate, holder, isByRef);
 }
Exemplo n.º 8
0
 public static char GetChar(int jsEnvIdx, IntPtr isolate, IGetValueFromJs getValueApi, IntPtr holder, bool isByRef)
 {
     return (char)getValueApi.GetNumber(isolate, holder, isByRef);
 }
Exemplo n.º 9
0
 private static object DoubleTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef)
 {
     return(getValueApi.GetNumber(isolate, value, isByRef));
 }