[Vala] Creating bindings for Oracle OCI



Hi all --

I've decided I wanna try writing the Oracle OCI bindings for vala.. It's
probably way out of my league, but I'm gonna try anyway.. unfortunately,
I don't know C very well, so right out of the gates I'm stuck.. but I
think if I can get past this, I'm hoping with what I've already learned
plus this piece, perhaps I'll be able to do the rest.

What I'm doing is working from a sample oci program, trying to implement
just enough of the vapi to support the sample program.. then extend the
vapi further as I need it.

Here's what I'm working from, so far:

  OCIEnv*  env;
  r=OCIEnvCreate( &env, OCI_DEFAULT, 0, 0, 0, 0, 0, 0);

Here's my vapi:

[CCode (cheader_filename = "oci.h")]
namespace OCI {

  [CCode (cname = "OCIEnv")]
  public struct Environment { } 
  [CCode (cname = "OCIEnvCreate")]
  public int Create (
    void* env,
    Mode mode,
    void* (ctxp),
    void* malocfp,
    void* ralocfp,
    void* mfreefp,
    size_t xtramemsz,
    void** usrmempp 
  );

}

(I've got the Mode enum in place too.. just didn't include it here)

This is a blurb from the oci header:

sword OCIEnvCreate  ( OCIEnv        **envhpp, 
                      ub4           mode, 
                      const void   *ctxp, 
                      const void   *(*malocfp) 
                                    (void *ctxp, 
                                        size_t size), 
                      const void   *(*ralocfp) 
                                    (void *ctxp, 
                                       void *memptr, 
                                       size_t newsize), 
                      const void    (*mfreefp) 
                                    ( void *ctxp, 
                                       void *memptr))
                      size_t    xtramemsz,
                      void     **usrmempp );


And here's my vala test:

    OCI.Environment* env;
    var  rt = OCI.Create(&env,Mode.DEFAULT, 0, 0, 0, 0, 0, 0);

env, mode and xtramemsz seem to be working fine how they're defined in
the vapi.. it's the other 5 that I can't figure out. I believe malocfp,
ralocfp and mfreefp are callback functions, but with my lack of c
knowledge, I don't see how it should be ok to pass an int in the case of
the example. (0) If I redefine the inputs as int, everything compiles
fine but I'm guessing thats not correct and if I really did have a
callback function implemented, it would die a horrible death.. so I'd
like to get it right before continuing.

The error I'm getting is: 'Cannot convert from `int' to `void*'' and I
understand the error.. just don't know enough about it to avoid it.. no
pun intended..

SOO.. if someone would kindly give me a clue, I think armed with that
knowledge, I may actualy figure this out before too long.

Appreciate the help!

SMF 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]