ethanblake4 / dart_eval

Extensible Dart interpreter for Dart with full interop
https://pub.dev/packages/dart_eval
BSD 3-Clause "New" or "Revised" License
334 stars 40 forks source link

How to set function property #163

Open Noobware1 opened 10 months ago

Noobware1 commented 10 months ago

Like the badCertificateCallback on Httpclient which requires type (bool Function(X509Certificate cert, String host, int port)?) how would I set it using $setProperty?

ethanblake4 commented 10 months ago

You can use a $Function (or maybe actually a $Closure, I don't remember)

hb-public-data commented 2 months ago

Hi @Noobware1 were you able to resolve this issue?

I have a similar issue where from the code that is being evaluated I want to pass a function to the test property.

bridgeObject.test = () => "asd";

In the Bridges Class:

@override
void $setProperty(Runtime runtime, String identifier, $Value value) {
   switch (identifier) {
      case 'test':
        test = value.$value; // UnimplementedError
    }
}  

value.$value and value.$reified have their values set to UnimplementedError. The runtimeType is equal to Type (EvalFunctionPtr).

@ethanblake4 maybe you have a better idea on what to do?