typemap
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:6k
- # typemap for Perl 5 interface to Berkeley DB version 2 & 3
- #
- # SCCS: %I%, %G%
- #
- # written by Paul Marquess <Paul.Marquess@btinternet.com>
- #
- #################################### DB SECTION
- #
- #
- void * T_PV
- u_int T_U_INT
- u_int32_t T_U_INT
- const char * T_PV_NULL
- PV_or_NULL T_PV_NULL
- IO_or_NULL T_IO_NULL
- AV * T_AV
- BerkeleyDB T_PTROBJ
- BerkeleyDB::Common T_PTROBJ_AV
- BerkeleyDB::Hash T_PTROBJ_AV
- BerkeleyDB::Btree T_PTROBJ_AV
- BerkeleyDB::Recno T_PTROBJ_AV
- BerkeleyDB::Queue T_PTROBJ_AV
- BerkeleyDB::Cursor T_PTROBJ_AV
- BerkeleyDB::TxnMgr T_PTROBJ_AV
- BerkeleyDB::Txn T_PTROBJ_AV
- BerkeleyDB::Log T_PTROBJ_AV
- BerkeleyDB::Lock T_PTROBJ_AV
- BerkeleyDB::Env T_PTROBJ_AV
- BerkeleyDB::Raw T_RAW
- BerkeleyDB::Common::Raw T_RAW
- BerkeleyDB::Hash::Raw T_RAW
- BerkeleyDB::Btree::Raw T_RAW
- BerkeleyDB::Recno::Raw T_RAW
- BerkeleyDB::Queue::Raw T_RAW
- BerkeleyDB::Cursor::Raw T_RAW
- BerkeleyDB::TxnMgr::Raw T_RAW
- BerkeleyDB::Txn::Raw T_RAW
- BerkeleyDB::Log::Raw T_RAW
- BerkeleyDB::Lock::Raw T_RAW
- BerkeleyDB::Env::Raw T_RAW
- BerkeleyDB::Env::Inner T_INNER
- BerkeleyDB::Common::Inner T_INNER
- BerkeleyDB::Txn::Inner T_INNER
- BerkeleyDB::TxnMgr::Inner T_INNER
- # BerkeleyDB__Env T_PTR
- DBT T_dbtdatum
- DBT_OPT T_dbtdatum_opt
- DBT_B T_dbtdatum_btree
- DBTKEY T_dbtkeydatum
- DBTKEY_B T_dbtkeydatum_btree
- DBTYPE T_U_INT
- DualType T_DUAL
- BerkeleyDB_type * T_IV
- BerkeleyDB_ENV_type * T_IV
- BerkeleyDB_TxnMgr_type * T_IV
- BerkeleyDB_Txn_type * T_IV
- BerkeleyDB__Cursor_type * T_IV
- DB * T_IV
- INPUT
- T_AV
- if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV)
- /* if (sv_isa($arg, "${ntype}")) */
- $var = (AV*)SvRV($arg);
- else
- croak("$var is not an array reference")
- T_RAW
- $var = ($type)SvIV($arg)
- T_U_INT
- $var = SvUV($arg)
- T_SV_REF_NULL
- if ($arg == &PL_sv_undef)
- $var = NULL ;
- else if (sv_derived_from($arg, "${ntype}")) {
- IV tmp = SvIV((SV *)GetInternalObject($arg));
- $var = ($type) tmp;
- }
- else
- croak("$var is not of type ${ntype}")
- T_HV_REF_NULL
- if ($arg == &PL_sv_undef)
- $var = NULL ;
- else if (sv_derived_from($arg, "${ntype}")) {
- HV * hv = (HV *)GetInternalObject($arg);
- SV ** svp = hv_fetch(hv, "db", 2, FALSE);
- IV tmp = SvIV(*svp);
- $var = ($type) tmp;
- }
- else
- croak("$var is not of type ${ntype}")
- T_HV_REF
- if (sv_derived_from($arg, "${ntype}")) {
- HV * hv = (HV *)GetInternalObject($arg);
- SV ** svp = hv_fetch(hv, "db", 2, FALSE);
- IV tmp = SvIV(*svp);
- $var = ($type) tmp;
- }
- else
- croak("$var is not of type ${ntype}")
- T_P_REF
- if (sv_derived_from($arg, "${ntype}")) {
- IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type) tmp;
- }
- else
- croak("$var is not of type ${ntype}")
- T_INNER
- {
- HV * hv = (HV *)SvRV($arg);
- SV ** svp = hv_fetch(hv, "db", 2, FALSE);
- IV tmp = SvIV(*svp);
- $var = ($type) tmp;
- }
- T_PV_NULL
- if ($arg == &PL_sv_undef)
- $var = NULL ;
- else {
- $var = ($type)SvPV($arg,PL_na) ;
- if (PL_na == 0)
- $var = NULL ;
- }
- T_IO_NULL
- if ($arg == &PL_sv_undef)
- $var = NULL ;
- else
- $var = IoOFP(sv_2io($arg))
- T_PTROBJ_NULL
- if ($arg == &PL_sv_undef)
- $var = NULL ;
- else if (sv_derived_from($arg, "${ntype}")) {
- IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type) tmp;
- }
- else
- croak("$var is not of type ${ntype}")
- T_PTROBJ_SELF
- if ($arg == &PL_sv_undef)
- $var = NULL ;
- else if (sv_derived_from($arg, "${ntype}")) {
- IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type) tmp;
- }
- else
- croak("$var is not of type ${ntype}")
- T_PTROBJ_AV
- if ($arg == &PL_sv_undef || $arg == NULL)
- $var = NULL ;
- else if (sv_derived_from($arg, "${ntype}")) {
- IV tmp = getInnerObject($arg) ;
- $var = ($type) tmp;
- }
- else
- croak("$var is not of type ${ntype}")
- T_dbtkeydatum
- ckFilter($arg, filter_store_key, "filter_store_key");
- DBT_clear($var) ;
- if (db->recno_or_queue) {
- Value = GetRecnoKey(db, SvIV($arg)) ;
- $var.data = & Value;
- $var.size = (int)sizeof(db_recno_t);
- }
- else {
- $var.data = SvPV($arg, PL_na);
- $var.size = (int)PL_na;
- }
- T_dbtkeydatum_btree
- ckFilter($arg, filter_store_key, "filter_store_key");
- DBT_clear($var) ;
- if (db->recno_or_queue ||
- (db->type == DB_BTREE && flagSet(DB_SET_RECNO))) {
- Value = GetRecnoKey(db, SvIV($arg)) ;
- $var.data = & Value;
- $var.size = (int)sizeof(db_recno_t);
- }
- else {
- $var.data = SvPV($arg, PL_na);
- $var.size = (int)PL_na;
- }
- T_dbtdatum
- ckFilter($arg, filter_store_value, "filter_store_value");
- DBT_clear($var) ;
- $var.data = SvPV($arg, PL_na);
- $var.size = (int)PL_na;
- $var.flags = db->partial ;
- $var.dlen = db->dlen ;
- $var.doff = db->doff ;
-
- T_dbtdatum_opt
- DBT_clear($var) ;
- if (flagSet(DB_GET_BOTH)) {
- ckFilter($arg, filter_store_value, "filter_store_value");
- $var.data = SvPV($arg, PL_na);
- $var.size = (int)PL_na;
- $var.flags = db->partial ;
- $var.dlen = db->dlen ;
- $var.doff = db->doff ;
- }
-
- T_dbtdatum_btree
- DBT_clear($var) ;
- if (flagSet(DB_GET_BOTH)) {
- ckFilter($arg, filter_store_value, "filter_store_value");
- $var.data = SvPV($arg, PL_na);
- $var.size = (int)PL_na;
- $var.flags = db->partial ;
- $var.dlen = db->dlen ;
- $var.doff = db->doff ;
- }
-
- OUTPUT
- T_RAW
- sv_setiv($arg, (IV)$var);
- T_SV_REF_NULL
- sv_setiv($arg, (IV)$var);
- T_HV_REF_NULL
- sv_setiv($arg, (IV)$var);
- T_HV_REF
- sv_setiv($arg, (IV)$var);
- T_P_REF
- sv_setiv($arg, (IV)$var);
- T_DUAL
- setDUALerrno($arg, $var) ;
- T_U_INT
- sv_setuv($arg, (UV)$var);
- T_PV_NULL
- sv_setpv((SV*)$arg, $var);
- T_dbtkeydatum_btree
- OutputKey_B($arg, $var)
- T_dbtkeydatum
- OutputKey($arg, $var)
- T_dbtdatum
- OutputValue($arg, $var)
- T_dbtdatum_opt
- OutputValue($arg, $var)
- T_dbtdatum_btree
- OutputValue_B($arg, $var)
- T_PTROBJ_NULL
- sv_setref_pv($arg, "${ntype}", (void*)$var);
- T_PTROBJ_SELF
- sv_setref_pv($arg, self, (void*)$var);