diff --git a/c/cjson/cjson.go b/c/cjson/cjson.go index 0a2e0906..286c0137 100644 --- a/c/cjson/cjson.go +++ b/c/cjson/cjson.go @@ -26,7 +26,7 @@ const ( LLGoPackage = "link: $(pkg-config --libs libcjson); -lcjson" ) -type JSON_bool c.Int +type Bool c.Int // llgo:type C type JSON struct { @@ -34,11 +34,11 @@ type JSON struct { } func ParseBytes(value []byte) *JSON { - return ParseWithLength((*c.Char)(unsafe.Pointer(&value[0])), uintptr(len(value))) + return ParseWithLength((*c.Char)(unsafe.Pointer(unsafe.SliceData(value))), uintptr(len(value))) } func ParseString(value string) *JSON { - return ParseWithLength(c.AllocaCStr(value), uintptr(len(value))) + return ParseWithLength((*c.Char)(unsafe.Pointer(unsafe.StringData(value))), uintptr(len(value))) } // CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item); @@ -87,7 +87,7 @@ func Parse(value *c.Char) *JSON //go:linkname ParseWithLength C.cJSON_ParseWithLength func ParseWithLength(value *c.Char, valueLength uintptr) *JSON -// CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated); +// CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cBool require_null_terminated); // // ParseWithOpts allows you to require (and check) that the JSON is null terminated, // and to retrieve the pointer to the final byte parsed. @@ -96,9 +96,9 @@ func ParseWithLength(value *c.Char, valueLength uintptr) *JSON // cJSON_GetErrorPtr(). // //go:linkname ParseWithOpts C.cJSON_ParseWithOpts -func ParseWithOpts(value *c.Char, return_parse_end **c.Char, require_null_terminated JSON_bool) *JSON +func ParseWithOpts(value *c.Char, return_parse_end **c.Char, require_null_terminated Bool) *JSON -// CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated); +// CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cBool require_null_terminated); // // ParseWithOpts allows you to require (and check) that the JSON is null terminated, // and to retrieve the pointer to the final byte parsed. @@ -107,7 +107,7 @@ func ParseWithOpts(value *c.Char, return_parse_end **c.Char, require_null_termin // cJSON_GetErrorPtr(). // //go:linkname ParseWithLengthOpts C.cJSON_ParseWithLengthOpts -func ParseWithLengthOpts(value *c.Char, buffer_length uintptr, return_parse_end **c.Char, require_null_terminated JSON_bool) *JSON +func ParseWithLengthOpts(value *c.Char, buffer_length uintptr, return_parse_end **c.Char, require_null_terminated Bool) *JSON // CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); // Render a JSON entity to text for transfer/storage. @@ -121,16 +121,16 @@ func (o *JSON) Print() *c.Char { return nil } // llgo:link (*JSON).PrintUnformatted C.cJSON_PrintUnformatted func (o *JSON) PrintUnformatted() *c.Char { return nil } -// CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt); +// CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cBool fmt); // // Render a JSON entity to text using a buffered strategy. // prebuffer is a guess at the final size. guessing well reduces reallocation. // fmt=0 gives unformatted, =1 gives formatted. // // llgo:link (*JSON).PrintBuffered C.cJSON_PrintBuffered -func (o *JSON) PrintBuffered(prebuffer c.Int, fmt JSON_bool) *c.Char { return nil } +func (o *JSON) PrintBuffered(prebuffer c.Int, fmt Bool) *c.Char { return nil } -// CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format); +// CJSON_PUBLIC(cBool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cBool format); // // Render a cJSON entity to text using a buffer already allocated in memory with given // length. Returns 1 on success and 0 on failure. @@ -138,8 +138,8 @@ func (o *JSON) PrintBuffered(prebuffer c.Int, fmt JSON_bool) *c.Char { return ni // so to be safe allocate 5 bytes more than you actually need // // llgo:link (*JSON).PrintPreallocated C.cJSON_PrintPreallocated -func (o *JSON) PrintPreallocated(buffer *c.Char, length c.Int, format JSON_bool) JSON_bool { - return JSON_bool(0) +func (o *JSON) PrintPreallocated(buffer *c.Char, length c.Int, format Bool) Bool { + return Bool(0) } // CJSON_PUBLIC(void) cJSON_Delete(cJSON *item); @@ -176,10 +176,10 @@ func (o *JSON) GetObjectItem(s *c.Char) *JSON { return nil } // llgo:link (*JSON).GetObjectItemCaseSensitive C.cJSON_GetObjectItemCaseSensitive func (o *JSON) GetObjectItemCaseSensitive(key *c.Char) *JSON { return nil } -// CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string); +// CJSON_PUBLIC(cBool) cJSON_HasObjectItem(const cJSON *object, const char *string); // // llgo:link (*JSON).HasObjectItem C.cJSON_HasObjectItem -func (o *JSON) HasObjectItem(s *c.Char) JSON_bool { return JSON_bool(0) } +func (o *JSON) HasObjectItem(s *c.Char) Bool { return Bool(0) } // CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); // @@ -204,75 +204,75 @@ func (o *JSON) GetStringValue() *c.Char { return nil } // llgo:link (*JSON).GetNumberValue C.cJSON_GetNumberValue func (o *JSON) GetNumberValue() c.Double { return 0 } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsInvalid(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsInvalid C.cJSON_IsInvalid -func (o *JSON) IsInvalid() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsInvalid() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsFalse(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsFalse C.cJSON_IsFalse -func (o *JSON) IsFalse() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsFalse() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsTrue(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsTrue C.cJSON_IsTrue -func (o *JSON) IsTrue() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsTrue() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsBool(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsBool C.cJSON_IsBool -func (o *JSON) IsBool() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsBool() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsNull(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsNull C.cJSON_IsNull -func (o *JSON) IsNull() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsNull() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsNumber(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsNumber C.cJSON_IsNumber -func (o *JSON) IsNumber() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsNumber() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsString(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsString C.cJSON_IsString -func (o *JSON) IsString() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsString() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsArray(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsArray C.cJSON_IsArray -func (o *JSON) IsArray() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsArray() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsObject(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsObject C.cJSON_IsObject -func (o *JSON) IsObject() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsObject() Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item); +// CJSON_PUBLIC(cBool) cJSON_IsRaw(const cJSON * const item); // // These functions check the type of an item // // llgo:link (*JSON).IsRaw C.cJSON_IsRaw -func (o *JSON) IsRaw() JSON_bool { return JSON_bool(0) } +func (o *JSON) IsRaw() Bool { return Bool(0) } // CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void); // @@ -312,12 +312,7 @@ func False() *JSON //go:linkname CreateFalse C.cJSON_CreateFalse func CreateFalse() *JSON -// CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean); -// -//go:linkname Bool C.cJSON_CreateBool -func Bool(boolean c.Int) *JSON - -// CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean); +// CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cBool boolean); // // same as Bool func // @@ -450,35 +445,35 @@ func CreateDoubleArray(numbers *c.Double, count c.Int) *JSON //go:linkname CreateStringArray C.cJSON_CreateStringArray func CreateStringArray(strings *c.Char, count c.Int) *JSON -// CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item); +// CJSON_PUBLIC(cBool) cJSON_AddItemToArray(cJSON *array, cJSON *item); // // Append item to the specified array. // // llgo:link (*JSON).AddItem C.cJSON_AddItemToArray -func (o *JSON) AddItem(item *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) AddItem(item *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item); +// CJSON_PUBLIC(cBool) cJSON_AddItemToArray(cJSON *array, cJSON *item); // // same as AddItem func // // llgo:link (*JSON).AddItemToArray C.cJSON_AddItemToArray -func (o *JSON) AddItemToArray(item *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) AddItemToArray(item *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); +// CJSON_PUBLIC(cBool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); // // Append item to the specified object. // // llgo:link (*JSON).SetItem C.cJSON_AddItemToObject -func (o *JSON) SetItem(key *c.Char, item *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) SetItem(key *c.Char, item *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); +// CJSON_PUBLIC(cBool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); // // same as SetItem func // // llgo:link (*JSON).AddItemToObject C.cJSON_AddItemToObject -func (o *JSON) AddItemToObject(key *c.Char, item *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) AddItemToObject(key *c.Char, item *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); +// CJSON_PUBLIC(cBool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); // // Use this when string is definitely const (i.e. a literal, or as good as), // and will definitely survive the cJSON object. @@ -486,21 +481,21 @@ func (o *JSON) AddItemToObject(key *c.Char, item *JSON) JSON_bool { return JSON_ // (item->type & cJSON_StringIsConst) is zero before writing to `item->string` // // llgo:link (*JSON).AddItemToObjectCS C.cJSON_AddItemToObjectCS -func (o *JSON) AddItemToObjectCS(s *c.Char, item *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) AddItemToObjectCS(s *c.Char, item *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); +// CJSON_PUBLIC(cBool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); // // Append reference to item to the specified array/object. // Use this when you want to add an existing cJSON to a new cJSON, // but don't want to corrupt your existing cJSON. // // llgo:link (*JSON).AddItemReferenceToArray C.cJSON_AddItemReferenceToArray -func (o *JSON) AddItemReferenceToArray(item *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) AddItemReferenceToArray(item *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); +// CJSON_PUBLIC(cBool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); // // llgo:link (*JSON).AddItemReferenceToObject C.cJSON_AddItemReferenceToObject -func (o *JSON) AddItemReferenceToObject(s *c.Char, item *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) AddItemReferenceToObject(s *c.Char, item *JSON) Bool { return Bool(0) } // CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item); // @@ -539,37 +534,37 @@ func (o *JSON) DeleteItemFromObject(s *c.Char) {} // llgo:link (*JSON).DeleteItemFromObjectCaseSensitive C.cJSON_DeleteItemFromObjectCaseSensitive func (o *JSON) DeleteItemFromObjectCaseSensitive(s *c.Char) {} -// CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); +// CJSON_PUBLIC(cBool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); // // Update array items. // Shifts pre-existing items to the right. // // llgo:link (*JSON).InsertItemInArray C.cJSON_InsertItemInArray -func (o *JSON) InsertItemInArray(which c.Int, newitem *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) InsertItemInArray(which c.Int, newitem *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); +// CJSON_PUBLIC(cBool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); // // llgo:link (*JSON).ReplaceItemViaPointer C.cJSON_ReplaceItemViaPointer -func (o *JSON) ReplaceItemViaPointer(item *JSON, replacement *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) ReplaceItemViaPointer(item *JSON, replacement *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); +// CJSON_PUBLIC(cBool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); // // llgo:link (*JSON).ReplaceItemInArray C.cJSON_ReplaceItemInArray -func (o *JSON) ReplaceItemInArray(which c.Int, newitem *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) ReplaceItemInArray(which c.Int, newitem *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); +// CJSON_PUBLIC(cBool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); // // llgo:link (*JSON).ReplaceItemInObject C.cJSON_ReplaceItemInObject -func (o *JSON) ReplaceItemInObject(s *c.Char, newitem *JSON) JSON_bool { return JSON_bool(0) } +func (o *JSON) ReplaceItemInObject(s *c.Char, newitem *JSON) Bool { return Bool(0) } -// CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); +// CJSON_PUBLIC(cBool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); // // llgo:link (*JSON).ReplaceItemInObjectCaseSensitive C.cJSON_ReplaceItemInObjectCaseSensitive -func (o *JSON) ReplaceItemInObjectCaseSensitive(s *c.Char, newitem *JSON) JSON_bool { - return JSON_bool(0) +func (o *JSON) ReplaceItemInObjectCaseSensitive(s *c.Char, newitem *JSON) Bool { + return Bool(0) } -// CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); +// CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cBool recurse); // // Duplicate a cJSON item // @@ -579,16 +574,16 @@ func (o *JSON) ReplaceItemInObjectCaseSensitive(s *c.Char, newitem *JSON) JSON_b // The item->next and ->prev pointers are always zero on return from Duplicate. // // llgo:link (*JSON).Duplicate C.cJSON_Duplicate -func (o *JSON) Duplicate(recurse JSON_bool) *JSON { return nil } +func (o *JSON) Duplicate(recurse Bool) *JSON { return nil } -// CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); +// CJSON_PUBLIC(cBool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cBool case_sensitive); // // Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, // they will be considered unequal. case_sensitive determines if object keys are treated // case sensitive (1) or case insensitive (0) // // llgo:link (*JSON).Compare C.cJSON_Compare -func (o *JSON) Compare(b *JSON, case_sensitive JSON_bool) JSON_bool { return JSON_bool(0) } +func (o *JSON) Compare(b *JSON, case_sensitive Bool) Bool { return Bool(0) } // CJSON_PUBLIC(void) cJSON_Minify(char *json); // @@ -617,10 +612,10 @@ func (o *JSON) AddTrueToObject(name *c.Char) *JSON { return nil } // llgo:link (*JSON).AddFalseToObject C.cJSON_AddFalseToObject func (o *JSON) AddFalseToObject(name *c.Char) *JSON { return nil } -// CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean); +// CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cBool boolean); // // llgo:link (*JSON).AddBoolToObject C.cJSON_AddBoolToObject -func (o *JSON) AddBoolToObject(name *c.Char, b JSON_bool) *JSON { return nil } +func (o *JSON) AddBoolToObject(name *c.Char, b Bool) *JSON { return nil } // CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number); //