Home » Developing U++ » UppHub » Sharing a few small packages
|
|
|
|
Re: Sharing a few small packages [message #59603 is a reply to message #59601] |
Mon, 13 February 2023 20:51   |
lindquist
Messages: 33 Registered: March 2006 Location: Denmark
|
Member |
|
|
I pushed an update to uppduk, so now ValueMap and ValueArray are supported.
The following test:
#include <Core/Core.h>
#include <Duktape/Duktape.h>
using namespace Upp;
String func(Value v) {
String json = AsJSON(v);
Cout() << "func(v : " << v.GetTypeName() << ") := " << json << EOL;
return pick(json);
}
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT);
Duktape duk;
duk.BindGlobal(&func, "func");
ASSERT(duk.Eval("func(1)") == "1");
ASSERT(duk.Eval("func({})") == "{}");
ASSERT(duk.Eval("func({foo:23,bar:23})") == R"({"foo":23,"bar":23})");
ASSERT(duk.Eval("func([])") == "[]");
ASSERT(duk.Eval("func('foo')") == "\"foo\"");
ASSERT(duk.Eval("func([1,'foo',{bar:[1,2,3]},true])") == R"([1,"foo",{"bar":[1,2,3]},true])");
Cout() << "all ok" << EOL;
}
Produces the following output:
func(v : int) := 1
func(v : N3Upp8ValueMap8NullDataE) := {}
func(v : N3Upp8ValueMap4DataE) := {"foo":23,"bar":23}
func(v : N3Upp10ValueArray8NullDataE) := []
func(v : String) := "foo"
func(v : N3Upp10ValueArray4DataE) := [1,"foo",{"bar":[1,2,3]},true]
all ok
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 21:17:32 CEST 2025
Total time taken to generate the page: 0.01710 seconds
|