Mercurial > repos > rhope
diff runtime/object.c @ 40:789a146a48e1
Started adding support for naked values in user defined objects
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 09 Oct 2009 01:01:26 -0400 |
parents | 640f541e9116 |
children | 1b86a1ee500a |
line wrap: on
line diff
--- a/runtime/object.c Thu Oct 08 00:37:24 2009 -0400 +++ b/runtime/object.c Fri Oct 09 01:01:26 2009 -0400 @@ -210,6 +210,29 @@ return copy; } +object * naked_to_boxed(uint32_t type, void * rawdata) +{ + object * dest; + blueprint * bp = get_blueprint_byid(type); + if(!bp->size) + return NULL; //We don't know how big a naked multi-size object is so we can't do anything with it + dest = alloc_object(bp); + memcpy(((char *)dest) + sizeof(object), rawdata, bp->size); + dest->bprint = bp; + rh_atomic_set(dest, refcount, 1); + bp->copy(dest); + return dest; +} + +void boxed_to_naked(object * src, void * dest) +{ + blueprint * bp = get_blueprint(src); + if(!bp->size) + return; //We don't know how big a naked multi-size object is so we can't do anything with it + memcpy(dest, ((char *)src) + sizeof(object), bp->size); + bp->copy(src); +} + void free_object(object * obj) { blueprint * bp = get_blueprint(obj);