Quellcode durchsuchen

Merge branch 'master' of github.com:taylor001/crown

Daniele Bartolini vor 10 Jahren
Ursprung
Commit
95f4185d16

+ 1 - 1
docs/doxygen/Doxyfile.doxygen

@@ -1429,7 +1429,7 @@ GENERATE_TREEVIEW      = NO
 # Minimum value: 0, maximum value: 20, default value: 4.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-ENUM_VALUES_PER_LINE   = 4
+ENUM_VALUES_PER_LINE   = 1
 
 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
 # to set the initial width (in pixels) of the frame in which the tree is shown.

+ 8 - 8
docs/lua_api.txt

@@ -241,13 +241,13 @@ Matrix4x4
 		Inverts the matrix *m* and returns the result.
 
 	**x** (m) : Vector3
-		Returns the x asis of the matrix *m*.
+		Returns the x axis of the matrix *m*.
 
 	**y** (m) : Vector3
-		Returns the y asis of the matrix *m*.
+		Returns the y axis of the matrix *m*.
 
 	**z** (m) : Vector3
-		Returns the z asis of the matrix *m*.
+		Returns the z axis of the matrix *m*.
 
 	**set_x** (m, x)
 		Sets the x axis of the matrix *m*.
@@ -715,7 +715,7 @@ SoundWorld
 		Resumes all previously paused sounds in the world.
 
 	**is_playing** (sound_world, id) : bool
-		Returns wheter the sound *id* is playing.
+		Returns whether the sound *id* is playing.
 
 ResourcePackage
 ================
@@ -837,7 +837,7 @@ Keyboard
 		Returns whether the button *id* is released in the current frame.
 
 	**any_pressed** () : bool
-		Returns wheter any button is pressed in the current frame.
+		Returns whether any button is pressed in the current frame.
 
 	**any_released** () : bool
 		Returns whether any button is released in the current frame.
@@ -883,7 +883,7 @@ Mouse
 		Returns whether the button *id* is released in the current frame.
 
 	**any_pressed** () : bool
-		Returns wheter any button is pressed in the current frame.
+		Returns whether any button is pressed in the current frame.
 
 	**any_released** () : bool
 		Returns whether any button is released in the current frame.
@@ -931,7 +931,7 @@ Touch
 		Returns whether the button *id* is released in the current frame.
 
 	**any_pressed** () : bool
-		Returns wheter any button is pressed in the current frame.
+		Returns whether any button is pressed in the current frame.
 
 	**any_released** () : bool
 		Returns whether any button is released in the current frame.
@@ -961,7 +961,7 @@ Pad1, Pad2, Pad3, Pad4
 		Returns whether the button *id* is released in the current frame.
 
 	**any_pressed** () : bool
-		Returns wheter any button is pressed in the current frame.
+		Returns whether any button is pressed in the current frame.
 
 	**any_released** () : bool
 		Returns whether any button is released in the current frame.

+ 1 - 1
src/audio/sound_world.h

@@ -32,7 +32,7 @@ public:
 	/// After this call, the instance will be destroyed.
 	virtual void stop(SoundInstanceId id) = 0;
 
-	/// Returns wheter the sound @a id is playing.
+	/// Returns whether the sound @a id is playing.
 	virtual bool is_playing(SoundInstanceId id) = 0;
 
 	/// Stops all the sounds in the world.

+ 7 - 9
src/console_server.cpp

@@ -25,13 +25,13 @@ ConsoleServer::ConsoleServer(uint16_t port, bool wait)
 
 	if (wait)
 	{
-		AcceptResult result;
+		AcceptResult ar;
 		TCPSocket client;
 		do
 		{
-			result = _server.accept(client);
+			ar = _server.accept(client);
 		}
-		while (result.error != AcceptResult::NO_ERROR);
+		while (ar.error != AcceptResult::NO_ERROR);
 
 		add_client(client);
 	}
@@ -47,7 +47,7 @@ void ConsoleServer::shutdown()
 
 void ConsoleServer::send(TCPSocket client, const char* json)
 {
-	uint32_t len = strlen(json);
+	uint32_t len = strlen32(json);
 	client.write((const char*)&len, 4);
 	client.write(json, len);
 }
@@ -55,7 +55,7 @@ void ConsoleServer::send(TCPSocket client, const char* json)
 void ConsoleServer::send(const char* json)
 {
 	for (uint32_t i = 0; i < vector::size(_clients); ++i)
-		send(_clients[i].socket, json);
+		send(_clients[i], json);
 }
 
 void ConsoleServer::update()
@@ -71,7 +71,7 @@ void ConsoleServer::update()
 	// Update all clients
 	for (uint32_t i = 0; i < vector::size(_clients); ++i)
 	{
-		ReadResult rr = update_client(_clients[i].socket);
+		ReadResult rr = update_client(_clients[i]);
 		if (rr.error != ReadResult::NO_ERROR)
 			array::push_back(to_remove, i);
 	}
@@ -90,9 +90,7 @@ void ConsoleServer::update()
 
 void ConsoleServer::add_client(TCPSocket socket)
 {
-	Client cl;
-	cl.socket = socket;
-	vector::push_back(_clients, cl);
+	vector::push_back(_clients, socket);
 }
 
 ReadResult ConsoleServer::update_client(TCPSocket client)

+ 2 - 12
src/console_server.h

@@ -28,7 +28,7 @@ public:
 
 private:
 
-	void send(TCPSocket client, const char* message);
+	void send(TCPSocket client, const char* json);
 
 	void add_client(TCPSocket socket);
 	ReadResult update_client(TCPSocket client);
@@ -40,18 +40,8 @@ private:
 
 private:
 
-	struct Client
-	{
-		TCPSocket socket;
-
-		void close()
-		{
-			socket.close();
-		}
-	};
-
 	TCPSocket _server;
-	Vector<Client> _clients;
+	Vector<TCPSocket> _clients;
 };
 
 /// Functions for accessing global console.

+ 2 - 2
src/core/command_line.h

@@ -23,8 +23,8 @@ struct CommandLine
 	{
 		for (int i = 0; i < _argc; i++)
 		{
-			if ((shortopt != '\0' && strlen(_argv[i]) > 1 && _argv[i][0] == '-' && _argv[i][1] == shortopt) ||
-				(strlen(_argv[i]) > 2 && _argv[i][0] == '-' && _argv[i][1] == '-' && strcmp(&_argv[i][2], longopt) == 0))
+			if ((shortopt != '\0' && strlen32(_argv[i]) > 1 && _argv[i][0] == '-' && _argv[i][1] == shortopt) ||
+				(strlen32(_argv[i]) > 2 && _argv[i][0] == '-' && _argv[i][1] == '-' && strcmp(&_argv[i][2], longopt) == 0))
 			{
 				return i;
 			}

+ 1 - 1
src/core/containers/array.h

@@ -36,7 +36,7 @@ namespace array
 	template <typename T> void resize(Array<T>& a, uint32_t size);
 
 	/// Reserves space in the array @a a for at least @a capacity items.
-	template <typename T> void reserve(uint32_t capacity);
+	template <typename T> void reserve(Array<T>& a, uint32_t capacity);
 
 	/// Sets the capacity of array @a a.
 	template <typename T> void set_capacity(Array<T>& a, uint32_t capacity);

+ 2 - 1
src/core/error/stacktrace_linux.cpp

@@ -8,6 +8,7 @@
 #if CROWN_PLATFORM_LINUX && CROWN_COMPILER_GCC
 
 #include "macros.h"
+#include "string_utils.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <cxxabi.h>
@@ -26,7 +27,7 @@ const char* addr2line(const char* addr, char* line, int len)
 	if (f)
 	{
 		fgets(line, len, f);
-		line[strlen(line) - 1] = '\0';
+		line[strlen32(line) - 1] = '\0';
 		pclose(f);
 		return line;
 	}

+ 1 - 1
src/core/filesystem/reader_writer.h

@@ -71,7 +71,7 @@ public:
 	/// The final null character is not copied to the file.
 	void write_string(const char* string)
 	{
-		_file.write(string, strlen(string));
+		_file.write(string, strlen32(string));
 	}
 
 private:

+ 54 - 54
src/core/json/json_parser.cpp

@@ -4,7 +4,7 @@
  */
 
 #include "json_parser.h"
-#include "njson.h"
+#include "sjson.h"
 #include "temp_allocator.h"
 #include "string_utils.h"
 #include "vector.h"
@@ -45,7 +45,7 @@ JSONElement JSONElement::operator[](uint32_t i)
 {
 	Array<const char*> array(default_allocator());
 
-	njson::parse_array(_at, array);
+	sjson::parse_array(_at, array);
 
 	CE_ASSERT(i < array::size(array), "Index out of bounds");
 
@@ -63,7 +63,7 @@ JSONElement JSONElement::index_or_nil(uint32_t i)
 	{
 		Array<const char*> array(default_allocator());
 
-		njson::parse_array(_at, array);
+		sjson::parse_array(_at, array);
 
 		if (i >= array::size(array))
 		{
@@ -79,7 +79,7 @@ JSONElement JSONElement::index_or_nil(uint32_t i)
 JSONElement JSONElement::key(const char* k)
 {
 	Map<DynamicString, const char*> object(default_allocator());
-	njson::parse(_at, object);
+	sjson::parse(_at, object);
 
 	const char* value = map::get(object, DynamicString(k), (const char*) NULL);
 	CE_ASSERT(value != NULL, "Key not found: '%s'", k);
@@ -92,7 +92,7 @@ JSONElement JSONElement::key_or_nil(const char* k)
 	if (_at != NULL)
 	{
 		Map<DynamicString, const char*> object(default_allocator());
-		njson::parse(_at, object);
+		sjson::parse(_at, object);
 
 		const char* value = map::get(object, DynamicString(k), (const char*) NULL);
 
@@ -106,24 +106,24 @@ JSONElement JSONElement::key_or_nil(const char* k)
 bool JSONElement::has_key(const char* k) const
 {
 	Map<DynamicString, const char*> object(default_allocator());
-	njson::parse(_at, object);
+	sjson::parse(_at, object);
 
 	return map::has(object, DynamicString(k));
 }
 
 bool JSONElement::to_bool(bool def) const
 {
-	return is_nil() ? def : njson::parse_bool(_at);
+	return is_nil() ? def : sjson::parse_bool(_at);
 }
 
 int32_t JSONElement::to_int(int32_t def) const
 {
-	return is_nil() ? def : njson::parse_int(_at);
+	return is_nil() ? def : sjson::parse_int(_at);
 }
 
 float JSONElement::to_float(float def) const
 {
-	return is_nil() ? def : njson::parse_float(_at);
+	return is_nil() ? def : sjson::parse_float(_at);
 }
 
 DynamicString JSONElement::to_string(const char* def) const
@@ -133,7 +133,7 @@ DynamicString JSONElement::to_string(const char* def) const
 	if (is_nil())
 		str = def;
 	else
-		njson::parse_string(_at, str);
+		sjson::parse_string(_at, str);
 
 	return str;
 }
@@ -145,10 +145,10 @@ Vector2 JSONElement::to_vector2(const Vector2& def) const
 
 	TempAllocator64 alloc;
 	Array<const char*> array(alloc);
-	njson::parse_array(_at, array);
+	sjson::parse_array(_at, array);
 
-	return vector2(njson::parse_float(array[0]),
-		njson::parse_float(array[1]));
+	return vector2(sjson::parse_float(array[0]),
+		sjson::parse_float(array[1]));
 }
 
 Vector3 JSONElement::to_vector3(const Vector3& def) const
@@ -158,11 +158,11 @@ Vector3 JSONElement::to_vector3(const Vector3& def) const
 
 	TempAllocator64 alloc;
 	Array<const char*> array(alloc);
-	njson::parse_array(_at, array);
+	sjson::parse_array(_at, array);
 
-	return vector3(njson::parse_float(array[0]),
-		njson::parse_float(array[1]),
-		njson::parse_float(array[2]));
+	return vector3(sjson::parse_float(array[0]),
+		sjson::parse_float(array[1]),
+		sjson::parse_float(array[2]));
 }
 
 Vector4 JSONElement::to_vector4(const Vector4& def) const
@@ -172,12 +172,12 @@ Vector4 JSONElement::to_vector4(const Vector4& def) const
 
 	TempAllocator64 alloc;
 	Array<const char*> array(alloc);
-	njson::parse_array(_at, array);
+	sjson::parse_array(_at, array);
 
-	return vector4(njson::parse_float(array[0]),
-		njson::parse_float(array[1]),
-		njson::parse_float(array[2]),
-		njson::parse_float(array[3]));
+	return vector4(sjson::parse_float(array[0]),
+		sjson::parse_float(array[1]),
+		sjson::parse_float(array[2]),
+		sjson::parse_float(array[3]));
 }
 
 Quaternion JSONElement::to_quaternion(const Quaternion& def) const
@@ -187,13 +187,13 @@ Quaternion JSONElement::to_quaternion(const Quaternion& def) const
 
 	TempAllocator64 alloc;
 	Array<const char*> array(alloc);
-	njson::parse_array(_at, array);
+	sjson::parse_array(_at, array);
 
-	const Vector3 axis = vector3(njson::parse_float(array[0])
-		, njson::parse_float(array[1])
-		, njson::parse_float(array[2])
+	const Vector3 axis = vector3(sjson::parse_float(array[0])
+		, sjson::parse_float(array[1])
+		, sjson::parse_float(array[2])
 		);
-	const float angle = njson::parse_float(array[3]);
+	const float angle = sjson::parse_float(array[3]);
 
 	return quaternion(axis, angle);
 }
@@ -217,14 +217,14 @@ StringId32 JSONElement::to_string_id(const StringId32 def) const
 
 	TempAllocator1024 alloc;
 	DynamicString str(alloc);
-	njson::parse_string(_at, str);
+	sjson::parse_string(_at, str);
 	return str.to_string_id();
 }
 
 ResourceId JSONElement::to_resource_id() const
 {
 	DynamicString str(default_allocator());
-	njson::parse_string(_at, str);
+	sjson::parse_string(_at, str);
 	return ResourceId(str.c_str());
 }
 
@@ -232,11 +232,11 @@ void JSONElement::to_array(Array<bool>& array) const
 {
 	Array<const char*> temp(default_allocator());
 
-	njson::parse_array(_at, temp);
+	sjson::parse_array(_at, temp);
 
 	for (uint32_t i = 0; i < array::size(temp); i++)
 	{
-		array::push_back(array, njson::parse_bool(temp[i]));
+		array::push_back(array, sjson::parse_bool(temp[i]));
 	}
 }
 
@@ -244,11 +244,11 @@ void JSONElement::to_array(Array<int16_t>& array) const
 {
 	Array<const char*> temp(default_allocator());
 
-	njson::parse_array(_at, temp);
+	sjson::parse_array(_at, temp);
 
 	for (uint32_t i = 0; i < array::size(temp); i++)
 	{
-		array::push_back(array, (int16_t)njson::parse_int(temp[i]));
+		array::push_back(array, (int16_t)sjson::parse_int(temp[i]));
 	}
 }
 
@@ -256,11 +256,11 @@ void JSONElement::to_array(Array<uint16_t>& array) const
 {
 	Array<const char*> temp(default_allocator());
 
-	njson::parse_array(_at, temp);
+	sjson::parse_array(_at, temp);
 
 	for (uint32_t i = 0; i < array::size(temp); i++)
 	{
-		array::push_back(array, (uint16_t)njson::parse_int(temp[i]));
+		array::push_back(array, (uint16_t)sjson::parse_int(temp[i]));
 	}
 }
 
@@ -268,11 +268,11 @@ void JSONElement::to_array(Array<int32_t>& array) const
 {
 	Array<const char*> temp(default_allocator());
 
-	njson::parse_array(_at, temp);
+	sjson::parse_array(_at, temp);
 
 	for (uint32_t i = 0; i < array::size(temp); i++)
 	{
-		array::push_back(array, (int32_t)njson::parse_int(temp[i]));
+		array::push_back(array, (int32_t)sjson::parse_int(temp[i]));
 	}
 }
 
@@ -280,11 +280,11 @@ void JSONElement::to_array(Array<uint32_t>& array) const
 {
 	Array<const char*> temp(default_allocator());
 
-	njson::parse_array(_at, temp);
+	sjson::parse_array(_at, temp);
 
 	for (uint32_t i = 0; i < array::size(temp); i++)
 	{
-		array::push_back(array, (uint32_t)njson::parse_int(temp[i]));
+		array::push_back(array, (uint32_t)sjson::parse_int(temp[i]));
 	}
 }
 
@@ -292,11 +292,11 @@ void JSONElement::to_array(Array<float>& array) const
 {
 	Array<const char*> temp(default_allocator());
 
-	njson::parse_array(_at, temp);
+	sjson::parse_array(_at, temp);
 
 	for (uint32_t i = 0; i < array::size(temp); i++)
 	{
-		array::push_back(array, njson::parse_float(temp[i]));
+		array::push_back(array, sjson::parse_float(temp[i]));
 	}
 }
 
@@ -304,13 +304,13 @@ void JSONElement::to_array(Vector<DynamicString>& array) const
 {
 	Array<const char*> temp(default_allocator());
 
-	njson::parse_array(_at, temp);
+	sjson::parse_array(_at, temp);
 
 	for (uint32_t i = 0; i < array::size(temp); i++)
 	{
 		TempAllocator256 ta;
 		DynamicString str(ta);
-		njson::parse_string(temp[i], str);
+		sjson::parse_string(temp[i], str);
 		vector::push_back(array, str);
 	}
 }
@@ -318,7 +318,7 @@ void JSONElement::to_array(Vector<DynamicString>& array) const
 void JSONElement::to_keys(Vector<DynamicString>& keys) const
 {
 	Map<DynamicString, const char*> object(default_allocator());
-	njson::parse(_at, object);
+	sjson::parse(_at, object);
 
 	const Map<DynamicString, const char*>::Node* it = map::begin(object);
 	while (it != map::end(object))
@@ -332,7 +332,7 @@ bool JSONElement::is_nil() const
 {
 	if (_at != NULL)
 	{
-		return njson::type(_at) == JsonValueType::NIL;
+		return sjson::type(_at) == JsonValueType::NIL;
 	}
 
 	return true;
@@ -342,7 +342,7 @@ bool JSONElement::is_bool() const
 {
 	if (_at != NULL)
 	{
-		return njson::type(_at) == JsonValueType::BOOL;
+		return sjson::type(_at) == JsonValueType::BOOL;
 	}
 
 	return false;
@@ -352,7 +352,7 @@ bool JSONElement::is_number() const
 {
 	if (_at != NULL)
 	{
-		return njson::type(_at) == JsonValueType::NUMBER;
+		return sjson::type(_at) == JsonValueType::NUMBER;
 	}
 
 	return false;
@@ -362,7 +362,7 @@ bool JSONElement::is_string() const
 {
 	if (_at != NULL)
 	{
-		return njson::type(_at) == JsonValueType::STRING;
+		return sjson::type(_at) == JsonValueType::STRING;
 	}
 
 	return false;
@@ -372,7 +372,7 @@ bool JSONElement::is_array() const
 {
 	if (_at != NULL)
 	{
-		return njson::type(_at) == JsonValueType::ARRAY;
+		return sjson::type(_at) == JsonValueType::ARRAY;
 	}
 
 	return false;
@@ -382,7 +382,7 @@ bool JSONElement::is_object() const
 {
 	if (_at != NULL)
 	{
-		return njson::type(_at) == JsonValueType::OBJECT;
+		return sjson::type(_at) == JsonValueType::OBJECT;
 	}
 
 	return false;
@@ -395,7 +395,7 @@ uint32_t JSONElement::size() const
 		return 0;
 	}
 
-	switch(njson::type(_at))
+	switch(sjson::type(_at))
 	{
 		case JsonValueType::NIL:
 		{
@@ -404,20 +404,20 @@ uint32_t JSONElement::size() const
 		case JsonValueType::OBJECT:
 		{
 			Map<DynamicString, const char*> object(default_allocator());
-			njson::parse(_at, object);
+			sjson::parse(_at, object);
 			return map::size(object);
 		}
 		case JsonValueType::ARRAY:
 		{
 			Array<const char*> array(default_allocator());
-			njson::parse_array(_at, array);
+			sjson::parse_array(_at, array);
 			return array::size(array);
 		}
 		case JsonValueType::STRING:
 		{
 			TempAllocator256 ta;
 			DynamicString string(ta);
-			njson::parse_string(_at, string);
+			sjson::parse_string(_at, string);
 			return string.length();
 		}
 		case JsonValueType::NUMBER:

+ 7 - 0
src/core/json/json_types.h

@@ -29,7 +29,14 @@ struct JsonValueType
 	};
 };
 
+/// Array of pointers to json-encoded strings.
+///
+/// @ingroup JSON
 typedef Array<const char*> JsonArray;
+
+/// Map from key to pointers to json-encoded strings.
+///
+/// @ingroup JSON
 typedef Map<FixedString, const char*> JsonObject;
 
 } // namespace crown

+ 43 - 43
src/core/json/njson.cpp → src/core/json/sjson.cpp

@@ -3,7 +3,7 @@
  * License: https://github.com/taylor001/crown/blob/master/LICENSE
  */
 
-#include "njson.h"
+#include "sjson.h"
 #include "string_utils.h"
 #include "temp_allocator.h"
 #include "map.h"
@@ -11,7 +11,7 @@
 
 namespace crown
 {
-namespace njson
+namespace sjson
 {
 	static const char* next(const char* json, const char c = 0)
 	{
@@ -478,19 +478,19 @@ namespace njson
 		array::pop_back(json);
 		parse(array::begin(json), object);
 	}
-} // namespace njson
+} // namespace sjson
 
-namespace njson
+namespace sjson
 {
 	Vector2 parse_vector2(const char* json)
 	{
 		TempAllocator64 ta;
 		JsonArray array(ta);
-		njson::parse_array(json, array);
+		sjson::parse_array(json, array);
 
 		Vector2 v;
-		v.x = njson::parse_float(array[0]);
-		v.y = njson::parse_float(array[1]);
+		v.x = sjson::parse_float(array[0]);
+		v.y = sjson::parse_float(array[1]);
 		return v;
 	}
 
@@ -498,12 +498,12 @@ namespace njson
 	{
 		TempAllocator64 ta;
 		JsonArray array(ta);
-		njson::parse_array(json, array);
+		sjson::parse_array(json, array);
 
 		Vector3 v;
-		v.x = njson::parse_float(array[0]);
-		v.y = njson::parse_float(array[1]);
-		v.z = njson::parse_float(array[2]);
+		v.x = sjson::parse_float(array[0]);
+		v.y = sjson::parse_float(array[1]);
+		v.z = sjson::parse_float(array[2]);
 		return v;
 	}
 
@@ -511,13 +511,13 @@ namespace njson
 	{
 		TempAllocator64 ta;
 		JsonArray array(ta);
-		njson::parse_array(json, array);
+		sjson::parse_array(json, array);
 
 		Vector4 v;
-		v.x = njson::parse_float(array[0]);
-		v.y = njson::parse_float(array[1]);
-		v.z = njson::parse_float(array[2]);
-		v.w = njson::parse_float(array[3]);
+		v.x = sjson::parse_float(array[0]);
+		v.y = sjson::parse_float(array[1]);
+		v.z = sjson::parse_float(array[2]);
+		v.w = sjson::parse_float(array[3]);
 		return v;
 	}
 
@@ -525,14 +525,14 @@ namespace njson
 	{
 		TempAllocator64 ta;
 		JsonArray array(ta);
-		njson::parse_array(json, array);
+		sjson::parse_array(json, array);
 
 		Vector3 axis;
-		axis.x = njson::parse_float(array[0]);
-		axis.y = njson::parse_float(array[1]);
-		axis.z = njson::parse_float(array[2]);
+		axis.x = sjson::parse_float(array[0]);
+		axis.y = sjson::parse_float(array[1]);
+		axis.z = sjson::parse_float(array[2]);
 
-		float angle = njson::parse_float(array[3]);
+		float angle = sjson::parse_float(array[3]);
 
 		return quaternion(axis, angle);
 	}
@@ -541,28 +541,28 @@ namespace njson
 	{
 		TempAllocator128 ta;
 		JsonArray array(ta);
-		njson::parse_array(json, array);
+		sjson::parse_array(json, array);
 
 		Matrix4x4 m;
-		m.x.x = njson::parse_float(array[ 0]);
-		m.x.y = njson::parse_float(array[ 1]);
-		m.x.z = njson::parse_float(array[ 2]);
-		m.x.w = njson::parse_float(array[ 3]);
-
-		m.y.x = njson::parse_float(array[ 4]);
-		m.y.y = njson::parse_float(array[ 5]);
-		m.y.z = njson::parse_float(array[ 6]);
-		m.y.w = njson::parse_float(array[ 7]);
-
-		m.z.x = njson::parse_float(array[ 8]);
-		m.z.y = njson::parse_float(array[ 9]);
-		m.z.z = njson::parse_float(array[10]);
-		m.z.w = njson::parse_float(array[11]);
-
-		m.t.x = njson::parse_float(array[12]);
-		m.t.y = njson::parse_float(array[13]);
-		m.t.z = njson::parse_float(array[14]);
-		m.t.w = njson::parse_float(array[15]);
+		m.x.x = sjson::parse_float(array[ 0]);
+		m.x.y = sjson::parse_float(array[ 1]);
+		m.x.z = sjson::parse_float(array[ 2]);
+		m.x.w = sjson::parse_float(array[ 3]);
+
+		m.y.x = sjson::parse_float(array[ 4]);
+		m.y.y = sjson::parse_float(array[ 5]);
+		m.y.z = sjson::parse_float(array[ 6]);
+		m.y.w = sjson::parse_float(array[ 7]);
+
+		m.z.x = sjson::parse_float(array[ 8]);
+		m.z.y = sjson::parse_float(array[ 9]);
+		m.z.z = sjson::parse_float(array[10]);
+		m.z.w = sjson::parse_float(array[11]);
+
+		m.t.x = sjson::parse_float(array[12]);
+		m.t.y = sjson::parse_float(array[13]);
+		m.t.z = sjson::parse_float(array[14]);
+		m.t.w = sjson::parse_float(array[15]);
 		return m;
 	}
 
@@ -570,7 +570,7 @@ namespace njson
 	{
 		TempAllocator1024 ta;
 		DynamicString str(ta);
-		njson::parse_string(json, str);
+		sjson::parse_string(json, str);
 		return str.to_string_id();
 	}
 
@@ -578,7 +578,7 @@ namespace njson
 	{
 		TempAllocator1024 ta;
 		DynamicString str(ta);
-		njson::parse_string(json, str);
+		sjson::parse_string(json, str);
 		return ResourceId(str.c_str());
 	}
 } // namespace json

+ 19 - 19
src/core/json/njson.h → src/core/json/sjson.h

@@ -12,52 +12,52 @@
 namespace crown
 {
 
-/// Functions to parse NJSON-encoded strings.
+/// Functions to parse SJSON-encoded strings.
 ///
 /// @ingroup JSON
-namespace njson
+namespace sjson
 {
-	/// Returns the data type of the NJSON string @a json.
+	/// Returns the data type of the SJSON string @a json.
 	JsonValueType::Enum type(const char* json);
 
-	/// Parses the NJSON string @a json ad puts it into @a string.
+	/// Parses the SJSON string @a json ad puts it into @a string.
 	void parse_string(const char* json, DynamicString& string);
 
-	/// Returns the NJSON number @a json as double.
+	/// Returns the SJSON number @a json as double.
 	double parse_number(const char* json);
 
-	/// Returns the NJSON number @a json as int.
+	/// Returns the SJSON number @a json as int.
 	int32_t parse_int(const char* json);
 
-	/// Returns the NJSON number @a json as float.
+	/// Returns the SJSON number @a json as float.
 	float parse_float(const char* json);
 
-	/// Returns the NJSON boolean @a json as bool.
+	/// Returns the SJSON boolean @a json as bool.
 	bool parse_bool(const char* json);
 
-	/// Parses the NJSON array @a json and puts it into @a array as pointers to
+	/// Parses the SJSON array @a json and puts it into @a array as pointers to
 	/// the corresponding items into the original @a json string.
 	void parse_array(const char* json, JsonArray& array);
 
-	/// Parses the NJSON object @a json and puts it into @a object as map from
+	/// Parses the SJSON object @a json and puts it into @a object as map from
 	/// key to pointer to the corresponding value into the original string @a json.
 	void parse_object(const char* json, Map<DynamicString, const char*>& object);
 
-	/// Parses the NJSON-encoded @a json.
+	/// Parses the SJSON-encoded @a json.
 	void parse(const char* json, Map<DynamicString, const char*>& object);
 
-	/// Parses the NJSON object @a json and puts it into @a object as map from
+	/// Parses the SJSON object @a json and puts it into @a object as map from
 	/// key to pointer to the corresponding value into the original string @a json.
 	void parse_object(const char* json, JsonObject& object);
 
-	/// Parses the NJSON-encoded @a json.
+	/// Parses the SJSON-encoded @a json.
 	void parse(const char* json, JsonObject& object);
 
-	/// Parses the NJSON-encoded @a json.
+	/// Parses the SJSON-encoded @a json.
 	void parse(Buffer& json, JsonObject& object);
-} // namespace njson
+} // namespace sjson
 
-namespace njson
+namespace sjson
 {
 	/// Returns the array @a json as Vector2.
 	/// @note Vector2 = [x, y]
@@ -72,11 +72,11 @@ namespace njson
 	Vector4 parse_vector4(const char* json);
 
 	/// Returns the array @a json as Quaternion.
-	/// @note Quaternion = [x, y, z, w]
+	/// @note Quaternion = [x, y, z, angle]
 	Quaternion parse_quaternion(const char* json);
 
 	/// Returns the array @a json as Matrix4x4.
-	/// @note Matrix4x4 = [x, x, x, x, y, y, y, y, z, z, z, z, t, t, t, t]
+	/// @note Matrix4x4 = [xx, xy, xz, xw, yx, yy, yz, yw, zx, zy, zz, zw, tx, ty, tz, tw]
 	Matrix4x4 parse_matrix4x4(const char* json);
 
 	/// Returns the string @a json as StringId32.
@@ -84,6 +84,6 @@ namespace njson
 
 	/// Returns the string @a json as ResourceId.
 	ResourceId parse_resource_id(const char* json);
-}
+} // namespace sjson
 
 } // namespace crown

+ 3 - 3
src/core/math/matrix4x4.h

@@ -482,7 +482,7 @@ inline void set_identity(Matrix4x4& m)
 	m.t.w = 1.0f;
 }
 
-/// Returns the x asis of the matrix @a m.
+/// Returns the x axis of the matrix @a m.
 inline Vector3 x(const Matrix4x4& m)
 {
 	Vector3 v;
@@ -492,7 +492,7 @@ inline Vector3 x(const Matrix4x4& m)
 	return v;
 }
 
-/// Returns the y asis of the matrix @a m.
+/// Returns the y axis of the matrix @a m.
 inline Vector3 y(const Matrix4x4& m)
 {
 	Vector3 v;
@@ -502,7 +502,7 @@ inline Vector3 y(const Matrix4x4& m)
 	return v;
 }
 
-/// Returns the z asis of the matrix @a m.
+/// Returns the z axis of the matrix @a m.
 inline Vector3 z(const Matrix4x4& m)
 {
 	Vector3 v;

+ 1 - 1
src/core/math/vector2.h

@@ -157,7 +157,7 @@ inline Vector2 min(const Vector2& a, const Vector2& b)
 	return v;
 }
 
-/// Returns the linearly interpolated vector between @a and @b at time @a t in [0, 1].
+/// Returns the linearly interpolated vector between @a a and @a b at time @a t in [0, 1].
 inline Vector2 lerp(const Vector2& a, const Vector2& b, float t)
 {
 	Vector2 v;

+ 1 - 1
src/core/math/vector3.h

@@ -176,7 +176,7 @@ inline Vector3 min(const Vector3& a, const Vector3& b)
 	return v;
 }
 
-/// Returns the linearly interpolated vector between @a and @b at time @a t in [0, 1].
+/// Returns the linearly interpolated vector between @a a and @a b at time @a t in [0, 1].
 inline Vector3 lerp(const Vector3& a, const Vector3& b, float t)
 {
 	Vector3 v;

+ 1 - 1
src/core/math/vector4.h

@@ -189,7 +189,7 @@ inline Vector4 min(const Vector4& a, const Vector4& b)
 	return v;
 }
 
-/// Returns the linearly interpolated vector between @a and @b at time @a t in [0, 1].
+/// Returns the linearly interpolated vector between @a a and @a b at time @a t in [0, 1].
 inline Vector4 lerp(const Vector4& a, const Vector4& b, float t)
 {
 	Vector4 v;

+ 3 - 3
src/core/os.h

@@ -112,7 +112,7 @@ namespace os
 		CE_ASSERT(err != 0, "GetFileTime: GetLastError = %d", GetLastError());
 		CE_UNUSED(err);
 		CloseHandle(hfile);
-		return (uint64_t)((ftwrite.dwHighDateTime << 32) | ftwrite.dwLowDateTime);
+		return (uint64_t)((uint64_t(ftwrite.dwHighDateTime) << 32) | ftwrite.dwLowDateTime);
 #endif
 	}
 
@@ -223,7 +223,7 @@ namespace os
 
 			TempAllocator512 ta;
 			DynamicString filename(fname, ta);
-			vector::push_back(files, fname);
+			vector::push_back(files, filename);
 		}
 		while (FindNextFile(file, &ffd) != 0);
 
@@ -335,7 +335,7 @@ namespace os
 		PROCESS_INFORMATION process;
 		memset(&process, 0, sizeof(process));
 
-		int err = CreateProcess(path, args, NULL, NULL, TRUE, 0, NULL, NULL, &info, &process);
+		int err = CreateProcess(path, (LPSTR)args, NULL, NULL, TRUE, 0, NULL, NULL, &info, &process);
 		CE_ASSERT(err != 0, "CreateProcess: GetLastError = %d", GetLastError());
 		CE_UNUSED(err);
 

+ 2 - 2
src/core/string_id.cpp

@@ -12,7 +12,7 @@ namespace crown
 {
 
 StringId32::StringId32(const char* str)
-	: _id(murmur32(str, strlen(str)))
+	: _id(murmur32(str, strlen32(str)))
 {
 }
 
@@ -28,7 +28,7 @@ const char* StringId32::to_string(char* buf)
 }
 
 StringId64::StringId64(const char* str)
-	: _id(murmur64(str, strlen(str)))
+	: _id(murmur64(str, strlen32(str)))
 {
 }
 

+ 14 - 13
src/core/strings/dynamic_string.h

@@ -9,6 +9,7 @@
 #include "memory.h"
 #include "array.h"
 #include "string_id.h"
+#include "string_utils.h"
 #include <string.h> // memmove
 
 namespace crown
@@ -78,7 +79,7 @@ inline DynamicString::DynamicString(const char* s, Allocator& a)
 	: _data(a)
 {
 	CE_ASSERT_NOT_NULL(s);
-	array::push(_data, s, (uint32_t)strlen(s));
+	array::push(_data, s, strlen32(s));
 }
 
 inline DynamicString& DynamicString::operator+=(const DynamicString& s)
@@ -89,7 +90,7 @@ inline DynamicString& DynamicString::operator+=(const DynamicString& s)
 inline DynamicString& DynamicString::operator+=(const char* s)
 {
 	CE_ASSERT_NOT_NULL(s);
-	array::push(_data, s, (uint32_t)strlen(s));
+	array::push(_data, s, strlen32(s));
 	return *this;
 }
 
@@ -109,7 +110,7 @@ inline DynamicString& DynamicString::operator=(const char* s)
 {
 	CE_ASSERT_NOT_NULL(s);
 	array::clear(_data);
-	array::push(_data, s, (uint32_t)strlen(s));
+	array::push(_data, s, strlen32(s));
 	return *this;
 }
 
@@ -143,7 +144,7 @@ inline void DynamicString::reserve(uint32_t n)
 
 inline uint32_t DynamicString::length() const
 {
-	return (uint32_t)strlen(this->c_str());
+	return strlen32(this->c_str());
 }
 
 inline void DynamicString::strip_leading(const char* s)
@@ -151,11 +152,11 @@ inline void DynamicString::strip_leading(const char* s)
 	CE_ASSERT_NOT_NULL(s);
 	CE_ASSERT(starts_with(s), "String does not start with %s", s);
 
-	const size_t my_len = strlen(c_str());
-	const size_t s_len = strlen(s);
+	const uint32_t my_len = strlen32(c_str());
+	const uint32_t s_len = strlen32(s);
 
 	memmove(array::begin(_data), array::begin(_data) + s_len, (my_len - s_len));
-	array::resize(_data, uint32_t(my_len - s_len));
+	array::resize(_data, my_len - s_len);
 }
 
 inline void DynamicString::strip_trailing(const char* s)
@@ -163,23 +164,23 @@ inline void DynamicString::strip_trailing(const char* s)
 	CE_ASSERT_NOT_NULL(s);
 	CE_ASSERT(ends_with(s), "String does not end with %s", s);
 
-	const size_t my_len = strlen(c_str());
-	const size_t s_len = strlen(s);
-	array::resize(_data, uint32_t(my_len - s_len));
+	const uint32_t my_len = strlen32(c_str());
+	const uint32_t s_len = strlen32(s);
+	array::resize(_data, my_len - s_len);
 }
 
 inline bool DynamicString::starts_with(const char* s) const
 {
 	CE_ASSERT_NOT_NULL(s);
-	return strncmp(c_str(), s, strlen(s)) == 0;
+	return strncmp(c_str(), s, strlen32(s)) == 0;
 }
 
 inline bool DynamicString::ends_with(const char* s) const
 {
 	CE_ASSERT_NOT_NULL(s);
 
-	const size_t my_len = strlen(c_str());
-	const size_t s_len = strlen(s);
+	const uint32_t my_len = strlen32(c_str());
+	const uint32_t s_len = strlen32(s);
 
 	if (my_len >= s_len)
 	{

+ 3 - 3
src/core/strings/fixed_string.h

@@ -22,7 +22,7 @@ public:
 	}
 
 	FixedString(const char* str)
-		: _length(strlen(str))
+		: _length(strlen32(str))
 		, _data(str)
 	{
 	}
@@ -41,14 +41,14 @@ public:
 
 	FixedString& operator=(const char* str)
 	{
-		_length = strlen(str);
+		_length = strlen32(str);
 		_data = str;
 		return *this;
 	}
 
 	bool operator==(const char* str) const
 	{
-		const uint32_t len = strlen(str);
+		const uint32_t len = strlen32(str);
 		return _length == len && !strncmp(_data, str, len);
 	}
 

+ 6 - 6
src/core/strings/path.cpp

@@ -15,9 +15,9 @@ namespace path
 	{
 		CE_ASSERT(path != NULL, "Path must be != NULL");
 #if CROWN_PLATFORM_POSIX
-		return strlen(path) > 0 && path[0] == SEPARATOR;
+		return strlen32(path) > 0 && path[0] == SEPARATOR;
 #elif CROWN_PLATFORM_WINDOWS
-		return strlen(path) > 2 && isalpha(path[0]) && path[1] == ':' && path[2] == SEPARATOR;
+		return strlen32(path) > 2 && isalpha(path[0]) && path[1] == ':' && path[2] == SEPARATOR;
 #endif
 	}
 
@@ -25,16 +25,16 @@ namespace path
 	{
 		CE_ASSERT(path != NULL, "Path must be != NULL");
 #if CROWN_PLATFORM_POSIX
-		return is_absolute_path(path) && strlen(path) == 1;
+		return is_absolute_path(path) && strlen32(path) == 1;
 #elif CROWN_PLATFORM_WINDOWS
-		return is_absolute_path(path) && strlen(path) == 3;
+		return is_absolute_path(path) && strlen32(path) == 3;
 #endif
 	}
 
 	void join(const char* a, const char* b, DynamicString& path)
 	{
-		const uint32_t la = strlen(a);
-		const uint32_t lb = strlen(b);
+		const uint32_t la = strlen32(a);
+		const uint32_t lb = strlen32(b);
 		path.reserve(la + lb + 1);
 		path += a;
 		path += SEPARATOR;

+ 2 - 2
src/core/strings/string_stream.h

@@ -86,9 +86,9 @@ namespace string_stream
 		return stream_printf(s, "%g", val);
 	}
 
-	inline StringStream& operator<<(StringStream& s, const char* string)
+	inline StringStream& operator<<(StringStream& s, const char* str)
 	{
-		array::push(s, string, (uint32_t)strlen(string));
+		array::push(s, str, strlen32(str));
 		return s;
 	}
 

+ 5 - 0
src/core/strings/string_utils.h

@@ -36,6 +36,11 @@ inline int32_t snprintf(char* str, size_t n, const char* format, ...)
 	return len;
 }
 
+inline uint32_t strlen32(const char* str)
+{
+	return (uint32_t)strlen(str);
+}
+
 inline const char* skip_spaces(const char* str)
 {
 	while (isspace(*str)) ++str;

+ 12 - 12
src/device.cpp

@@ -26,7 +26,7 @@
 #include "profiler.h"
 #include "console_server.h"
 #include "input_device.h"
-#include "njson.h"
+#include "sjson.h"
 #include "map.h"
 
 #if CROWN_PLATFORM_ANDROID
@@ -88,9 +88,6 @@ void Device::init()
 
 	_input_manager = CE_NEW(_allocator, InputManager)();
 
-	audio_globals::init();
-	physics_globals::init();
-
 	bgfx::init(bgfx::RendererType::Count
 		, BGFX_PCI_ID_NONE
 		, 0
@@ -101,6 +98,9 @@ void Device::init()
 	material_manager::init();
 	debug_line::init();
 
+	audio_globals::init();
+	physics_globals::init();
+
 	_boot_package = create_resource_package(_boot_package_id);
 	_boot_package->load();
 	_boot_package->flush();
@@ -130,19 +130,19 @@ void Device::shutdown()
 	_boot_package->unload();
 	destroy_resource_package(*_boot_package);
 
-	debug_line::shutdown();
-	material_manager::shutdown();
-
-	bgfx::shutdown();
-
 	physics_globals::shutdown();
 	audio_globals::shutdown();
 
+	debug_line::shutdown();
+	material_manager::shutdown();
+
 	CE_DELETE(_allocator, _input_manager);
 	CE_DELETE(_allocator, _resource_manager);
 	CE_DELETE(_allocator, _resource_loader);
 	CE_DELETE(_allocator, _bundle_filesystem);
 
+	bgfx::shutdown();
+
 	profiler_globals::shutdown();
 
 	_allocator.clear();
@@ -432,10 +432,10 @@ void Device::read_config()
 	const char* cfile = (const char*)_resource_manager->get(CONFIG_TYPE, config_name);
 
 	JsonObject config(ta);
-	njson::parse(cfile, config);
+	sjson::parse(cfile, config);
 
-	_boot_script_id  = njson::parse_resource_id(config["boot_script"]);
-	_boot_package_id = njson::parse_resource_id(config["boot_package"]);
+	_boot_script_id  = sjson::parse_resource_id(config["boot_script"]);
+	_boot_package_id = sjson::parse_resource_id(config["boot_package"]);
 
 	_resource_manager->unload(CONFIG_TYPE, config_name);
 }

+ 4 - 3
src/device.h

@@ -20,6 +20,7 @@
 #include "allocator.h"
 #include "log.h"
 #include "proxy_allocator.h"
+#include "string_utils.h"
 #include <bx/allocator.h>
 #include <bgfx/bgfx.h>
 
@@ -159,7 +160,7 @@ private:
 		{
 			char buf[2048];
 			strncpy(buf, _format, sizeof(buf));
-			buf[strlen(buf)-1] = '\0'; // Remove trailing newline
+			buf[strlen32(buf)-1] = '\0'; // Remove trailing newline
 			CE_LOGDV(buf, _argList);
 		}
 
@@ -204,7 +205,7 @@ private:
 		virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* /*_file*/, uint32_t /*_line*/)
 		{
 			if (!_ptr)
-				return _allocator.allocate((uint32_t)_size, (uint32_t)_align == 0 ? 1 : _align);
+				return _allocator.allocate((uint32_t)_size, (uint32_t)_align == 0 ? 1 : (uint32_t)_align);
 
 			if (_size == 0)
 			{
@@ -213,7 +214,7 @@ private:
 			}
 
 			// Realloc
-			void* p = _allocator.allocate((uint32_t)_size, (uint32_t)_align == 0 ? 1 : _align);
+			void* p = _allocator.allocate((uint32_t)_size, (uint32_t)_align == 0 ? 1 : (uint32_t)_align);
 			_allocator.deallocate(_ptr);
 			return p;
 		}

+ 3 - 2
src/input/input_device.cpp

@@ -6,7 +6,8 @@
 #include "input_device.h"
 #include "error.h"
 #include "allocator.h"
-#include <string.h> // strlen, strcpy, memset
+#include "string_utils.h"
+#include <string.h> // strcpy, memset
 
 namespace crown
 {
@@ -88,7 +89,7 @@ InputDevice* InputDevice::create(Allocator& a, const char* name, uint8_t num_but
 		+ sizeof(InputDevice)
 		+ sizeof(uint8_t)*num_buttons*2
 		+ sizeof(Vector3)*num_axes
-		+ strlen(name) + 1;
+		+ strlen32(name) + 1;
 
 	InputDevice* id = (InputDevice*)a.allocate(size);
 

+ 2 - 2
src/input/input_device.h

@@ -35,7 +35,7 @@ struct InputDevice
 	/// Returns whether the specified @a b button is released in the current frame.
 	bool released(uint8_t i) const;
 
-	/// Returns wheter any button is pressed in the current frame.
+	/// Returns whether any button is pressed in the current frame.
 	bool any_pressed() const;
 
 	/// Returns whether any button is released in the current frame.
@@ -62,7 +62,7 @@ public:
 	uint8_t* _last_state;    // num_buttons
 	uint8_t* _current_state; // num_buttons
 	Vector3* _axis;          // num_axes
-	char* _name;             // strlen(name) + 1
+	char* _name;             // strlen32(name) + 1
 
 public:
 

+ 1 - 1
src/renderers/gui.cpp

@@ -200,7 +200,7 @@ void Gui::draw_text(const char* str, const char* font, uint32_t font_size, const
 	// Vector2 m_pen;
 
 	// const float scale = ((float)font_size / (float)resource->font_size());
-	// const uint32_t str_len = strlen(str);
+	// const uint32_t str_len = strlen32(str);
 
 	// TransientVertexBuffer vb;
 	// TransientIndexBuffer ib;

+ 19 - 12
src/renderers/shader.cpp

@@ -6,13 +6,14 @@
 #include "shader.h"
 #include "config.h"
 #include "filesystem.h"
-#include "json_parser.h"
 #include "os.h"
 #include "reader_writer.h"
 #include "resource_manager.h"
 #include "compile_options.h"
 #include "temp_allocator.h"
 #include "string_stream.h"
+#include "sjson.h"
+#include "map.h"
 
 #if CROWN_DEBUG
 #	define SHADERC_NAME "./shaderc-debug-"
@@ -51,7 +52,7 @@ namespace shader_resource
 #if CROWN_PLATFORM_LINUX
 		args <<	"120";
 #elif CROWN_PLATFORM_WINDOWS
-		args << (strcmp(type, "vertex") == 0) ? "vs_3_0" : "ps_3_0";
+		args << ((strcmp(type, "vertex") == 0) ? "vs_3_0" : "ps_3_0");
 #endif
 
 		return os::execute_process(SHADERC_PATH, c_str(args), output);
@@ -60,15 +61,22 @@ namespace shader_resource
 	void compile(const char* path, CompileOptions& opts)
 	{
 		Buffer buf = opts.read(path);
-		JSONParser json(buf);
-		JSONElement root = json.root();
-
-		DynamicString vs_code2 = root.key("vs_code").to_string();
-		DynamicString fs_code2 = root.key("fs_code").to_string();
-		DynamicString varying_def = root.key("varying_def").to_string();
-		DynamicString common_code = root.key("common").to_string();
-		DynamicString vs_in_out = root.key("vs_in_out").to_string();
-		DynamicString fs_in_out = root.key("fs_in_out").to_string();
+		TempAllocator4096 ta;
+		JsonObject object(ta);
+		sjson::parse(buf, object);
+
+		DynamicString vs_code2(ta);
+		DynamicString fs_code2(ta);
+		DynamicString varying_def(ta);
+		DynamicString common_code(ta);
+		DynamicString vs_in_out(ta);
+		DynamicString fs_in_out(ta);
+		sjson::parse_string(object["vs_code"], vs_code2);
+		sjson::parse_string(object["fs_code"], fs_code2);
+		sjson::parse_string(object["varying_def"], varying_def);
+		sjson::parse_string(object["common"], common_code);
+		sjson::parse_string(object["vs_in_out"], vs_in_out);
+		sjson::parse_string(object["fs_in_out"], fs_in_out);
 
 		DynamicString vs_code(default_allocator());
 		DynamicString fs_code(default_allocator());
@@ -103,7 +111,6 @@ namespace shader_resource
 		varying_file->write(varying_def.c_str(), varying_def.length());
 		opts._fs.close(*varying_file);
 
-		TempAllocator4096 ta;
 		StringStream output(ta);
 		using namespace string_stream;
 

+ 16 - 16
src/resource/font_resource.cpp

@@ -8,7 +8,7 @@
 #include "filesystem.h"
 #include "string_utils.h"
 #include "compile_options.h"
-#include "njson.h"
+#include "sjson.h"
 #include "map.h"
 
 namespace crown
@@ -19,16 +19,16 @@ namespace font_resource
 	{
 		TempAllocator512 ta;
 		JsonObject obj(ta);
-		njson::parse(json, obj);
-
-		glyph.id        = njson::parse_int(obj["id"]);
-		glyph.x         = njson::parse_int(obj["x"]);
-		glyph.y         = njson::parse_int(obj["y"]);
-		glyph.width     = njson::parse_int(obj["width"]);
-		glyph.height    = njson::parse_int(obj["height"]);
-		glyph.x_offset  = njson::parse_float(obj["x_offset"]);
-		glyph.y_offset  = njson::parse_float(obj["y_offset"]);
-		glyph.x_advance = njson::parse_float(obj["x_advance"]);
+		sjson::parse(json, obj);
+
+		glyph.id        = sjson::parse_int(obj["id"]);
+		glyph.x         = sjson::parse_int(obj["x"]);
+		glyph.y         = sjson::parse_int(obj["y"]);
+		glyph.width     = sjson::parse_int(obj["width"]);
+		glyph.height    = sjson::parse_int(obj["height"]);
+		glyph.x_offset  = sjson::parse_float(obj["x_offset"]);
+		glyph.y_offset  = sjson::parse_float(obj["y_offset"]);
+		glyph.x_advance = sjson::parse_float(obj["x_advance"]);
 	}
 
 	void compile(const char* path, CompileOptions& opts)
@@ -39,12 +39,12 @@ namespace font_resource
 		JsonObject object(ta);
 		JsonArray glyphs(ta);
 
-		njson::parse(buf, object);
-		njson::parse_array(object["glyphs"], glyphs);
+		sjson::parse(buf, object);
+		sjson::parse_array(object["glyphs"], glyphs);
 
-		const uint32_t count      = njson::parse_int(object["count"]);
-		const uint32_t size       = njson::parse_int(object["size"]);
-		const uint32_t font_size  = njson::parse_int(object["font_size"]);
+		const uint32_t count      = sjson::parse_int(object["count"]);
+		const uint32_t size       = sjson::parse_int(object["size"]);
+		const uint32_t font_size  = sjson::parse_int(object["font_size"]);
 		const uint32_t num_glyphs = array::size(glyphs);
 
 		Array<FontGlyphData> m_glyphs(default_allocator());

+ 14 - 14
src/resource/package_resource.cpp

@@ -10,7 +10,7 @@
 #include "reader_writer.h"
 #include "compile_options.h"
 #include "array.h"
-#include "njson.h"
+#include "sjson.h"
 #include "map.h"
 
 namespace crown
@@ -23,7 +23,7 @@ namespace package_resource
 
 		TempAllocator4096 ta;
 		JsonObject object(ta);
-		njson::parse(buf, object);
+		sjson::parse(buf, object);
 
 		JsonArray texture(ta);
 		JsonArray script(ta);
@@ -68,73 +68,73 @@ namespace package_resource
 
 		for (uint32_t i = 0; i < num_textures; ++i)
 		{
-			PackageResource::Resource res(TEXTURE_TYPE, njson::parse_resource_id(texture[i]));
+			PackageResource::Resource res(TEXTURE_TYPE, sjson::parse_resource_id(texture[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_scripts; ++i)
 		{
-			PackageResource::Resource res(SCRIPT_TYPE, njson::parse_resource_id(script[i]));
+			PackageResource::Resource res(SCRIPT_TYPE, sjson::parse_resource_id(script[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_sounds; ++i)
 		{
-			PackageResource::Resource res(SOUND_TYPE, njson::parse_resource_id(sound[i]));
+			PackageResource::Resource res(SOUND_TYPE, sjson::parse_resource_id(sound[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_meshes; ++i)
 		{
-			PackageResource::Resource res(MESH_TYPE, njson::parse_resource_id(mesh[i]));
+			PackageResource::Resource res(MESH_TYPE, sjson::parse_resource_id(mesh[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_units; ++i)
 		{
-			PackageResource::Resource res(UNIT_TYPE, njson::parse_resource_id(unit[i]));
+			PackageResource::Resource res(UNIT_TYPE, sjson::parse_resource_id(unit[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_sprites; ++i)
 		{
-			PackageResource::Resource res(SPRITE_TYPE, njson::parse_resource_id(sprite[i]));
+			PackageResource::Resource res(SPRITE_TYPE, sjson::parse_resource_id(sprite[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_materials; ++i)
 		{
-			PackageResource::Resource res(MATERIAL_TYPE, njson::parse_resource_id(material[i]));
+			PackageResource::Resource res(MATERIAL_TYPE, sjson::parse_resource_id(material[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_fonts; ++i)
 		{
-			PackageResource::Resource res(FONT_TYPE, njson::parse_resource_id(font[i]));
+			PackageResource::Resource res(FONT_TYPE, sjson::parse_resource_id(font[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_levels; ++i)
 		{
-			PackageResource::Resource res(LEVEL_TYPE, njson::parse_resource_id(level[i]));
+			PackageResource::Resource res(LEVEL_TYPE, sjson::parse_resource_id(level[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_phyconfs; ++i)
 		{
-			PackageResource::Resource res(PHYSICS_CONFIG_TYPE, njson::parse_resource_id(phyconf[i]));
+			PackageResource::Resource res(PHYSICS_CONFIG_TYPE, sjson::parse_resource_id(phyconf[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_shaders; ++i)
 		{
-			PackageResource::Resource res(SHADER_TYPE, njson::parse_resource_id(shader[i]));
+			PackageResource::Resource res(SHADER_TYPE, sjson::parse_resource_id(shader[i]));
 			array::push_back(resources, res);
 		}
 
 		for (uint32_t i = 0; i < num_sanimations; ++i)
 		{
-			PackageResource::Resource res(SPRITE_ANIMATION_TYPE, njson::parse_resource_id(sprite_animation[i]));
+			PackageResource::Resource res(SPRITE_ANIMATION_TYPE, sjson::parse_resource_id(sprite_animation[i]));
 			array::push_back(resources, res);
 		}
 

+ 3 - 3
src/resource/sound_resource.cpp

@@ -7,7 +7,7 @@
 #include "dynamic_string.h"
 #include "filesystem.h"
 #include "compile_options.h"
-#include "njson.h"
+#include "sjson.h"
 #include "map.h"
 
 namespace crown
@@ -37,10 +37,10 @@ namespace sound_resource
 
 		TempAllocator4096 ta;
 		JsonObject object(ta);
-		njson::parse(buf, object);
+		sjson::parse(buf, object);
 
 		DynamicString name(ta);
-		njson::parse_string(object["source"], name);
+		sjson::parse_string(object["source"], name);
 
 		Buffer sound = opts.read(name.c_str());
 		const WAVHeader* wav = (const WAVHeader*)array::begin(sound);

+ 15 - 15
src/resource/sprite_resource.cpp

@@ -15,7 +15,7 @@
 #include "vector4.h"
 #include "resource_manager.h"
 #include "compile_options.h"
-#include "njson.h"
+#include "sjson.h"
 #include "map.h"
 
 namespace crown
@@ -34,12 +34,12 @@ namespace sprite_resource
 	{
 		TempAllocator512 ta;
 		JsonObject obj(ta);
-		njson::parse(json, obj);
+		sjson::parse(json, obj);
 
-		frame.name   = njson::parse_string_id(obj["name"]);
-		frame.region = njson::parse_vector4(obj["region"]);
-		frame.offset = njson::parse_vector2(obj["offset"]);
-		frame.scale  = njson::parse_vector2(obj["scale"]);
+		frame.name   = sjson::parse_string_id(obj["name"]);
+		frame.region = sjson::parse_vector4(obj["region"]);
+		frame.offset = sjson::parse_vector2(obj["offset"]);
+		frame.scale  = sjson::parse_vector2(obj["scale"]);
 	}
 
 	void compile(const char* path, CompileOptions& opts)
@@ -48,10 +48,10 @@ namespace sprite_resource
 
 		TempAllocator4096 ta;
 		JsonObject object(ta);
-		njson::parse(buf, object);
+		sjson::parse(buf, object);
 
 		JsonArray frames(ta);
-		njson::parse_array(object["frames"], frames);
+		sjson::parse_array(object["frames"], frames);
 
 		// Read width/height
 		const float width         = parse_float(object["width" ]);
@@ -177,24 +177,24 @@ namespace sprite_animation_resource
 	{
 		TempAllocator512 ta;
 		JsonObject obj(ta);
-		njson::parse(json, obj);
+		sjson::parse(json, obj);
 
 		SpriteAnimationName san;
-		san.id = njson::parse_string_id(obj["name"]);
+		san.id = sjson::parse_string_id(obj["name"]);
 
 		JsonArray obj_frames(ta);
-		njson::parse_array(obj["frames"], obj_frames);
+		sjson::parse_array(obj["frames"], obj_frames);
 
 		const uint32_t num_frames = array::size(obj_frames);
 
 		SpriteAnimationData sad;
 		sad.num_frames  = num_frames;
 		sad.first_frame = array::size(frames);
-		sad.time        = njson::parse_float(obj["time"]);
+		sad.time        = sjson::parse_float(obj["time"]);
 
 		// Read frames
 		for (uint32_t ff = 0; ff < num_frames; ++ff)
-			array::push_back(frames, (uint32_t)njson::parse_int(obj_frames[ff]));
+			array::push_back(frames, (uint32_t)sjson::parse_int(obj_frames[ff]));
 
 		array::push_back(names, san);
 		array::push_back(anim_data, sad);
@@ -206,10 +206,10 @@ namespace sprite_animation_resource
 
 		TempAllocator4096 ta;
 		JsonObject object(ta);
-		njson::parse(buf, object);
+		sjson::parse(buf, object);
 
 		JsonArray animations(ta);
-		njson::parse_array(object["animations"], animations);
+		sjson::parse_array(object["animations"], animations);
 
 		Array<SpriteAnimationName> anim_names(default_allocator());
 		Array<SpriteAnimationData> anim_data(default_allocator());

+ 3 - 3
src/resource/texture_resource.cpp

@@ -10,7 +10,7 @@
 #include "resource_manager.h"
 #include "log.h"
 #include "compile_options.h"
-#include "njson.h"
+#include "sjson.h"
 #include "map.h"
 #include <algorithm>
 
@@ -564,10 +564,10 @@ namespace texture_resource
 
 		TempAllocator4096 ta;
 		JsonObject object(ta);
-		njson::parse(buf, object);
+		sjson::parse(buf, object);
 
 		DynamicString name(ta);
-		njson::parse_string(object["source"], name);
+		sjson::parse_string(object["source"], name);
 
 		File* source = opts._fs.open(name.c_str(), FileOpenMode::READ);
 		BinaryReader br(*source);