Exemplo n.º 1
0
 public DefaultGenerators(
     GlobalNamespaceProvider globalNamespace,
     IDocumentationLinker documentation,
     ExternalDocCommentsReader docReader,
     Logger logger)
 {
     Constant              = new ConstantCodeGenerator();
     Property              = new PropertyCodeGenerator(this, documentation, docReader);
     Enum                  = new EnumCodeGenerator(documentation, docReader);
     ExplicitOffsetField   = new FieldCodeGenerator(documentation, docReader, true);
     AutoLayoutField       = new FieldCodeGenerator(documentation, docReader, false);
     Struct                = new StructCodeGenerator(this, documentation, docReader);
     NativeStruct          = new NativeStructCodeGenerator(this, globalNamespace);
     NativeInvocation      = new NativeInvocationCodeGenerator(this, globalNamespace);
     Callable              = new CallableCodeGenerator(this, documentation, docReader, globalNamespace);
     Method                = new MethodCodeGenerator(this);
     Function              = new FunctionCodeGenerator(this);
     Interface             = new InterfaceCodeGenerator(this, documentation, docReader, globalNamespace);
     Group                 = new GroupCodeGenerator(this, documentation, docReader);
     LocalInterop          = new LocalInteropCodeGenerator(this);
     InteropMethod         = new InteropMethodCodeGenerator();
     ShadowCallable        = new ShadowCallbackGenerator(this, globalNamespace);
     ReverseCallableProlog = new ReverseCallablePrologCodeGenerator(this, globalNamespace);
     Vtbl                  = new VtblGenerator(this, globalNamespace);
     Shadow                = new ShadowGenerator(this, globalNamespace);
     Marshalling           = new MarshallingRegistry(globalNamespace, logger);
 }
Exemplo n.º 2
0
 private DelegateDeclarationSyntax GenerateDelegateDeclaration(CsCallable csElement, PlatformDetectionType platform, InteropMethodSignature sig)
 {
     return(DelegateDeclaration(ParseTypeName(sig.ReturnType.TypeName), VtblGenerator.GetMethodDelegateName(csElement, platform))
            .AddAttributeLists(
                AttributeList(
                    SingletonSeparatedList(
                        Attribute(
                            ParseName("System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute"))
                        .AddArgumentListArguments(
                            AttributeArgument(
                                MemberAccessExpression(
                                    SyntaxKind.SimpleMemberAccessExpression,
                                    MemberAccessExpression(
                                        SyntaxKind.SimpleMemberAccessExpression,
                                        MemberAccessExpression(
                                            SyntaxKind.SimpleMemberAccessExpression,
                                            MemberAccessExpression(
                                                SyntaxKind.SimpleMemberAccessExpression,
                                                IdentifierName("System"),
                                                IdentifierName("Runtime")),
                                            IdentifierName("InteropServices")),
                                        IdentifierName("CallingConvention")),
                                    IdentifierName(sig.CallingConvention.ToManagedCallingConventionName())))))))
            .WithParameterList(
                ParameterList(
                    (csElement is CsMethod ?
                     SingletonSeparatedList(
                         Parameter(Identifier("thisObject"))
                         .WithType(GeneratorHelpers.IntPtrType))
                 : default)
Exemplo n.º 3
0
 public DefaultGenerators(GeneratorConfig config, Ioc ioc)
 {
     Constant              = new ConstantCodeGenerator(ioc);
     Property              = new PropertyCodeGenerator(ioc);
     Enum                  = new EnumCodeGenerator(ioc);
     ExplicitOffsetField   = new FieldCodeGenerator(ioc, true);
     AutoLayoutField       = new FieldCodeGenerator(ioc, false);
     Struct                = new StructCodeGenerator(ioc);
     NativeStruct          = new NativeStructCodeGenerator(ioc);
     NativeInvocation      = new NativeInvocationCodeGenerator(ioc);
     Callable              = new CallableCodeGenerator(ioc);
     Method                = new MethodCodeGenerator(ioc);
     Function              = new FunctionCodeGenerator(ioc);
     Interface             = new InterfaceCodeGenerator(ioc);
     Group                 = new GroupCodeGenerator(ioc);
     ShadowCallable        = new ShadowCallbackGenerator(ioc);
     ReverseCallableProlog = new ReverseCallablePrologCodeGenerator(ioc);
     Vtbl                  = new VtblGenerator(ioc);
     Shadow                = new ShadowGenerator(ioc);
     Marshalling           = new MarshallingRegistry(ioc);
     Config                = config;
 }