]> err.no Git - libchamplain/commitdiff
Champlain::MapSourceDesc is now a GBoxed type.
authorEmmanuel Rodriguez <emmanuel.rodriguez@gmail.com>
Sat, 13 Jun 2009 13:29:54 +0000 (15:29 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sun, 14 Jun 2009 15:11:16 +0000 (11:11 -0400)
This is supposed to make the bindings easier. This patch is still untested.

bindings/perl/Champlain/MANIFEST
bindings/perl/Champlain/champlain-perl.h
bindings/perl/Champlain/maps
bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs

index de10a6934f9d3f0a0477063ceb799e317172513c..fa990d367c23f01f9216b31bcdf30a0e4f6afe8a 100644 (file)
@@ -12,6 +12,7 @@ xs/ChamplainBaseMarker.xs
 xs/ChamplainCache.xs
 xs/ChamplainLayer.xs
 xs/ChamplainMapSource.xs
+xs/ChamplainMapSourceDesc.xs
 xs/ChamplainMapSourceFactory.xs
 xs/ChamplainMarker.xs
 xs/ChamplainNetworkMapSource.xs
index ff59278da2c3d4646261a0d4006133d3d5535c05..e571663cf2e3e8c70d970b1a2fc7660dcb544798 100644 (file)
 #endif
 
 
-/* Custom definitions for the bindings of Champlain::MapSourceDesc */
-typedef ChamplainMapSourceDesc ChamplainMapSourceDesc_ornull;
-
-SV* newSVChamplainMapSourceDesc (ChamplainMapSourceDesc *desc);
-ChamplainMapSourceDesc* SvChamplainMapSourceDesc (SV *data);
-
-#define SvChamplainMapSourceDesc_ornull(sv)  (gperl_sv_is_defined (sv) ? SvChamplainMapSourceDesc(sv) : NULL)
-#define newSVChamplainMapSourceDesc_ornull(val)  (((val) == NULL) ? &PL_sv_undef : newSVChamplainMapSourceDesc(val))
-
-
 #include "champlain-autogen.h"
 
 #endif /* _CHAMPLAIN_PERL_H_ */
index 151334e82318bc80595e3231154b44e16e229bf8..aaf00ccd66cf194b907931cac45dea9a5e9fff7b 100644 (file)
@@ -11,3 +11,4 @@ CHAMPLAIN_TYPE_MAP_PROJECTION      ChamplainMapProjection     GEnum    Champlain
 CHAMPLAIN_TYPE_STATE               ChamplainState             GEnum    Champlain::State
 CHAMPLAIN_TYPE_MAP_SOURCE_FACTORY  ChamplainMapSourceFactory  GObject  Champlain::MapSourceFactory
 CHAMPLAIN_TYPE_CACHE               ChamplainCache             GObject  Champlain::Cache
+CHAMPLAIN_TYPE_MAP_SOURCE_DESC     ChamplainMapSourceDesc     GBoxed   Champlain::MapSourceDesc
index 3cc403e4921dbcf7b77ffd7345e9287f080258d0..61b1a0be39d18fbee85ace4f3911e43b43867f43 100644 (file)
@@ -44,86 +44,6 @@ fetch_or_croak (HV* hash , const char* key , I32 klen) {
 }
 
 
-SV*
-newSVChamplainMapSourceDesc (ChamplainMapSourceDesc *desc) {
-       HV *hash = NULL;
-       SV *sv = NULL;
-       HV *stash = NULL;
-       
-       if (desc == NULL) {
-               return &PL_sv_undef;
-       }
-       
-       hash = newHV();
-       sv = newRV_noinc((SV *) hash);
-       
-       /* Copy the data members of the struct into the hash */
-       hv_store(hash, "id", 2, newSVGChar(desc->id), 0);
-       hv_store(hash, "name", 4, newSVGChar(desc->name), 0);
-       hv_store(hash, "license", 7, newSVGChar(desc->license), 0);
-       hv_store(hash, "license_uri", 11, newSVGChar(desc->license_uri), 0);
-       hv_store(hash, "min_zoom_level", 14, newSViv(desc->min_zoom_level), 0);
-       hv_store(hash, "max_zoom_level", 14, newSViv(desc->max_zoom_level), 0);
-       hv_store(hash, "projection", 10, newSVChamplainMapProjection(desc->projection), 0);
-
-       /*
-          This is tricky as we have to wrap the C callback into a Perl sub.
-          hv_store(hash, "constructor", 11, newSVChamplainMapProjection(desc->projection), 0);
-       */
-       
-       /* Bless this stuff */
-       stash = gv_stashpv("Champlain::MapSourceDesc", TRUE);
-       sv_bless(sv, stash);
-       
-       return sv;
-}
-
-
-ChamplainMapSourceDesc*
-SvChamplainMapSourceDesc (SV *data) {
-       HV *hash;
-       SV *value;
-       ChamplainMapSourceDesc desc = {0,};
-
-       if ((!data) || (!SvOK(data)) || (!SvRV(data)) || (SvTYPE(SvRV(data)) != SVt_PVHV)) {
-               croak("SvChamplainMapSourceDesc: value must be an hashref");
-       }
-
-       hash = (HV *) SvRV(data);
-       
-       /* All keys are mandatory */
-       if (value = fetch_or_croak(hash, "id", 2)) {
-               desc.id = g_strdup(SvGChar(value));
-       }
-       
-       if (value = fetch_or_croak(hash, "name", 4)) {
-               desc.name = g_strdup(SvGChar(value));
-       }
-       
-       if (value = fetch_or_croak(hash, "license", 7)) {
-               desc.license = g_strdup(SvGChar(value));
-       }
-       
-       if (value = fetch_or_croak(hash, "license_uri", 11)) {
-               desc.license_uri = g_strdup(SvGChar(value));
-       }
-       
-       if (value = fetch_or_croak(hash, "min_zoom_level", 14)) {
-               desc.min_zoom_level = (gint)SvIV(value);
-       }
-       
-       if (value = fetch_or_croak(hash, "max_zoom_level", 14)) {
-               desc.max_zoom_level = (gint)SvIV(value);
-       }
-       
-       if (value = fetch_or_croak(hash, "projection", 10)) {
-               desc.projection = SvChamplainMapProjection(value);
-       }
-
-       return g_memdup(&desc, sizeof(desc));
-}
-
-
 MODULE = Champlain::MapSourceFactory  PACKAGE = Champlain::MapSourceFactory  PREFIX = champlain_map_source_factory_