Giter VIP home page Giter VIP logo

Comments (10)

nilproject avatar nilproject commented on July 28, 2024

.call(...) (lower case) is an implementation of Function.prototype.call(...). You should not use it directly from C# (or any another .NET-language).
You may use Call(null) if arguments are not passed.

At this moment support of generics is very bugged. It's coming soon

from nil.js.

LambderFTW avatar LambderFTW commented on July 28, 2024

Alright. Thanks for the tips. I'm really excited about this project.

from nil.js.

LambderFTW avatar LambderFTW commented on July 28, 2024

This happened inside NamespaceProvider.cs
(I downloaded a zip of the source and built it myself, no modifications)

http://prntscr.com/aalmvg

For some reason it didn't like it when I JSValue.Wrapped something, assigned it and tried to access from JS.

Also, when I tried to JSValue.Marshal a List<Action> and I try to call .Add it throws an exception saying it's not callable. (in the latest nuget version)

from nil.js.

nilproject avatar nilproject commented on July 28, 2024

For all types, which implements IList, engine creates special wrapper NativeList. This wrapper provides array-like interface. You may use push(...) instead of Add(...). If you want to get a native List interface, you should use JSValue.Wrap(...)

Thank for your error report.

from nil.js.

LambderFTW avatar LambderFTW commented on July 28, 2024

I want to create a JS object and define its properties then assign to them.
Right now, I'm doing it this way: JSValue.Assign(JSValue.Marshal(new object()))
I'd like to know if there's a better alternative.

Also, how can I cast things inside JS? For example, I'd like to cast a function to an Action<> and then add it to a List<Action<>> all within JS.

from nil.js.

nilproject avatar nilproject commented on July 28, 2024

Just add this function into List. Function will be converted automatically.

Use JSValue.Assign(JSObject.CreateObject());

from nil.js.

LambderFTW avatar LambderFTW commented on July 28, 2024

I tried that and it seemed to work a few hours ago.
But now it doesn't for some odd reason.
http://pastebin.com/TcM3Jg08

from nil.js.

nilproject avatar nilproject commented on July 28, 2024

You trying to do it with develop branch of engine?
I think, you should use version-2.0 branch or nuget package.

from nil.js.

LambderFTW avatar LambderFTW commented on July 28, 2024

I tried both.
Seems it does work for this
hostlib.DefineProperty("AddAction").Assign(JSValue.Marshal(new Action<Action<string>>(x => LogActions.Add(x))));
but not for the actual LogActions.Add (if I wrap List<Action<string>> LogActions)

from nil.js.

nilproject avatar nilproject commented on July 28, 2024

Already fixed. Added tests 770358a

from nil.js.

Related Issues (20)

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.