Esempio n. 1
0
        public static Value lib_graphics2d_initializeTexture(VmContext vm, Value[] args)
        {
            Value          arg1         = args[0];
            Value          arg2         = args[1];
            Value          arg3         = args[2];
            Value          arg4         = args[3];
            Value          arg5         = args[4];
            ObjectInstance objInstance1 = (ObjectInstance)arg1.internalValue;

            object[] objArray1 = new object[7];
            objInstance1.nativeData = objArray1;
            objInstance1            = (ObjectInstance)arg2.internalValue;
            objArray1[0]            = objInstance1.nativeData;
            ListImpl list1  = (ListImpl)arg3.internalValue;
            Value    value  = Interpreter.Vm.CrayonWrapper.getItemFromList(list1, 0);
            double   float1 = (double)value.internalValue;

            value = Interpreter.Vm.CrayonWrapper.getItemFromList(list1, 2);
            double float2 = (double)value.internalValue;

            objArray1[1] = float1;
            objArray1[3] = float2;
            value        = Interpreter.Vm.CrayonWrapper.getItemFromList(list1, 1);
            float1       = (double)value.internalValue;
            value        = Interpreter.Vm.CrayonWrapper.getItemFromList(list1, 3);
            float2       = (double)value.internalValue;
            objArray1[2] = float1;
            objArray1[4] = float2;
            objArray1[5] = (int)arg4.internalValue;
            objArray1[6] = (int)arg5.internalValue;
            return(vm.globalNull);
        }
Esempio n. 2
0
        public static object lib_fileiocommon_listToBytes(ListImpl listOfMaybeInts)
        {
            byte[] bytes     = new byte[listOfMaybeInts.size];
            Value  intValue  = null;
            int    byteValue = 0;
            int    i         = (listOfMaybeInts.size - 1);

            while ((i >= 0))
            {
                intValue = listOfMaybeInts.array[i];
                if ((intValue.type != 3))
                {
                    return(null);
                }
                byteValue = (int)intValue.internalValue;
                if ((byteValue >= 256))
                {
                    return(null);
                }
                if ((byteValue < 0))
                {
                    if ((byteValue < -128))
                    {
                        return(null);
                    }
                    byteValue += 256;
                }
                bytes[i] = (byte)byteValue;
                i       -= 1;
            }
            return(bytes);
        }
Esempio n. 3
0
        public static Value lib_xml_parse(VmContext vm, Value[] args)
        {
            string         xml          = (string)args[0].internalValue;
            ListImpl       list1        = (ListImpl)args[1].internalValue;
            ObjectInstance objInstance1 = (ObjectInstance)args[2].internalValue;

            object[] objArray1 = objInstance1.nativeData;
            if ((objArray1 == null))
            {
                objArray1 = new object[2];
                objInstance1.nativeData = objArray1;
                objArray1[0]            = new Dictionary <string, string>();
                objArray1[1]            = new Dictionary <int, int>();
            }
            List <Value> output = new List <Value>();
            string       errMsg = lib_xml_parseImpl(vm, xml, PST_IntBuffer16, output, (Dictionary <string, string>)objArray1[0], (Dictionary <int, int>)objArray1[1]);

            if ((errMsg != null))
            {
                return(Interpreter.Vm.CrayonWrapper.buildString(vm.globals, errMsg));
            }
            ListImpl list2 = (ListImpl)Interpreter.Vm.CrayonWrapper.buildList(output).internalValue;

            list1.size     = list2.size;
            list1.capacity = list2.capacity;
            list1.array    = list2.array;
            return(vm.globalNull);
        }
Esempio n. 4
0
        public static Value lib_processutil_launchProcess(VmContext vm, Value[] args)
        {
            ObjectInstance bridge = (ObjectInstance)args[0].internalValue;

            bridge.nativeData    = new object[5];
            bridge.nativeData[0] = true;
            bridge.nativeData[1] = 0;
            bridge.nativeData[2] = new List <string>();
            bridge.nativeData[3] = new List <string>();
            bridge.nativeData[4] = new object();
            string         execName        = (string)args[1].internalValue;
            ListImpl       argsRaw         = (ListImpl)args[2].internalValue;
            bool           isAsync         = (bool)args[3].internalValue;
            Value          cb              = args[4];
            ObjectInstance dispatcherQueue = (ObjectInstance)args[5].internalValue;
            List <string>  argStrings      = new List <string>();
            int            i = 0;

            while ((i < argsRaw.size))
            {
                Value a = Interpreter.Vm.CrayonWrapper.getItemFromList(argsRaw, i);
                argStrings.Add((string)a.internalValue);
                i += 1;
            }
            ProcessUtilHelper.LaunchProcessImpl(bridge.nativeData, execName, argStrings, isAsync, cb, vm);
            return(vm.globalNull);
        }
Esempio n. 5
0
        public static Value lib_zip_initializeZipReader(VmContext vm, Value[] args)
        {
            int      sc     = 0;
            ListImpl scOut  = (ListImpl)args[2].internalValue;
            int      execId = (int)args[3].internalValue;

            int[] byteArray = lib_zip_validateByteList(args[1], true);
            if ((byteArray == null))
            {
                sc = 1;
            }
            else
            {
                ObjectInstance obj = (ObjectInstance)args[0].internalValue;
                obj.nativeData    = new object[2];
                obj.nativeData[0] = ZipHelper.CreateZipReader(byteArray);
                obj.nativeData[1] = 0;
                if ((obj.nativeData[0] == null))
                {
                    sc = 2;
                }
                else
                {
                    sc = 0;
                }
                if (AlwaysFalse())
                {
                    sc = 3;
                    Interpreter.Vm.CrayonWrapper.vm_suspend_context_by_id(vm, execId, 1);
                }
            }
            Interpreter.Vm.CrayonWrapper.setItemInList(scOut, 0, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, sc));
            return(vm.globalNull);
        }
Esempio n. 6
0
        public static Value lib_processutil_readBridge(VmContext vm, Value[] args)
        {
            ObjectInstance bridge     = (ObjectInstance)args[0].internalValue;
            ListImpl       outputList = (ListImpl)args[1].internalValue;
            int            type       = (int)args[2].internalValue;
            object         mtx        = bridge.nativeData[4];

            if ((type == 1))
            {
                int outputInt = ProcessUtilHelper.ReadBridgeInt(mtx, bridge.nativeData, type);
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, outputInt));
            }
            else
            {
                List <string> output = new List <string>();
                ProcessUtilHelper.ReadBridgeStrings(mtx, bridge.nativeData, type, output);
                int i = 0;
                while ((i < output.Count))
                {
                    Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildString(vm.globals, output[i]));
                    i += 1;
                }
            }
            return(vm.globalNull);
        }
Esempio n. 7
0
        public static Value lib_graphics2dtext_glRenderCharTile(VmContext vm, Value[] args)
        {
            object nativeFont = ((ObjectInstance)args[0].internalValue).nativeData[0];

            object[] tileNativeData = ((ObjectInstance)args[1].internalValue).nativeData;
            int      charId         = (int)args[2].internalValue;
            ListImpl sizeOut        = (ListImpl)args[3].internalValue;
            object   bmp            = Graphics2DTextHelper.RenderCharTile(nativeFont, charId, PST_IntBuffer16);

            if ((bmp == null))
            {
                return(vm.globalFalse);
            }
            int width          = PST_IntBuffer16[0];
            int height         = PST_IntBuffer16[1];
            int effectiveLeft  = PST_IntBuffer16[2];
            int effectiveWidth = PST_IntBuffer16[3];

            tileNativeData[0] = bmp;
            tileNativeData[1] = width;
            tileNativeData[2] = height;
            tileNativeData[3] = effectiveLeft;
            tileNativeData[4] = effectiveWidth;
            Interpreter.Vm.CrayonWrapper.clearList(sizeOut);
            Interpreter.Vm.CrayonWrapper.addToList(sizeOut, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, width));
            Interpreter.Vm.CrayonWrapper.addToList(sizeOut, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, height));
            Interpreter.Vm.CrayonWrapper.addToList(sizeOut, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, effectiveLeft));
            Interpreter.Vm.CrayonWrapper.addToList(sizeOut, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, effectiveWidth));
            return(vm.globalTrue);
        }
Esempio n. 8
0
        public static Value lib_zip_readerPeekNextEntryCallback(bool problemsEncountered, bool foundAnything, bool isDirectory, string name, List <int> bytesAsIntList, object[] nativeData, ListImpl output, VmContext vm)
        {
            if (problemsEncountered)
            {
                return(vm.globalFalse);
            }
            nativeData[1] = (1 + (int)nativeData[1]);
            Interpreter.Vm.CrayonWrapper.setItemInList(output, 0, Interpreter.Vm.CrayonWrapper.buildBoolean(vm.globals, foundAnything));
            if (!foundAnything)
            {
                return(vm.globalTrue);
            }
            Interpreter.Vm.CrayonWrapper.setItemInList(output, 1, Interpreter.Vm.CrayonWrapper.buildString(vm.globals, name));
            if (isDirectory)
            {
                Interpreter.Vm.CrayonWrapper.setItemInList(output, 2, Interpreter.Vm.CrayonWrapper.buildBoolean(vm.globals, isDirectory));
                return(vm.globalTrue);
            }
            ListImpl byteValues = (ListImpl)Interpreter.Vm.CrayonWrapper.getItemFromList(output, 3).internalValue;
            int      length     = bytesAsIntList.Count;
            int      i          = 0;

            Value[] positiveNumbers = vm.globals.positiveIntegers;
            Value[] valuesOut       = new Value[length];
            i = 0;
            while ((i < length))
            {
                valuesOut[i] = positiveNumbers[bytesAsIntList[i]];
                i           += 1;
            }
            byteValues.array    = valuesOut;
            byteValues.capacity = length;
            byteValues.size     = length;
            return(vm.globalTrue);
        }
Esempio n. 9
0
        public static int[] lib_zip_validateByteList(Value byteListValue, bool convert)
        {
            if ((byteListValue.type != 6))
            {
                return(null);
            }
            int[]    output = null;
            ListImpl bytes  = (ListImpl)byteListValue.internalValue;
            int      length = bytes.size;

            if (convert)
            {
                output = new int[length];
            }
            else
            {
                output    = new int[1];
                output[0] = 1;
            }
            Value value = null;
            int   b     = 0;
            int   i     = 0;

            while ((i < length))
            {
                value = bytes.array[i];
                if ((value.type != 3))
                {
                    return(null);
                }
                b = (int)value.internalValue;
                if ((b > 255))
                {
                    return(null);
                }
                if ((b < 0))
                {
                    if ((b >= -128))
                    {
                        b += 255;
                    }
                    else
                    {
                        return(null);
                    }
                }
                if (convert)
                {
                    output[i] = b;
                }
                i += 1;
            }
            return(output);
        }
Esempio n. 10
0
        public static void lib_zip_initAsyncCallback(ListImpl scOut, object[] nativeData, object nativeZipArchive, VmContext vm, int execContext)
        {
            int sc = 0;

            if ((nativeZipArchive == null))
            {
                sc = 2;
            }
            Interpreter.Vm.CrayonWrapper.setItemInList(scOut, 0, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, sc));
            nativeData[0] = nativeZipArchive;
            Interpreter.Vm.CrayonWrapper.runInterpreter(vm, execContext);
        }
Esempio n. 11
0
        public static Value lib_http_sendRequest(VmContext vm, Value[] args)
        {
            Value          body         = args[5];
            ObjectInstance objInstance1 = (ObjectInstance)args[0].internalValue;

            object[] objArray1 = new object[3];
            objInstance1.nativeData = objArray1;
            objArray1[2]            = false;
            string        method  = (string)args[2].internalValue;
            string        url     = (string)args[3].internalValue;
            List <string> headers = new List <string>();
            ListImpl      list1   = (ListImpl)args[4].internalValue;
            int           i       = 0;

            while ((i < list1.size))
            {
                headers.Add((string)list1.array[i].internalValue);
                i += 1;
            }
            object bodyRawObject = body.internalValue;
            int    bodyState     = 0;

            if ((body.type == 5))
            {
                bodyState = 1;
            }
            else if ((body.type == 8))
            {
                objInstance1  = (ObjectInstance)bodyRawObject;
                bodyRawObject = objInstance1.nativeData[0];
                bodyState     = 2;
            }
            else
            {
                bodyRawObject = null;
            }
            bool getResponseAsText = ((int)args[6].internalValue == 1);

            if ((bool)args[1].internalValue)
            {
                HttpHelper.SendRequestAsync(objArray1, method, url, headers, bodyState, bodyRawObject, getResponseAsText, vm, args[8], ((ObjectInstance)args[9].internalValue).nativeData);
            }
            else
            {
                int execId = (int)args[7].internalValue;
                if (HttpHelper.SendRequestSync(objArray1, method, url, headers, bodyState, bodyRawObject, getResponseAsText))
                {
                    Interpreter.Vm.CrayonWrapper.vm_suspend_context_by_id(vm, execId, 1);
                }
            }
            return(vm.globalNull);
        }
Esempio n. 12
0
        public static Value lib_srandom_getBoolean(VmContext vm, Value[] args)
        {
            ListImpl intPtr = (ListImpl)args[0].internalValue;
            int      value  = 0;

            value           = ((((int)intPtr.array[0].internalValue * 20077) + 12345) & 65535);
            intPtr.array[0] = Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, value);
            if (((value & 1) == 0))
            {
                return(vm.globalFalse);
            }
            return(vm.globalTrue);
        }
Esempio n. 13
0
        public static Value lib_graphics2dtext_getNativeFontUniqueKey(VmContext vm, Value[] args)
        {
            ListImpl     list1  = (ListImpl)args[7].internalValue;
            List <Value> output = new List <Value>();

            output.AddRange(new Value[] { args[0], args[1], args[2], args[6] });
            ListImpl list2 = (ListImpl)Interpreter.Vm.CrayonWrapper.buildList(output).internalValue;

            list1.array    = list2.array;
            list1.capacity = list2.capacity;
            list1.size     = list2.size;
            return(vm.globalNull);
        }
Esempio n. 14
0
        public static Value lib_graphics2dtext_createNativeFont(VmContext vm, Value[] args)
        {
            Value[]        ints = vm.globals.positiveIntegers;
            ObjectInstance nf   = (ObjectInstance)args[0].internalValue;

            object[] nfOut    = nf.nativeData;
            int      fontType = (int)args[1].internalValue;
            string   fontPath = "";

            if ((fontType == 0))
            {
                fontType = (int)args[2].internalValue;
            }
            else
            {
                fontPath = (string)args[2].internalValue;
                if ((fontType == 1))
                {
                    Value res = Interpreter.Vm.CrayonWrapper.resource_manager_getResourceOfType(vm, fontPath, "TTF");
                    if ((res.type == 1))
                    {
                        return(ints[2]);
                    }
                    ListImpl resList = (ListImpl)res.internalValue;
                    if (!(bool)Interpreter.Vm.CrayonWrapper.getItemFromList(resList, 0).internalValue)
                    {
                        return(ints[2]);
                    }
                    fontPath = (string)Interpreter.Vm.CrayonWrapper.getItemFromList(resList, 1).internalValue;
                }
            }
            int fontClass    = 0;
            int fontSize     = (int)args[3].internalValue;
            int red          = (int)args[4].internalValue;
            int green        = (int)args[5].internalValue;
            int blue         = (int)args[6].internalValue;
            int styleBitmask = (int)args[7].internalValue;
            int isBold       = (styleBitmask & 1);
            int isItalic     = (styleBitmask & 2);

            nfOut[0] = Graphics2DTextHelper.CreateNativeFont(fontType, fontClass, fontPath, fontSize, (isBold > 0), (isItalic > 0));
            if ((nfOut[0] == null))
            {
                if ((fontType == 3))
                {
                    return(ints[1]);
                }
                return(ints[2]);
            }
            return(ints[0]);
        }
Esempio n. 15
0
        public static Value lib_game_getScreenInfo(VmContext vm, Value[] args)
        {
            Value outList = args[0];

            int[] o = PST_IntBuffer16;
            if (GameWindow.GetScreenInfo(o))
            {
                ListImpl output = (ListImpl)outList.internalValue;
                Interpreter.Vm.CrayonWrapper.clearList(output);
                Interpreter.Vm.CrayonWrapper.addToList(output, Interpreter.Vm.CrayonWrapper.buildBoolean(vm.globals, (o[0] == 1)));
                Interpreter.Vm.CrayonWrapper.addToList(output, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, o[1]));
                Interpreter.Vm.CrayonWrapper.addToList(output, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, o[2]));
            }
            return(outList);
        }
Esempio n. 16
0
        public static Value lib_cryptocommon_addBytes(VmContext vm, Value[] args)
        {
            ObjectInstance obj          = (ObjectInstance)args[0].internalValue;
            ListImpl       fromByteList = (ListImpl)args[1].internalValue;
            List <int>     toByteList   = (List <int>)obj.nativeData[0];
            int            length       = fromByteList.size;
            int            i            = 0;

            while ((i < length))
            {
                toByteList.Add((int)fromByteList.array[i].internalValue);
                i += 1;
            }
            return(vm.globalFalse);
        }
Esempio n. 17
0
        public static Value lib_game_gamepad_get_axis_2d_state(VmContext vm, Value[] args)
        {
            Value          arg1         = args[0];
            Value          arg2         = args[1];
            Value          arg3         = args[2];
            ObjectInstance objInstance1 = (ObjectInstance)arg1.internalValue;
            int            int1         = (int)arg2.internalValue;
            ListImpl       list1        = (ListImpl)arg3.internalValue;

            Libraries.Game.GamepadTranslationHelper.GetDeviceAxis2dState(objInstance1.nativeData[0], int1, PST_IntBuffer16);
            Interpreter.Vm.CrayonWrapper.clearList(list1);
            Interpreter.Vm.CrayonWrapper.addToList(list1, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, PST_IntBuffer16[0]));
            Interpreter.Vm.CrayonWrapper.addToList(list1, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, PST_IntBuffer16[1]));
            return(vm.globalNull);
        }
Esempio n. 18
0
        public static Value lib_srandom_getFloat(VmContext vm, Value[] args)
        {
            ListImpl intPtr = (ListImpl)args[0].internalValue;
            int      value1 = 0;

            value1 = ((((int)intPtr.array[0].internalValue * 20077) + 12345) & 65535);
            int value2 = (((value1 * 20077) + 12345) & 65535);
            int value3 = (((value2 * 20077) + 12345) & 65535);

            intPtr.array[0] = Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, value3);
            value1          = ((value1 >> 8) & 255);
            value2          = ((value2 >> 8) & 255);
            value3          = ((value3 >> 8) & 255);
            return(Interpreter.Vm.CrayonWrapper.buildFloat(vm.globals, (((value1 << 16) | (value2 << 8) | value3)) / (16777216.0)));
        }
Esempio n. 19
0
        public static Value lib_game_gamepad_initialize_device(VmContext vm, Value[] args)
        {
            int            int1         = (int)args[0].internalValue;
            ObjectInstance objInstance1 = (ObjectInstance)args[1].internalValue;
            ListImpl       list1        = (ListImpl)args[2].internalValue;
            object         object1      = Libraries.Game.GamepadTranslationHelper.GetDeviceReference(int1);

            objInstance1.nativeData    = new object[1];
            objInstance1.nativeData[0] = object1;
            Interpreter.Vm.CrayonWrapper.clearList(list1);
            Interpreter.Vm.CrayonWrapper.addToList(list1, Interpreter.Vm.CrayonWrapper.buildString(vm.globals, Libraries.Game.GamepadTranslationHelper.GetDeviceName(object1)));
            Interpreter.Vm.CrayonWrapper.addToList(list1, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, Libraries.Game.GamepadTranslationHelper.GetDeviceButtonCount(object1)));
            Interpreter.Vm.CrayonWrapper.addToList(list1, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, Libraries.Game.GamepadTranslationHelper.GetDeviceAxis1dCount(object1)));
            Interpreter.Vm.CrayonWrapper.addToList(list1, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, Libraries.Game.GamepadTranslationHelper.GetDeviceAxis2dCount(object1)));
            return(vm.globalNull);
        }
Esempio n. 20
0
        public static Value lib_graphics2dtext_isResourceAvailable(VmContext vm, Value[] args)
        {
            string path = (string)args[0].internalValue;
            Value  res  = Interpreter.Vm.CrayonWrapper.resource_manager_getResourceOfType(vm, path, "TTF");

            if ((res.type == 1))
            {
                return(vm.globalFalse);
            }
            ListImpl resList = (ListImpl)res.internalValue;

            if (!(bool)Interpreter.Vm.CrayonWrapper.getItemFromList(resList, 0).internalValue)
            {
                return(vm.globalFalse);
            }
            return(vm.globalTrue);
        }
Esempio n. 21
0
        public static Value lib_imageencoder_encodeToBytes(VmContext vm, Value[] args)
        {
            object       platformBitmap  = Interpreter.Vm.CrayonWrapper.getNativeDataItem(args[0], 0);
            int          imageFormat     = (int)args[1].internalValue;
            List <Value> byteOutputList  = new List <Value>();
            int          statusCode      = ImageEncoderUtil.Encode(platformBitmap, imageFormat, byteOutputList, vm.globals.positiveIntegers);
            int          length          = byteOutputList.Count;
            ListImpl     finalOutputList = (ListImpl)args[2].internalValue;
            int          i = 0;

            while ((i < length))
            {
                Interpreter.Vm.CrayonWrapper.addToList(finalOutputList, byteOutputList[i]);
                i += 1;
            }
            return(Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, statusCode));
        }
Esempio n. 22
0
        public static Value lib_cryptosha1_digest(VmContext vm, Value[] args)
        {
            ObjectInstance obj      = (ObjectInstance)args[0].internalValue;
            ListImpl       output   = (ListImpl)args[1].internalValue;
            List <int>     byteList = (List <int>)obj.nativeData[0];

            int[] resultBytes = lib_cryptosha1_digestImpl(byteList);
            int   i           = 0;

            while ((i < 20))
            {
                int b = resultBytes[i];
                Interpreter.Vm.CrayonWrapper.addToList(output, vm.globals.positiveIntegers[b]);
                i += 1;
            }
            return(args[1]);
        }
Esempio n. 23
0
        public static Value lib_fileiocommon_fileInfo(VmContext vm, Value[] args)
        {
            int mask = (int)args[2].internalValue;

            FileIOCommonHelper.GetFileInfo((string)args[1].internalValue, mask, PST_IntBuffer16, PST_FloatBuffer16);
            ListImpl outputList = (ListImpl)args[3].internalValue;

            Interpreter.Vm.CrayonWrapper.clearList(outputList);
            VmGlobals globals = vm.globals;

            Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildBoolean(globals, (PST_IntBuffer16[0] > 0)));
            Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildBoolean(globals, (PST_IntBuffer16[1] > 0)));
            if (((mask & 1) != 0))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildInteger(globals, PST_IntBuffer16[2]));
            }
            else
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, globals.valueNull);
            }
            if (((mask & 2) != 0))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildBoolean(globals, (PST_IntBuffer16[3] > 0)));
            }
            else
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, globals.valueNull);
            }
            if (((mask & 4) != 0))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildFloat(globals, PST_FloatBuffer16[0]));
            }
            else
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, globals.valueNull);
            }
            if (((mask & 8) != 0))
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildFloat(globals, PST_FloatBuffer16[1]));
            }
            else
            {
                Interpreter.Vm.CrayonWrapper.addToList(outputList, globals.valueNull);
            }
            return(args[3]);
        }
Esempio n. 24
0
        public static Value lib_matrices_toVector(VmContext vm, Value[] args)
        {
            ObjectInstance obj = (ObjectInstance)args[0].internalValue;

            object[] nd     = obj.nativeData;
            double[] data   = (double[])nd[0];
            int      width  = (int)nd[1];
            int      height = (int)nd[2];
            int      length = (width * height);

            if ((args[1].type != 6))
            {
                nd[5] = "Output argument must be a list";
                return(vm.globalNull);
            }
            ListImpl output = (ListImpl)args[1].internalValue;

            while ((output.size < length))
            {
                Interpreter.Vm.CrayonWrapper.addToList(output, vm.globalNull);
            }
            double value  = 0.0;
            Value  toList = null;
            int    i      = 0;

            while ((i < length))
            {
                value = data[i];
                if ((value == 0))
                {
                    toList = vm.globals.floatZero;
                }
                else if ((value == 1))
                {
                    toList = vm.globals.floatOne;
                }
                else
                {
                    toList = new Value(4, data[i]);
                }
                output.array[i] = toList;
                i += 1;
            }
            return(args[1]);
        }
Esempio n. 25
0
        public static Value lib_game_getTouchState(VmContext vm, Value[] args)
        {
            ListImpl output = (ListImpl)args[0].internalValue;

            int[] data = new int[31];
            data[0] = 0;
            AlwaysTrue();
            int _len = data[0];
            int end  = ((_len * 3) + 1);
            int i    = 1;

            while ((i < end))
            {
                Interpreter.Vm.CrayonWrapper.addToList(output, Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, data[i]));
                i += 1;
            }
            return(vm.globalNull);
        }
Esempio n. 26
0
        public static Value lib_http_getResponseBytes(VmContext vm, Value[] args)
        {
            Value          outputListValue = args[1];
            ObjectInstance objInstance1    = (ObjectInstance)args[0].internalValue;

            object[]     objArray1 = objInstance1.nativeData;
            List <Value> tList     = new List <Value>();

            HttpHelper.GetResponseBytes(objArray1[0], vm.globals.positiveIntegers, tList);
            ListImpl outputList = (ListImpl)outputListValue.internalValue;
            Value    t          = Interpreter.Vm.CrayonWrapper.buildList(tList);
            ListImpl otherList  = (ListImpl)t.internalValue;

            outputList.capacity = otherList.capacity;
            outputList.array    = otherList.array;
            outputList.size     = tList.Count;
            return(outputListValue);
        }
Esempio n. 27
0
        public static Value lib_graphics2dtext_glSetNativeDataIntArray(VmContext vm, Value[] args)
        {
            ObjectInstance obj = (ObjectInstance)args[0].internalValue;

            object[] nativeData = obj.nativeData;
            ListImpl values     = (ListImpl)args[2].internalValue;
            int      length     = values.size;

            int[] intArray = new int[length];
            int   i        = 0;

            while ((i < length))
            {
                intArray[i] = (int)Interpreter.Vm.CrayonWrapper.getItemFromList(values, i).internalValue;
                i          += 1;
            }
            nativeData[(int)args[1].internalValue] = intArray;
            return(vm.globalNull);
        }
Esempio n. 28
0
        public static Value lib_zip_readerPeekNextEntry(VmContext vm, Value[] args)
        {
            ObjectInstance obj = (ObjectInstance)args[0].internalValue;

            object[] nd     = obj.nativeData;
            ListImpl output = (ListImpl)args[1].internalValue;
            int      execId = (int)args[2].internalValue;

            bool[]     boolOut  = new bool[3];
            string[]   nameOut  = new string[1];
            List <int> integers = new List <int>();

            ZipHelper.ReadNextZipEntry(nd[0], (int)nd[1], boolOut, nameOut, integers);
            if (AlwaysFalse())
            {
                Interpreter.Vm.CrayonWrapper.vm_suspend_context_by_id(vm, execId, 1);
                return(vm.globalTrue);
            }
            return(lib_zip_readerPeekNextEntryCallback(!boolOut[0], boolOut[1], boolOut[2], nameOut[0], integers, nd, output, vm));
        }
Esempio n. 29
0
        public static Value lib_easing_apply_pts(VmContext vm, Value[] args)
        {
            ListImpl sampleValues = (ListImpl)args[1].internalValue;
            int      _len         = sampleValues.size;

            double[] samples = new double[_len];
            int      i       = 0;

            while ((i < _len))
            {
                samples[i] = (double)sampleValues.array[i].internalValue;
                i         += 1;
            }
            samples[0]          = 0.0;
            samples[(_len - 1)] = 1.0;
            ObjectInstance o = (ObjectInstance)args[0].internalValue;

            o.nativeObject = new EasingSampling(_len, samples);
            return(vm.globals.valueNull);
        }
Esempio n. 30
0
        public static Value lib_fileiocommon_directoryList(VmContext vm, Value[] args)
        {
            Value         diskhost    = args[0];
            string        path        = (string)args[1].internalValue;
            bool          useFullPath = (bool)args[2].internalValue;
            ListImpl      outputList  = (ListImpl)args[3].internalValue;
            List <string> stringList1 = new List <string>();
            int           sc          = FileIOCommonHelper.GetDirectoryList(path, useFullPath, stringList1);

            if ((sc == 0))
            {
                int i = 0;
                while ((i < stringList1.Count))
                {
                    Interpreter.Vm.CrayonWrapper.addToList(outputList, Interpreter.Vm.CrayonWrapper.buildString(vm.globals, stringList1[i]));
                    i += 1;
                }
            }
            return(Interpreter.Vm.CrayonWrapper.buildInteger(vm.globals, sc));
        }
Esempio n. 31
0
        public static IList GetList(String csvLink, Boolean hasColumnNames, String groupBy, String filterBy, String filterValue, Boolean excatFilterMatch, String[] columnNamesToInclude)
        {
            ListImpl list = new ListImpl();

            //WebClient client = new WebClient();
            String content = "";

            content = GetContent(csvLink.Replace("dl=0", "dl=1"));

            int iStart = content.IndexOf("//dl-web.dropbox.com/");

            if (iStart > 0)
            {
                int iEnd = content.IndexOf("\"", iStart);
                if (iEnd > 0)
                {
                    csvLink = content.Substring(iStart, iEnd - iStart);
                    content = GetContent(csvLink);
                }
            }
            if( columnNamesToInclude != null )
                columnNamesToInclude = columnNamesToInclude.Select(x => x.ToLower()).ToArray();

            var lines = content.Split('\r');

            //var lines = System.IO.File.ReadAllLines(fileName, System.Text.Encoding.UTF7);

            List<int> colsWithContent = new List<int>();

            List<IRow> rows = new List<IRow>();

            for (int i = 0; i < lines.Count(); i++)
            {
                var row = lines[i].Split(';');
                IRow newRow = new RowImpl();
                for (int iCol = 0; iCol < row.Length; iCol++)
                {
                    String colValue = row[iCol];

                    //  ColumnNames
                    if (i == 0 && hasColumnNames && (columnNamesToInclude == null || columnNamesToInclude.Contains(colValue.ToLower())))
                    {
                        if (!String.IsNullOrEmpty(colValue))
                        {
                            if (!String.IsNullOrEmpty(colValue))
                            {
                                colsWithContent.Add(iCol);
                            }

                            list.ColumnNames.Add(new ColumnNameImpl { Name = colValue });
                        }
                    }
                    else if (i > 0 || !hasColumnNames)
                    {
                        if (!hasColumnNames || colsWithContent.Contains(iCol))
                        {
                            int realCol = colsWithContent.IndexOf(iCol);
                            if (hasColumnNames && String.IsNullOrEmpty(list.ColumnNames[realCol].Type))
                                list.ColumnNames[realCol].Type = GetType(colValue);

                            var newVal = new ValueImpl { Value = colValue };
                            Boolean addRow = true;
                            DateTime tTemp;
                            if (list.ColumnNames[realCol].Type == "DateTime")
                            {
                                if (!DateTime.TryParse(colValue, out tTemp))
                                    tTemp = DateTime.MinValue;

                                newVal.Value = tTemp;

                            }

                            if (newVal.Value is String)
                                newVal.Value = newVal.Value.ToString().Replace("\n", "");

                            if (addRow)
                                newRow.Values.Add(newVal);

                        }
                    }
                }

                if (!hasColumnNames || (newRow.Values.Count == list.ColumnNames.Count && newRow.Values.Any(y => !String.IsNullOrEmpty(y.Value as String)) && (i > 0 || !hasColumnNames)))
                    rows.Add(newRow);
            }

            ListEntryImpl listEntry = null;

            if (!String.IsNullOrEmpty(filterBy))
            {
                int index = list.ColumnNames.Select(x => x.Name.ToLower()).ToList().IndexOf(filterBy.ToLower());

                if (index > -1)
                {
                    if (excatFilterMatch)
                        rows = rows.Where(x => (x.Values[index].Value ?? "").ToString() == filterValue).ToList();
                    else
                        rows = rows.Where(x => (x.Values[index].Value ?? "").ToString().ToLower().Contains(filterValue.ToLower())).ToList();
                }
            }

            if (!String.IsNullOrEmpty(groupBy))
            {
                int index = list.ColumnNames.Select(x => x.Name).ToList().IndexOf(groupBy);

                if (index > -1)
                {
                    var grouping = rows.GroupBy(x => x.Values[index].Value.ToString()).OrderBy(x => x.Key);
                    rows = new List<IRow>();

                    foreach (var group in grouping)
                    {
                        listEntry = new ListEntryImpl { Title = group.Key.Replace("\n", ""), Parent = list, Rows = group.ToList() };
                        list.Add(listEntry);
                    }

                }
            }

            if (list.Count() == 0 && rows.Count > 0)
            {
                listEntry = new ListEntryImpl { Parent = list, Rows = rows };
                list.Add(listEntry);
            }

            list.CsvLink = csvLink;

            return list;
        }