From: Brad Medeiros <bradmedeiros0@gmail.com>
To: guile-user@gnu.org
Subject: Passing in data to a function defined with scm_c_define_gsubr
Date: Thu, 12 Aug 2021 22:26:47 -0700 [thread overview]
Message-ID: <CAMnXraQJcwZaRYiWa83NfHpYQZjVaP96MzJUO0F3vL+bfbUbjA@mail.gmail.com> (raw)
Hello everyone!
In short, I'm asking if there is a way to pass some sort of additional
void* to a function defined with scm_c_define_gsubr (or another equivalent
fn call that has the same behavior) so I can retrieve data that will
resolve a unique id, but more context below.
I am currently using guile in a game engine as a way to script different
objects. In doing so, I end up dynamically creating modules, and defining
functions with scm_c_define_gsubr. I need a way to determine a unique id
associated with the gameobject to which the function is associated with.
Currently what I'm doing to resolve this is by calling scm_current_module. This
had been working for me, but I realized my implementation is wrong.
While in practice this has been ok because I had been calling these
functions after I had set the module (in the body of a callback). However,
I realize that this does not generally work, because in practice I
sometimes will call these functions in other contexts when the current
module is not currently bound. I have some links to my actual usage of
source code if this is helpful. Binding for fns:
https://github.com/BradfordMedeiros/ModEngine/blob/master/src/scheme/scheme_bindings.cpp#L737
Conceptual usage of trying to associate the fn call with a scene id:
https://github.com/BradfordMedeiros/ModEngine/blob/master/src/scheme/scheme_bindings.cpp#L87
Currently flawed way I'm resolving the id of that scene:
https://github.com/BradfordMedeiros/ModEngine/blob/master/src/scheme/scriptmanager.cpp#L18
reply other threads:[~2021-08-13 5:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMnXraQJcwZaRYiWa83NfHpYQZjVaP96MzJUO0F3vL+bfbUbjA@mail.gmail.com \
--to=bradmedeiros0@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).