Skip to content

Commit

Permalink
switch to restricting just call expressions
Browse files Browse the repository at this point in the history
Less restrictive, but also less annoying.
Still works with [] syntax for  tables
  • Loading branch information
planetis-m committed May 21, 2024
1 parent de02456 commit 5eba9c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/raylib.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2650,18 +2650,18 @@ proc `[]=`*(x: var MaterialMaps, i: MaterialMapIndex, val: MaterialMap) =
checkArrayAccess(Material(x).maps, i.int, MaxMaterialMaps)
Material(x).maps[i.int] = val

proc `texture=`*(x: var MaterialMap, val: Texture{lvalue}) {.nodestroy, inline.} =
proc `texture=`*(x: var MaterialMap, val: Texture) {.nodestroy, inline.} =
## Set texture for a material map type (Diffuse, Specular...)
## NOTE: Previous texture should be manually unloaded
x.texture = val

template `texture=`*(x: var MaterialMap, val: Texture) =
template `texture=`*(x: var MaterialMap, val: Texture{call}) =
{.error: "Cannot pass a rvalue, as `x` does not take ownership of the texture.".}

proc `shader=`*(x: var Material, val: Shader{lvalue}) {.nodestroy, inline.} =
proc `shader=`*(x: var Material, val: Shader) {.nodestroy, inline.} =
x.shader = val

template `shader=`*(x: var Material, val: Shader) =
template `shader=`*(x: var Material, val: Shader{call}) =
{.error: "Cannot pass a rvalue, as `x` does not take ownership of the shader.".}

proc texture*(x: MaterialMap): lent Texture {.inline.} =
Expand Down
8 changes: 4 additions & 4 deletions tools/raylib_fields.nim
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,18 @@ proc `[]=`*(x: var MaterialMaps, i: MaterialMapIndex, val: MaterialMap) =
checkArrayAccess(Material(x).maps, i.int, MaxMaterialMaps)
Material(x).maps[i.int] = val

proc `texture=`*(x: var MaterialMap, val: Texture{lvalue}) {.nodestroy, inline.} =
proc `texture=`*(x: var MaterialMap, val: Texture) {.nodestroy, inline.} =
## Set texture for a material map type (Diffuse, Specular...)
## NOTE: Previous texture should be manually unloaded
x.texture = val

template `texture=`*(x: var MaterialMap, val: Texture) =
template `texture=`*(x: var MaterialMap, val: Texture{call}) =
{.error: "Cannot pass a rvalue, as `x` does not take ownership of the texture.".}

proc `shader=`*(x: var Material, val: Shader{lvalue}) {.nodestroy, inline.} =
proc `shader=`*(x: var Material, val: Shader) {.nodestroy, inline.} =
x.shader = val

template `shader=`*(x: var Material, val: Shader) =
template `shader=`*(x: var Material, val: Shader{call}) =
{.error: "Cannot pass a rvalue, as `x` does not take ownership of the shader.".}

proc texture*(x: MaterialMap): lent Texture {.inline.} =
Expand Down

0 comments on commit 5eba9c8

Please sign in to comment.