some untested code to deal with perl hashes

This commit is contained in:
Sears Russell 2009-12-31 17:39:35 +00:00
parent 7ff80f37ef
commit 69c513b913
2 changed files with 11 additions and 1 deletions

View file

@ -175,6 +175,11 @@ static byte * bytes_SV(SV* sv, STRLEN * sz) {
*sz = sizeof(recordid); *sz = sizeof(recordid);
tmp = (byte*)&valR; tmp = (byte*)&valR;
code = 'R'; code = 'R';
} else if (sv_isobject(sv) && sv_derived_from(sv, "Stasis::Hash")) {
valR = recordid_SV(sv);
*sz = sizeof(recordid);
tmp = (byte*)&valR;
code = 'H';
} else { } else {
abort(); abort();
} }
@ -213,6 +218,11 @@ static SV * SV_bytes(byte* bytes, STRLEN sz) {
assert(sz-1 == sizeof(recordid)); assert(sz-1 == sizeof(recordid));
ret = SV_recordid(*(recordid*)bytes); ret = SV_recordid(*(recordid*)bytes);
} break; } break;
case 'H': {
assert(sz-1 == sizeof(recordid));
ret = SV_recordid(*(recordid*)bytes);
ret = sv_bless(ret, gv_stashpv("Stasis::Hash", GV_ADD));
} break;
default: { default: {
abort(); abort();
} }

View file

@ -14,7 +14,7 @@
#ifdef STASIS_BUFFER_MANAGER_FACTORY #ifdef STASIS_BUFFER_MANAGER_FACTORY
stasis_buffer_manager_t * stasis_buffer_manager_factory = STASIS_BUFFER_MANAGER_FACTORY; stasis_buffer_manager_t * stasis_buffer_manager_factory = STASIS_BUFFER_MANAGER_FACTORY;
#else #else
stasis_buffer_manager_t * (*stasis_buffer_manager_factory)(stasis_log_t*, stasis_dirty_page_table_t*) = stasis_buffer_manager_hash_factory; stasis_buffer_manager_t * (*stasis_buffer_manager_factory)(stasis_log_t*, stasis_dirty_page_table_t*) = stasis_buffer_manager_concurrent_hash_factory;
#endif #endif
#ifdef BUFFER_MANAGER_O_DIRECT #ifdef BUFFER_MANAGER_O_DIRECT