Fix doc generation

This commit is contained in:
Ruslan Mustakov 2018-06-04 16:24:52 +07:00
commit b3ad6134d9
4 changed files with 25 additions and 25 deletions

View file

@ -104,7 +104,8 @@ proc buildDocs*(outDir, godotNimDir, godotBin: string) =
createDir(godotApiFolder) createDir(godotApiFolder)
genApiFiles(godotApiFolder, godotBinAbs) genApiFiles(godotApiFolder, godotBinAbs)
for file in walkDirRec(godotApiFolder, {pcFile, pcDir}, [".nim"]): for file in walkDirRec(godotApiFolder, {pcFile, pcDir}, [".nim"]):
spawn execOrFail("nim doc -d:useRealtimeGc --path:godot " & quoted(file)) spawn execOrFail("nim doc -d:useRealtimeGc --path:godot -o:" &
quoted(outName(godotApiFolder, file)) & ' ' & quoted(file))
sync() sync()

View file

@ -42,6 +42,9 @@ proc newVariant*(dict: Dictionary): Variant {.inline.} =
new(result, variantFinalizer) new(result, variantFinalizer)
initGodotVariant(result.godotVariant[], dict.godotDictionary) initGodotVariant(result.godotVariant[], dict.godotDictionary)
proc asDictionary*(self: Variant): Dictionary {.inline.} =
newDictionary(self.godotVariant[].asGodotDictionary())
proc contains*(self: Dictionary; key: Variant): bool {.inline.}= proc contains*(self: Dictionary; key: Variant): bool {.inline.}=
self.godotDictionary.contains(key.godotVariant[]) self.godotDictionary.contains(key.godotVariant[])

View file

@ -29,6 +29,12 @@ template definePoolArrayBase(T, GodotT, DataT, fieldName, newProcName,
new(result, poolArrayFinalizer) new(result, poolArrayFinalizer)
result.fieldName = arr result.fieldName = arr
proc hash*(arr: T): Hash =
for item in arr.fieldName.items():
result = result !&
(when type(item) is GodotString: ($item).hash() else: item.hash())
result = !$result
template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName;
noData = false) = noData = false) =
@ -86,11 +92,6 @@ template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName;
for pair in arr.fieldName.mpairs: for pair in arr.fieldName.mpairs:
yield (pair[0].int, pair[1]) yield (pair[0].int, pair[1])
proc hash*(arr: T): Hash =
for item in arr.items():
result = result !& item.hash()
result = !$result
definePoolArrayBase(PoolByteArray, GodotPoolByteArray, uint8, definePoolArrayBase(PoolByteArray, GodotPoolByteArray, uint8,
godotPoolByteArray, newPoolByteArray, godotPoolByteArray, newPoolByteArray,
initGodotPoolByteArray) initGodotPoolByteArray)
@ -164,8 +165,3 @@ iterator items*(arr: PoolStringArray): string =
iterator pairs*(arr: PoolStringArray): tuple[key: int, val: string] = iterator pairs*(arr: PoolStringArray): tuple[key: int, val: string] =
for i in 0..<arr.len: for i in 0..<arr.len:
yield (i, arr[i]) yield (i, arr[i])
proc hash*(arr: PoolStringArray): Hash =
for s in arr:
result = result !& s.hash()
result = !$result

View file

@ -2,7 +2,8 @@ import tables, hashes
import godotcoretypes import godotcoretypes
import internal.godotinternaltypes, internal.godotvariants, import internal.godotinternaltypes, internal.godotvariants,
internal.godotstrings internal.godotstrings, internal.godotdictionaries,
internal.godotarrays
type type
Variant* = ref object Variant* = ref object
@ -140,11 +141,7 @@ proc newVariant*(obj: ptr GodotObject): Variant {.inline.} =
new(result, variantFinalizer) new(result, variantFinalizer)
initGodotVariant(result.godotVariant, obj) initGodotVariant(result.godotVariant, obj)
import arrays, poolarrays, dictionaries import poolarrays
proc newVariant*(arr: Array): Variant {.inline.} =
new(result, variantFinalizer)
initGodotVariant(result.godotVariant, arr.godotArray[])
proc newVariant*(pba: PoolByteArray): Variant {.inline.} = proc newVariant*(pba: PoolByteArray): Variant {.inline.} =
new(result, variantFinalizer) new(result, variantFinalizer)
@ -228,12 +225,6 @@ proc asRID*(self: Variant): RID {.inline.} =
proc asGodotObject*(self: Variant): ptr GodotObject {.inline.} = proc asGodotObject*(self: Variant): ptr GodotObject {.inline.} =
self.godotVariant.asGodotObject() self.godotVariant.asGodotObject()
proc asDictionary*(self: Variant): Dictionary {.inline.} =
newDictionary(self.godotVariant.asGodotDictionary())
proc asArray*(self: Variant): Array {.inline.} =
newArray(self.godotVariant.asGodotArray())
proc asPoolByteArray*(self: Variant): PoolByteArray {.inline.} = proc asPoolByteArray*(self: Variant): PoolByteArray {.inline.} =
newPoolByteArray(self.godotVariant.asGodotPoolByteArray()) newPoolByteArray(self.godotVariant.asGodotPoolByteArray())
@ -277,8 +268,8 @@ proc hash*(self: Variant): Hash =
of VariantType.NodePath: self.asNodePath().hash() of VariantType.NodePath: self.asNodePath().hash()
of VariantType.RID: self.asRID().hash() of VariantType.RID: self.asRID().hash()
of VariantType.Object: self.asGodotObject().objectHash() of VariantType.Object: self.asGodotObject().objectHash()
of VariantType.Dictionary: self.asDictionary().hash() of VariantType.Dictionary: hash(self.godotVariant.asGodotDictionary().godotHash())
of VariantType.Array: self.asArray().hash() of VariantType.Array: hash(self.godotVariant.asGodotArray().godotHash())
of VariantType.PoolByteArray: self.asPoolByteArray().hash() of VariantType.PoolByteArray: self.asPoolByteArray().hash()
of VariantType.PoolIntArray: self.asPoolIntArray().hash() of VariantType.PoolIntArray: self.asPoolIntArray().hash()
of VariantType.PoolRealArray: self.asPoolRealArray().hash() of VariantType.PoolRealArray: self.asPoolRealArray().hash()
@ -287,6 +278,15 @@ proc hash*(self: Variant): Hash =
of VariantType.PoolVector3Array: self.asPoolVector3Array().hash() of VariantType.PoolVector3Array: self.asPoolVector3Array().hash()
of VariantType.PoolColorArray: self.asPoolColorArray().hash() of VariantType.PoolColorArray: self.asPoolColorArray().hash()
import arrays
proc newVariant*(arr: Array): Variant {.inline.} =
new(result, variantFinalizer)
initGodotVariant(result.godotVariant, arr.godotArray[])
proc asArray*(self: Variant): Array {.inline.} =
newArray(self.godotVariant.asGodotArray())
proc hasMethod*(self: Variant; meth: string): bool = proc hasMethod*(self: Variant; meth: string): bool =
var s = meth.toGodotString() var s = meth.toGodotString()
result = self.godotVariant.hasMethod(s) result = self.godotVariant.hasMethod(s)