Hi.

I have a situation with libgit2 where the function I need to call is a field in 
a struct (the field gets populated with different functions with the same 
signature depending on certain conditions).

I’m facing two problems now:
1. how do I define a function as the field type of an NBExternalStructure?
2. how can I call the function?

I’ve tried using callbacks as field types. That works as far as I can access 
the functions by pointer. But how would I then call that function?
I’ve looked at NBNativeFunction and NBNativeFunctionGen but I can’t see how I 
should use either of those to make a plain call.

Here’s a more precise description of my problem:

writepack := LG2GitOdbWritepackS new.
… “initialize the struct externally”

“now call the function ‘commit’ and pass the arguments (this is how I imagine 
it could work…)"
writepack commit
        value: writepack
        value: anotherStruct.


Needed struct fields:

backend:        git_odb_backend *
append:                 int (*)(git_odb_writepack *, const void *, size_t, 
git_transfer_progress *)
commit:                 int (*)(git_odb_writepack *, git_transfer_progress *)
free:                   void (*)(git_odb_writepack *)


My current (ad hoc) struct fields:

fieldsDesc
        ^#(
        LG2GitOdbO backend;
        LG2WritePackAppendCb append;
        LG2WritePackCommitCb commit;
        LG2WritePackFreeCb free;
        )


I’d even be happy if I have to implement a method on LG2GitOdbWritepackS for 
every function call (e.g. “writepack commit: arg1 and: arg2”) but how would I 
make the call?

Any ideas?
Max

Reply via email to