Mercurial > repos > rhope
view runtime/worker.c @ 180:c40e0faa1c92
Add Call to Dict and List
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 19 Jun 2011 10:43:11 -0700 |
parents | 7428aa5d6ade |
children |
line wrap: on
line source
object * _internal_worker_alloc(int16_t size) { t_Worker * worker = (t_Worker *)new_multisize(TYPE_WORKER, sizeof(nt_Worker)+sizeof(object *)*size); worker->payload.Size = size; return (object *)worker; } void _internal_worker_setinput(object * worker, int16_t num, object * val) { //Client code is responsible for checking if we've allocated enough space object **params = (object **)(((t_Worker *)worker)+1); params[num] = val; } object * _internal_worker_getinput(object * worker, int16_t num) { //Client code MUST check if input is populated before calling this function object **params = (object **)(((t_Worker *)worker)+1); object * ret = add_ref(params[num]); release_ref(worker); return ret; } int32_t _internal_worker_hasinput(object * worker, int16_t num) { object **params = (object **)(((t_Worker *)worker)+1); if(params[num]) { release_ref(worker); return 1; } else { release_ref(worker); return 0; } } void internalworkercopy(object * obj) { int32_t idx; t_Worker * worker = (t_Worker *)obj; object **params = (object **)(worker+1); for(idx = 0; idx < worker->payload.Size; ++idx) { if(params[idx]) { add_ref(params[idx]); } } } void internalworkercleanup(object * obj) { int32_t idx; t_Worker * worker = (t_Worker *)obj; object **params = (object **)(worker+1); for(idx = 0; idx < worker->payload.Size; ++idx) { if(params[idx]) { release_ref(params[idx]); } } }