Skip to content

Commit

Permalink
Merge pull request #57 from status-im/feat/add_float64_metatype
Browse files Browse the repository at this point in the history
feat: add support for float64 as QMetatype
  • Loading branch information
IvanBelyakoff committed Apr 12, 2024
2 parents 13a8890 + ef8b329 commit 20d4db1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/nimqml/private/nimqmlmacros.nim
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ proc fromQVariantConversion(x: string): string {.compiletime.} =
of "int": result = "intVal"
of "string": result = "stringVal"
of "bool": result = "boolVal"
of "float": result = "floatVal"
of "double": result = "doubleVal"
of "float32": result = "floatVal"
of "float": result = "doubleVal"
of "QObject": result = "qobjectVal"
of "QVariant": result = ""
else: error("Unsupported conversion from QVariant to $1" % x)
Expand All @@ -106,8 +106,8 @@ proc toMetaType(x: string): string {.compiletime.} =
of "int": result = "Int"
of "bool": result = "Bool"
of "string": result = "QString"
of "double": result = "Double"
of "float": result = "Float"
of "float": result = "Double"
of "float32": result = "Float"
of "pointer": result = "VoidStar"
of "QVariant": result = "QVariant"
of "QObject": result = "QObjectStar"
Expand Down
1 change: 1 addition & 0 deletions src/nimqml/private/nimqmltypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type
UnknownType = 0.cint,
Bool = 1.cint,
Int = 2.cint,
Double = 6.cint,
QString = 10.cint,
VoidStar = 31.cint,
Float = 38.cint,
Expand Down
5 changes: 5 additions & 0 deletions src/nimqml/private/qvariant.nim
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ proc newQVariant*(value: QVariant): QVariant =
result.setup(value)

proc newQVariant*(value: float): QVariant =
## Return a new QVariant given a float
new(result, delete)
result.setup(value.cdouble)

proc newQVariant*(value: float32): QVariant =
## Return a new QVariant given a float
new(result, delete)
result.setup(value.cfloat)
Expand Down

0 comments on commit 20d4db1

Please sign in to comment.