Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Oct 12, 2024
1 parent b1f510c commit acd30c0
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions wrapper/raylib_gen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,22 @@ const
"ModelAnimation/boneCount",
"ModelAnimation/frameCount",
])
openArrayParameters = toHashSet([
"SetWindowIcons/images",
"DrawLineStrip/points",
"DrawTriangleFan/points",
"DrawTriangleStrip/points",
"DrawSplineLinear/points",
"DrawSplineBasis/points",
"DrawSplineCatmullRom/points",
"DrawSplineBezierQuadratic/points",
"DrawSplineBezierCubic/points",
"CheckCollisionPointPoly/points",
"ImageKernelConvolution/kernel",
"ImageDrawTriangleFan/points",
"ImageDrawTriangleStrip/points",
"DrawTriangleStrip3D/points",
])
privateSymbols = toHashSet([
# Struct fields
"MaterialMap/texture",
Expand Down Expand Up @@ -621,10 +637,8 @@ proc preprocessFunctions(ctx: var ApiContext) =
proc checkCstringType(fnc: FunctionInfo, kind: string): bool =
kind == "cstring" and fnc.name notin wrappedFuncs and hasVarargs notin fnc.flags

proc checkOpenarrayType(fnc: FunctionInfo, kind: string, isArray: bool, nextName: string): bool =
kind != "pointer" and isArray and ((nextName == "count" or nextName.endsWith("Count")) or
(nextName == "size" or nextName.endsWith("Size"))) and
fnc.name notin wrappedFuncs and hasVarargs notin fnc.flags
proc isOpenArrayParameter(x, y: string): bool =
(if y != "": x & "/" & y else: x) in openArrayParameters

keepIf(ctx.api.functions, proc (x: FunctionInfo): bool = x.name notin excludedFuncs)
for fnc in mitems(ctx.api.functions):
Expand Down Expand Up @@ -654,7 +668,7 @@ proc preprocessFunctions(ctx: var ApiContext) =
if checkCstringType(fnc, paramType):
param.flags.incl isString
autoWrap = true
if i < fnc.params.high and checkOpenarrayType(fnc, paramType, isArray, fnc.params[i+1].name):
if isOpenArrayParameter(fnc.name, param.name):
param.extra = convertType(param.`type`, ptOpenArray)
param.flags.incl isOpenArray
fnc.params[i+1].flags.incl isArrayLength
Expand Down

0 comments on commit acd30c0

Please sign in to comment.