Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
lindquist is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MessageCtrl: A passive notifications ctrl and manager.
Next Topic: Scatter: DataRange for explicit functions
Goto Forum:
  


Current Time: Mon May 06 18:02:27 CEST 2024

Total time taken to generate the page: 0.01856 seconds