Example #1
0
 /// <summary>
 /// 渡された<see cref="QiSignatures.TypeDynamic"/>シグネチャを持った変数をそのまま格納するか、
 /// そうでない場合渡された値を動的型コンテナに格納してインスタンスを初期化します。
 /// </summary>
 /// <param name="value">インスタンスが保持する値</param>
 public QiDynamic(QiValue value)
 {
     if (value.ValueKind == QiValueKind.QiDynamic)
     {
         QiValue = value;
     }
     else
     {
         QiValue = QiValue.Create(QiSignatures.TypeDynamic);
         QiValue.SetValue(value);
     }
 }
Example #2
0
 internal static bool SetInt64(QiValue v, long target)
     => Convert.ToBoolean(qi_value_set_int64(v.Handle, target));
 internal static void SetValue(QiPromise promise, QiValue value)
     => qi_promise_set_value(promise.Handle, value.Handle);
Example #4
0
        internal static bool SetRaw(QiValue v, byte[] data)
        {
            var dataPtr = Marshal.AllocHGlobal(data.Length);

            Marshal.Copy(data, 0, dataPtr, data.Length);
            var result = Convert.ToBoolean(qi_value_raw_set(v.Handle, dataPtr, data.Length));
            Marshal.FreeHGlobal(dataPtr);

            return result;
        }
Example #5
0
 internal static bool SetDynamic(QiValue container, QiValue value)
     => Convert.ToBoolean(qi_value_dynamic_set(container.Handle, value.Handle));
Example #6
0
 internal static QiValue GetTuple(QiValue container, uint idx)
     => new QiValue(qi_value_tuple_get(container.Handle, idx));
Example #7
0
 internal static bool SetObject(QiValue v, QiObject obj)
     => Convert.ToBoolean(qi_value_set_object(v.Handle, obj.Handle));
Example #8
0
 internal static QiValue KeysMap(QiValue container) 
     => new QiValue(qi_value_map_keys(container.Handle));
Example #9
0
 internal static bool GetDouble(QiValue v, ref double target)
     => Convert.ToBoolean(qi_value_get_double(v.Handle, ref target));
Example #10
0
 internal static bool SetDouble(QiValue v, double target)
     => Convert.ToBoolean(qi_value_set_double(v.Handle, target));
Example #11
0
 internal static float GetFloatWithDefault(QiValue v, float defaultValue)
     => qi_value_get_float_default(v.Handle, defaultValue);
Example #12
0
 internal static bool GetFloat(QiValue v, ref float target)
     => Convert.ToBoolean(qi_value_get_float(v.Handle, ref target));
Example #13
0
 internal static bool SetFloat(QiValue v, float target)
     => Convert.ToBoolean(qi_value_set_float(v.Handle, target));
Example #14
0
 internal static long GetInt64WithDefault(QiValue v, long defaultValue)
     => qi_value_get_int64_default(v.Handle, defaultValue);
Example #15
0
 internal static bool GetInt64(QiValue v, ref long target)
     => Convert.ToBoolean(qi_value_get_int64(v.Handle, ref target));
Example #16
0
 internal static bool SetMap(QiValue container, QiValue key, QiValue element)
     => Convert.ToBoolean(qi_value_map_set(container.Handle, key.Handle, element.Handle));
Example #17
0
 internal static QiValue GetMap(QiValue container, QiValue key) 
     => new QiValue(qi_value_map_get(container.Handle, key.Handle));
Example #18
0
 internal static double GetDoubleWithDefault(QiValue v, double defaultValue)
     => qi_value_get_double_default(v.Handle, defaultValue);
Example #19
0
 internal static QiObject GetObject(QiValue v)
     => new QiObject(qi_value_get_object(v.Handle));
Example #20
0
        internal static bool SetString(QiValue v, string target)
        {
            //NOTE: アンマネージ側はヌル終端文字を想定してるらしい
            var data = Encoding.UTF8.GetBytes(target);
            IntPtr tPtr = Marshal.AllocHGlobal(data.Length + 1);
            Marshal.Copy(data, 0, tPtr, data.Length);
            Marshal.WriteByte(tPtr, data.Length, 0x00);
            bool result = Convert.ToBoolean(qi_value_set_string(v.Handle, tPtr));
            Marshal.FreeHGlobal(tPtr);

            return result;
        }
Example #21
0
 internal static bool SetTuple(QiValue container, uint idx, QiValue element)
     => Convert.ToBoolean(qi_value_tuple_set(container.Handle, idx, element.Handle));
Example #22
0
        internal static string GetString(QiValue v)
        {
            IntPtr utf8nullEndStringPtr = qi_value_get_string(v.Handle);
            int byteLength = 0;
            //ヌル終端探し(これ上限無いの地味に怖いなあ)
            while(Marshal.ReadByte(utf8nullEndStringPtr, byteLength) != (byte)0x00)
            {
                byteLength++;
            }

            var strBytes = new byte[byteLength];
            Marshal.Copy(utf8nullEndStringPtr, strBytes, 0, byteLength);
            return Encoding.UTF8.GetString(strBytes);
        }
Example #23
0
 internal static int SizeTuple(QiValue container)
     => qi_value_tuple_size(container.Handle);
Example #24
0
 internal static QiValue GetList(QiValue container, uint idx)
     => new QiValue(qi_value_list_get(container.Handle, idx));
Example #25
0
 internal static QiValue GetDynamic(QiValue container)
     => new QiValue(qi_value_dynamic_get(container.Handle));
Example #26
0
 internal static bool AddList(QiValue container, QiValue element)
     => Convert.ToBoolean(qi_value_list_push_back(container.Handle, element.Handle));
Example #27
0
        internal static byte[] GetRaw(QiValue v)
        {
            IntPtr data = IntPtr.Zero;
            int size = 0;

            int response = qi_value_raw_get(v.Handle, ref data, ref size);
            //冗長だけど念のためサイズも確認
            if(response > 0 && size > 0)
            {
                byte[] result = new byte[size];
                Marshal.Copy(data, result, 0, size);
                //(少なくとも自作実装では)元データのポインタを貰う想定なので解放しない
                //Marshal.FreeHGlobal(data);
                return result;
            }
            else
            {
                Marshal.FreeHGlobal(data);
                return new byte[0];
            }
        }
Example #28
0
 internal static int SizeList(QiValue container) => qi_value_list_size(container.Handle);
 internal QiMethodArgumentInfo(QiValue argInfo)
 {
     Name = argInfo[0].ToString();
     Description = argInfo[1].ToString();
 }
Example #30
0
 internal static uint SizeMap(QiValue container)  => qi_value_map_size(container.Handle);