SimulaVR / godot-haskell

Haskell bindings for GdNative
BSD 3-Clause "New" or "Revised" License
167 stars 16 forks source link

Trouble registering signals #25

Closed georgewsinger closed 4 years ago

georgewsinger commented 4 years ago

Adding dummy signals to godot-haskell/template/demo/src/Lib.hs:

instance NativeScript Main where
  classInit base = Main base <$> newTVarIO 0
  classMethods =
    [ func NoRPC "_process" $
        \self [deltaVt] -> do
          delta <- fromGodotVariant deltaVt
          (sec, sec') <- atomically $ do
            t <- readTVar (_mTime self)
            let t' = t + delta
            writeTVar (_mTime self) t'
            return (floor t, floor t') :: STM (Int, Int)
          when (sec < sec') $
            "Seconds passed: " ++ Prelude.show sec'
              & T.pack
              & (toLowLevel :: Text -> IO GodotString)
              >>= Api.godot_print
    ]
  -- Dummy signals:
  classSignals = [ signal "map" [("gsvs", GodotVariantTypeObject)]
                 , signal "unmap" [("gsvs", GodotVariantTypeObject)]
                 ]

yields (similar to the errors we're receiving right now in Simula):

OpenGL ES 3.0 Renderer: GeForce GTX 1070/PCIe/SSE2
Registering class Main
Registering method _process to class Main
ERROR: godot_nativescript_register_signal: Attempted to register method on non-existent class!
   At: modules/gdnative/nativescript/godot_nativescript.cpp:154.
Registering signal map to class Main
ERROR: godot_nativescript_register_signal: Attempted to register method on non-existent class!
   At: modules/gdnative/nativescript/godot_nativescript.cpp:154.
Registering signal unmap to class Main
Haskell NativeScript lib initialized
Seconds passed: 1
Seconds passed: 2

Is this a signal registering bug in godot-haskell?

georgewsinger commented 4 years ago

:heavy_check_mark: Fixed and pushed to master.