From: Emmanuel Rodriguez Date: Sat, 16 May 2009 20:08:20 +0000 (+0200) Subject: Add the VERSION macros X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01f18b493afaf6bcdbbdc05d8969c38f4e593913;p=libchamplain Add the VERSION macros - MAJOR_VERSION, MINOR_VERSION and MICRO_VERSION - CHECK_VERSION - GET_VERSION_INFO --- diff --git a/bindings/perl/Champlain/t/Champlain.t b/bindings/perl/Champlain/t/Champlain.t index c84c16a..23da614 100644 --- a/bindings/perl/Champlain/t/Champlain.t +++ b/bindings/perl/Champlain/t/Champlain.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Clutter::TestHelper tests => 5; +use Clutter::TestHelper tests => 11; use Champlain ':coords'; @@ -18,6 +18,21 @@ sub tests { sub test_version { ok($Champlain::VERSION, "Library loaded"); + + ok(defined Champlain::MAJOR_VERSION, "MAJOR_VERSION exists"); + ok(defined Champlain::MINOR_VERSION, "MINOR_VERSION exists"); + ok(defined Champlain::MICRO_VERSION, "MICRO_VERSION exists"); + + ok (Champlain->CHECK_VERSION(0,0,0), "CHECK_VERSION pass"); + ok (!Champlain->CHECK_VERSION(50,0,0), "CHECK_VERSION fail"); + + my @version = Champlain->GET_VERSION_INFO; + my @expected = ( + Champlain::MAJOR_VERSION, + Champlain::MINOR_VERSION, + Champlain::MICRO_VERSION, + ); + is_deeply(\@version, \@expected, "GET_VERSION_INFO"); } diff --git a/bindings/perl/Champlain/xs/Champlain.xs b/bindings/perl/Champlain/xs/Champlain.xs index aeb323a..b677907 100644 --- a/bindings/perl/Champlain/xs/Champlain.xs +++ b/bindings/perl/Champlain/xs/Champlain.xs @@ -8,3 +8,48 @@ BOOT: #include "register.xsh" #include "boot.xsh" + +guint +MAJOR_VERSION () + CODE: + RETVAL = CHAMPLAIN_MAJOR_VERSION; + + OUTPUT: + RETVAL + + +guint +MINOR_VERSION () + CODE: + RETVAL = CHAMPLAIN_MINOR_VERSION; + + OUTPUT: + RETVAL + + +guint +MICRO_VERSION () + CODE: + RETVAL = CHAMPLAIN_MICRO_VERSION; + + OUTPUT: + RETVAL + + +void +GET_VERSION_INFO (class) + PPCODE: + EXTEND (SP, 3); + PUSHs (sv_2mortal (newSViv (CHAMPLAIN_MAJOR_VERSION))); + PUSHs (sv_2mortal (newSViv (CHAMPLAIN_MINOR_VERSION))); + PUSHs (sv_2mortal (newSViv (CHAMPLAIN_MICRO_VERSION))); + PERL_UNUSED_VAR (ax); + + +gboolean +CHECK_VERSION (class, int major, int minor, int micro) + CODE: + RETVAL = CHAMPLAIN_CHECK_VERSION (major, minor, micro); + + OUTPUT: + RETVAL