urho/SharpieBinder
OmidID 8fcfc02ef8 Fix bug of generating extra class instead of struct(Copy paste problem) 2018-05-21 02:26:37 -07:00
..
AssetsModelGenerator Add ShaderParameters to CoreAssets 2017-04-29 23:06:42 +03:00
Properties
StructsValidator Move each Binding/*.csproj to separate folders (VS has a bug when switching contexts) 2017-10-30 16:50:00 +03:00
bin
.gitignore
Commenter.cs Surface GPUObject. Close #176 2017-01-09 05:08:19 +01:00
CxxBinder.cs Fix bug of generating extra class instead of struct(Copy paste problem) 2018-05-21 02:26:37 -07:00
LICENSE
NamespaceRegistry.cs Small CxxBinder refactoring\cleanup. 2017-01-09 03:09:49 +03:00
OptionalParametersParser.cs Update bindings 2017-10-23 20:38:27 +02:00
Program.cs
README.md
ScanBaseTypes.cs add more setters (keep SetX methods public) 2017-07-29 02:18:43 +02:00
SharpieBinder.csproj Add optional parameters everywhere (SharpieBinder) 2017-05-14 02:32:44 +02:00
SharpieBinder.sln refresh-docs 2017-12-03 19:20:30 +01:00
StringUtil.cs Add optional parameters everywhere (SharpieBinder) 2017-05-14 02:32:44 +02:00
nuget.config
packages.config

README.md

Requirements

  • ObjectiveSharpie built and installed
  • 64-bit Mono
  • libclang-mono.dylib installed in /usr/lib (from ObjectiveSharpie)
  • PCH file generated from parsing all Urho3D header files

When executed, currently dumps the C# bindigns in /tmp/ra

Design Binding Notes

The API in Urho3D is luckily not designed to be used as an object oriented toolbox, so it is rare the case where users must subclass. This has the advantage for a binding that there is no need to support the scenario where subclasses in C# must be able to override methods in the system.

Consideration: should we allow subclassing of the Urho classes? If we do, then we need to have a "Runtime.GetObejct"-like system to ensure that given an unmanaged pointer, we always return the same instance to managed code.

If not, we could just make all wrappers be dumb wrappers and override the Equals, operator == and operator != methods.

Overview of SharpieBinder

The Urho binder in this directory works by using the precompiled header file for all of Urho's API and producing C# bindings that P/Invoke into a glue library written in C, which in turn calls into the C++ API.

This uses the ObjectieSharpie binding to Clang which surfaces the information, and the Sharpie's binder library, which provides a mechanism to walk the AST.

The program creates two AST walkers, one that does a first pass to collect information like core types and pairs of getters and setters, and a second step that redoes the work and produces an NRefactory set of AST nodes that eventually generate C# sources and some manual print commands to generate the C binding.