Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonmojo committed Jul 11, 2023
1 parent 0ebc6e6 commit 6999e7a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Direct casts are exposed through the `DNObjectCastTo` method. It works the same

In the Swift bindings, we have extension methods on `DNObject` (the base type for all generated class and struct bindings) which makes type checking/casting much easier:

```
```swift
let string = System.String.empty!

if string.is(System.String.typeOf) {
Expand Down Expand Up @@ -288,7 +288,7 @@ The same rules apply to shadowed members.

Sometimes you need to box primitives in .NET to use them in a more "generic" context. For instance, if you have an array of `System.Object`'s (`object[]`) and want to store integers (`int`, `long`, etc.) in it you need to box them. In C# this is handled transparently or explicitly if you cast for example, an `int` to an `object` (`var intAsObj = (object)5`).

In the generated bindings, you always have to do this explicitly and we provide helper functions in C and Swift for that task.
In the generated bindings, you always have to do this explicitly and we provide helper functions in C and Swift for exactly that task.
For instance, to convert a C `int32_t` to a `System_Object_t` and back again you can do this:

```c
Expand Down Expand Up @@ -502,6 +502,22 @@ Also see this [StackOverflow post](https://stackoverflow.com/questions/10431579/



## Unit Tests

We've got quite an extensive suite of unit tests. All of them are written in Swift but some target the generated C bindings while others target the Swift API surface.

To run them, open [BeyondNETSamplesSwift.xcworkspace](Samples/Beyond.NET.Sample.Swift/BeyondNETSamplesSwift.xcworkspace) in Xcode and go to `Product -> Test`.

Building this in Xcode will take care of the following:
- It compiles the code generator CLI app using NativeAOT
- It compiles the .NET sample project
- It compiles the sample project's generated bindings using NativeAOT
- It compiles a macOS framework containing the generated C and Swift bindings

So this is all automatic if you just open the Xcode workspace and build it or run the tests. The individual steps are implemented as build phases in the Xcode project.



## License

The project is licensed under the [MIT license](LICENSE).
Expand Down

0 comments on commit 6999e7a

Please sign in to comment.