ryobg / JContainers

JSON-based data structures for Papyrus - the TESV Skyrim SE scripting language
MIT License
107 stars 23 forks source link

How to use JFormDB_solveInt() from C++? #80

Closed Odie closed 3 years ago

Odie commented 3 years ago

Hi there!

I'm trying to call JFormDB_solveInt from C++ but am not entirely sure how I'm supposed to call it.

I'm setting up the function pointer like so:

SInt32(*JFormDB_solveInt)(void* domain, forms::form_ref_lightweight& f, const char* path, SInt32 defaultValue) = nullptr;
...
void SetupJCAPI(const jc::root_interface* root) {
...
   obtain_func(refl, "solveInt", "JFormDB", JFormDB_solveInt);
...
}

Not entirely sure if I'm getting the function signature right. In any case, I then proceeded to try to fetch an int like so:

JFormDB_solveInt(default_domain, collections::make_lightweight_form_ref(item->type, default_domain), "a_flag_name", 0);

The compiler was pretty unhappy about the default_domain that's been passed here. In my plugin, the domain is simply typed as a typeless pointer. However, make_lightweight_form tries to get at the ._form_watcher field.

https://github.com/ryobg/JContainers/blob/9920b7eb6e6ead25247b834b547cf4bca86d1d8b/src/JContainers/src/forms/form_observer.h#L228-L231

So... how do I actually go about calling this function?

Thanks!

Odie commented 3 years ago

Sorry, I really can't wrap my head around the c++ source. Will try to find another way to implement the feature I'm after.

Closing issue. =)