public TypeIgnoreChecker(ITypeMapDatabase database, GeneratorKind generatorKind = GeneratorKind.CSharp) { TypeMapDatabase = database; VisitOptions.ClearFlags(VisitFlags.ClassBases | VisitFlags.TemplateArguments); this.generatorKind = generatorKind; }
public ParserGen(GeneratorKind kind, string triple, bool isGnuCpp11Abi = false) { Kind = kind; Triple = triple; IsGnuCpp11Abi = isGnuCpp11Abi; }
private TypePrinter GetTypePrinter(GeneratorKind kind, BindingContext context) { TypePrinter typePrinter; switch (kind) { case GeneratorKind.C: typePrinter = new CppTypePrinter(Context) { PrintFlavorKind = CppTypePrintFlavorKind.C }; break; case GeneratorKind.CPlusPlus: case GeneratorKind.QuickJS: case GeneratorKind.NAPI: case GeneratorKind.TypeScript: typePrinter = new CppTypePrinter(Context); break; case GeneratorKind.CLI: typePrinter = new CLITypePrinter(Context); break; case GeneratorKind.CSharp: typePrinter = new CSharpTypePrinter(Context); break; default: throw new System.NotImplementedException(); } return(typePrinter); }
Generator CreateGeneratorFromKind(GeneratorKind kind) { switch (kind) { case GeneratorKind.C: return(new CGenerator(Context)); case GeneratorKind.CPlusPlus: return(new CppGenerator(Context)); case GeneratorKind.CLI: return(new CLIGenerator(Context)); case GeneratorKind.CSharp: return(new CSharpGenerator(Context)); case GeneratorKind.QuickJS: return(new QuickJSGenerator(Context)); case GeneratorKind.NAPI: return(new NAPIGenerator(Context)); } throw new NotImplementedException(); }
public static Type GetMappedType(this Type type, TypeMapDatabase typeMaps, GeneratorKind generatorKind) { TypeMap typeMap; if (typeMaps.FindTypeMap(type, out typeMap)) { var typePrinterContext = new TypePrinterContext { Kind = TypePrinterContextKind.Managed, Type = typeMap.Type }; switch (generatorKind) { case GeneratorKind.CLI: return(typeMap.CLISignatureType(typePrinterContext).Desugar()); case GeneratorKind.CSharp: return(typeMap.CSharpSignatureType(typePrinterContext).Desugar()); } } return(type.Desugar()); }
public DriverOptions() { Headers = new List<string>(); Libraries = new List<string>(); Abi = IsUnixPlatform ? CppAbi.Itanium : CppAbi.Microsoft; MicrosoftMode = !IsUnixPlatform; OutputDir = Directory.GetCurrentDirectory(); Libraries = new List<string>(); CheckSymbols = false; GeneratorKind = GeneratorKind.CSharp; GenerateLibraryNamespace = true; GeneratePartialClasses = true; GenerateClassMarshals = false; OutputInteropIncludes = true; MaxIndent = 80; CommentPrefix = "///"; Encoding = Encoding.ASCII; CodeFiles = new List<string>(); Is32Bit = true; #if IS_64_BIT Is32Bit = false; #endif }
public ParserGen(GeneratorKind kind, string triple, CppAbi abi, bool isGnuCpp11Abi = false) { Kind = kind; Triple = triple; Abi = abi; IsGnuCpp11Abi = isGnuCpp11Abi; }
public TypeIgnoreChecker(ITypeMapDatabase database, GeneratorKind generatorKind = GeneratorKind.CSharp) { TypeMapDatabase = database; VisitOptions.VisitClassBases = false; VisitOptions.VisitTemplateArguments = false; this.generatorKind = generatorKind; }
internal IteratorInstance GetIterator(Realm realm, GeneratorKind hint = GeneratorKind.Sync, ICallable method = null) { if (!TryGetIterator(realm, out var iterator, hint, method)) { ExceptionHelper.ThrowTypeError(realm, "The value is not iterable"); } return(iterator); }
public void SetupTypeMaps(GeneratorKind generatorKind) { var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in loadedAssemblies) { var types = assembly.FindDerivedTypes(typeof(TypeMap)); SetupTypeMaps(types, generatorKind); } }
protected TestsGenerator(string name, GeneratorKind languageKind) { this.name = name; options = new Options(); options.Language = languageKind; driver = new Driver(options); Setup(); }
public static CManagedToNativeTypePrinter GetCTypePrinter(GeneratorKind kind) { var typePrinter = new CManagedToNativeTypePrinter { PrintScopeKind = TypePrintScopeKind.Qualified, PrintFlavorKind = GetTypePrinterFlavorKind(kind), PrintVariableArrayAsPointers = true }; return(typePrinter); }
protected TestsGenerator(string name, GeneratorKind languageKind) { this.name = name; options = new Options(); options.GeneratorKind = languageKind; project = new Project(); driver = new Driver(project, options); Setup(); }
Generator CreateGeneratorFromKind(GeneratorKind kind) { switch (kind) { case GeneratorKind.CLI: return new CLIGenerator(this); case GeneratorKind.CSharp: return new CSharpGenerator(this); } return null; }
Generator CreateGeneratorFromKind(GeneratorKind kind) { switch (kind) { case GeneratorKind.CLI: return(new CLIGenerator(Context)); case GeneratorKind.CSharp: return(new CSharpGenerator(Context)); } return(null); }
private static string GetGeneratorKindName(GeneratorKind kind) { switch (kind) { case GeneratorKind.CLI: return("C++/CLI"); case GeneratorKind.CSharp: return("C#"); default: return(kind.ToString()); } }
private void SetupTypeMaps(IEnumerable <System.Type> types, GeneratorKind generatorKind) { foreach (var typeMap in types) { var attrs = typeMap.GetCustomAttributes(typeof(TypeMapAttribute), true); foreach (TypeMapAttribute attr in attrs) { if (attr.GeneratorKind == null || attr.GeneratorKind == generatorKind) { TypeMaps[attr.Type] = typeMap; } } } }
private static CppTypePrintFlavorKind GetTypePrinterFlavorKind(GeneratorKind kind) { switch (kind) { case GeneratorKind.C: return(CppTypePrintFlavorKind.C); case GeneratorKind.CPlusPlus: return(CppTypePrintFlavorKind.Cpp); case GeneratorKind.ObjectiveC: return(CppTypePrintFlavorKind.ObjC); } throw new NotImplementedException(); }
internal bool TryGetIterator(Realm realm, out IteratorInstance iterator, GeneratorKind hint = GeneratorKind.Sync, ICallable method = null) { var obj = TypeConverter.ToObject(realm, this); if (method is null) { if (hint == GeneratorKind.Async) { method = obj.GetMethod(GlobalSymbolRegistry.AsyncIterator); if (method is null) { var syncMethod = obj.GetMethod(GlobalSymbolRegistry.Iterator); var syncIteratorRecord = obj.GetIterator(realm, GeneratorKind.Sync, syncMethod); // TODO async CreateAsyncFromSyncIterator(syncIteratorRecord); ExceptionHelper.ThrowNotImplementedException("async"); } } else { method = obj.GetMethod(GlobalSymbolRegistry.Iterator); } } if (method is null) { iterator = null; return(false); } var iteratorResult = method.Call(obj, Arguments.Empty) as ObjectInstance; if (iteratorResult is null) { ExceptionHelper.ThrowTypeError(realm, "Result of the Symbol.iterator method is not an object"); } if (iteratorResult is IteratorInstance i) { iterator = i; } else { iterator = new IteratorInstance.ObjectIterator(iteratorResult); } return(true); }
private void RunButton_Click(object sender, EventArgs e) { if (module != null) { GeneratorKind mode = GeneratorKind.CSharp; if (radioButton4.Checked) { mode = GeneratorKind.CSharp; } if (radioButton5.Checked) { mode = GeneratorKind.CLI; } if (radioButton6.Checked) { mode = GeneratorKind.C; } if (radioButton7.Checked) { mode = GeneratorKind.CPlusPlus; } if (radioButton8.Checked) { mode = GeneratorKind.ObjectiveC; } if (radioButton9.Checked) { mode = GeneratorKind.Java; } // std.cs生成 File.Copy(Application.StartupPath + @"\Std.cs", bindPath + @"\Std.cs", true); // SymbolResolver.cs生成 File.Copy(Application.StartupPath + @"\SymbolResolver.cs", bindPath + @"\SymbolResolver.cs", true); var builder = new BuildLib(module, mode); ConsoleDriver.Run(builder); } Process.Start(bindPath); module = null; Environment.Exit(0); }
public TypeMapDatabase(ASTContext astContext, GeneratorKind generatorKind) { TypeMaps = new Dictionary <string, TypeMap>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { try { var types = assembly.FindDerivedTypes(typeof(TypeMap)); SetupTypeMaps(types, generatorKind, astContext); } catch (System.Reflection.ReflectionTypeLoadException ex) { Diagnostics.Error("Error loading type maps from assembly '{0}': {1}", assembly.GetName().Name, ex.Message); } } }
public virtual Type SignatureType(GeneratorKind kind, TypePrinterContext ctx) { switch (kind) { case GeneratorKind.CPlusPlus: return(CppSignatureType(ctx)); case GeneratorKind.CLI: return(CLISignatureType(ctx)); case GeneratorKind.CSharp: return(CSharpSignatureType(ctx)); default: throw new System.NotImplementedException(); } }
static bool GetGeneratorKindFromLang(string lang, out GeneratorKind kind) { kind = GeneratorKind.CSharp; switch (lang) { case "CSharp": case "C#": kind = GeneratorKind.CSharp; return(true); case "CLI": kind = GeneratorKind.CLI; return(true); } return(false); }
public void SetupTypeMaps(GeneratorKind generatorKind) { var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in loadedAssemblies) { try { var types = assembly.FindDerivedTypes(typeof(TypeMap)); SetupTypeMaps(types, generatorKind); } catch (System.Reflection.ReflectionTypeLoadException ex) { Diagnostics.Error("Error loading type maps from assembly '{0}': {1}", assembly.GetName().Name, ex.Message); } } }
private void SetupTypeMaps(IEnumerable <System.Type> types, GeneratorKind generatorKind, ASTContext astContext) { foreach (var type in types) { var attrs = type.GetCustomAttributes(typeof(TypeMapAttribute), true); foreach (TypeMapAttribute attr in attrs) { if (attr.GeneratorKind == 0 || attr.GeneratorKind == generatorKind) { var typeMap = (TypeMap)Activator.CreateInstance(type); typeMap.ASTContext = astContext; typeMap.TypeMapDatabase = this; this.TypeMaps[attr.Type] = typeMap; } } } }
public virtual void MarshalToNative(GeneratorKind kind, MarshalContext ctx) { switch (kind) { case GeneratorKind.CPlusPlus: CppMarshalToNative(ctx); return; case GeneratorKind.CLI: CLIMarshalToNative(ctx); return; case GeneratorKind.CSharp: CSharpMarshalToNative(ctx as CSharpMarshalContext); return; default: throw new System.NotImplementedException(); } }
private void SetupTypeMaps(IEnumerable<System.Type> types, GeneratorKind generatorKind) { foreach (var typeMap in types) { var attrs = typeMap.GetCustomAttributes(typeof(TypeMapAttribute), true); foreach (TypeMapAttribute attr in attrs) { if (attr.GeneratorKind == 0 || attr.GeneratorKind == generatorKind) { TypeMaps[attr.Type] = typeMap; } } } }
public TypeMapAttribute(string type, GeneratorKind generatorKind) { Type = type; GeneratorKind = generatorKind; }
public NamespacesBaseTests(GeneratorKind kind) : base("NamespacesBase", kind) { }
public ParserGen(GeneratorKind kind, string triple, CppAbi abi) { Kind = kind; Triple = triple; Abi = abi; }
public NamespacesDerivedTests(GeneratorKind kind) : base("NamespacesDerived", kind) { }
protected GeneratorTest(string name, GeneratorKind kind) { this.name = name; this.kind = kind; }
public CommonTestsGenerator(GeneratorKind kind) : base("Common", kind) { }
public DriverOptions() { Abi = IsUnixPlatform ? CppAbi.Itanium : CppAbi.Microsoft; MicrosoftMode = !IsUnixPlatform; OutputDir = Directory.GetCurrentDirectory(); Modules = new List<Module>(); GeneratorKind = GeneratorKind.CSharp; GeneratePartialClasses = true; GenerateClassMarshals = false; OutputInteropIncludes = true; MaxIndent = 80; CommentPrefix = "///"; Encoding = Encoding.ASCII; StripLibPrefix = true; ExplicitlyPatchedVirtualFunctions = new HashSet<string>(); }
public EncodingsTestsGenerator(GeneratorKind kind) : base("Encodings", kind) { }
public VTableTests(GeneratorKind kind) : base("VTables", kind) { }
public STL(GeneratorKind kind) : base("STL", kind) { }
public void SetupTypeMaps(GeneratorKind generatorKind) { var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in loadedAssemblies) { var types = assembly.FindDerivedTypes(typeof(TypeMap)); SetupTypeMaps(types, generatorKind); } }
public TypeMapAttribute(string type, GeneratorKind generatorKind) { Type = type; GeneratorKind = generatorKind; }
static bool GetGeneratorKindFromLang(string lang, out GeneratorKind kind) { kind = GeneratorKind.CSharp; switch(lang) { case "CSharp": case "C#": kind = GeneratorKind.CSharp; return true; case "CLI": kind = GeneratorKind.CLI; return true; } return false; }
public CLITestsGenerator(GeneratorKind kind) : base("CLI", kind) { }
public CommonTestsGenerator(GeneratorKind kind) : base("Common", kind) { }
public CSharpTestsGenerator(GeneratorKind kind) : base("CSharp", kind) { }
public CSharpTempTests(GeneratorKind kind) : base("CSharpTemp", kind) { }
public CLITemp(GeneratorKind kind) : base("CLITemp", kind) { }
public TypeMaps(GeneratorKind kind) : base("TypeMaps", kind) { }
public VTableTests(GeneratorKind kind) : base("VTables", kind) { }
public ParserGen(GeneratorKind kind, string triple, CppAbi abi) { Kind = kind; Triple = triple; Abi = abi; }
public Basic(GeneratorKind kind) : base("Basic", kind) { }
public StandardLibTestsGenerator(GeneratorKind kind) : base("StandardLib", kind) { }
public NamespacesDerivedTests(GeneratorKind kind) : base("NamespacesDerived", kind) { }
protected GeneratorTest(string name, GeneratorKind kind) { this.name = name; this.kind = kind; }
public EmptyTestsGenerator(GeneratorKind kind) : base("Empty", kind) { }
public UTF16Tests(GeneratorKind kind) : base("UTF16", kind) { }
public ParserGen(GeneratorKind kind) { Kind = kind; }