Exemple #1
0
        private static IntPtr cs_alloc_array_type(int arg1, hxValueType arg2)
        {
            Array arr;

            switch (arg2)
            {
            case hxValueType.valtBool:
                arr = new Array <bool>(new bool[arg1]);
                break;

            case hxValueType.valtInt:
                arr = new Array <int>(new int[arg1]);
                break;

            case hxValueType.valtFloat:
                arr = new Array <double>(new double[arg1]);
                break;

            case hxValueType.valtString:
                arr = new Array <String>(new String[arg1]);
                break;

            case hxValueType.valtObject:
                arr = new Array <object>(new object[arg1]);
                break;

            default:
                return(IntPtr.Zero);
            }
            return(CSHandleContainer.GetCurrent().CreateGCHandle(arr));
        }
Exemple #2
0
        private static IntPtr cs_alloc_wstring_len(IntPtr inStr, int inLen)
        {
            byte[] bytes;
            String str;
            int    totalLen;

            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
            case PlatformID.Win32S:
            case PlatformID.Win32Windows:
                totalLen = inLen * 2;
                bytes    = new byte[totalLen];
                Marshal.Copy(inStr, bytes, 0, totalLen);
                str = Encoding.Unicode.GetString(bytes);
                return(CSHandleContainer.GetCurrent().CreateGCHandle(str));

            default:
                totalLen = inLen * 4;
                bytes    = new byte[totalLen];
                Marshal.Copy(inStr, bytes, 0, totalLen);
                str = Encoding.UTF32.GetString(bytes);
                return(CSHandleContainer.GetCurrent().CreateGCHandle(str));
            }
        }
Exemple #3
0
        internal static CSHandleContainer GetCurrent()
        {
            if (container == null)
                container = new CSHandleContainer();

            return container;
        }
Exemple #4
0
        private static IntPtr cs_alloc_string_len(IntPtr inStr, int inLen)
        {
            byte[] bytes = new byte[inLen];
            Marshal.Copy(inStr, bytes, 0, inLen);
            String str = Encoding.UTF8.GetString(bytes, 0, inLen);

            return(CSHandleContainer.GetCurrent().CreateGCHandle(str));
        }
Exemple #5
0
        internal static CSHandleContainer GetCurrent()
        {
            if (container == null)
            {
                container = new CSHandleContainer();
            }

            return(container);
        }
Exemple #6
0
        private static IntPtr cs_buffer_data(IntPtr inBuffer)
        {
            byte[] buffer = (byte[])HandleUtils.GetObjectFromIntPtr(inBuffer);
            if (buffer == null)
            {
                return(IntPtr.Zero);
            }

            return(CSHandleContainer.GetCurrent().GetAddrOfBlittableObject(buffer));
        }
Exemple #7
0
        private static IntPtr cs_val_call0(IntPtr inArg1)
        {
            Function arg1 = (Function)HandleUtils.GetObjectFromIntPtr(inArg1);

            if (arg1 == null)
            {
                throw new ArgumentNullException("Null function call");
            }

            return(CSHandleContainer.GetCurrent().CreateGCHandle(arg1.__hx_invoke0_o()));
        }
Exemple #8
0
        private static IntPtr cs_val_array_i(IntPtr inArg1, int arg2)
        {
            Array arg1 = (Array)HandleUtils.GetObjectFromIntPtr(inArg1);

            if (arg1 == null)
            {
                return(IntPtr.Zero);
            }

            return(CSHandleContainer.GetCurrent().CreateGCHandle(arg1[arg2]));
        }
Exemple #9
0
        private static IntPtr cs_val_field(IntPtr inArg1, int arg2)
        {
            object arg1 = HandleUtils.GetObjectFromIntPtr(inArg1);

            if (arg1 == null)
            {
                throw new ArgumentNullException("Null object get");
            }

            CSHandleContainer container = CSHandleContainer.GetCurrent();
            String            field     = container.GetStringFromId(arg2);

            return(container.CreateGCHandle(Reflect.field(arg1, field)));
        }
Exemple #10
0
        private static void cs_alloc_field(IntPtr inArg1, int arg2, IntPtr inArg3)
        {
            object arg1 = HandleUtils.GetObjectFromIntPtr(inArg1);
            object arg3 = HandleUtils.GetObjectFromIntPtr(inArg3);

            if (arg1 == null)
            {
                throw new ArgumentNullException("Null object set");
            }

            String field = CSHandleContainer.GetCurrent().GetStringFromId(arg2);

            Reflect.setField(arg1, field, arg3);
        }
Exemple #11
0
        private static IntPtr cs_val_array_int(IntPtr inArg1)
        {
            Array arg1 = (Array)HandleUtils.GetObjectFromIntPtr(inArg1);

            if (arg1 == null)
            {
                return(IntPtr.Zero);
            }

            Array <int> intHxArray = arg1 as Array <int>;

            if (intHxArray != null)
            {
                return(CSHandleContainer.GetCurrent().GetAddrOfBlittableObject(intHxArray.__a));
            }

            return(IntPtr.Zero);
        }
Exemple #12
0
        private static IntPtr cs_val_string(IntPtr inArg1)
        {
            String arg1 = (String)HandleUtils.GetObjectFromIntPtr(inArg1);

            if (arg1 == null)
            {
                return(IntPtr.Zero);
            }

            CSHandleContainer container = CSHandleContainer.GetCurrent();

            byte[] bytes  = System.Text.Encoding.UTF8.GetBytes(arg1);
            IntPtr memory = container.AllocateMemory(sizeof(byte) * (bytes.Length + 1));

            Marshal.Copy(bytes, 0, memory, bytes.Length);
            Marshal.WriteByte(memory, bytes.Length, 0);
            return(memory);
        }
Exemple #13
0
 private static int cs_val_id(String arg1)
 {
     return(CSHandleContainer.GetCurrent().GetId(arg1));
 }
Exemple #14
0
 private static IntPtr cs_alloc_buffer_len(int inLen)
 {
     byte[] buffer = new byte[inLen];
     return(CSHandleContainer.GetCurrent().CreatePinnedGCHandle(buffer));
 }
Exemple #15
0
 private static IntPtr cs_alloc_float(double arg1)
 {
     return(CSHandleContainer.GetCurrent().CreateGCHandle(arg1));
 }
Exemple #16
0
 private static IntPtr cs_alloc_abstract(int arg1, IntPtr arg2)
 {
     return(CSHandleContainer.GetCurrent().CreateGCHandle(new CSAbstract(arg1, arg2)));
 }
Exemple #17
0
 private static IntPtr cs_alloc_empty_object()
 {
     return(CSHandleContainer.GetCurrent().CreateGCHandle(new DynamicObject()));
 }
Exemple #18
0
 private static IntPtr cs_alloc_bool(bool arg1)
 {
     return(CSHandleContainer.GetCurrent().CreateGCHandle(arg1));
 }
Exemple #19
0
        private static IntPtr cs_query_root(IntPtr inValue)
        {
            CSPersistent persistent = (CSPersistent)HandleUtils.GetObjectFromIntPtr(inValue);

            return(CSHandleContainer.GetCurrent().CreateGCHandle(persistent.Value));
        }
Exemple #20
0
 private static IntPtr cs_alloc_array(int arg1)
 {
     return(CSHandleContainer.GetCurrent().CreateGCHandle(new Array <object>(new object[arg1])));
 }