Browse Source

Bing JSON to Lua and AngelScript.

aster2013 11 years ago
parent
commit
f95275aaa9

+ 1 - 1
Source/Engine/LuaScript/pkgs/Graphics/Camera.pkg

@@ -1,6 +1,6 @@
 $#include "Camera.h"
 $#include "Camera.h"
 
 
-enum FillMode{};
+enum FillMode {};
 
 
 static const unsigned VO_NONE;
 static const unsigned VO_NONE;
 static const unsigned VO_LOW_MATERIAL_QUALITY;
 static const unsigned VO_LOW_MATERIAL_QUALITY;

+ 26 - 0
Source/Engine/LuaScript/pkgs/Resource/JSONFile.pkg

@@ -0,0 +1,26 @@
+$#include "JSONFile.h"
+
+enum JSONValueType {};
+
+class JSONFile : Resource
+{
+    JSONFile();
+    ~JSONFile();
+
+    JSONValue CreateRoot(JSONValueType valueType = JSON_OBJECT);
+    JSONValue GetRoot(JSONValueType valueType = JSON_ANY);
+};
+
+${
+#define TOLUA_DISABLE_tolua_ResourceLuaAPI_JSONFile_new00
+static int tolua_ResourceLuaAPI_JSONFile_new00(lua_State* tolua_S)
+{
+    return ToluaNewObject<JSONFile>(tolua_S);
+}
+
+#define TOLUA_DISABLE_tolua_ResourceLuaAPI_JSONFile_new00_local
+static int tolua_ResourceLuaAPI_JSONFile_new00_local(lua_State* tolua_S)
+{
+    return ToluaNewObjectGC<JSONFile>(tolua_S);
+}
+$}

+ 117 - 0
Source/Engine/LuaScript/pkgs/Resource/JSONValue.pkg

@@ -0,0 +1,117 @@
+$#include "JSONValue.h"
+
+enum JSONValueType
+{
+    JSON_ANY = 0,
+    JSON_OBJECT,
+    JSON_ARRAY
+};
+
+class JSONValue
+{
+    bool IsNull() const;
+    bool NotNull() const;
+    operator bool () const;
+
+    JSONValue CreateChild(const String name, JSONValueType valueType = JSON_OBJECT);
+    JSONValue GetChild(const String name, JSONValueType valueType = JSON_ANY) const;
+    void SetInt(const String name, int value);
+    void SetBool(const String name, bool value);
+    void SetFloat(const String name, float value);
+    void SetVector2(const String name, const Vector2& value);
+    void SetVector3(const String name, const Vector3& value);
+    void SetVector4(const String name, const Vector4& value);
+    void SetVectorVariant(const String name, const Variant& value);
+    void SetQuaternion(const String name, const Quaternion& value);
+    void SetColor(const String name, const Color& value);
+    void SetString(const String name, const String value);
+    // void SetBuffer(const String name, const void* data, unsigned size);
+    // void SetBuffer(const String name, const PODVector<unsigned char>& value);
+    void SetResourceRef(const String name, const ResourceRef& value);
+    void SetResourceRefList(const String name, const ResourceRefList& value);
+    void SetIntRect(const String name, const IntRect& value);
+    void SetIntVector2(const String name, const IntVector2& value);
+    void SetMatrix3(const String name, const Matrix3& value);
+    void SetMatrix3x4(const String name, const Matrix3x4& value);
+    void SetMatrix4(const String name, const Matrix4& value);
+    void SetVariant(const String name, const Variant& value);
+    void SetVariantValue(const String name, const Variant& value);
+
+    bool IsObject() const;
+    int GetInt(const String name) const;
+    bool GetBool(const String name) const;
+    float GetFloat(const String name) const;
+    Vector2 GetVector2(const String name) const;
+    Vector3 GetVector3(const String name) const;
+    Vector4 GetVector4(const String name) const;
+    Variant GetVectorVariant(const String name) const;
+    Quaternion GetQuaternion(const String name) const;
+    Color GetColor(const String name) const;
+    String GetString(const String name) const;
+    const char* GetCString(const String name) const;
+    // PODVector<unsigned char> GetBuffer(const String name) const;
+    // bool GetBuffer(const String name, void* dest, unsigned size) const;
+    ResourceRef GetResourceRef(const String name) const;
+    ResourceRefList GetResourceRefList(const String name) const;
+    IntRect GetIntRect(const String name) const;
+    IntVector2 GetIntVector2(const String name) const;
+    Matrix3 GetMatrix3(const String name) const;
+    Matrix3x4 GetMatrix3x4(const String name) const;
+    Matrix4 GetMatrix4(const String name) const;
+    Variant GetVariant(const String name) const;
+    Variant GetVariantValue(const String name, VariantType type) const;
+
+    JSONValue CreateChild(JSONValueType valueType = JSON_OBJECT);
+    JSONValue GetChild(unsigned index, JSONValueType valueType = JSON_ANY) const;
+    void AddInt(int value);
+    void AddBool(bool value);
+    void AddFloat(float value);
+    void AddVector2(const Vector2& value);
+    void AddVector3(const Vector3& value);
+    void AddVector4(const Vector4& value);
+    void AddVectorVariant(const Variant& value);
+    void AddQuaternion(const Quaternion& value);
+    void AddColor(const Color& value);
+    void AddString(const String value);
+    // void AddBuffer(const PODVector<unsigned char>& value);
+    // void AddBuffer(const void* data, unsigned size);
+    void AddResourceRef(const ResourceRef& value);
+    void AddResourceRefList(const ResourceRefList& value);
+    void AddIntRect(const IntRect& value);
+    void AddIntVector2(const IntVector2& value);
+    void AddMatrix3(const Matrix3& value);
+    void AddMatrix3x4(const Matrix3x4& value);
+    void AddMatrix4(const Matrix4& value);
+    void AddVariant(const Variant& value);
+    void AddVariantValue(const Variant& value);
+    bool IsArray() const;
+    unsigned GetSize() const;
+    int GetInt(unsigned index) const;
+    bool GetBool(unsigned index) const;
+    float GetFloat(unsigned index) const;
+    Vector2 GetVector2(unsigned index) const;
+    Vector3 GetVector3(unsigned index) const;
+    Vector4 GetVector4(unsigned index) const;
+    Variant GetVectorVariant(unsigned index) const;
+    Quaternion GetQuaternion(unsigned index) const;
+    Color GetColor(unsigned index) const;
+    String GetString(unsigned index) const;
+    const char* GetCString(unsigned index) const;
+    // PODVector<unsigned char> GetBuffer(unsigned index) const;
+    // bool GetBuffer(unsigned index, void* dest, unsigned size) const;
+    ResourceRef GetResourceRef(unsigned index) const;
+    ResourceRefList GetResourceRefList(unsigned index) const;
+    IntRect GetIntRect(unsigned index) const;
+    IntVector2 GetIntVector2(unsigned index) const;
+    Matrix3 GetMatrix3(unsigned index) const;
+    Matrix3x4 GetMatrix3x4(unsigned index) const;
+    Matrix4 GetMatrix4(unsigned index) const;
+    Variant GetVariant(unsigned index) const;
+    Variant GetVariantValue(unsigned index, VariantType type) const;
+
+    static const JSONValue EMPTY;
+
+    tolua_readonly tolua_property__is_set bool null;
+    tolua_readonly tolua_property__is_set bool object;
+    tolua_readonly tolua_property__is_set bool array;
+};

+ 3 - 1
Source/Engine/LuaScript/pkgs/ResourceLuaAPI.pkg

@@ -1,8 +1,10 @@
 $pfile "Resource/Resource.pkg"
 $pfile "Resource/Resource.pkg"
 $pfile "Resource/Image.pkg"
 $pfile "Resource/Image.pkg"
-$pfile "Resource/ResourceCache.pkg"
+$pfile "Resource/JSONValue.pkg"
+$pfile "Resource/JSONFile.pkg"
 $pfile "Resource/XMLElement.pkg"
 $pfile "Resource/XMLElement.pkg"
 $pfile "Resource/XMLFile.pkg"
 $pfile "Resource/XMLFile.pkg"
+$pfile "Resource/ResourceCache.pkg"
 
 
 $using namespace Urho3D;
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
 $#pragma warning(disable:4800)

+ 112 - 0
Source/Engine/Script/ResourceAPI.cpp

@@ -23,6 +23,8 @@
 #include "Precompiled.h"
 #include "Precompiled.h"
 #include "APITemplates.h"
 #include "APITemplates.h"
 #include "Image.h"
 #include "Image.h"
+#include "JSONFile.h"
+#include "JSONValue.h"
 #include "PackageFile.h"
 #include "PackageFile.h"
 #include "ResourceCache.h"
 #include "ResourceCache.h"
 
 
@@ -164,6 +166,114 @@ static void RegisterImage(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Image", "bool get_compressed() const", asMETHOD(Image, IsCompressed), asCALL_THISCALL);
     engine->RegisterObjectMethod("Image", "bool get_compressed() const", asMETHOD(Image, IsCompressed), asCALL_THISCALL);
 }
 }
 
 
+
+static void RegisterJSONValue(asIScriptEngine* engine)
+{
+    engine->RegisterEnum("JSONValueType");
+    engine->RegisterEnumValue("JSONValueType", "JSON_ANY", JSON_ANY);
+    engine->RegisterEnumValue("JSONValueType", "JSON_OBJECT", JSON_OBJECT);
+    engine->RegisterEnumValue("JSONValueType", "JSON_ARRAY", JSON_ARRAY);
+
+    engine->RegisterObjectType("JSONValue", sizeof(JSONValue), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
+    engine->RegisterObjectMethod("JSONValue", "bool get_isNull() const", asMETHOD(JSONValue, IsNull), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "bool get_notNull() const", asMETHOD(JSONValue, NotNull), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "JSONValue& opAssign(const JSONValue&in)", asMETHOD(JSONValue, operator =), asCALL_THISCALL);
+
+    engine->RegisterObjectMethod("JSONValue", "JSONValue CreateChild(const String&in, JSONValueType valueType = JSON_OBJECT)", asMETHODPR(JSONValue, CreateChild,(const String&, JSONValueType), JSONValue), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "JSONValue GetChild(const String&in, JSONValueType valueType = JSON_ANY) const", asMETHODPR(JSONValue, GetChild, (const String&, JSONValueType) const, JSONValue), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetInt(const String&in, int)", asMETHOD(JSONValue, SetInt), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetBool(const String&in, bool)", asMETHOD(JSONValue, SetBool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetFloat(const String&in, float)", asMETHOD(JSONValue, SetFloat), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetVector2(const String&in, const Vector2&in)", asMETHOD(JSONValue, SetVector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetVector3(const String&in, const Vector3&in)", asMETHOD(JSONValue, SetVector3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetVector4(const String&in, const Vector4&in)", asMETHOD(JSONValue, SetVector4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetVectorVariant(const String&in, const Variant&in)", asMETHOD(JSONValue, SetVectorVariant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetQuaternion(const String&in, const Quaternion&in)", asMETHOD(JSONValue, SetQuaternion), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetColor(const String&in, const Color&in)", asMETHOD(JSONValue, SetColor), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetString(const String&in, const String)", asMETHOD(JSONValue, SetString), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetResourceRef(const String&in, const ResourceRef&in)", asMETHOD(JSONValue, SetResourceRef), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetResourceRefList(const String&in, const ResourceRefList&in)", asMETHOD(JSONValue, SetResourceRefList), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetIntRect(const String&in, const IntRect&in)", asMETHOD(JSONValue, SetIntRect), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetIntVector2(const String&in, const IntVector2&in)", asMETHOD(JSONValue, SetIntVector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetMatrix3(const String&in, const Matrix3&in)", asMETHOD(JSONValue, SetMatrix3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetMatrix3x4(const String&in, const Matrix3x4&in)", asMETHOD(JSONValue, SetMatrix3x4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetMatrix4(const String&in, const Matrix4&in)", asMETHOD(JSONValue, SetMatrix4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetVariant(const String&in, const Variant&in)", asMETHOD(JSONValue, SetVariant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void SetVariantValue(const String&in, const Variant&in)", asMETHOD(JSONValue, SetVariantValue), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "bool get_isObject() const", asMETHOD(JSONValue, IsObject), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "int GetInt(const String&in) const", asMETHODPR(JSONValue, GetInt, (const String&) const, int), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "bool GetBool(const String&in) const", asMETHODPR(JSONValue, GetBool, (const String&) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "float GetFloat(const String&in) const", asMETHODPR(JSONValue, GetFloat, (const String&) const, float), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Vector2 GetVector2(const String&in) const", asMETHODPR(JSONValue, GetVector2, (const String&) const, Vector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Vector3 GetVector3(const String&in) const", asMETHODPR(JSONValue, GetVector3, (const String&) const, Vector3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Vector4 GetVector4(const String&in) const", asMETHODPR(JSONValue, GetVector4, (const String&) const, Vector4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Variant GetVectorVariant(const String&in) const", asMETHODPR(JSONValue, GetVectorVariant, (const String&) const, Variant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Quaternion GetQuaternion(const String&in) const", asMETHODPR(JSONValue, GetQuaternion, (const String&) const, Quaternion), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Color GetColor(const String&in) const", asMETHODPR(JSONValue, GetColor, (const String&) const, Color), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "String GetString(const String&in) const", asMETHODPR(JSONValue, GetString, (const String&) const, String), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "const char* GetCString(const String&in) const", asMETHODPR(JSONValue, GetCString, (const String&) const, const char*), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "ResourceRef GetResourceRef(const String&in) const", asMETHODPR(JSONValue, GetResourceRef, (const String&) const, ResourceRef), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "ResourceRefList GetResourceRefList(const String&in) const", asMETHODPR(JSONValue, GetResourceRefList, (const String&) const, ResourceRefList), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "IntRect GetIntRect(const String&in) const", asMETHODPR(JSONValue, GetIntRect, (const String&) const, IntRect), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "IntVector2 GetIntVector2(const String&in) const", asMETHODPR(JSONValue, GetIntVector2, (const String&) const, IntVector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Matrix3 GetMatrix3(const String&in) const", asMETHODPR(JSONValue, GetMatrix3, (const String&) const, Matrix3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Matrix3x4 GetMatrix3x4(const String&in) const", asMETHODPR(JSONValue, GetMatrix3x4, (const String&) const, Matrix3x4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Matrix4 GetMatrix4(const String&in) const", asMETHODPR(JSONValue, GetMatrix4, (const String&) const, Matrix4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Variant GetVariant(const String&in) const", asMETHODPR(JSONValue, GetVariant, (const String&) const, Variant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Variant GetVariantValue(const String&in, VariantType type) const", asMETHODPR(JSONValue, GetVariantValue, (const String&, VariantType) const, Variant), asCALL_THISCALL);
+
+    engine->RegisterObjectMethod("JSONValue", "JSONValue CreateChild(JSONValueType valueType = JSON_OBJECT)", asMETHODPR(JSONValue, CreateChild, (JSONValueType), JSONValue), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "JSONValue GetChild(unsigned index, JSONValueType valueType = JSON_ANY) const", asMETHODPR(JSONValue, GetChild, (unsigned, JSONValueType) const, JSONValue), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddInt(int)", asMETHOD(JSONValue, AddInt), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddBool(bool)", asMETHOD(JSONValue, AddBool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddFloat(float)", asMETHOD(JSONValue, AddFloat), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddVector2(const Vector2&in)", asMETHOD(JSONValue, AddVector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddVector3(const Vector3&in)", asMETHOD(JSONValue, AddVector3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddVector4(const Vector4&in)", asMETHOD(JSONValue, AddVector4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddVectorVariant(const Variant&in)", asMETHOD(JSONValue, AddVectorVariant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddQuaternion(const Quaternion&in)", asMETHOD(JSONValue, AddQuaternion), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddColor(const Color&in)", asMETHOD(JSONValue, AddColor), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddString(const String)", asMETHOD(JSONValue, AddString), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddResourceRef(const ResourceRef&in)", asMETHOD(JSONValue, AddResourceRef), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddResourceRefList(const ResourceRefList&in)", asMETHOD(JSONValue, AddResourceRefList), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddIntRect(const IntRect&in)", asMETHOD(JSONValue, AddIntRect), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddIntVector2(const IntVector2&in)", asMETHOD(JSONValue, AddIntVector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddMatrix3(const Matrix3&in)", asMETHOD(JSONValue, AddMatrix3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddMatrix3x4(const Matrix3x4&in)", asMETHOD(JSONValue, AddMatrix3x4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddMatrix4(const Matrix4&in)", asMETHOD(JSONValue, AddMatrix4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddVariant(const Variant&in)", asMETHOD(JSONValue, AddVariant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "void AddVariantValue(const Variant&in)", asMETHOD(JSONValue, AddVariantValue), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "bool get_isArray() const", asMETHOD(JSONValue, IsArray), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "uint get_size() const", asMETHOD(JSONValue, GetSize), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "int GetInt(uint) const", asMETHODPR(JSONValue, GetInt, (unsigned) const, int), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "bool GetBool(uint) const", asMETHODPR(JSONValue, GetBool, (unsigned) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "float GetFloat(uint) const", asMETHODPR(JSONValue, GetFloat, (unsigned) const, float), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Vector2 GetVector2(uint) const", asMETHODPR(JSONValue, GetVector2, (unsigned) const, Vector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Vector3 GetVector3(uint) const", asMETHODPR(JSONValue, GetVector3, (unsigned) const, Vector3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Vector4 GetVector4(uint) const", asMETHODPR(JSONValue, GetVector4, (unsigned) const, Vector4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Variant GetVectorVariant(uint) const", asMETHODPR(JSONValue, GetVectorVariant, (unsigned) const, Variant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Quaternion GetQuaternion(uint) const", asMETHODPR(JSONValue, GetQuaternion, (unsigned) const, Quaternion), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Color GetColor(uint) const", asMETHODPR(JSONValue, GetColor, (unsigned) const, Color), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "String GetString(uint) const", asMETHODPR(JSONValue, GetString, (unsigned) const, String), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "const char*uint(unsigned) const", asMETHODPR(JSONValue, GetCString, (unsigned) const, const char*), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "ResourceRef GetResourceRef(uint) const", asMETHODPR(JSONValue, GetResourceRef, (unsigned) const, ResourceRef), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "ResourceRefList GetResourceRefList(uint) const", asMETHODPR(JSONValue, GetResourceRefList, (unsigned) const, ResourceRefList), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "IntRect GetIntRect(uint) const", asMETHODPR(JSONValue, GetIntRect, (unsigned) const, IntRect), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "IntVector2 GetIntVector2(uint) const", asMETHODPR(JSONValue, GetIntVector2, (unsigned) const, IntVector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Matrix3 GetMatrix3(uint) const", asMETHODPR(JSONValue, GetMatrix3, (unsigned) const, Matrix3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Matrix3x4 GetMatrix3x4(uint) const", asMETHODPR(JSONValue, GetMatrix3x4, (unsigned) const, Matrix3x4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Matrix4 GetMatrix4(uint) const", asMETHODPR(JSONValue, GetMatrix4, (unsigned) const, Matrix4), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Variant GetVariant(uint) const", asMETHODPR(JSONValue, GetVariant, (unsigned) const, Variant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONValue", "Variant GetVariantValue(uint, VariantType type) const", asMETHODPR(JSONValue, GetVariantValue, (unsigned, VariantType) const, Variant), asCALL_THISCALL);
+}
+
+static void RegisterJSONFile(asIScriptEngine* engine)
+{
+    RegisterResource<JSONFile>(engine, "JSONFile");
+    engine->RegisterObjectMethod("JSONFile", "XMLElement CreateRoot(JSONValueType valueType = JSON_ANY)", asMETHOD(JSONFile, CreateRoot), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONFile", "XMLElement GetRoot(JSONValueType valueType = JSON_ANY)", asMETHOD(JSONFile, GetRoot), asCALL_THISCALL);
+}
+
 static void ConstructXMLElement(XMLElement* ptr)
 static void ConstructXMLElement(XMLElement* ptr)
 {
 {
     new(ptr) XMLElement();
     new(ptr) XMLElement();
@@ -356,6 +466,8 @@ void RegisterResourceAPI(asIScriptEngine* engine)
     RegisterResource(engine);
     RegisterResource(engine);
     RegisterResourceCache(engine);
     RegisterResourceCache(engine);
     RegisterImage(engine);
     RegisterImage(engine);
+    RegisterJSONValue(engine);
+    RegisterJSONFile(engine);
     RegisterXMLElement(engine);
     RegisterXMLElement(engine);
     RegisterXMLFile(engine);
     RegisterXMLFile(engine);
 }
 }