node-gir icon indicating copy to clipboard operation
node-gir copied to clipboard

Add support for arrays + INOUT arguments

Open Place1 opened this issue 6 years ago • 2 comments

Place1 avatar Jul 09 '18 09:07 Place1

@romgrk I'm struggling a little bit with INOUT arguments. You can see my approach in this PR.

I'm trying to encapsule the logic and memory management of IN/OUT args in a Parameter class similar to your approach in node-gtk. I'd love some tips of maybe even a breakdown of how it should work to get me over the last bump.

Place1 avatar Jul 09 '18 09:07 Place1

Do you have more specific questions? I see the general flow of the thing, but I'd need to understand the whole relevant parts of the codebase to spot specific bugs/issues.

General observations:

  • INOUT-arguments are similar to OUT-arguments in that you always need to add a level of indirection to them. In node-gtk, we first fill the GIArgument as for an IN-argument, then store that value in a pointer on the stack, then point the GIArgument to that stack-pointer.
  • You will eventually need a FreeGIArgument function, to deallocate any resources created during the function call. (for reference, here is PyGObject version: https://gitlab.gnome.org/GNOME/pygobject/blob/master/gi/pygi-argument.c#L1005-1271)
  • You're allocating your Out/In/InOutParameter instances on the heap. Function calling is a "hot" part of the bindings, if it's possible to do so you should use the stack only.

romgrk avatar Jul 09 '18 16:07 romgrk