github.com/goplus/llgo@v0.8.3/c/cjson/cjson.go (about) 1 /* 2 * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package cjson 18 19 import ( 20 _ "unsafe" 21 22 "github.com/goplus/llgo/c" 23 ) 24 25 const ( 26 LLGoPackage = "link: cjson" 27 ) 28 29 // llgo:type C 30 type JSON struct { 31 Unused [0]byte 32 } 33 34 //go:linkname Null C.cJSON_CreateNull 35 func Null() *JSON 36 37 //go:linkname True C.cJSON_CreateTrue 38 func True() *JSON 39 40 //go:linkname False C.cJSON_CreateFalse 41 func False() *JSON 42 43 //go:linkname Bool C.cJSON_CreateBool 44 func Bool(boolean c.Int) *JSON 45 46 //go:linkname Number C.cJSON_CreateNumber 47 func Number(num float64) *JSON 48 49 //go:linkname String C.cJSON_CreateString 50 func String(str *c.Char) *JSON 51 52 //go:linkname Array C.cJSON_CreateArray 53 func Array() *JSON 54 55 //go:linkname Object C.cJSON_CreateObject 56 func Object() *JSON 57 58 // raw json 59 // 60 //go:linkname Raw C.cJSON_CreateRaw 61 func Raw(raw *c.Char) *JSON 62 63 // Create a string where valuestring references a string so 64 // it will not be freed by Delete 65 // 66 //go:linkname StringRef C.cJSON_CreateStringReference 67 func StringRef(str *c.Char) *JSON 68 69 // Create an object that only references it's elements so 70 // they will not be freed by Delete 71 // 72 //go:linkname ObjectRef C.cJSON_CreateObjectReference 73 func ObjectRef(child *JSON) *JSON 74 75 // Create an array that only references it's elements so 76 // they will not be freed by Delete 77 // 78 //go:linkname ArrayRef C.cJSON_CreateArrayReference 79 func ArrayRef(child *JSON) *JSON 80 81 // Delete a JSON entity and all subentities. 82 // 83 // llgo:link (*JSON).Delete C.cJSON_Delete 84 func (o *JSON) Delete() {} 85 86 // Append item to the specified array. 87 // 88 // llgo:link (*JSON).AddItem C.cJSON_AddItemToArray 89 func (o *JSON) AddItem(item *JSON) c.Int { return 0 } 90 91 // Append item to the specified object. 92 // 93 // llgo:link (*JSON).SetItem C.cJSON_AddItemToObject 94 func (o *JSON) SetItem(key *c.Char, item *JSON) c.Int { return 0 } 95 96 // llgo:link (*JSON).CStr C.cJSON_PrintUnformatted 97 func (o *JSON) CStr() *c.Char { return nil } 98 99 // Same as CStr. Provided for Go+. 100 // 101 // llgo:link (*JSON).Cstr C.cJSON_PrintUnformatted 102 func (o *JSON) Cstr() *c.Char { return nil } 103 104 // Render a JSON entity to text for transfer/storage. 105 // 106 // llgo:link (*JSON).Print C.cJSON_Print 107 func (o *JSON) Print() *c.Char { return nil } 108 109 // Render a JSON entity to text for transfer/storage without any formatting. 110 // 111 // llgo:link (*JSON).PrintUnformatted C.cJSON_PrintUnformatted 112 func (o *JSON) PrintUnformatted() *c.Char { return nil } 113 114 // Render a JSON entity to text using a buffered strategy. 115 // 116 // prebuffer is a guess at the final size. guessing well reduces reallocation. 117 // 118 // fmt=0 gives unformatted, =1 gives formatted. 119 // 120 // llgo:link (*JSON).PrintBuffered C.cJSON_PrintBuffered 121 func (o *JSON) PrintBuffered(prebuffer c.Int, fmt c.Int) *c.Char { return nil }