sirtony / mond.bindingex Goto Github PK
View Code? Open in Web Editor NEW[Abandoned] An alternative binding API for Mond.
License: MIT License
[Abandoned] An alternative binding API for Mond.
License: MIT License
TypeConverter.MarshalToClr
doesn't handle a few common cases:
Object
IDictionary<K,V>
and friendsIList<T>
and friendsexpectedType
and will give the wrong typeFor the delegate situation, we might need to use Expression<TDelegate>
to implement it properly.
There's currently no way to specify generic type arguments to methods, making them uncallable. This should be fixed by returning a function to bind the type parameters that in turn returns the usable function.
class Foo
{
public static string NameOf<T>() => typeof( T ).FullName;
}
const int = using( 'System.Int32' );
fun nameof( T ) {
const bound = Foo.nameOf( T );
return bound();
}
printLn( nameof( int ) ); // System.Int32
.NET has several special methods (operator overloads included, see #2) that should be mapped to Mond in order to make the binding as transparent as possible. This includes:
Equals
method to Mond __eq
metamethod when possible to allow simpler object comparison.__get
and __set
metamethods when possible to allow usage of indexers in Mond.GetEnumerator
, MoveNext
, Current
, and Reset
/Dispose
) to allow objects to be enumerated with a foreach
statement in Mond.Right now bindings can only be created from .NET code but there should be a way to access stuff without having to change the host application. Exposing a way for scripts to call the Bind
methods would make it easier to interact with the host application without having to change it that much.
I really like how Jint handles this and it should be possible to implement in Mond (aside from new
, of course) with metamethods.
(Also, why a new
method instead of __call
for instantiation?)
Mond does not support pass-by-reference or out
parameters, meaning certain methods (i.e. System.Double.TryParse( string s, out double value )
) can be called, but the value of their out
parameters cannot be used.
Two possible ways to get around this would be to expect objects to be passed to ref
/out
params and have the library automatically set a specifically named field on the object, or use reflection to change the private fields on MondValue to reflect the new value.
Pointer types in C# are unsafe and should be disallowed by throwing an exception when attempting to call a method/constructor with a pointer type anywhere in its signature.
The current binding code will register .NET operator overloads (i.e. public static Point operator +( Point a, Point b );
; this includes implicit and explicit cast operators) as valid static methods as they are simply syntax sugar and get transformed to op_Addition
and the like.
These operator methods should either be discarded or mapped to a corresponding Mond metamethod if possible.
Switching to the new csproj format and retargeting to .NET Standard would allow this to be used on more platforms.
The project can target the desktop framework, too, for a cleaner dependency list. I should update Mond to target net46
on top of .NET Standard.
For some reason, calling toString()
or the __string
metamethod on an instance of a class binding throws a NotSupportedException
, yet the bound .NET ToString()
works properly.
var code = @"
var bigInt = BigInteger.new( 100 );
printLn( bigInt.ToString() ); // OK; prints '100'
printLn( bigInt ); // error
printLn( bigInt.toString() ); // error
";
var options = new MondCompilerOptions { UseImplicitGlobals = true };
var program = MondProgram.Compile( code );
var state = new MondState();
MondObjectBinder.Bind<BigInteger>( state, MondBindingOptions.AutoLock | MondBindingOptions.AutoInsert );
state.Load( program );
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.