After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 510235 - glib GChecksum binding
glib GChecksum binding
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: general
2.4.x
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2008-01-17 17:47 UTC by Naveen Verma
Modified: 2008-01-20 17:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GChecksum binding patch (11.97 KB, patch)
2008-01-17 17:48 UTC, Naveen Verma
none Details | Review
Updated patch for checksum (11.14 KB, patch)
2008-01-18 13:59 UTC, Naveen Verma
none Details | Review
Convert all the static function with _WRAP_METHOD (8.95 KB, patch)
2008-01-18 20:18 UTC, Naveen Verma
none Details | Review
Added some more conversion macro (1.17 KB, patch)
2008-01-18 20:19 UTC, Naveen Verma
none Details | Review

Description Naveen Verma 2008-01-17 17:47:17 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.
Comment 1 Naveen Verma 2008-01-17 17:48:16 UTC
Created attachment 103078 [details] [review]
GChecksum binding patch
Comment 2 Murray Cumming 2008-01-17 18:14:58 UTC
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.
Comment 3 Naveen Verma 2008-01-17 18:48:18 UTC
(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.
Comment 4 Naveen Verma 2008-01-18 13:59:40 UTC
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.
Comment 5 Murray Cumming 2008-01-18 16:10:07 UTC
(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.

Comment 6 Naveen Verma 2008-01-18 17:01:58 UTC
(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.
> 

Comment 7 Naveen Verma 2008-01-18 20:18:27 UTC
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.
Comment 8 Naveen Verma 2008-01-18 20:19:37 UTC
Created attachment 103164 [details] [review]
Added some more conversion macro

Added some more conversion macro to be used in checksum _WRAP_METHOD macros.
Comment 9 Murray Cumming 2008-01-20 17:48:53 UTC
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.
Comment 10 Murray Cumming 2008-01-20 17:54:13 UTC
Also, please don't forget to patch the ChangeLog in future.