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 722067 - Add ABS() function for short type
Add ABS() function for short type
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings: GLib
0.23.x
Other Linux
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2014-01-12 23:55 UTC by oliver.steven
Modified: 2014-01-16 22:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to add ABS function to short type (768 bytes, patch)
2014-01-12 23:55 UTC, oliver.steven
none Details | Review
Add ABS function to short type (728 bytes, patch)
2014-01-13 00:26 UTC, oliver.steven
none Details | Review
Add ABS function to short type (728 bytes, patch)
2014-01-14 01:43 UTC, oliver.steven
none Details | Review
Add ABS function to short type (697 bytes, patch)
2014-01-14 01:45 UTC, oliver.steven
none Details | Review

Description oliver.steven 2014-01-12 23:55:33 UTC
Created attachment 266086 [details] [review]
Patch to add ABS function to short type

The summary really says it all. This did involve a small amount of C code though.
Comment 1 oliver.steven 2014-01-12 23:57:23 UTC
See the following mailing list message for inspiration:

https://mail.gnome.org/archives/vala-list/2013-December/msg00024.html
Comment 2 Luca Bruno 2014-01-13 00:12:49 UTC
Sorry but, is it really necessary to use fabs? I guess converting to int would be easier no?
Comment 3 Luca Bruno 2014-01-13 00:13:22 UTC
Also, you should be able to directly use the int abs like this:

[CCode (cname = "abs", cheader_filename = "stdlib.h")]
public short abs ();
Comment 4 oliver.steven 2014-01-13 00:15:40 UTC
(In reply to comment #2)
> Sorry but, is it really necessary to use fabs? I guess converting to int would
> be easier no?

Now that I look again, yes, that would probably be better. I'll update the patch.
Comment 5 oliver.steven 2014-01-13 00:26:16 UTC
Created attachment 266087 [details] [review]
Add ABS function to short type

Updated based on comments from Luca Bruno
Comment 6 Luca Bruno 2014-01-13 19:12:59 UTC
What's the problem in doing straight:
[CCode (cname = "abs", cheader_filename = "stdlib.h")]
public short abs ();
Comment 7 oliver.steven 2014-01-13 19:17:22 UTC
Ah! Because I didn't fully understand what you meant in Comment 3.
Comment 8 oliver.steven 2014-01-14 01:43:47 UTC
Created attachment 266221 [details] [review]
Add ABS function to short type
Comment 9 oliver.steven 2014-01-14 01:45:21 UTC
Created attachment 266222 [details] [review]
Add ABS function to short type
Comment 10 Luca Bruno 2014-01-16 21:44:49 UTC
commit 69ed59dc5b5b837eb0f6247e79c40817fd38051f
Author: Steven Oliver <oliver.steven@gmail.com>
Date:   Thu Jan 16 22:41:23 2014 +0100

    glib-2.0: Add abs() to short type
    
    Fixes bug 722067


Should not have been static. Anyway, I've fixed it for you.

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 11 oliver.steven 2014-01-16 22:16:25 UTC
Awesome! Thanks for quick resolution!