示例#1
0
 /// <summary>
 /// Marshal as JavaScript <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</see>.
 /// </summary>
 public static JSMarshalerType Function(JSMarshalerType result)
 {
     CheckTask(result);
     return(new JSMarshalerType(new JSFunctionBinding.JSBindingType
     {
         Type = MarshalerType.Function,
         ResultMarshalerType = result._signatureType.Type,
     }));
 }
示例#2
0
 /// <summary>
 /// Marshal as JavaScript <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</see>.
 /// </summary>
 public static JSMarshalerType Action(JSMarshalerType arg1)
 {
     CheckTask(arg1);
     return(new JSMarshalerType(new JSFunctionBinding.JSBindingType
     {
         Type = MarshalerType.Action,
         Arg1MarshalerType = arg1._signatureType.Type
     }));
 }
示例#3
0
 /// <summary>
 /// Marshal as instance of Span class on JavaScript side.
 /// </summary>
 /// <remarks>Marshaler is not pinning the data, caller is responsible for doing that.</remarks>
 public static JSMarshalerType Span(JSMarshalerType element)
 {
     CheckArraySegment(element);
     return(new JSMarshalerType(new JSFunctionBinding.JSBindingType
     {
         Type = MarshalerType.Span,
         Arg1MarshalerType = element._signatureType.Type
     }));
 }
示例#4
0
 public static JSMarshalerType Nullable(JSMarshalerType primitive)
 {
     CheckNullable(primitive);
     return(new JSMarshalerType(new JSFunctionBinding.JSBindingType
     {
         Type = MarshalerType.Nullable,
         ResultMarshalerType = primitive._signatureType.Type
     }));
 }
示例#5
0
        internal static void CheckArraySegment(JSMarshalerType underlyingSig)
        {
            MarshalerType underlying = underlyingSig._signatureType.Type;

            if (underlying == MarshalerType.Byte ||
                underlying == MarshalerType.Int32 ||
                underlying == MarshalerType.Double
                )
            {
                return;
            }
            throw new ArgumentException("Bad array element type");
        }
示例#6
0
 /// <summary>
 /// Marshal as JavaScript <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</see>.
 /// </summary>
 public static JSMarshalerType Function(JSMarshalerType arg1, JSMarshalerType arg2, JSMarshalerType result)
 {
     CheckTask(arg1);
     CheckTask(arg2);
     CheckTask(result);
     return(new JSMarshalerType(new JSFunctionBinding.JSBindingType
     {
         Type = MarshalerType.Function,
         Arg1MarshalerType = arg1._signatureType.Type,
         Arg2MarshalerType = arg2._signatureType.Type,
         ResultMarshalerType = result._signatureType.Type,
     }));
 }
示例#7
0
        internal static void CheckTask(JSMarshalerType underlyingSig)
        {
            MarshalerType underlying = underlyingSig._signatureType.Type;

            // TODO maybe allow Task<byte[]> and Task<int[]> which don't need element marshaler
            if (underlying == MarshalerType.Array ||
                underlying == MarshalerType.ArraySegment ||
                underlying == MarshalerType.Span

                || underlying == MarshalerType.Task ||
                underlying == MarshalerType.Action ||
                underlying == MarshalerType.Function
                )
            {
                throw new ArgumentException("Bad task result type");
            }
        }
示例#8
0
        internal static void CheckNullable(JSMarshalerType underlyingSig)
        {
            MarshalerType underlying = underlyingSig._signatureType.Type;

            if (underlying == MarshalerType.Boolean ||
                underlying == MarshalerType.Byte ||
                underlying == MarshalerType.Int16 ||
                underlying == MarshalerType.Int32 ||
                underlying == MarshalerType.BigInt64 ||
                underlying == MarshalerType.Int52 ||
                underlying == MarshalerType.IntPtr ||
                underlying == MarshalerType.Double ||
                underlying == MarshalerType.Single ||
                underlying == MarshalerType.Single ||
                underlying == MarshalerType.Char ||
                underlying == MarshalerType.DateTime ||
                underlying == MarshalerType.DateTimeOffset
                )
            {
                return;
            }
            throw new ArgumentException("Bad nullable value type");
        }