GNOME Bugzilla – Bug 510235
glib GChecksum binding
Last modified: 2008-01-20 17:54:13 UTC
I have attached a patch which includes following changes: 1. Modified glib_function.def 2. Modified glib_enum.def 3. Modified Makefile_list_of_hg.am_fragment 4. New added checksum.hg 5. New added checksum.ccg Could anyone please check, review it and let me any problem in patch or in code.
Created attachment 103078 [details] [review] GChecksum binding patch
You have not used any _CLASS_* method, or any _WRAP_METHOD(). I don't know why. Thanks, but I will probably just do this myself some time.
(In reply to comment #2) > You have not used any _CLASS_* method, or any _WRAP_METHOD(). I don't know why. > Thanks, but I will probably just do this myself some time. > I have used _WRAP_METHOD() for a few functions like update() and get_string(). But for some reason these functions did not get added in the generated code(.h, .cc), then I change them as normal function definitions. I would really like to know the reason why it did not work for me. So that I can take care about it later.
Created attachment 103141 [details] [review] Updated patch for checksum This time i have used _CLASS_* and WRAP_METHOD macro. Which remove much of hand written code. The only one thing i did not understand how to make a conversion of any datatype if it is not already defined using _CONVERSION(). In checksum class if we define two conversion macro one from Checksum to GChecksum and another from const glib::ustring to const guchar* then we can define more functions my using WRAP_METHOD macro.
(In reply to comment #4) > Created an attachment (id=103141) [edit] > Updated patch for checksum > > This time i have used _CLASS_* and WRAP_METHOD macro. Which remove much of hand > written code. Great. That's much better. But I think you can probably use _WRAP_METHOD() for those static functions too. > The only one thing i did not understand how to make a conversion of any > datatype if it is not already defined using _CONVERSION(). > In checksum class if we define two conversion macro one from Checksum to > GChecksum > and another from const glib::ustring to const guchar* then we can define more > functions my using WRAP_METHOD macro. You can add a _CONVERSION line in one of the tools/m4/convert_*.m4 files.
(In reply to comment #5) > (In reply to comment #4) > > Created an attachment (id=103141) [edit] > > Updated patch for checksum > > > > This time i have used _CLASS_* and WRAP_METHOD macro. Which remove much of hand > > written code. > > Great. That's much better. But I think you can probably use _WRAP_METHOD() for > those static functions too. Yes you are write that one thing can be done after define _CONVERSION macro for conversion from ChecksumType to GChecksumType as I stated in last message. I have got some suggestion how to create _CONVERSION macro one from you also in this message. I am looking into that. Soon I will add another patch with changes. > > > The only one thing i did not understand how to make a conversion of any > > datatype if it is not already defined using _CONVERSION(). > > In checksum class if we define two conversion macro one from Checksum to > > GChecksum > > and another from const glib::ustring to const guchar* then we can define more > > functions my using WRAP_METHOD macro. > > You can add a _CONVERSION line in one of the tools/m4/convert_*.m4 files. >
Created attachment 103163 [details] [review] Convert all the static function with _WRAP_METHOD Now I have generated almost all the functions(including static) using _WRAP_METHOD, except one static function get_length and one constructor, because generated code does not work as per expected. I have give reason in comment section of .hg file.
Created attachment 103164 [details] [review] Added some more conversion macro Added some more conversion macro to be used in checksum _WRAP_METHOD macros.
That's much better. Committed with some minor changes: - Made get functions const. - Don't return const std::string or const Glib::ustring because that's meaningless. - Corrected the whitespace formatting to be the same as the other .hg files. - Removed the vim formatting comments. - used @newin2p16 instead of "Since: 2.16". - Don't put implemenation comments ("Unable to use _WRAP_CTOR generate code did not get compiled.") in reference documentation. (/** or /// comments) - Don't write reference documentation when using _WRAP_METHOD() because gmmproc will build it automatically from the C documentation. Later I will regenerate the .xml to make this work. - Added methods that take guchar*, instead of std::string, because not all data will be a string. - Used std::string instead of Glib::ustring because it is data of unknown encoding. Please try to submit all changes as one patch in future - you can just replace the existing patch. Thanks for your help and thanks for learning so well. If you'd like to do more, do take a look at the open bugs or look through glibmm for other (useful to C++) API that has not been wrapped. There's similar work in gtkmm or other newer *mm libraries such as cluttermm or gstreamermm.
Also, please don't forget to patch the ChangeLog in future.