Gimp

 view release on metacpan or  search on metacpan

lib/Gimp/Net.xs  view on Meta::CPAN


            cv = hv_fetch (object_cache, (char *)(id=l,&id), sizeof(id), 0);
            if (!cv)
              croak ("Internal error: asked to deobjectify an object not in the cache, please report!");

            sv = *cv;
            SvREFCNT_inc (sv);
          }
        else
          sv = sv_bless (newRV_noinc (net2sv (objectify, &s)), gv_stashpv (str, 1));

        break;

      case 'a':
        sscanf (s, "%x:%n", &i, &n); s += n;
        av = newAV ();
        av_extend (av, (I32)i);
        for (j = 0; j <= i; j++)
          av_store (av, (I32)j, net2sv (objectify, &s));

        sv = (SV*)av;
        break;

      default:
        croak ("Internal error: unable to handle argtype '%c' in net2sv, please report!", s[-1]);
    }

  *_s = s;
  return sv;
}

MODULE = Gimp::Net	PACKAGE = Gimp::Net

PROTOTYPES: ENABLE

BOOT:
#ifdef ENABLE_NLS
        setlocale (LC_ALL, "");
#endif

SV *
args2net(deobjectify,...)
int deobjectify
CODE:
  int index;
  char* previous_locale = setlocale(LC_NUMERIC, "C");
  if (deobjectify) init_object_cache;
  RETVAL = newSVpv ("", 0);
  (void) SvUPGRADE (RETVAL, SVt_PV);
  SvGROW (RETVAL, INITIAL_PV);
  for (index = 1; index < items; index++)
    sv2net (deobjectify, RETVAL, ST(index));
  setlocale(LC_NUMERIC, previous_locale);
OUTPUT:
  RETVAL

void
net2args(objectify,s)
int	objectify
char *	s
PPCODE:
  if (objectify) init_object_cache;
  /* this depends on a trailing zero! */
  char* previous_locale = setlocale(LC_NUMERIC, "C");
  while (*s)
    {
      SV *sv;
      PUTBACK; // this is necessary due to eval_pv in net2sv
      sv = net2sv (objectify, &s);
      SPAGAIN; // works without, but recommended by perl expert - leaving in
      XPUSHs (sv_2mortal (sv));
    }
  setlocale(LC_NUMERIC, previous_locale);

void
destroy_objects(...)
CODE:
  int index;
  for (index = 0; index < items; index++)
    destroy_object (ST(index));



( run in 0.672 second using v1.01-cache-2.11-cpan-5511b514fd6 )