comparison 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
comparison
equal deleted inserted replaced
39:3d92bc1352c2 40:789a146a48e1
208 bp->copy(copy); 208 bp->copy(copy);
209 release_ref(tocopy); 209 release_ref(tocopy);
210 return copy; 210 return copy;
211 } 211 }
212 212
213 object * naked_to_boxed(uint32_t type, void * rawdata)
214 {
215 object * dest;
216 blueprint * bp = get_blueprint_byid(type);
217 if(!bp->size)
218 return NULL; //We don't know how big a naked multi-size object is so we can't do anything with it
219 dest = alloc_object(bp);
220 memcpy(((char *)dest) + sizeof(object), rawdata, bp->size);
221 dest->bprint = bp;
222 rh_atomic_set(dest, refcount, 1);
223 bp->copy(dest);
224 return dest;
225 }
226
227 void boxed_to_naked(object * src, void * dest)
228 {
229 blueprint * bp = get_blueprint(src);
230 if(!bp->size)
231 return; //We don't know how big a naked multi-size object is so we can't do anything with it
232 memcpy(dest, ((char *)src) + sizeof(object), bp->size);
233 bp->copy(src);
234 }
235
213 void free_object(object * obj) 236 void free_object(object * obj)
214 { 237 {
215 blueprint * bp = get_blueprint(obj); 238 blueprint * bp = get_blueprint(obj);
216 if(bp->cleanup) 239 if(bp->cleanup)
217 bp->cleanup(obj); 240 bp->cleanup(obj);