# HG changeset patch # User Mike Pavone # Date 1294632210 18000 # Node ID 9fab36cc706b8006bd13211754502628532a3090 # Parent bac2c74801f0298b99e4d5754ba59148cb10f2d7 Add Raw Size method to blueprint to allow code to query the raw size of a type in bytes diff -r bac2c74801f0 -r 9fab36cc706b kernel.rhope --- a/kernel.rhope Sun Jan 09 22:51:10 2011 -0500 +++ b/kernel.rhope Sun Jan 09 23:03:30 2011 -0500 @@ -183,6 +183,7 @@ Foreign C:runtime { _internal_blueprint_eq[left(Blueprint),right(Blueprint):out(Int32,Naked)] + _internal_blueprint_rawsize[bp(Blueprint):out(Int32,Naked)] _internal_worker_alloc[size(Int16,Naked):out(Worker)] _internal_worker_setinput[worker(Worker,Boxed,Mutable),num(Int16,Naked),val:worker] _internal_worker_getinput[worker(Worker),num(Int16,Naked):out] @@ -248,6 +249,11 @@ out <- [_internal_blueprint_eq[left,right]]!=[0] } +Raw Size@Blueprint[bp:out] +{ + out <- _internal_blueprint_rawsize[bp] +} + _Keys[list,val,key:out] { out <- [list]Append[key] diff -r bac2c74801f0 -r 9fab36cc706b runtime/blueprint.c --- a/runtime/blueprint.c Sun Jan 09 22:51:10 2011 -0500 +++ b/runtime/blueprint.c Sun Jan 09 23:03:30 2011 -0500 @@ -26,4 +26,12 @@ return l->bp == r->bp; } +int32_t _internal_blueprint_rawsize(object * bp) +{ + int32_t ret; + t_Blueprint * bprint = (t_Blueprint *)bp; + ret = bprint->bp->size; + release_ref(bp); + return ret; +} diff -r bac2c74801f0 -r 9fab36cc706b runtime/blueprint.h --- a/runtime/blueprint.h Sun Jan 09 22:51:10 2011 -0500 +++ b/runtime/blueprint.h Sun Jan 09 23:03:30 2011 -0500 @@ -9,6 +9,7 @@ object * make_Blueprint(int32_t type_id); int32_t _internal_blueprint_eq(object * left, object * right); +int32_t _internal_blueprint_rawsize(object * bp); typedef struct { blueprint * bp; diff -r bac2c74801f0 -r 9fab36cc706b runtime/object.h --- a/runtime/object.h Sun Jan 09 22:51:10 2011 -0500 +++ b/runtime/object.h Sun Jan 09 23:03:30 2011 -0500 @@ -27,8 +27,8 @@ uint32_t last_convertto; uint32_t first_convertfrom; uint32_t last_convertfrom; - int32_t size; - int32_t boxed_size; + int32_t size; + int32_t boxed_size; } blueprint; struct object {