/// <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, })); }
/// <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 })); }
/// <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 })); }
public static JSMarshalerType Nullable(JSMarshalerType primitive) { CheckNullable(primitive); return(new JSMarshalerType(new JSFunctionBinding.JSBindingType { Type = MarshalerType.Nullable, ResultMarshalerType = primitive._signatureType.Type })); }
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"); }
/// <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, })); }
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"); } }
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"); }