Example #1
0
 public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypeSyntax elementType, bool enablePinning, InteropGenerationOptions options)
 {
     _manualMarshallingGenerator = manualMarshallingGenerator;
     _elementType   = elementType;
     _enablePinning = enablePinning;
     _options       = options;
 }
Example #2
0
 public NonBlittableElementsMarshalling(
     TypeSyntax unmanagedElementType,
     IMarshallingGenerator elementMarshaller,
     TypePositionInfo elementInfo)
 {
     _unmanagedElementType = unmanagedElementType;
     _elementMarshaller    = elementMarshaller;
     _elementInfo          = elementInfo;
 }
Example #3
0
 /// <summary>
 /// Gets the return type for the unmanaged signature that represents the provided <paramref name="info"/>.
 /// </summary>
 /// <param name="generator">The marshalling generator for this <paramref name="info"/></param>
 /// <param name="info">Object to marshal</param>
 public static TypeSyntax AsReturnType(this IMarshallingGenerator generator, TypePositionInfo info)
 {
     return(generator.GetNativeSignatureBehavior(info) switch
     {
         SignatureBehavior.ManagedTypeAndAttributes => info.ManagedType.Syntax,
         SignatureBehavior.NativeType => generator.AsNativeType(info),
         SignatureBehavior.PointerToNativeType => PointerType(generator.AsNativeType(info)),
         _ => throw new InvalidOperationException()
     });
 public StatefulLinearCollectionNonBlittableElementsMarshalling(
     ICustomTypeMarshallingStrategy innerMarshaller,
     MarshallerShape shape,
     TypeSyntax unmanagedElementType,
     IMarshallingGenerator elementMarshaller,
     TypePositionInfo elementInfo,
     ExpressionSyntax numElementsExpression)
     : base(unmanagedElementType, elementMarshaller, elementInfo)
 {
     _innerMarshaller       = innerMarshaller;
     _shape                 = shape;
     _numElementsExpression = numElementsExpression;
 }
Example #5
0
        /// <summary>
        /// Gets any attributes that should be applied to the return type for this <paramref name="info"/>.
        /// </summary>
        /// <param name="generator">The marshalling generator for this <paramref name="info"/></param>
        /// <param name="info">Object to marshal</param>
        /// <returns>Attributes for the return type for this <paramref name="info"/>, or <c>null</c> if no attributes should be added.</returns>
        public static AttributeListSyntax? GenerateAttributesForReturnType(this IMarshallingGenerator generator, TypePositionInfo info)
        {
            if (generator.GetNativeSignatureBehavior(info) != SignatureBehavior.ManagedTypeAndAttributes)
            {
                return null;
            }

            if (!TryRehydrateMarshalAsAttribute(info, out AttributeSyntax marshalAsAttribute))
            {
                return null;
            }
            return AttributeList(SingletonSeparatedList(marshalAsAttribute));
        }
Example #6
0
 /// <summary>
 /// Gets a parameter for the unmanaged signature that represents the provided <paramref name="info"/>.
 /// </summary>
 /// <param name="generator">The marshalling generator for this <paramref name="info"/></param>
 /// <param name="info">Object to marshal</param>
 public static ParameterSyntax AsParameter(this IMarshallingGenerator generator, TypePositionInfo info)
 {
     SignatureBehavior behavior = generator.GetNativeSignatureBehavior(info);
     if (behavior == SignatureBehavior.ManagedTypeAndAttributes)
     {
         return GenerateForwardingParameter(info);
     }
     return Parameter(Identifier(info.InstanceIdentifier))
         .WithType(behavior switch
         {
             SignatureBehavior.NativeType => generator.AsNativeType(info),
             SignatureBehavior.PointerToNativeType => PointerType(generator.AsNativeType(info)),
             _ => throw new InvalidOperationException()
         });
Example #7
0
 public StatelessLinearCollectionNonBlittableElementsMarshalling(
     TypeSyntax marshallerTypeSyntax,
     TypeSyntax nativeTypeSyntax,
     MarshallerShape shape,
     TypeSyntax unmanagedElementType,
     IMarshallingGenerator elementMarshaller,
     TypePositionInfo elementInfo,
     ExpressionSyntax numElementsExpression)
     : base(unmanagedElementType, elementMarshaller, elementInfo)
 {
     _marshallerTypeSyntax = marshallerTypeSyntax;
     _nativeTypeSyntax     = nativeTypeSyntax;
     _shape = shape;
     _numElementsExpression = numElementsExpression;
 }
 public PinnableManagedValueMarshaller(IMarshallingGenerator manualMarshallingGenerator)
 {
     _manualMarshallingGenerator = manualMarshallingGenerator;
 }
Example #9
0
 public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypeSyntax elementType, bool enablePinning)
 {
     _manualMarshallingGenerator = manualMarshallingGenerator;
     _elementType   = elementType;
     _enablePinning = enablePinning;
 }
Example #10
0
 public ArrayMarshaller(IMarshallingGenerator manualMarshallingGenerator, TypePositionInfo elementInfo, bool enablePinning)
 {
     _manualMarshallingGenerator = manualMarshallingGenerator;
     _elementInfo   = elementInfo;
     _enablePinning = enablePinning;
 }
Example #11
0
 protected BaseJSGenerator(MarshalerType marshalerType, IMarshallingGenerator inner)
 {
     _inner = inner;
     Type   = marshalerType;
 }
 public PlatformDefinedStringMarshaller(IMarshallingGenerator windowsMarshaller, IMarshallingGenerator nonWindowsMarshaller)
 {
     _windowsMarshaller    = windowsMarshaller;
     _nonWindowsMarshaller = nonWindowsMarshaller;
 }
 public PinnableManagedValueMarshaller(IMarshallingGenerator innerMarshallingGenerator)
 {
     _innerMarshallingGenerator = innerMarshallingGenerator;
 }
        private static IMarshallingGenerator ValidateByValueMarshalKind(TypePositionInfo info, StubCodeContext context, IMarshallingGenerator generator)
        {
            if (generator is Forwarder)
            {
                // Forwarder allows everything since it just forwards to a P/Invoke.
                return(generator);
            }

            if (info.IsByRef && info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default)
            {
                throw new MarshallingNotSupportedException(info, context)
                      {
                          NotSupportedDetails = Resources.InOutAttributeByRefNotSupported
                      };
            }
            else if (info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.In)
            {
                throw new MarshallingNotSupportedException(info, context)
                      {
                          NotSupportedDetails = Resources.InAttributeNotSupportedWithoutOut
                      };
            }
            else if (info.ByValueContentsMarshalKind != ByValueContentsMarshalKind.Default &&
                     !generator.SupportsByValueMarshalKind(info.ByValueContentsMarshalKind, context))
            {
                throw new MarshallingNotSupportedException(info, context)
                      {
                          NotSupportedDetails = Resources.InOutAttributeMarshalerNotSupported
                      };
            }
            return(generator);
        }
Example #15
0
 public StaticPinnableManagedValueMarshaller(IMarshallingGenerator innerMarshallingGenerator, TypeSyntax getPinnableReferenceType)
 {
     _innerMarshallingGenerator = innerMarshallingGenerator;
     _getPinnableReferenceType  = getPinnableReferenceType;
 }
Example #16
0
 public PrimitiveJSGenerator(MarshalerType marshalerType, IMarshallingGenerator inner)
     : base(marshalerType, inner)
 {
 }