Re: [Vala] Gcrypt bindings



On Sun, 2008-10-19 at 20:51 +0200, Jiqing Qiang wrote:
   Thanks for your input. Concerning the problem you mentioned, I'm
aware of it, but I don't really know how to write it in a better way,
suggestions are welcome.

Vala is pretty flexible when it comes to boxing existing C code into a
vala model. You don't necessarily need a 1-1 name mapping between
namespaces, enums/classes etc. Although it's probably advisable to let
the compiler do this for you when you write vala code. The vala api
files are merely a blueprint of this model you want to use and if it
doesn't fit exactly with the C names, you can override them in the
attributes.
So you could have something like:

namespace GCrypt {
        public enum CipherAlgorithm {
        }
        public class Cipher {
        }
        public enum HashAlgorithm {
        }
        public class Hash {
        }
}

or even:

namespace GCrypt {
        public class Cipher {   
                public enum Algorithm {
                }
        }
        public class Hash {
                public enum Algorithm {
                }
        }
}

I haven't fully checked your vapi file but I had to add cname = "struct
gcry_cipher_handle", free_function = "gcry_cipher_close" for the Cipher
class (gcry_cipher_hd_t is a handle typedef for struct
gcry_cipher_handle*).

Regards,
Hans




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