Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nim 0.19/devel compatibility #42

Closed
wants to merge 10 commits into from

Conversation

bluenote10
Copy link
Contributor

Attempt to fix #41

I addressed the most obvious issues regarding Nim 0.19.

Unfortunately, I still can't compile the nim-godot-stub, because there is now a very strange macro error:

fpscounter.nim(7, 7) template/generic instantiation of `gdobj` from here
fpscounter.nim(10, 3) Warning: the '.this' pragma is deprecated [Deprecated]
fpscounter.nim(7, 7) template/generic instantiation of `gdobj` from here
../../godot-nim/godot/nim/godotmacros.nim(513, 23) Error: type mismatch: got <int literal(0)> but expected 'bool'

This is referring to the code line:

  result.add(getAst(
    registerGodotClass(classNameIdent, classNameLit, isRef, parentName,
                       genSym(nskProc, "createFunc"), obj.isTool)))

As far as I can see from stdout debugging none of the arguments is an int literal (0). Is this a Nim bug?

@bluenote10
Copy link
Contributor Author

bluenote10 commented Dec 30, 2018

I wasn't on the latest devel. If I use latest devel I don't get the error above, but rather the compiler crashes with an internal error :(. This is also what the travis build says. Hm, pretty hard to reproduce because it involves so much auto-generated code...

Error: internal error: (filename: "semexprs.nim", line: 406, column: 19)
Error: internal error: (filename: "semexprs.nim", line: 406, column: 19)
Traceback (most recent call last)
nim.nim(109)             nim
nim.nim(73)              handleCmdLine
cmdlinehelper.nim(92)    loadConfigsAndRunMainCommand
main.nim(171)            mainCommand
main.nim(78)             commandCompileToC
modules.nim(134)         compileProject
modules.nim(79)          compileModule
passes.nim(197)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(604)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(200)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(604)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(200)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(604)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(200)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(604)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(200)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(604)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2591)       semExpr
semstmts.nim(1868)       semMacroDef
semstmts.nim(1752)       semProcAux
semexprs.nim(1613)       semProcBody
semexprs.nim(2569)       semExpr
semstmts.nim(1988)       semStmtList
semexprs.nim(2571)       semExpr
semstmts.nim(447)        semVarOrLet
semexprs.nim(59)         semExprWithType
semexprs.nim(2547)       semExpr
semstmts.nim(160)        semIf
semexprs.nim(59)         semExprWithType
semexprs.nim(2477)       semExpr
semexprs.nim(2086)       semMagic
semexprs.nim(896)        semDirectOp
semexprs.nim(746)        semOverloadedCallAnalyseEffects
semcall.nim(504)         semOverloadedCall
semcall.nim(312)         resolveOverloads
semcall.nim(93)          pickBestCandidate
sigmatch.nim(2438)       matches
sigmatch.nim(2378)       matchesAux
sigmatch.nim(2189)       prepareOperand
semexprs.nim(41)         semOperand
semexprs.nim(2477)       semExpr
semexprs.nim(2013)       semMagic
msgs.nim(545)            semIs
msgs.nim(538)            internalError
msgs.nim(414)            rawMessage
msgs.nim(411)            rawMessage
msgs.nim(327)            handleError
msgs.nim(317)            quit
FAILURE

@bluenote10
Copy link
Contributor Author

The internal error was caused by this Nim issue: nim-lang/Nim#10136

Fortunately it should be simple to work-around the issue, because the toGodotName probably can be a proc instead of a macro.

Now I'm again stuck with the issue in the first post :(.

@bluenote10
Copy link
Contributor Author

It looks like the problem is this Nim bug: nim-lang/Nim#7375

Looking for a work-around...

@bluenote10 bluenote10 changed the title Attempt to make 0.19 compatible Nim 0.19/devel compatibility Jan 8, 2019
@zetashift
Copy link
Contributor

zetashift commented Jan 13, 2019

Trying to run this with the latest devel which fixed the typedesc is issue. Currently getting this error:

..\_godotapi\input.nim(88, 34) template/generic instantiation of `getSingleton` from here
..\..\..\..\..\.nimble\pkgs\godot-0.7.18\nim\godotnim.nim(369, 30) Error: type mismatch: got <string>
but expected one of:
macro asCString(s: static[string]): cstring

expression: asCString(toGodotName(T))
       Tip: 11 messages have been suppressed, use --verbose to show them.
     Error: Execution failed with exit code 1
        ... Command: "C:\Users\rskar\.nimble\bin\nim.exe" c --noNimblePath --path:"C:\Users\rskar\.nimble\pkgs\godot-0.7.18" --path:"C:\Users\rskar\.nimble\pkgs\compiler-0.19.9" "-o:..\_dlls\nim_64.dll"  "..\src\stub.nim" 

Also got a nakefile.nim error but that was solvable by removing the isNil check.

@RSDuck
Copy link

RSDuck commented Jan 13, 2019

I don't know if that's the expected behaviour, but I think the problem is that the return value of toGodotName is set to string. This way the returned string literal is immedietly treated as a non const(aka static) string. It's probably solved by changing the return type to untyped.

@zetashift
Copy link
Contributor

Changing the return type of toGodotName to untyped didn't do it for, still the same error. Changing the parameter type of asCString(s: static[string]) to `untyped gave me a different error:

..\..\..\..\..\.nimble\pkgs\godot-0.7.18\nim\godotnim.nim(363, 42) Error: type mismatch: got <NimNode>
but expected one of:
proc newRStrLit(s: string): NimNode

But yeah my metaprogramming experience is really limited so I'm not sure what I'm doing.

@bluenote10
Copy link
Contributor Author

For me this works fine with a ~2 days old devel. The travis builds were successful as well back then. Can we retrigger them to see if travis can reproduce the problem?

Note that I had a workaround for the typedesc is issue, so that doesn't matter.

@zetashift
Copy link
Contributor

zetashift commented Jan 13, 2019

the `is issue has been solved in latest devel though: nim-lang/Nim@ab99bdf
EDIT: but yeah retriggering the travis build would be a great thing

@zetashift
Copy link
Contributor

zetashift commented Jan 20, 2019

So I got around this error but now I'm getting linking errors(which is weird other Nim projects of mine compile fine), using Window 10 x64:

CC: stdlib_system
CC: stdlib_math
CC: stdlib_strutils
CC: stdlib_dynlib
Error: execution of an external compiler program 'vccexe.exe /c --platform:amd64 /nologo -DWIN32_LEAN_AND_MEAN /Zi /FS /Od  /IC:\Users\rskar\.choosenim\toolchains\nim-#devel\lib /IC:\Users\rskar\stack\dev\gamedev\godot-nim-stub-master\src /FoC:\Users\rskar\stack\dev\gamedev\godot-nim-stub-master\src\.nimcache\windows\amd64\stdlib_math.c.obj C:\Users\rskar\stack\dev\gamedev\godot-nim-stub-master\src\.nimcache\windows\amd64\stdlib_math.c' failed with exit code: 2

stdlib_math.c
C:\Users\rskar\.choosenim\toolchains\nim-#devel\lib\nimbase.h(257): fatal error C1083: Cannot open include file: 'limits.h': No such file or directory
       Tip: 11 messages have been suppressed, use --verbose to show them.
     Error: Execution failed with exit code 1
        ... Command: "C:\Users\rskar\.nimble\bin\nim.exe" c --noNimblePath --path:"C:\Users\rskar\.nimble\pkgs\godot-0.7.18" --path:"C:\Users\rskar\.nimble\pkgs\compiler-0.19.9" "-o:..\_dlls\nim_64.dll"  "..\src\stub.nim"

Edit: I'm a fool: #35
Edit2: compiles now on devel and runs fine.

@narimiran
Copy link

compiles now on devel and runs fine.

Any news on this one?

We would like to include godot-nim in our test suite to ensure we don't introduce some breaking changes in the future, but for that to happen godot-nim first needs to compile on current devel (or 0.19 branch).

@bluenote10
Copy link
Contributor Author

It's been a while that I worked on this, but from my point of view it was ready to merge...

@endragor doesn't seem very active recently. Anyone else with merge rights on this repo?

Copy link
Member

@endragor endragor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep the library compatible with the earlier version of Nim (0.18.0), because it's being used in production. I pointed out where incompatibilities currently exist. Would you be able to update the PR based on the comments I provided?

Thanks for your work and apologies for the huge delay in responding.

@@ -197,7 +197,7 @@ proc parseType(definition, callSite: NimNode): ObjectDecl =
parseError(option, "valid type specifier expected")
result.isTool = isTool

if result.parentName.isNil: result.parentName = "Object"
if result.parentName == "": result.parentName = "Object"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .len == 0 check to keep this compatible with earlier versions of Nim.

@@ -447,7 +444,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
let objTy = newNimNode(nnkObjectTy)
typeDef.add(newNimNode(nnkRefTy).add(objTy))
objTy.add(newEmptyNode())
if obj.parentName.isNil:
if obj.parentName == "":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .len == 0 check to keep this compatible with earlier versions of Nim.

@@ -506,23 +503,25 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
result.add(meth.nimNode)

# Register Godot object
let parentName = if obj.parentName.isNil: newStrLitNode("Object")
let parentName = if obj.parentName == "": newStrLitNode("Object")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .len == 0 check.

else: newStrLitNode(obj.parentName)
let classNameLit = newStrLitNode(obj.name)
let classNameIdent = ident(obj.name)
let isRef: bool = if obj.parentName.isNil: false
let isRef: bool = if obj.parentName == "": false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .len == 0 check.

@@ -204,7 +202,7 @@ macro baseNativeType(T: typedesc): cstring =
if typeName == "NimGodotObject":
break
t = getType(t[1][1])
if baseT.isNil:
if baseT == "":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .len == 0 check.


macro toGodotName(T: typedesc): string =
var godotName: string
proc toGodotName(T: typedesc): string =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark this explicitly as {.compileTime.} to make sure it's never executed in runtime.

@@ -717,7 +709,7 @@ proc fromVariant*(s: var string, val: Variant): ConversionResult =
if val.getType() == VariantType.String:
s = val.asString()
elif val.getType() == VariantType.Nil:
s = nil
s = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be set to nil in versions prior to 0.19.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would one achieve this? Using a when switch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, such as when (NimMajor, NimMinor, NimPatch) < (0, 19, 0):

@@ -546,15 +545,15 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
methodNameLit, minArgs, maxArgs,
argTypes, methFuncIdent, hasReturnValue) =
{.emit: """/*TYPESECTION*/
N_NOINLINE(void, setStackBottom)(void* thestackbottom);
N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setStackBottom should still be used for versions prior to 0.19.0 here and in godotnim.nim.

@endragor
Copy link
Member

Also, please bump the minor version.

@zetashift
Copy link
Contributor

zetashift commented Feb 26, 2019

@bluenote10 any update on this, should I make a PR on your branch with the requested changes?

@bluenote10
Copy link
Contributor Author

@zetashift That would be great, I wanted to work on it, but I simply couldn't find the time...

@zetashift
Copy link
Contributor

So the {this : self} pragma got deprecated, how should we work around this issue?

@zetashift
Copy link
Contributor

zetashift commented Mar 4, 2019

Currently getting a big error and I have no idea how to solve this, this is using bluenote's branch opening the godot-nim-stub:

ERROR: : Unhandled Nim exception: godotnim.nim(860)        godot_nativescript_init
godotnim.nim(249)        godottypes
tables.nim(860)          []=
tableimpl.nim(98)        []=
tableimpl.nim(32)        rawGet
system.nim(3059)         sysFatal
Error: unhandled exception: index 1540970516 not in 0 .. -1 [IndexError]

   At: ..\..\..\..\..\.nimble\pkgs\godot-0.7.19\nim\godotnim.nim:907
ERROR: : Unhandled Nim exception: godotnim.nim(860)        godot_nativescript_init
godotnim.nim(249)        godottypes
tables.nim(860)          []=
tableimpl.nim(98)        []=
tableimpl.nim(32)        rawGet
Error: unhandled exception:  [NilAccessError]

   At: ..\..\..\..\..\.nimble\pkgs\godot-0.7.19\nim\godotnim.nim:907
ERROR: : Unhandled Nim exception: godotnim.nim(860)        godot_nativescript_init
godotnim.nim(249)        godottypes
tables.nim(860)          []=
tableimpl.nim(98)        []=
tableimpl.nim(32)        rawGet
[[reraised from:
godotnim.nim(860)        godot_nativescript_init
godotnim.nim(249)        godottypes
tables.nim(860)          []=
tableimpl.nim(98)        []=
tableimpl.nim(32)        rawGet
]]
Error: unhandled exception:  [NilAccessError]
ERROR: : Unhandled Nim exception: godotnim.nim(860)        godot_nativescript_init
godotnim.nim(249)        godottypes
tables.nim(860)          []=
tableimpl.nim(98)        []=
tableimpl.nim(32)        rawGet
system.nim(3059)         sysFatal
Error: unhandled exception: index 1540970516 not in 0 .. -1 [IndexError]

   At: ..\..\..\..\..\.nimble\pkgs\godot-0.7.19\nim\godotnim.nim:907
ERROR: : Unhandled Nim exception: godotnim.nim(860)        godot_nativescript_init
godotnim.nim(249)        godottypes
tables.nim(860)          []=
tableimpl.nim(98)        []=
tableimpl.nim(32)        rawGet
Error: unhandled exception:  [NilAccessError]

   At: ..\..\..\..\..\.nimble\pkgs\godot-0.7.19\nim\godotnim.nim:907
ERROR: : Unhandled Nim exception: godotnim.nim(860)        godot_nativescript_init
godotnim.nim(249)        godottypes
tables.nim(860)          []=
tableimpl.nim(98)        []=
tableimpl.nim(32)        rawGet
[[reraised from:
godotnim.nim(860)        godot_nativescript_init
godotnim.nim(249)        godottypes
tables.nim(860)          []=
tableimpl.nim(98)        []=
tableimpl.nim(32)        rawGet
]]
Error: unhandled exception:  [NilAccessError]

@jyapayne
Copy link
Contributor

jyapayne commented Mar 11, 2019

With the latest Nim devel as of yesterday, I can get your changes to compile and run the example code (with some modifications). I need to change toGodotName back to a macro and edit the nim-godot-stub project to remove the isNil checks and the edit mainpanel.nim to be as follows:

import godot
import scene_tree, resource_loader, packed_scene, panel, global_constants,
       input_event_mouse_button

gdobj MainPanel of Panel:
  method ready*() =
    setProcessInput(true)

  method input*(event: InputEvent) =
    if event of InputEventMouseButton:
      let ev = event as InputEventMouseButton
      if ev.buttonIndex == BUTTON_LEFT:
        getTree().setInputAsHandled()
        let scene = load("res://scene.tscn") as PackedScene
        # This line gives me a "stack smashing error" at runtime. You can also add
        # a flag to the nakefile.nim's compilation line to disable bounds checking,
        # but we should probably find out why this happens. Maybe it only happens for me?
        # getTree().root.addChild(scene.instance())
        let root = getTree().root
        let panel = root.getChild(0)
        root.addChildBelowNode(panel, scene.instance())
        queueFree()

I should note that I'm also using a Godot binary compiled from latest master on the godot repo.

@zetashift
Copy link
Contributor

Using Godot 3.1, latest devel, compiles indeed fine(also added this on my PR to @bluenote10 branch). However the runtime error, even with your changes still happens:

ERROR: No loader found for resource: res://
   At: core/io/resource_loader.cpp:285
ERROR: Error loading resource: ''
   At: core/bind/core_bind.cpp:79
ERROR: : Unhandled Nim exception (NilAccessError):
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject

   At: ..\..\..\..\..\.nimble\pkgs\godot-0.7.19\nim\godotmacros.nim:582
ERROR: No loader found for resource: res://
   At: core/io/resource_loader.cpp:285
ERROR: Error loading resource: ''
   At: core/bind/core_bind.cpp:79
ERROR: : Unhandled Nim exception (NilAccessError):
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
[[reraised from:
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
]]

   At: ..\..\..\..\..\.nimble\pkgs\godot-0.7.19\nim\godotmacros.nim:582
ERROR: No loader found for resource: res://
   At: core/io/resource_loader.cpp:285
ERROR: Error loading resource: ''
   At: core/bind/core_bind.cpp:79
ERROR: : Unhandled Nim exception (NilAccessError):
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
[[reraised from:
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
]]
[[reraised from:
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
]]

   At: ..\..\..\..\..\.nimble\pkgs\godot-0.7.19\nim\godotmacros.nim:582
ERROR: No loader found for resource: res://
   At: core/io/resource_loader.cpp:285
ERROR: Error loading resource: ''
   At: core/bind/core_bind.cpp:79
ERROR: : Unhandled Nim exception (NilAccessError):
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
[[reraised from:
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
]]
[[reraised from:
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
]]
[[reraised from:
godotmacros.nim(611)     methFunc
node.nim(54)             input
mainpanel.nim(19)        input
packed_scene.nim(74)     instance
godotnim.nim(485)        godotObject
]]

   At: ..\..\..\..\..\.nimble\pkgs\godot-0.7.19\nim\godotmacros.nim:582

Sorry for the lengthly log this is what the godot console gives me.

@adrianperreault
Copy link

adrianperreault commented Mar 26, 2019

Using Godot 3.1, latest devel, I had the same issue as @zetashift when attempting to switch scenes.

I accidentally fixed it by adding:
echo(repr self) echo(repr argToPassToGodot1)

to the load() proc in _godotapi/resource_loader.nim

resource_loader.nim

proc load(path: string; typeHint: string = ""; noCache: bool = false): Resource =

  if isNil(singletonResourceLoader):
    singletonResourceLoader = getSingleton[ResourceLoader]()
  let self = singletonResourceLoader
  if isNil(resourceLoaderLoadMethodBind):
    resourceLoaderLoadMethodBind = getMethod(cstring"_ResourceLoader",
        cstring"load")
  var
    argsStatic: array[2, pointer]
    argsToPassToGodot = cast[ptr array[MAX_ARG_COUNT, pointer]](argsStatic.addr)
  var argToPassToGodot0 = toGodotString(path)
  argsToPassToGodot[][0] = unsafeAddr(argToPassToGodot0)
  var argToPassToGodot1 = toGodotString(typeHint)
  argsToPassToGodot[][1] = unsafeAddr(argToPassToGodot1)
  argsToPassToGodot[][2] = unsafeAddr(noCache)

  ################ Fixed Issue ???
  echo(repr self)
  echo(repr argToPassToGodot1)
  #################

  var ptrCallRet: pointer
  var ptrCallVal: ptr GodotObject
  ptrCallRet = addr(ptrCallVal)
  resourceLoaderLoadMethodBind.ptrCall(self.godotObject, argsToPassToGodot,
                                       ptrCallRet)
  deinit(argToPassToGodot0)
  deinit(argToPassToGodot1)
  result = asNimGodotObject[type(result)](ptrCallVal, false, true)

var resourceLoaderGetRecognizedExtensionsForTypeMethodBind {.threadvar.}: ptr GodotMethodBind

One quick question: I'm able to connect to the built in object signals such as "mouse_entered" etc. by manually setting them in the node tab in the editor. But, when I try doing it in code with something like:

    method ready*() =
        setProcess(true)
        btn = getNode("ActiveScene/btn").as(Button)
        discard btn.connect("pressed", self, "on_btn_pressed", newArray())

I get a runtime crash:

ERROR: NetSocketPosix::_get_socket_error: Socket error: 10054
   At: drivers\unix\net_socket_posix.cpp:190

Is there a correct way to connect to non-user signals in code?

All in all, @endragor, thank you greatly for these amazing bindings! : )

Edit: There seems to have been an off-by-one error in the bindings generator for the var argsStatic: array[*number*, pointer] portion of godotapigen.nim's doGenerateMethod proc... Setting the correct array count in var argsStatic: array[*number*, pointer] in load() proc in _godotapi/resource_loader.nim:

  var
    argsStatic: array[3, pointer]

or, in connect() proc in _godotapi/objects.nim:

  var
    argsStatic: array[5, pointer]

fixes the scene loading bug @zetashift had, as well as that signal connecting issue I had.

@adrianperreault adrianperreault mentioned this pull request Mar 26, 2019
@@ -450,13 +456,13 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string],
ident("array"), ident("MAX_ARG_COUNT"),
if isVarargs: newNode(nkPtrTy).addChain(ident("GodotVariant"))
else: ident("pointer"))))
staticArgsLen = if varargsName.isNil: meth.args.len
staticArgsLen = if varargsName.isSome: meth.args.len
Copy link

@adrianperreault adrianperreault Mar 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? Should it be if varargsName.isNone?

@zetashift
Copy link
Contributor

it's working now too, not sure why the bindings generate this :(.
After changings the argsStatic I can run godot-nim on godot 3.1,
This PR : godotengine/godot#27320 should also make it work again without having to restart the editor

Small changes to add 0.18.0 compatibility
@zetashift
Copy link
Contributor

@endragor do you have any idea on the off-by-one error?

@adrianperreault
Copy link

@zetashift Have you tried a clean rebuild? nake clean nake build?
With a fresh clone, latest changes the argStatic off-by-one issue went away for me.

@zetashift
Copy link
Contributor

@adrianperreault yep works fine for me too now with a fresh install.
@endragor sorry for the ping, anything left to do?

@zetashift
Copy link
Contributor

zetashift commented May 12, 2019

Currently the only annoying thing is the {.this: } pragma is deprecated warning. Any idea how we can fix this? I'm really not that good with macro heavy code :S.

Edit: https://github.com/pragmagic/godot-nim/blob/master/godot/nim/godotmacros.nim#L487 seems I should look here?

@endragor
Copy link
Member

Latest Nim support is added in v0.7.21.

@endragor endragor closed this Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nim 0.19
7 participants