Hi,
2012/10/16 mikbal <
sae...@gmail.com>:
> var.setInt(10);
> var.increment();
> var.getAndSet();
>
> these are not necessary. imo JsVariable should stay as a value type.
> references will introduce unnecessary complexity for such a simple type.
>
I think of a value type, the set methods can be helper functions which
calls "execJavaScript('x = 123')". a strong reference which always has
the same value is not possible i think.
>
> About objects,
> i get objects and arrays like this,
>
> function SendVariableToCpp(obj){}
>
> SendVariableToCpp(window.JSON.stringify(MyObj));
>
> then parse it in c++.
> it supports nested objects too.
> i would be great if new berkelium supported objects and array as function
> parameters.
> JsVariable should be expanded to a recursive tree structure to hold
> objects/arrays.
For this i think JsVariable must be a very very complex type, much
complexer then setter support.
maybe it is easier to use an existing json library for this?
We can use a simple javascript callback mehtod like:
void TabDelegate::JavaScriptCallback(Tab* tab, String name, String jsonData);
and provide an optional library where you can write:
void TabDelegate::JavaScriptCallback(Tab* tab, String name, String jsonData) {
JSON json(jsonData);
std::string str1 = json.index(5).string();
std::string str2 = json.index(8).get("key");
int i = json.index(20).int();
}
can this be a solution that fit your needs?
Dennis