浏览代码

Added TJSONBool Create method.

woollybah 6 年之前
父节点
当前提交
36b4ef17e1
共有 3 个文件被更改,包括 18 次插入0 次删除
  1. 2 0
      json.mod/common.bmx
  2. 6 0
      json.mod/glue.c
  3. 10 0
      json.mod/json.bmx

+ 2 - 0
json.mod/common.bmx

@@ -74,6 +74,8 @@ Extern
 	Function json_object_iter:Byte Ptr(handle:Byte Ptr)
 	Function json_object_iter_next:Byte Ptr(handle:Byte Ptr, iter:Byte Ptr)
 	Function bmx_json_object_iter_value:Object(iter:Byte Ptr)
+
+	Function bmx_json_bool:Byte Ptr(v:Int)
 	
 End Extern
 

+ 6 - 0
json.mod/glue.c

@@ -61,6 +61,8 @@ int bmx_json_object_del(json_t * handle, BBString * key);
 
 BBObject * bmx_json_object_iter_value(void * iter);
 
+json_t * bmx_json_bool(int v);
+
 
 void bmx_json_decref(json_t * handle) {
 	json_decref(handle);
@@ -202,3 +204,7 @@ BBObject * bmx_json_object_iter_value(void * iter) {
 		return &bbNullObject;
 	}
 }
+
+json_t * bmx_json_bool(int v) {
+	return json_boolean(v);
+}

+ 10 - 0
json.mod/json.bmx

@@ -32,6 +32,7 @@ ModuleInfo "Copyright: 2014-2019 Bruce A Henderson"
 
 ModuleInfo "History: 1.04"
 ModuleInfo "History: Added index operator overloading to TJSONArray."
+ModuleInfo "History: Added TJSONBool Create method."
 ModuleInfo "History: 1.03"
 ModuleInfo "History: Updated to Jansson 2.12"
 ModuleInfo "History: 1.02"
@@ -716,6 +717,15 @@ Type TJSONBool Extends TJSON
 
 	Field isTrue:Int
 
+	Rem
+	bbdoc: Creates an instance of #TJSONBool with @v.
+	End Rem
+	Method Create:TJSONBool(v:Int)
+		jsonPtr = bmx_json_bool(v)
+		isTrue = v
+		Return Self
+	End Method
+
 End Type
 
 Rem