Should we always unpack sciter values during event handling?
pravic opened this issue · 0 comments
pravic commented
Consider the following script code:
var obj = {num:100, str:"Hello World"};
view.CallSomething(obj);
On native side we will receive the VALUE_TYPE::T_OBJECT
even if it was a plain map (dictionary) type, because Sciter prefers not to isolate its values implicitly before native handler calls (i.e. convert from internal TIScript value to the JSON compatible array (T_ARRAY) or map (T_MAP) type).
And, since we can't convert all Sciter objects to the particular Python types, we have a problem here.
We have the following ways to go:
- Introduce new type of event handlers which will not convert Sciter values to Python ones (like
EventHandler.on_sciter_call
in addition toon_script_call
which does the conversion. - Isolate (convert) all incoming values coming from Sciter.
- Isolate only compatible values, which can be converted (e.g. T_OBJECT with UT_OBJECT_ARRAY subtype) and leave rest unmodified.
Personally, I would prefer the last option, but we will have an ambiguity in this case with value types coming to our handlers: like part of them will be as Python types and part - as plain Sciter ones.