Browse Source

Updated documentation to the latest API.

pull/456/head
João Matos 10 years ago
parent
commit
cd6fb4a1e3
  1. 26
      docs/GettingStarted.md

26
docs/GettingStarted.md

@ -179,13 +179,13 @@ public interface ILibrary
void Setup(Driver driver); void Setup(Driver driver);
/// Setup your passes here. /// Setup your passes here.
void SetupPasses(Driver driver, PassBuilder passes); void SetupPasses(Driver driver);
/// Do transformations that should happen before passes are processed. /// Do transformations that should happen before passes are processed.
void Preprocess(Driver driver, Library lib); void Preprocess(Driver driver, ASTContext ctx);
/// Do transformations that should happen after passes are processed. /// Do transformations that should happen after passes are processed.
void Postprocess(Driver driver, Library lib); void Postprocess(Driver driver, ASTContext ctx);
} }
``` ```
@ -372,15 +372,15 @@ whose methods get called for each declaration that was parsed from the headers
CppSharp already comes with a collection of useful built-in passes and we will CppSharp already comes with a collection of useful built-in passes and we will
now see how to use them to fix the flaws enumerated above. now see how to use them to fix the flaws enumerated above.
2. `void SetupPasses(Driver driver, PassBuilder passes)` 2. `void SetupPasses(Driver driver)`
New passes are added to the generator by using the API provided by `PassBuilder`. New passes are added to the generator by using the API provided by `PassBuilder`.
```csharp ```csharp
void SetupPasses(Driver driver, PassBuilder passes) void SetupPasses(Driver driver)
{ {
passes.RenameDeclsUpperCase(RenameTargets.Any); driver.TranslationUnitPasses.AddPass(new RenameDeclsUpperCase(RenameTargets.Any));
passes.FunctionToInstanceMethod(); driver.TranslationUnitPasses.AddPass(new FunctionToInstanceMethodPass());
} }
``` ```
@ -487,8 +487,8 @@ Now that the bindings are looking good from a .NET perspective, let's see how
we can achieve more advanced things by using the remaining overloads in the we can achieve more advanced things by using the remaining overloads in the
interface. interface.
3. `void Preprocess(Driver driver, Library lib);` 3. `void Preprocess(Driver driver, ASTContext ctx);`
4. `void Postprocess(Driver driver, Library lib);` 4. `void Postprocess(Driver driver, ASTContext ctx);`
As their comments suggest, these get called either before or after the the As their comments suggest, these get called either before or after the the
passes we setup earlier are run and they allow you free reign to manipulate passes we setup earlier are run and they allow you free reign to manipulate
@ -498,11 +498,11 @@ Let's say we want to change the class to provide .NET value semantics,
drop one field from the generated bindings and rename the `FooAdd` function. drop one field from the generated bindings and rename the `FooAdd` function.
```csharp ```csharp
void Postprocess(Driver driver, Library lib) void Postprocess(Driver driver, ASTContext ctx)
{ {
lib.SetClassAsValueType("Foo"); ctx.SetClassAsValueType("Foo");
lib.SetNameOfFunction("FooAdd", "FooCalc"); ctx.SetNameOfFunction("FooAdd", "FooCalc");
lib.IgnoreClassField("Foo", "b"); ctx.IgnoreClassField("Foo", "b");
} }
``` ```

Loading…
Cancel
Save