From 571585c0d64c4b9884091e4957d2fc67efee0d0c Mon Sep 17 00:00:00 2001 From: Emmanuel Rodriguez Date: Sun, 10 May 2009 22:53:30 +0200 Subject: [PATCH] Implement champlain_map_source_factory_register() (constructor callback is missing) Fix the checks for the keys in SvChamplainMapSourceDesc(). --- .../Champlain/xs/ChamplainMapSourceFactory.xs | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs b/bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs index 5befcd2..3b64c0b 100644 --- a/bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs +++ b/bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs @@ -56,8 +56,7 @@ SvChamplainMapSourceDesc (SV *data) { * - filename */ desc = g_new0(ChamplainMapSourceDesc, 1); - - if (! ((s = hv_fetch(hash, "id", 2, 0)) && SvOK(*s))) { + if ((s = hv_fetch(hash, "id", 2, 0)) && SvOK(*s)) { desc->id = SvGChar(*s); } else { @@ -65,7 +64,7 @@ SvChamplainMapSourceDesc (SV *data) { croak("SvChamplainMapSourceDesc: requires the key: 'id'"); } - if (! ((s = hv_fetch(hash, "name", 4, 0)) && SvOK(*s))) { + if ((s = hv_fetch(hash, "name", 4, 0)) && SvOK(*s)) { desc->name = SvGChar(*s); } else { @@ -73,7 +72,7 @@ SvChamplainMapSourceDesc (SV *data) { croak("SvChamplainMapSourceDesc: requires the key: 'name'"); } - if (! ((s = hv_fetch(hash, "license", 7, 0)) && SvOK(*s))) { + if ((s = hv_fetch(hash, "license", 7, 0)) && SvOK(*s)) { desc->license = SvGChar(*s); } else { @@ -81,7 +80,7 @@ SvChamplainMapSourceDesc (SV *data) { croak("SvChamplainMapSourceDesc: requires the key: 'license'"); } - if (! ((s = hv_fetch(hash, "license_uri", 11, 0)) && SvOK(*s))) { + if ((s = hv_fetch(hash, "license_uri", 11, 0)) && SvOK(*s)) { desc->license_uri = SvGChar(*s); } else { @@ -89,7 +88,7 @@ SvChamplainMapSourceDesc (SV *data) { croak("SvChamplainMapSourceDesc: requires the key: 'license_uri'"); } - if (! ((s = hv_fetch(hash, "min_zoom_level", 14, 0)) && SvOK(*s))) { + if ((s = hv_fetch(hash, "min_zoom_level", 14, 0)) && SvOK(*s)) { desc->min_zoom_level = (gint)SvIV(*s); } else { @@ -97,7 +96,7 @@ SvChamplainMapSourceDesc (SV *data) { croak("SvChamplainMapSourceDesc: requires the key: 'min_zoom_level'"); } - if (! ((s = hv_fetch(hash, "max_zoom_level", 14, 0)) && SvOK(*s))) { + if ((s = hv_fetch(hash, "max_zoom_level", 14, 0)) && SvOK(*s)) { desc->max_zoom_level = (gint)SvIV(*s); } else { @@ -105,7 +104,7 @@ SvChamplainMapSourceDesc (SV *data) { croak("SvChamplainMapSourceDesc: requires the key: 'max_zoom_level'"); } - if (! ((s = hv_fetch(hash, "projection", 10, 0)) && SvOK(*s))) { + if ((s = hv_fetch(hash, "projection", 10, 0)) && SvOK(*s)) { desc->projection = SvChamplainMapProjection(*s); } else { @@ -146,8 +145,19 @@ ChamplainMapSource* champlain_map_source_factory_create (ChamplainMapSourceFactory *factory, const gchar *id) -#gboolean -#champlain_map_source_factory_register (ChamplainMapSourceFactory *factory, const gchar *id, ChamplainMapSourceConstructor callback) +gboolean +champlain_map_source_factory_register (ChamplainMapSourceFactory *factory, SV *data) + PREINIT: + ChamplainMapSourceDesc *desc = NULL; + SV *sv = NULL; + + CODE: + + desc = SvChamplainMapSourceDesc(data); + RETVAL = champlain_map_source_factory_register(factory, desc); + + OUTPUT: + RETVAL const gchar* -- 2.39.5