64-bit + unsigned integer support

This commit is contained in:
Jacek Sieka 2021-02-09 12:28:28 +01:00
parent 6776fed33f
commit 9a65a1847e
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8
2 changed files with 79 additions and 6 deletions

View File

@ -160,6 +160,9 @@ proc dos_qapplication_load_translation(engine: DosQQmlApplicationEngine, content
# QVariant
proc dos_qvariant_create(): DosQVariant {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_create_int(value: cint): DosQVariant {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_create_uint(value: cuint): DosQVariant {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_create_longlong(value: clonglong): DosQVariant {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_create_ulonglong(value: culonglong): DosQVariant {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_create_bool(value: bool): DosQVariant {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_create_string(value: cstring): DosQVariant {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_create_qobject(value: DosQObject): DosQVariant {.cdecl, dynlib: dynLibName, importc.}
@ -169,11 +172,17 @@ proc dos_qvariant_create_double(value: cdouble): DosQVariant {.cdecl, dynlib: dy
proc dos_qvariant_delete(variant: DosQVariant) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_isnull(variant: DosQVariant): bool {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_toInt(variant: DosQVariant): cint {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_toUInt(variant: DosQVariant): cuint {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_toLongLong(variant: DosQVariant): clonglong {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_toULongLong(variant: DosQVariant): culonglong {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_toBool(variant: DosQVariant): bool {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_toString(variant: DosQVariant): cstring {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_toDouble(variant: DosQVariant): cdouble {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_toFloat(variant: DosQVariant): cfloat {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setInt(variant: DosQVariant, value: cint) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setUInt(variant: DosQVariant, value: cuint) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setLongLong(variant: DosQVariant, value: clonglong) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setULongLong(variant: DosQVariant, value: culonglong) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setBool(variant: DosQVariant, value: bool) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setString(variant: DosQVariant, value: cstring) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_assign(leftValue: DosQVariant, rightValue: DosQVariant) {.cdecl, dynlib: dynLibName, importc.}

View File

@ -2,9 +2,21 @@ proc setup*(variant: QVariant) =
## Setup a new QVariant
variant.vptr = dos_qvariant_create()
proc setup*(variant: QVariant, value: int) =
proc setup*(variant: QVariant, value: int | int32 | int64) =
## Setup a new QVariant given a cint value
variant.vptr = dos_qvariant_create_int(value.cint)
variant.vptr =
when sizeof(value) == sizeof(cint):
dos_qvariant_create_int(value.cint)
else:
dos_qvariant_create_longlong(value.clonglong)
proc setup*(variant: QVariant, value: uint | uint32 | uint64) =
## Setup a new QVariant given a cint value
variant.vptr =
when sizeof(value) == sizeof(cuint):
dos_qvariant_create_uint(value.cuint)
else:
dos_qvariant_create_ulonglong(value.culonglong)
proc setup*(variant: QVariant, value: bool) =
## Setup a new QVariant given a bool value
@ -49,7 +61,7 @@ proc newQVariant*(): QVariant =
new(result, delete)
result.setup()
proc newQVariant*(value: int): QVariant =
proc newQVariant*(value: int | int32 | int64 | uint | uint32 | uint64): QVariant =
## Return a new QVariant given a cint
new(result, delete)
result.setup(value)
@ -90,12 +102,64 @@ proc isNull*(variant: QVariant): bool =
proc intVal*(variant: QVariant): int =
## Return the QVariant value as int
dos_qvariant_toInt(variant.vptr).int
when sizeof(result) == sizeof(cint):
dos_qvariant_toInt(variant.vptr).int
else:
dos_qvariant_toLongLong(variant.vptr).int
proc `intVal=`*(variant: QVariant, value: int) =
## Sets the QVariant value int value
var rawValue = value.cint
dos_qvariant_setInt(variant.vptr, rawValue)
when sizeof(value) == sizeof(cint):
dos_qvariant_setInt(variant.vptr, value.cint)
else:
dos_qvariant_setLongLong(variant.vptr, value.clonglong)
proc int32Val*(variant: QVariant): int32 =
## Return the QVariant value as int
dos_qvariant_toInt(variant.vptr).int32
proc `int32Val=`*(variant: QVariant, value: int32) =
## Sets the QVariant value int value
dos_qvariant_setInt(variant.vptr, value.cint)
proc int64Val*(variant: QVariant): int64 =
## Return the QVariant value as int
dos_qvariant_toLongLong(variant.vptr).int64
proc `int64Val=`*(variant: QVariant, value: int64) =
## Sets the QVariant value int value
dos_qvariant_setLongLong(variant.vptr, value.clonglong)
proc uintVal*(variant: QVariant): uint =
## Return the QVariant value as int
when sizeof(result) == sizeof(cuint):
dos_qvariant_toUInt(variant.vptr).uint
else:
dos_qvariant_toULongLong(variant.vptr).uint
proc `uintVal=`*(variant: QVariant, value: uint) =
## Sets the QVariant value uint value
when sizeof(value) == sizeof(cuint):
dos_qvariant_setUInt(variant.vptr, value.cuint)
else:
dos_qvariant_setULongLong(variant.vptr, value.culonglong)
proc uint32Val*(variant: QVariant): uint32 =
## Return the QVariant value as int
dos_qvariant_toUInt(variant.vptr).uint32
proc `uint32Val=`*(variant: QVariant, value: uint32) =
## Sets the QVariant value int value
var rawValue = value.culonglong
dos_qvariant_setUInt(variant.vptr, value.cuint)
proc uint64Val*(variant: QVariant): uint64 =
## Return the QVariant value as int
dos_qvariant_toULongLong(variant.vptr).uint64
proc `uint64Val=`*(variant: QVariant, value: uint64) =
## Sets the QVariant value int value
dos_qvariant_setULongLong(variant.vptr, value.culonglong)
proc boolVal*(variant: QVariant): bool =
## Return the QVariant value as bool