[libchamplain] Champlain::MapSourceDesc is now a GBoxed type.



commit e718e74988637c58234238707b17ec611267a5b8
Author: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
Date:   Sat Jun 13 15:29:54 2009 +0200

    Champlain::MapSourceDesc is now a GBoxed type.
    
    This is supposed to make the bindings easier. This patch is still untested.

 bindings/perl/Champlain/MANIFEST                   |    1 +
 bindings/perl/Champlain/champlain-perl.h           |   10 ---
 bindings/perl/Champlain/maps                       |    1 +
 .../perl/Champlain/xs/ChamplainMapSourceFactory.xs |   80 --------------------
 4 files changed, 2 insertions(+), 90 deletions(-)
---
diff --git a/bindings/perl/Champlain/MANIFEST b/bindings/perl/Champlain/MANIFEST
index de10a69..fa990d3 100644
--- a/bindings/perl/Champlain/MANIFEST
+++ b/bindings/perl/Champlain/MANIFEST
@@ -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
diff --git a/bindings/perl/Champlain/champlain-perl.h b/bindings/perl/Champlain/champlain-perl.h
index ff59278..e571663 100644
--- a/bindings/perl/Champlain/champlain-perl.h
+++ b/bindings/perl/Champlain/champlain-perl.h
@@ -11,16 +11,6 @@
 #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_ */
diff --git a/bindings/perl/Champlain/maps b/bindings/perl/Champlain/maps
index 151334e..aaf00cc 100644
--- a/bindings/perl/Champlain/maps
+++ b/bindings/perl/Champlain/maps
@@ -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
diff --git a/bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs b/bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs
index 3cc403e..61b1a0b 100644
--- a/bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs
+++ b/bindings/perl/Champlain/xs/ChamplainMapSourceFactory.xs
@@ -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_
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]