Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Oct 7, 2024
1 parent 278a340 commit f740ee4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/raylib.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,7 @@ proc `[]=`*(x: var ModelAnimationFramePoses; i, j: int, val: Transform) =
checkArrayAccess(ModelAnimation(x).framePoses, i, ModelAnimation(x).frameCount)
checkArrayAccess(ModelAnimation(x).framePoses[i], j, ModelAnimation(x).boneCount)
ModelAnimation(x).framePoses[i][j] = val

proc glyphCount*(x: Font): int32 {.inline.} = x.glyphCount
proc vertexCount*(x: Mesh): int32 {.inline.} = x.vertexCount
proc triangleCount*(x: Mesh): int32 {.inline.} = x.triangleCount
Expand Down
2 changes: 1 addition & 1 deletion tools/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type

InfoFlags* = enum
isPrivate, isWrappedFunc, hasVarargs, isOpenArray, isVarParam,
isDistinct, isCompleteStruct, isMangled, isString, isFunc
isDistinct, isCompleteStruct, isMangled, isString, isFunc, isArrayLength

TopLevel* = object
defines*: seq[DefineInfo]
Expand Down
22 changes: 8 additions & 14 deletions tools/newdsl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ proc generateObject*(b: var Builder, obj: StructInfo) =
if obj.name != "Matrix" or fld.name in ["m0", "m1", "m2", "m3"]: # row starts
b.addTree("")
b.addIdent fld.name
if obj.name == "Matrix" and fld.name notin ["m12", "m13", "m14", "m15"]: # row ends
b.addRaw "*, "
continue
if isPrivate notin fld.flags:
b.addRaw "*"
if obj.name == "Matrix" and fld.name notin ["m12", "m13", "m14", "m15"]: # row ends
b.addRaw ", "
continue
b.addRaw ": "
b.addIdent fld.`type`
b.addDoc fld.description
Expand Down Expand Up @@ -154,10 +154,8 @@ proc generateWrappedProc*(b: var Builder, fnc: FunctionInfo) =
withSection(b, "proc "):
b.addIdent fnc.name
b.addRaw "*("
var skipNext = false
for i, param in fnc.params:
if skipNext:
skipNext = false
if isArrayLength in param.flags:
continue
if i > 0:
b.addRaw ", "
Expand All @@ -169,7 +167,6 @@ proc generateWrappedProc*(b: var Builder, fnc: FunctionInfo) =
b.addRaw "openArray["
b.addRaw param.baseType
b.addRaw "]"
skipNext = true
elif isVarParam in param.flags:
b.addRaw "var "
b.addRaw param.baseType
Expand All @@ -189,7 +186,6 @@ proc generateWrappedProc*(b: var Builder, fnc: FunctionInfo) =
b.addRaw "$"
b.addIdent fnc.name
b.addRaw "Priv("
var nextValue = ""
for i, param in fnc.params:
if i > 0:
b.addRaw ", "
Expand All @@ -199,18 +195,16 @@ proc generateWrappedProc*(b: var Builder, fnc: FunctionInfo) =
b.addRaw "]("
elif isVarParam in param.flags:
b.addRaw "addr "
if nextValue != "":
b.addRaw nextValue
if isArrayLength in param.flags:
b.addRaw param.baseType
b.addRaw ".len."
b.addRaw param.`type`
nextValue = ""
else:
b.addIdent param.name
if isString in param.flags:
b.addRaw ".cstring"
if isOpenArray in param.flags:
b.addRaw ")"
nextValue = param.name
b.addRaw ")\n"

proc genBindings*(b: var Builder; ctx: ApiContext;
Expand Down Expand Up @@ -249,9 +243,9 @@ proc genBindings*(b: var Builder; ctx: ApiContext;
for fnc in items(ctx.api.functions):
generateProc(b, fnc)
# b.addNewLine()
b.addRaw "\n{.pop.}"
b.addNewLine()
b.addRaw "\n{.pop.}\n"
b.addRaw afterFuncs
b.addNewLine()
# Generate property procs
for x in items(ctx.readOnlyFieldAccessors):
b.addRaw "proc "
Expand Down
2 changes: 2 additions & 0 deletions tools/raylib_gen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ proc preprocessFunctions(ctx: var ApiContext) =
if i < fnc.params.high and checkOpenarrayType(fnc, paramType, many, fnc.params[i+1].name):
param.baseType = baseType
param.flags.incl isOpenArray
fnc.params[i+1].flags.incl isArrayLength
fnc.params[i+1].baseType = param.name # Needs cleanup
autoWrap = true
if paramType.startsWith("var "):
param.flags.incl isVarParam
Expand Down

0 comments on commit f740ee4

Please sign in to comment.