Use GDNative API struct
This commit is contained in:
parent
cf75723fa1
commit
b62db02d8f
32 changed files with 2846 additions and 1535 deletions
|
|
@ -1,35 +1,38 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
GodotString* {.byref.} = object
|
||||
data: array[sizeof(int), byte]
|
||||
import godotinternaltypes, gdnativeapi
|
||||
|
||||
proc initGodotString(dest: var GodotString) {.inline, raises: [].} =
|
||||
getGDNativeAPI().stringNew(dest)
|
||||
|
||||
proc initGodotString(dest: var GodotString) {.
|
||||
importc: "godot_string_new".}
|
||||
proc initGodotString(dest: var GodotString; contents: cstring;
|
||||
size: cint) {.
|
||||
importc: "godot_string_new_data".}
|
||||
size: cint) {.inline.} =
|
||||
## Initializes ``dest`` from UTF-8 ``contents``
|
||||
getGDNativeAPI().stringNewData(dest, contents, size)
|
||||
|
||||
proc getData(self: GodotString; dest: cstring;
|
||||
size: var cint) {.
|
||||
noSideEffect
|
||||
importc: "godot_string_get_data".}
|
||||
size: var cint) {.inline.} =
|
||||
## Converts ``self`` into UTF-8 encoding, putting the result into ``dest``.
|
||||
getGDNativeAPI().stringGetData(self, dest, size)
|
||||
|
||||
proc len*(self: GodotString): cint {.inline.} =
|
||||
## Returns the length of string in bytes if it is represented as UTF-8.
|
||||
getData(self, nil, result)
|
||||
|
||||
proc cstring*(self: GodotString): cstring {.
|
||||
importc: "godot_string_c_str".}
|
||||
proc `==`*(self, b: GodotString): bool {.
|
||||
importc: "godot_string_operator_equal".}
|
||||
proc `<`*(self, b: GodotString): bool {.
|
||||
importc: "godot_string_operator_less".}
|
||||
proc `&`*(self, b: GodotString): GodotString {.
|
||||
importc: "godot_string_operator_plus".}
|
||||
proc cstring*(self: GodotString): cstring {.inline.} =
|
||||
getGDNativeAPI().stringCStr(self)
|
||||
|
||||
proc deinit*(self: var GodotString) {.importc: "godot_string_destroy".}
|
||||
proc `==`*(self, b: GodotString): bool {.inline.} =
|
||||
getGDNativeAPI().stringOperatorEqual(self, b)
|
||||
|
||||
proc `<`*(self, b: GodotString): bool {.inline.} =
|
||||
getGDNativeAPI().stringOperatorLess(self, b)
|
||||
|
||||
proc `&`*(self, b: GodotString): GodotString {.inline.} =
|
||||
getGDNativeAPI().stringOperatorPlus(self, b)
|
||||
|
||||
proc deinit*(self: var GodotString) {.inline.} =
|
||||
getGDNativeAPI().stringDestroy(self)
|
||||
|
||||
proc `$`*(self: GodotString): string =
|
||||
## Converts the ``GodotString`` into Nim string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue