cimgui / cimnodes

C wrapping of https://github.com/Nelarius/imnodes
29 stars 16 forks source link

Why there is no ImNodesContext type in structs_and_enums.json? #7

Open gucio321 opened 1 year ago

gucio321 commented 1 year ago

after a quick look at code I suppose that imnodes_internal.h support is missing

sonoro1234 commented 1 year ago

Yes

gucio321 commented 1 year ago

Ok, are there any plans to fix this? I'd love to contribute but unfortunately I have absolutely no experience with lua.

sonoro1234 commented 1 year ago

It is no fix but enhancement. I can check it but imnodes seems abandoned.

Which is the use of ImNodesContext that you need? With imnodes.h you have the declaration as an opaque type.

gucio321 commented 1 year ago

We need this structure to be in json file in cimgui-go, because we can't generate wrapper for functions like CreateContext -essential to use the library

sonoro1234 commented 1 year ago

As CreateContext is returning a pointer to ImNodesContext (ImNodesContext ) you should not need the detailed structure of ImNodesContext. It could even be defined as a `void `. Whatever is returned by imnodes_CreateContext can be used in imnodes_SetCurrentContext or imnodes_DestroyContext without knowing the specific ImNodesContext structure.

An opaque type is a type which is exposed in APIs via a pointer but never concretely defined.

In typedefs_dict.json you will see "ImGuiContext": "struct ImGuiContext", which in C is typedef struct ImNodesContext ImNodesContext; where ImNodesContext is an opaque struct. You cant use ImNodesContext but you can use ImNodesContext *

gucio321 commented 1 year ago

yes, but there are three problems:

It'd be the best solution for us (if possible) to implement solution already present in cimgui - add cimnodes_internal to generator

sonoro1234 commented 1 year ago

If you know any GLFW wrapping in go, you could look how is handled in:

GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);

https://www.glfw.org/docs/3.3/window_guide.html#window_object

https://github.com/go-gl/glfw is one of them.

gucio321 commented 1 year ago

Well, i Knorr about this method am theoretically i could do it this way, but (as mentioned above) handling pointers is not the reason why i need nodesContext in structs_and_enums.json We also need to generate setters/getters for fields of this structure so that our users could obtain some days about this context.

sonoro1234 commented 1 year ago

generate setters/getters for fields of this structure

When a structure is opaque it is usually for avoiding this. Which fields would be interesting to get/set and what for?

gucio321 commented 1 year ago

When a structure is opaque it is usually for avoiding this.

I see. However cimgui allows generating these types when internal specified... What we need is a compatibility between cimgui and other wrappers because so that our generator could work as expected. Also I can't say which exactly field of ImNodesContext our users may need, however because of GO's types privacy, they wouldn't be able to access these fields anyhow (when they theoritically could if they used C++ code by #include "imnodes_internal.h")