}
-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_