Skip to content

method assumes virtual methods always start with an underscore #87

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

Closed
geekrelief opened this issue Feb 3, 2021 · 3 comments · May be fixed by #88
Closed

method assumes virtual methods always start with an underscore #87

geekrelief opened this issue Feb 3, 2021 · 3 comments · May be fixed by #88

Comments

@geekrelief
Copy link
Contributor

Example:
EditorPlugin.has_main_screen is a virtual method, but does not have an underscore.
https://docs.godotengine.org/en/stable/classes/class_editorplugin.html#class-editorplugin-method-has-main-screen

method hasMainScreen():bool = true

use of method on a proc assumes it's virtual

isVirtual: meth.kind == nnkMethodDef,

and gdobj prepends an underscore to all method names.

let godotMethodName = if meth.isVirtual: "_" & toGodotStyle(meth.name)

As a work around to override the virtual function you declare it as proc with gdExport like:

proc hasMainScreen():bool {.gdExport.} =
  true
@endragor
Copy link
Member

endragor commented Feb 3, 2021

You can override the name selected by default, like this: {.gdExport: "has_main_screen".}.
methods are exported with _ prepended by default, because that's the convention Godot mostly follows itself. Yes, it's not always that way, and you can override it where needed. If not for this default, you'd have to do method process() {.gdExport: "_process".} everywhere, which is annoying.

@geekrelief
Copy link
Contributor Author

I just tried passing a param as you suggested, and it doesn't work. I must be missing something because I don't see where that's happening in godotmacros.nim. I see hint and hintStr using removeStrPragma to get the value, but gdExport is using removePragma:

let isGdExport = removePragma(nameNode, "gdExport")

let isGdExport = removePragma(meth, "gdExport")

@endragor
Copy link
Member

endragor commented Feb 3, 2021

Ah, maybe I confused this with another project. Well, then I think the way it's described in my previous comment is how this should be resolved.

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 a pull request may close this issue.

2 participants