Exemplo n.º 1
0
        private static void ToUInt32(IntPtr info)
        {
            NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info);
            uint result = 0;

            if (arguments.Length > 0)
            {
                NSJSUInt8Array value      = arguments[0] as NSJSUInt8Array;
                NSJSInt32      startIndex = null;
                if (arguments.Length > 1)
                {
                    startIndex = arguments[1] as NSJSInt32;
                }
                if (value != null)
                {
                    int offset = 0;
                    if (startIndex != null)
                    {
                        offset = startIndex.Value;
                    }
                    if (offset < 0)
                    {
                        offset = 0;
                    }
                    byte[] buffer = value.Buffer;
                    if (buffer != null)
                    {
                        result = BITCONVERTER.ToUInt32(buffer, offset);
                    }
                }
            }
            arguments.SetReturnValue(result);
        }
Exemplo n.º 2
0
        private static void GetBytes(IntPtr info)
        {
            NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info);

            byte[] result = null;
            if (arguments.Length > 0)
            {
                NSJSValue value = arguments[0];
                if (value != null)
                {
                    NSJSInt32 int32 = value as NSJSInt32;
                    if (int32 != null)
                    {
                        result = BITCONVERTER.GetBytes(int32.Value);
                    }
                    NSJSUInt32 uint32 = value as NSJSUInt32;
                    if (uint32 != null)
                    {
                        result = BITCONVERTER.GetBytes(uint32.Value);
                    }
                    NSJSBoolean boolean = value as NSJSBoolean;
                    if (boolean != null)
                    {
                        result = BITCONVERTER.GetBytes(boolean.Value);
                    }
                    NSJSDouble float64 = value as NSJSDouble;
                    if (float64 != null)
                    {
                        result = BITCONVERTER.GetBytes(float64.Value);
                    }
                    NSJSDateTime datetime = value as NSJSDateTime;
                    if (datetime != null)
                    {
                        result = BITCONVERTER.GetBytes(NSJSDateTime.DateTimeToLocalDate(datetime.Value));
                    }
                    ;
                }
            }
            if (result != null)
            {
                arguments.SetReturnValue(result);
            }
            else
            {
                arguments.SetReturnValue(NSJSValue.Undefined(arguments.VirtualMachine));
            }
        }
Exemplo n.º 3
0
        private static void ToDateTime(IntPtr info)
        {
            NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info);
            NSJSValue result = null;

            if (arguments.Length > 0)
            {
                NSJSUInt8Array value      = arguments[0] as NSJSUInt8Array;
                NSJSInt32      startIndex = null;
                if (arguments.Length > 1)
                {
                    startIndex = arguments[1] as NSJSInt32;
                }
                if (value != null)
                {
                    int offset = 0;
                    if (startIndex != null)
                    {
                        offset = startIndex.Value;
                    }
                    if (offset < 0)
                    {
                        offset = 0;
                    }
                    byte[] buffer = value.Buffer;
                    if (buffer != null)
                    {
                        long ticks = BITCONVERTER.ToInt64(buffer, offset);
                        result = NSJSDateTime.New(arguments.VirtualMachine, ticks);
                    }
                }
            }
            if (result == null)
            {
                result = NSJSValue.Undefined(arguments.VirtualMachine);
            }
            arguments.SetReturnValue(result);
        }