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 acd30c0 commit d23cc45
Showing 1 changed file with 50 additions and 16 deletions.
66 changes: 50 additions & 16 deletions wrapper/raylib_gen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,52 @@ const
"LoadAudioStream",
"UpdateAudioStream",
])
functionOverloads = toHashSet([
"GetScreenToWorldRayEx",
"GetWorldToScreenEx",
"UpdateCameraPro",
"DrawPixelV",
"DrawLineV",
"DrawLineEx",
"DrawCircleV",
"DrawCircleLinesV",
"DrawRectangleV",
"DrawRectangleRec",
"DrawRectanglePro",
"DrawRectangleGradientEx",
"DrawRectangleLinesEx",
"DrawRectangleRoundedLinesEx",
"DrawPolyLinesEx",
"ImageTextEx",
"ImageDrawPixelV",
"ImageDrawLineV",
"ImageDrawLineEx",
"ImageDrawCircleV",
"ImageDrawCircleLinesV",
"ImageDrawRectangleV",
"ImageDrawRectangleRec",
"ImageDrawTriangleEx",
"ImageDrawTextEx",
"UpdateTextureRec",
"DrawTextureV",
"DrawTextureEx",
"DrawTextureRec",
"DrawTexturePro",
"LoadFontEx",
"DrawTextEx",
"DrawTextPro",
"MeasureTextEx",
"DrawCubeV",
"DrawCubeWiresV",
"DrawSphereEx",
"DrawCylinderEx",
"DrawCylinderWiresEx",
"DrawModelEx",
"DrawModelWiresEx",
"DrawModelPointsEx",
"DrawBillboardRec",
"DrawBillboardPro",
])
noSideEffectsFuncs = toHashSet([
"CheckCollisionCircleLine",
"UpdateModelAnimationBoneMatrices",
Expand Down Expand Up @@ -612,26 +658,14 @@ proc preprocessAliases(ctx: var ApiContext) =

proc preprocessFunctions(ctx: var ApiContext) =
proc shouldRemoveSuffix(fnc: FunctionInfo): bool =
const exceptions = [
"DrawRectangleGradientV",
"SetShaderValueV",
"ColorToHSV",
"ColorFromHSV",
"CheckCollisionCircleRec",
"CheckCollisionPointRec"
]
fnc.name notin exceptions and
((fnc.name.endsWith("V") and fnc.returnType != "Vector2") or
(fnc.name.endsWith("Rec") and fnc.returnType != "Rectangle") or
fnc.name.endsWith("Ex") or fnc.name.endsWith("Pro"))
fnc.name in functionOverloads

proc generateProcName(fnc: FunctionInfo): string =
result = fnc.name
const suffixes = ["V", "Rec", "Ex", "Pro"]
if shouldRemoveSuffix(fnc):
result.removeSuffix("V")
result.removeSuffix("Rec")
result.removeSuffix("Ex")
result.removeSuffix("Pro")
for suffix in suffixes:
result.removeSuffix(suffix)
result = uncapitalizeAscii(result)

proc checkCstringType(fnc: FunctionInfo, kind: string): bool =
Expand Down

0 comments on commit d23cc45

Please sign in to comment.