Example #1
0
        private static ServerCommandArgument CalcCommandArgument(NativeParameterType type)
        {
            var value = ServerCommandArgument.Terminator;

            switch (type & ArgumentMask)
            {
            case NativeParameterType.Int32:
            case NativeParameterType.Single:
            case NativeParameterType.Bool:
                value = ServerCommandArgument.Value;
                break;

            case NativeParameterType.String:
                value = ServerCommandArgument.String;
                break;
            }

            if (type.HasFlag(NativeParameterType.Array))
            {
                value = ServerCommandArgument.Array;
            }

            if (type.HasFlag(NativeParameterType.Reference))
            {
                value |= ServerCommandArgument.Reference;
            }

            return(value);
        }
Example #2
0
        private static bool CalcRequiresLength(NativeParameterType type)
        {
            var isArray     = type.HasFlag(NativeParameterType.Array);
            var isReference = type.HasFlag(NativeParameterType.Reference);
            var isValue     = (type & (NativeParameterType.Int32 | NativeParameterType.Single | NativeParameterType.Bool)) != 0;

            return(isArray || isReference && !isValue);
        }
 private static void EmitConvertToInt(ILGenerator ilGenerator, NativeParameterType type)
 {
     if (type.HasFlag(NativeParameterType.Single))
     {
         ilGenerator.EmitConvert <float, int>();
     }
     if (type.HasFlag(NativeParameterType.Bool))
     {
         ilGenerator.EmitConvert <bool, int>();
     }
 }