feat(cpp/inih): add inih parser_2
This commit is contained in:
@@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/c"
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgoexamples/cpp/inih"
|
"github.com/goplus/llgo/cpp/inih"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -38,6 +38,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
isDatabaseEnabled := reader.GetBoolean(inih.Str("database"), inih.Str("enabled"), false)
|
isDatabaseEnabled := reader.GetBoolean(inih.Str("database"), inih.Str("enabled"), false)
|
||||||
port := reader.GetInteger(inih.Str("database"), inih.Str("port"), 0)
|
port := reader.GetInteger(inih.Str("database"), inih.Str("port"), 0)
|
||||||
|
s := reader.GetString(inih.Str("database"), inih.Str("server"), inih.Str("unknown")).String()
|
||||||
|
println("s :", s)
|
||||||
println("isDatabaseEnabled:", isDatabaseEnabled, "port:", port)
|
println("isDatabaseEnabled:", isDatabaseEnabled, "port:", port)
|
||||||
demo2()
|
demo2()
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/goplus/llgo/c"
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgo/c/inih"
|
"github.com/goplus/llgo/cpp/inih"
|
||||||
)
|
)
|
||||||
|
|
||||||
func demo1() {
|
func demo1() {
|
||||||
|
|||||||
2230
cpp/inih/demangled.txt
Normal file
2230
cpp/inih/demangled.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
package inih
|
package inih
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/c"
|
"github.com/goplus/llgo/c"
|
||||||
)
|
)
|
||||||
@@ -11,34 +11,59 @@ type Reader struct {
|
|||||||
Unused [24]byte
|
Unused [24]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func Str(s string) *stdstring {
|
type StdString struct {
|
||||||
var r stdstring
|
buf [24]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type stringHead struct {
|
||||||
|
data unsafe.Pointer
|
||||||
|
size int
|
||||||
|
}
|
||||||
|
|
||||||
|
type __long struct {
|
||||||
|
__cap_ int
|
||||||
|
__size_ int
|
||||||
|
__data_ unsafe.Pointer
|
||||||
|
}
|
||||||
|
|
||||||
|
func Str(s string) *StdString {
|
||||||
|
var r StdString
|
||||||
r.init(c.GoStringData(s), c.Int(len(s)))
|
r.init(c.GoStringData(s), c.Int(len(s)))
|
||||||
return &r
|
return &r
|
||||||
}
|
}
|
||||||
|
|
||||||
type stdstring struct {
|
func (r *StdString) String() string {
|
||||||
buf [24]byte
|
if r.buf[0]&1 == 0 {
|
||||||
|
return c.GoString((*c.Char)(unsafe.Pointer(&r.buf[1])))
|
||||||
|
} else {
|
||||||
|
v := *(*__long)(unsafe.Pointer(&r.buf[0]))
|
||||||
|
return *(*string)(unsafe.Pointer(&stringHead{data: v.__data_, size: v.__size_}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// llgo:link (*stdstring).init C._ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm
|
// llgo:link (*StdString).init C._ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm
|
||||||
func (*stdstring) init(s *c.Char, size c.Int) {}
|
func (*StdString) init(s *c.Char, size c.Int) {}
|
||||||
|
|
||||||
//go:linkname NewReader C._ZN9INIReaderC1EPKcm
|
//go:linkname NewReader C._ZN9INIReaderC1EPKcm
|
||||||
func NewReader(fileName *c.Char, size c.Ulong) Reader
|
func NewReader(fileName *c.Char, size c.Ulong) Reader
|
||||||
|
|
||||||
//go:linkname NewReaderFile C._ZN9INIReaderC1ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
|
//go:linkname NewReaderFile C._ZN9INIReaderC1ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
|
||||||
func NewReaderFile(fileName *stdstring) Reader
|
func NewReaderFile(fileName *StdString) Reader
|
||||||
|
|
||||||
// llgo:link (*Reader).ParseError C._ZNK9INIReader10ParseErrorEv
|
// llgo:link (*Reader).ParseError C._ZNK9INIReader10ParseErrorEv
|
||||||
func (*Reader) ParseError() c.Int { return 0 }
|
func (*Reader) ParseError() c.Int { return 0 }
|
||||||
|
|
||||||
// llgo:link (*Reader).GetInteger C._ZNK9INIReader10GetIntegerERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_l
|
// llgo:link (*Reader).GetInteger C._ZNK9INIReader10GetIntegerERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_l
|
||||||
func (*Reader) GetInteger(section *stdstring, name *stdstring, defaultValue c.Long) c.Long {
|
func (*Reader) GetInteger(section *StdString, name *StdString, defaultValue c.Long) c.Long {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// llgo:link (*Reader).GetBoolean C._ZNK9INIReader10GetBooleanERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_b
|
// llgo:link (*Reader).GetBoolean C._ZNK9INIReader10GetBooleanERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_b
|
||||||
func (*Reader) GetBoolean(section *stdstring, name *stdstring, defaultValue bool) bool {
|
func (*Reader) GetBoolean(section *StdString, name *StdString, defaultValue bool) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// llgo:link (*Reader).GetString C._ZNK9INIReader9GetStringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_S8_
|
||||||
|
func (*Reader) GetString(section *StdString, name *StdString, defaultValue *StdString) *StdString {
|
||||||
|
return &StdString{}
|
||||||
|
}
|
||||||
|
|||||||
2230
cpp/inih/output.txt
Normal file
2230
cpp/inih/output.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user