Added suppoer QHashIntQByteArray

This commit is contained in:
Filippo Cucchetto 2016-02-20 11:12:24 +01:00
parent 23826e2721
commit 9d0947a450
4 changed files with 31 additions and 28 deletions

View File

@ -21,10 +21,10 @@ include private/qapplication.nim
include private/qguiapplication.nim
include private/qurl.nim
include private/qquickview.nim
include private/qhashintbytearray.nim
#include private.nimqmltypes
#var qobjectRegistry = initTable[ptr QObjectObj, bool]()
#include private/qguiapplication.nim
#include private/qmodelindex.nim
#include private/qhashintbytearray.nim
#include private/qabstractlistmodel.nim
#include private.nimqmlmacros

View File

@ -10,6 +10,7 @@ type
DosQMetaTypeArray* {.unchecked.} = array[0..0, DosQMetaType]
DosQUrl* = distinct pointer
DosQQuickView* = distinct pointer
DosQHashIntByteArray* = distinct pointer
DosSignalDefinition* = object
name*: cstring
@ -128,4 +129,9 @@ proc dos_qquickview_show(view: DosQQuickView) {.cdecl, importc.}
proc dos_qquickview_source(view: DosQQuickView, filename: var cstring, length: var int) {.cdecl, importc.}
proc dos_qquickview_set_source(view: DosQQuickView, filename: cstring) {.cdecl, importc.}
# QHash<int, QByteArra>
proc dos_qhash_int_qbytearray_create(qHash: var DosQHashIntByteArray) {.cdecl, importc.}
proc dos_qhash_int_qbytearray_delete(qHash: DosQHashIntByteArray) {.cdecl, importc.}
proc dos_qhash_int_qbytearray_insert(qHash: DosQHashIntByteArray, key: int, value: cstring) {.cdecl, importc.}
proc dos_qhash_int_qbytearray_value(qHash: DosQHashIntByteArray, key: int, value: var cstring) {.cdecl, importc.}

View File

@ -23,6 +23,10 @@ type
# A QQuickView
vptr: DosQQuickView
QHashIntByteArray* = ref object of RootObj ## \
# A QHash<int, QByteArray>
vptr: DosQHashIntByteArray
QtItemFlag* {.pure.} = enum ## \
## Item flags
##

View File

@ -1,33 +1,26 @@
proc dos_qhash_int_qbytearray_create(qHash: var RawQHashIntByteArray) {.cdecl, importc.}
proc dos_qhash_int_qbytearray_delete(qHash: RawQHashIntByteArray) {.cdecl, importc.}
proc dos_qhash_int_qbytearray_insert(qHash: RawQHashIntByteArray, key: int, value: cstring) {.cdecl, importc.}
proc dos_qhash_int_qbytearray_value(qHash: RawQHashIntByteArray, key: int, value: var cstring) {.cdecl, importc.}
proc setup*(self: var QHashIntByteArray) =
## Setup the QHash
dos_qhash_int_qbytearray_create(self.vptr)
proc create*(qHash: var QHashIntByteArray) =
## Create the QHash
debugMsg("QHashIntByteArray", "create")
dos_qhash_int_qbytearray_create(qHash.data)
qHash.deleted = false
proc delete*(qHash: QHashIntByteArray) =
proc delete*(self: QHashIntByteArray) =
## Delete the QHash
if not qHash.deleted:
debugMsg("QHashIntByteArray", "delete")
dos_qhash_int_qbytearray_delete(qHash.data)
qHash.deleted = true
proc insert*(qHash: QHashIntByteArray, key: int, value: cstring) =
## Insert the value at the given key
dos_qhash_int_qbytearray_insert(qHash.data, key, value)
proc value*(qHash: QHashIntByteArray, key: int): string =
## Return the value associated at the given key
var rawString: cstring
dos_qhash_int_qbytearray_value(qHash.data, key, rawString)
result = $rawString
dos_chararray_delete(rawString)
if self.vptr.isNil:
return
debugMsg("QHashIntByteArray", "delete")
dos_qhash_int_qbytearray_delete(self.vptr)
proc newQHashIntQByteArray*(): QHashIntByteArray =
## Create a new QHashIntQByteArray
new(result, delete)
result.create()
result.setup()
proc insert*(self: QHashIntByteArray, key: int, value: cstring) =
## Insert the value at the given key
dos_qhash_int_qbytearray_insert(self.vptr, key, value)
proc value*(self: QHashIntByteArray, key: int): string =
## Return the value associated at the given key
var rawString: cstring
dos_qhash_int_qbytearray_value(self.vptr, key, rawString)
result = $rawString
dos_chararray_delete(rawString)