Giter Club home page Giter Club logo

mond.bindingex's People

Contributors

rohansi avatar sirtony avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

rohansi

mond.bindingex's Issues

Handle more cases in TypeConverter.MarshalToClr

TypeConverter.MarshalToClr doesn't handle a few common cases:

  • conversion to Object
  • conversion to IDictionary<K,V> and friends
  • conversion to IList<T> and friends
  • delegates don't consider expectedType and will give the wrong type

For the delegate situation, we might need to use Expression<TDelegate> to implement it properly.

No way to call generic methods.

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

Mapping correct .NET special methods to Mond

.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:

  • Mapping .NET Equals method to Mond __eq metamethod when possible to allow simpler object comparison.
  • Mapping .NET indexers to __get and __set metamethods when possible to allow usage of indexers in Mond.
  • Mapping .NET enumerator methods (GetEnumerator, MoveNext, Current, and Reset/Dispose) to allow objects to be enumerated with a foreach statement in Mond.
  • Mapping all .NET operator overloads to their corresponding Mond metamethods (see #2).

Expose binding functionality to scripts

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?)

Handle ref/out parameters and pointer types.

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.

.NET operator overloads are added to object as static methods

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.

Target .NET Standard

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.

Calling toString() or the __string metamethod throws an exception

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 );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.