Closed JomerDev closed 6 years ago
How do you "enumerating an tiscript object" ?
I am using the tiscript::enumerator for this.
Example:
nlohmann::json tisObjToJson( HVM vm, nlohmann::json j, tiscript::value obj ) { tiscript::enumerator each( vm, obj ); for( tiscript::value key, val; each( key, val );) { std::string k = aux::w2utf( tiscript::c_string( key ) ).c_str(); if( tiscript::is_string( val ) ) { j[ k ] = strdup( aux::w2utf( tiscript::c_string( val ) ).c_str() ); } else if( tiscript::is_int( val ) ) { j[ k ] = tiscript::c_int( val ); } else if( tiscript::is_float( val ) ) { j[ k ] = tiscript::c_float( val ); } else if( tiscript::is_bool( val ) ) { j[ k ] = tiscript::c_bool( val ); } else if( tiscript::is_symbol( val ) ) { j[ k ] = strdup( aux::w2utf( tiscript::c_symbol( val ) ).c_str() ); } else if( tiscript::is_array( val ) ) { j[ k ] = tisArrToJson( vm, nlohmann::json::array(), val ); } else if( tiscript::is_object( val ) ) { j[ k ] = tisObjToJson( vm, nlohmann::json::object(), val ); } else { j[ k ] = nullptr; } } return j; }
Where k
is declared?
Oops, I removed it accidentally while copying it to github. I added it to my previous comment. k is declared like this: std::string k = aux::w2utf( tiscript::c_string( key ) ).c_str();
And what are "empty key and a symbol instead" exactly?
The only pair that gets added to the nlohmann::json object with the function above is an empty string as key "" and the value "nothing" as string. At least in the new sdk version
Thanks for clarification.
Problem is on my side, fixing.
Thank you. Are there any news about this problem?
Thank you for the fix. But sadly there seems to be one problem remaining.
It now seems like the key and value are switched, meaning that this
tiscript::enumerator each( vm, obj ); for( tiscript::value key, value; each( key, value);) {}
now has the objects key in the "value" variable and the objects value in the "key" variable
Thanks, fixing.
Thank you for fixing this
I'm sorry to say that I have found another Issue. Sciter crashes with a Segmentation fault when I set a mediaVar in a frame while I have at least one svg shown on screen. While I can reproduce it with libsciter-gtk.so and my code on ubuntu every time, I can't reproduce it on Windows or with usciter. I can send you a complete gdb backtrace of the functions called up to the crash,if you want to take a look at this. I didn't want to open another github issue because sadly it is really vague right now.
Stack trace will be enough, thanks in advance.
The stack trace in question: https://pastebin.com/xZtBNrLj Thank you for looking into this
Thanks, is it possible to get somehow minimal html/css/svg set where this is reproducible. So far I cannot reproduce it on smaples that I have here.
segfault_example.zip I've attached an example. Just start usciter, open the main.htm and click on the tab named "Crash tab". It should segfault immediately,I could reproduce it every time.
Thanks.
One more bug of GCC code generator, or probably our mutual misunderstanding with it. Sigh.
You can take updated .so from https://github.com/c-smile/sciter-sdk/tree/master/bin.gtk/x64
Thank you very much for the quick fix
I updated sciter-gtk.so from version 4.1.5.5856 today because of the window closure sequence bug and now enumerating an tiscript object only returns an empty key and a symbol instead of the keys and values of the object.
It works again when I replace it new .so with the old one.