本文整理汇总了C#中CppSharp.Driver类的典型用法代码示例。如果您正苦于以下问题:C# Driver类的具体用法?C# Driver怎么用?C# Driver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Driver类属于CppSharp命名空间,在下文中一共展示了Driver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Preprocess
public void Preprocess(Driver driver, ASTContext ctx)
{
ctx.IgnoreEnumWithMatchingItem("SDL_FALSE");
ctx.IgnoreEnumWithMatchingItem("DUMMY_ENUM_VALUE");
ctx.SetNameOfEnumWithMatchingItem("SDL_SCANCODE_UNKNOWN", "ScanCode");
ctx.SetNameOfEnumWithMatchingItem("SDLK_UNKNOWN", "Key");
ctx.SetNameOfEnumWithMatchingItem("KMOD_NONE", "KeyModifier");
ctx.SetNameOfEnumWithMatchingItem("SDL_LOG_CATEGORY_CUSTOM", "LogCategory");
ctx.GenerateEnumFromMacros("InitFlags", "SDL_INIT_(.*)").SetFlags();
ctx.GenerateEnumFromMacros("Endianness", "SDL_(.*)_ENDIAN");
ctx.GenerateEnumFromMacros("InputState", "SDL_RELEASED", "SDL_PRESSED");
ctx.GenerateEnumFromMacros("AlphaState", "SDL_ALPHA_(.*)");
ctx.GenerateEnumFromMacros("HatState", "SDL_HAT_(.*)");
ctx.IgnoreHeadersWithName("SDL_atomic*");
ctx.IgnoreHeadersWithName("SDL_endian*");
ctx.IgnoreHeadersWithName("SDL_main*");
ctx.IgnoreHeadersWithName("SDL_mutex*");
ctx.IgnoreHeadersWithName("SDL_stdinc*");
ctx.IgnoreHeadersWithName("SDL_error");
ctx.IgnoreEnumWithMatchingItem("SDL_ENOMEM");
ctx.IgnoreFunctionWithName("SDL_Error");
}
示例2: Run
public static void Run(ILibrary library)
{
var options = new DriverOptions();
var Log = new TextDiagnosticPrinter();
var driver = new Driver(options, Log);
library.Setup(driver);
driver.Setup();
if(driver.Options.Verbose)
Log.Level = DiagnosticKind.Debug;
if (!options.Quiet)
Log.EmitMessage("Parsing libraries...");
if (!driver.ParseLibraries())
return;
if (!options.Quiet)
Log.EmitMessage("Indexing library symbols...");
driver.Symbols.IndexSymbols();
if (!options.Quiet)
Log.EmitMessage("Parsing code...");
if (!driver.ParseCode())
return;
if (!options.Quiet)
Log.EmitMessage("Processing code...");
library.Preprocess(driver, driver.ASTContext);
driver.SetupPasses(library);
driver.ProcessCode();
library.Postprocess(driver, driver.ASTContext);
if (!options.Quiet)
Log.EmitMessage("Generating code...");
var outputs = driver.GenerateCode();
foreach (var output in outputs)
{
foreach (var pass in driver.GeneratorOutputPasses.Passes)
{
pass.Driver = driver;
pass.VisitGeneratorOutput(output);
}
}
if (!driver.Options.DryRun)
driver.WriteCode(outputs);
if (driver.Options.IsCSharpGenerator)
driver.CompileCode();
}
示例3: Preprocess
public void Preprocess(Driver driver, ASTContext lib)
{
string qtModule = "Qt" + this.module;
string moduleIncludes = Path.Combine(this.includePath, qtModule);
foreach (TranslationUnit unit in lib.TranslationUnits.Where(u => u.FilePath != "<invalid>"))
{
if (Path.GetDirectoryName(unit.FilePath) != moduleIncludes)
{
unit.ExplicityIgnored = true;
}
else
{
IgnorePrivateDeclarations(unit);
}
}
lib.SetClassAsValueType("QByteArray");
lib.SetClassAsValueType("QListData");
lib.SetClassAsValueType("QListData::Data");
lib.SetClassAsValueType("QLocale");
lib.SetClassAsValueType("QModelIndex");
lib.SetClassAsValueType("QPoint");
lib.SetClassAsValueType("QPointF");
lib.SetClassAsValueType("QSize");
lib.SetClassAsValueType("QSizeF");
lib.SetClassAsValueType("QRect");
lib.SetClassAsValueType("QRectF");
lib.SetClassAsValueType("QGenericArgument");
lib.SetClassAsValueType("QVariant");
// TODO: remove these when their symbols have been replaced or included
lib.IgnoreClassMethodWithName("QXmlStreamReader", "attributes");
lib.IgnoreClassMethodWithName("QTimeZone", "offsetData");
lib.IgnoreClassMethodWithName("QTimeZone", "nextTransition");
lib.IgnoreClassMethodWithName("QTimeZone", "previousTransition");
}
示例4: Setup
public void Setup(Driver driver)
{
var options = driver.Options;
options.LibraryName = "CppSharp";
options.DryRun = true;
options.Headers.AddRange(new string[]
{
"clang/AST/Expr.h",
});
options.SetupXcode();
options.MicrosoftMode = false;
options.TargetTriple = "i686-apple-darwin12.4.0";
options.addDefines ("__STDC_LIMIT_MACROS");
options.addDefines ("__STDC_CONSTANT_MACROS");
var llvmPath = Path.Combine (GetSourceDirectory ("deps"), "llvm");
var clangPath = Path.Combine(llvmPath, "tools", "clang");
options.addIncludeDirs(Path.Combine(llvmPath, "include"));
options.addIncludeDirs(Path.Combine(llvmPath, "build", "include"));
options.addIncludeDirs (Path.Combine (llvmPath, "build", "tools", "clang", "include"));
options.addIncludeDirs(Path.Combine(clangPath, "include"));
}
示例5: SetupPasses
public void SetupPasses(Driver driver)
{
driver.TranslationUnitPasses.RemovePrefix("SDL_");
driver.TranslationUnitPasses.RemovePrefix("SCANCODE_");
driver.TranslationUnitPasses.RemovePrefix("SDLK_");
driver.TranslationUnitPasses.RemovePrefix("KMOD_");
driver.TranslationUnitPasses.RemovePrefix("LOG_CATEGORY_");
}
示例6: Setup
public void Setup(Driver driver)
{
var options = driver.Options;
options.LibraryName = "SDL";
options.Headers.Add("SDL.h");
options.addIncludeDirs("../../../examples/SDL/SDL-2.0/include");
options.OutputDir = "SDL";
}
示例7: Preprocess
public void Preprocess(Driver driver, ASTContext lib)
{
lib.SetClassAsValueType("CppSharp::ParserOptions");
lib.SetClassAsValueType("CppSharp::ParserDiagnostic");
lib.SetClassAsValueType("CppSharp::ParserResult");
lib.RenameNamespace("CppSharp::CppParser", "Parser");
}
示例8: Setup
public void Setup(Driver driver)
{
var options = driver.Options;
options.LibraryName = "SDL";
options.Headers.Add("SDL.h");
var sdlPath = Path.Combine(GetExamplesDirectory("SDL"), "SDL-2.0/include");
options.addIncludeDirs(sdlPath);
options.OutputDir = "SDL";
}
示例9: Postprocess
public void Postprocess(Driver driver, ASTContext lib)
{
CollectTypeDefsPerTypePass collectTypeDefsPerTypePass = new CollectTypeDefsPerTypePass();
collectTypeDefsPerTypePass.VisitLibrary(driver.ASTContext);
new ClearCommentsPass().VisitLibrary(driver.ASTContext);
new GetCommentsFromQtDocsPass(this.docs, this.module, collectTypeDefsPerTypePass.TypeDefsPerType).VisitLibrary(driver.ASTContext);
new CaseRenamePass(
RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate | RenameTargets.Field,
RenameCasePattern.UpperCamelCase).VisitLibrary(driver.ASTContext);
}
示例10: Preprocess
public void Preprocess(Driver driver, ASTContext ctx)
{
ctx.RenameNamespace("CppSharp::CppParser", "Parser");
var exprClass = ctx.FindCompleteClass ("clang::Expr");
var exprUnit = ctx.TranslationUnits [0];
var subclassVisitor = new SubclassVisitor (exprClass);
exprUnit.Visit (subclassVisitor);
var subclasses = subclassVisitor.Classes;
}
示例11: Postprocess
public void Postprocess(Driver driver, ASTContext ctx)
{
ctx.SetNameOfEnumWithName("PIXELTYPE", "PixelType");
ctx.SetNameOfEnumWithName("BITMAPORDER", "BitmapOrder");
ctx.SetNameOfEnumWithName("PACKEDORDER", "PackedOrder");
ctx.SetNameOfEnumWithName("ARRAYORDER", "ArrayOrder");
ctx.SetNameOfEnumWithName("PACKEDLAYOUT", "PackedLayout");
ctx.SetNameOfEnumWithName("PIXELFORMAT", "PixelFormats");
ctx.SetNameOfEnumWithName("assert_state", "AssertState");
ctx.SetClassBindName("assert_data", "AssertData");
ctx.SetNameOfEnumWithName("eventaction", "EventAction");
ctx.SetNameOfEnumWithName("LOG_CATEGORY", "LogCategory");
}
示例12: Preprocess
public void Preprocess(Driver driver, ASTContext lib)
{
var qtModule = "Qt" + this.module;
var moduleIncludes = Path.Combine(this.includePath, qtModule);
foreach (var unit in lib.TranslationUnits.Where(u => u.FilePath != "<invalid>"))
{
if (Path.GetDirectoryName(unit.FilePath) != moduleIncludes)
{
LinkDeclaration(unit);
}
else
{
IgnorePrivateDeclarations(unit);
}
}
lib.SetClassAsValueType("QByteArray");
lib.SetClassAsValueType("QListData");
lib.SetClassAsValueType("QListData::Data");
lib.SetClassAsValueType("QLocale");
lib.SetClassAsValueType("QModelIndex");
lib.SetClassAsValueType("QPoint");
lib.SetClassAsValueType("QPointF");
lib.SetClassAsValueType("QSize");
lib.SetClassAsValueType("QSizeF");
lib.SetClassAsValueType("QRect");
lib.SetClassAsValueType("QRectF");
lib.SetClassAsValueType("QGenericArgument");
lib.SetClassAsValueType("QGenericReturnArgument");
lib.SetClassAsValueType("QVariant");
lib.IgnoreClassMethodWithName("QString", "fromStdWString");
lib.IgnoreClassMethodWithName("QString", "toStdWString");
if (this.module == "Widgets")
{
// HACK: work around https://llvm.org/bugs/show_bug.cgi?id=24655
foreach (var method in lib.FindCompleteClass("QAbstractSlider").Methods.Where(m => m.Access == AccessSpecifier.Protected))
{
method.AccessDecl.PreprocessedEntities.Clear();
}
string[] classesWithTypeEnums =
{
"QGraphicsEllipseItem", "QGraphicsItemGroup", "QGraphicsLineItem",
"QGraphicsPathItem", "QGraphicsPixmapItem", "QGraphicsPolygonItem", "QGraphicsProxyWidget",
"QGraphicsRectItem", "QGraphicsSimpleTextItem", "QGraphicsTextItem", "QGraphicsWidget"
};
foreach (var enumeration in classesWithTypeEnums.Select(c => lib.FindCompleteClass(c)).SelectMany(
@class => @class.Enums.Where(e => string.IsNullOrEmpty(e.Name))))
{
enumeration.Name = "TypeEnum";
}
}
}
示例13:
void ILibrary.Setup(Driver driver)
{
// 现在先写死的路径,以方便 测试功能是否使,后面真正用到时,再写命令行来更灵活的处理绑定吧
// 估计以后要区分 32位与64位
// 擦: 现在的 CppSharp 只支持32位,估计以后可能支持吧
var options = driver.Options;
options.GeneratorKind = GeneratorKind.CSharp;
options.LibraryName = "Common";
options.Headers.Add(@"D:\GitSourceCode\TempCode\XunLongJiMobileServer\Common\Include\TestExportClass.h");
options.Libraries.Add(@"D:\GitSourceCode\TempCode\XunLongJiMobileServer\Lib/Win32/Debug\Common.lib");
options.ShowHelpText = true;
options.OutputDir = @"d:\CppWrapper";
options.OutputNamespace = "XLJCommon";
}
示例14: Setup
public void Setup(Driver driver)
{
var options = driver.Options;
options.LibraryName = "CppSharp.CppParser.dll";
options.GeneratorKind = Kind;
options.Headers.Add("AST.h");
options.Headers.Add("CppParser.h");
var basePath = Path.Combine(GetSourceDirectory(), "CppParser");
options.IncludeDirs.Add(basePath);
options.Libraries.Add("CppSharp.CppParser.lib");
options.LibraryDirs.Add(".");
options.OutputDir = "../../../../src/CppParser/Bindings/";
options.OutputDir += Kind.ToString();
options.GenerateLibraryNamespace = false;
options.CheckSymbols = false;
}
示例15: Preprocess
public void Preprocess(Driver driver, Library lib)
{
// FBase.h is just an aggregrating header file, which also contains
// a block-comment for the Base namespace. We don't need to generate
// any code for it.
lib.IgnoreHeadersWithName("FBase.h");
// We are mapping Tizen::Base::String to a standard .NET string class,
// so don't need to generate any code for that either.
//lib.IgnoreHeadersWithName("FBaseString.h");
// Don't know why we are ignoring these. Ask Joao.
//lib.IgnoreHeadersWithName("FBaseObject.h");
//lib.IgnoreHeadersWithName("FOspCompat.h");
//lib.IgnoreClassWithName("Tizen::Base::Object");
}