MMapDB

 view release on metacpan or  search on metacpan

MMapDB.xs  view on Meta::CPAN

# endif


MODULE = MMapDB		PACKAGE = MMapDB		

PROTOTYPES: DISABLED

void
index_lookup(I, ...)
    MMapDB I;
  PPCODE:
    if( expect_true(items>1) ) {
      UV pos=SvUV(ST(1));
      STRLEN keylen;
      char *datap, *intfmt, *keyp;
      SV **svp=av_fetch(I, MMDB_DATA, 0);
      void *strtbl, *found=0;
      UV dataend, dbfmt;
      int i, isidx=1;

      if( expect_false(!(svp && SvROK(*svp))) ) goto END;

MMapDB.xs  view on Meta::CPAN

	 * So it calls PUTPACK afterwards and we must return here
	 * to avoid the implicit PUTBACK that XS inserts. */
	return;
      }
    }
   END:

void
index_lookup_position(I, ...)
    MMapDB I;
  PPCODE:
    if( expect_true(items>1) ) {
      UV pos=SvUV(ST(1));
      STRLEN keylen;
      char *datap, *intfmt, *keyp;
      SV **svp=av_fetch(I, MMDB_DATA, 0);
      void *strtbl;
      UV dataend, dbfmt;
      int i, isidx=1;

      if( expect_false(!(svp && SvROK(*svp))) ) goto END;

MMapDB.xs  view on Meta::CPAN

	mPUSHu(L(intfmt[0],srch)(keyp, keylen, dbfmt, SvUTF8(ST(i)), datap+pos,
				 strtbl, dataend));
      }
    }
   END:

void
id_index_lookup(I, id)
    MMapDB I;
    UV id;
  PPCODE:
    {
      char *datap, *intfmt;
      UV pos;
      SV **svp=av_fetch(I, MMDB_DATA, 0);

      if( expect_true((svp && SvROK(*svp))) ) {
	datap=SvPV_nolen(SvRV(*svp));

	intfmt=SvPV_nolen(*av_fetch(I, MMDB_INTFMT, 0));
	pos=SvUV(*av_fetch(I, MMDB_IDIDX, 0));

MMapDB.xs  view on Meta::CPAN

	if( pos!=(UV)-1 ) {
	  /* EXTEND(SP,1); # not necessary there is already room for 2 items */
	  PUSHs(sv_2mortal(newSVuv(pos)));
	}
      }
    }

void
data_record(I, ...)
    MMapDB I;
  PPCODE:
    if( items>1 ) {
      int i;
      UV pos;
      char *datap, *intfmt;
      UV dataend, dbfmt;
      SV **svp=av_fetch(I, MMDB_DATA, 0);
      AV* av;
      void* strtbl;

      if( expect_true((svp && SvROK(*svp))) ) {

MMapDB.xs  view on Meta::CPAN

	  } else {
	    PUSHs(&PL_sv_undef);
	  }
	}
      }
    }

void
index_lookup_records(I, ...)
    MMapDB I;
  PPCODE:
    if( expect_true(items>1) ) {
      UV pos=SvUV(ST(1));
      STRLEN keylen;
      char *datap, *intfmt, *keyp;
      SV **svp=av_fetch(I, MMDB_DATA, 0);
      void *strtbl, *found=0;
      UV dataend, dbfmt;
      int i, isidx=1;

      if( expect_false(!(svp && SvROK(*svp))) ) goto END;

MMapDB.xs  view on Meta::CPAN

	 * So it calls PUTPACK afterwards and we must return here
	 * to avoid the implicit PUTBACK that XS inserts. */
	return;
      }
    }
   END:

void
data_value(I, ...)
    MMapDB I;
  PPCODE:
    if( items>1 ) {
      int i;
      UV pos;
      char *datap, *intfmt;
      UV dataend, dbfmt;
      SV **svp=av_fetch(I, MMDB_DATA, 0);
      SV* rsv;
      void* strtbl;

      if( expect_true((svp && SvROK(*svp))) ) {

MMapDB.xs  view on Meta::CPAN

	  } else {
	    PUSHs(&PL_sv_undef);
	  }
	}
      }
    }

void
index_lookup_values(I, ...)
    MMapDB I;
  PPCODE:
    if( expect_true(items>1) ) {
      UV pos=SvUV(ST(1));
      STRLEN keylen;
      char *datap, *intfmt, *keyp;
      SV **svp=av_fetch(I, MMDB_DATA, 0);
      void *strtbl, *found=0;
      UV dataend, dbfmt;
      int i, isidx=1;

      if( expect_false(!(svp && SvROK(*svp))) ) goto END;

MMapDB.xs  view on Meta::CPAN

	 * So it calls PUTPACK afterwards and we must return here
	 * to avoid the implicit PUTBACK that XS inserts. */
	return;
      }
    }
   END:

void
data_sort(I, ...)
    MMapDB I;
  PPCODE:
    if( items>1 ) {
      int i;
      UV pos;
      char *datap, *intfmt;
      UV dataend, dbfmt;
      SV **svp=av_fetch(I, MMDB_DATA, 0);
      SV* rsv;
      void* strtbl;

      if( expect_true((svp && SvROK(*svp))) ) {

MMapDB.xs  view on Meta::CPAN

	  } else {
	    PUSHs(&PL_sv_undef);
	  }
	}
      }
    }

void
index_lookup_sorts(I, ...)
    MMapDB I;
  PPCODE:
    if( expect_true(items>1) ) {
      UV pos=SvUV(ST(1));
      STRLEN keylen;
      char *datap, *intfmt, *keyp;
      SV **svp=av_fetch(I, MMDB_DATA, 0);
      void *strtbl, *found=0;
      UV dataend, dbfmt;
      int i, isidx=1;

      if( expect_false(!(svp && SvROK(*svp))) ) goto END;



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