Skip to content

Commit

Permalink
Change the ILibrary methods to take a driver instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Jun 23, 2013
1 parent 35180f7 commit d0fb961
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/OpenCV/OpenCV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Setup(DriverOptions options)
options.OutputDir = "opencv";
}

public void Preprocess(Library lib)
public void Preprocess(Driver driver, Library lib)
{
}

Expand Down
33 changes: 13 additions & 20 deletions examples/SDL/SDL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@ namespace CppSharp
/// </summary>
class SDL : ILibrary
{
public void Setup(DriverOptions options)
public void Setup(Driver driver)
{
var options = driver.Options;
options.LibraryName = "SDL";
options.Headers.Add("SDL.h");
options.IncludeDirs.Add("../../../examples/SDL/SDL-2.0/include");
options.OutputDir = "SDL";
}

public void Preprocess(Library lib)
public void SetupPasses(Driver driver, PassBuilder passes)
{
passes.RemovePrefix("SDL_");
passes.RemovePrefix("SCANCODE_");
passes.RemovePrefix("SDLK_");
passes.RemovePrefix("KMOD_");
passes.RemovePrefix("LOG_CATEGORY_");
}

public void Preprocess(Driver driver, Library lib)
{
lib.IgnoreEnumWithMatchingItem("SDL_FALSE");
lib.IgnoreEnumWithMatchingItem("DUMMY_ENUM_VALUE");
Expand Down Expand Up @@ -57,28 +67,11 @@ public void Postprocess(Library lib)
//lib.SetNameOfEnumWithName("LOG_CATEGORY", "LogCategory");
}

public void SetupPasses(PassBuilder p)
{
p.RemovePrefix("SDL_");
p.RemovePrefix("SCANCODE_");
p.RemovePrefix("SDLK_");
p.RemovePrefix("KMOD_");
p.RemovePrefix("LOG_CATEGORY_");
}

public void GenerateStart(TextTemplate template)
{
}

public void GenerateAfterNamespaces(TextTemplate template)
{
}

static class Program
{
public static void Main(string[] args)
{
Driver.Run(new SDL());
ConsoleDriver.Run(new SDL());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Generator/Library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface ILibrary
/// <summary>
/// Do transformations that should happen before passes are processed.
/// </summary>
void Preprocess(Library lib);
void Preprocess(Driver driver, Library lib);

/// <summary>
/// Do transformations that should happen after passes are processed.
Expand All @@ -30,7 +30,7 @@ public interface ILibrary
/// <summary>
/// Setup the driver options here.
/// </summary>
void Setup(DriverOptions options);
void Setup(Driver driver);

/// <summary>
/// Setup your passes here.
Expand Down
2 changes: 1 addition & 1 deletion tests/Hello/Hello.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public Hello(LanguageGeneratorKind kind)
{
}

public override void Preprocess(Library lib)
public override void Preprocess(Driver driver, Library lib)
{
lib.SetClassAsValueType("Bar");
lib.SetClassAsValueType("Bar2");
Expand Down

0 comments on commit d0fb961

Please sign in to comment.