annotate runtime/worker.c @ 78:4d5ea487f810

Working String implementation and some basic (but nowhere near exhaustive) tests
author Mike Pavone <pavone@retrodev.com>
date Thu, 08 Jul 2010 21:55:47 -0400
parents a844c623c7df
children 7428aa5d6ade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
74
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 object * _internal_worker_alloc(int16_t size)
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 {
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 t_Worker * worker = (t_Worker *)new_multisize(TYPE_WORKER, sizeof(nt_Worker)+sizeof(object *)*size);
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 worker->payload.Size = size;
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 return (object *)worker;
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 }
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 void _internal_worker_setinput(object * worker, int16_t num, object * val)
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 {
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 //Client code is responsible for checking if we've allocated enough space
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 object **params = (object **)(((t_Worker *)worker)+1);
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 params[num] = val;
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 }
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 object * _internal_worker_getinput(object * worker, int16_t num)
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 {
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 //Client code MUST check if input is populated before calling this function
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 object **params = (object **)(((t_Worker *)worker)+1);
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 object * ret = add_ref(params[num]);
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 release_ref(worker);
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 return ret;
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 }
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 int32_t _internal_worker_hasinput(object * worker, int16_t num)
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 {
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27 object **params = (object **)(((t_Worker *)worker)+1);
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 if(params[num])
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29 {
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30 release_ref(worker);
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31 return 1;
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32 } else {
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33 release_ref(worker);
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34 return 0;
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35 }
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36 }
a844c623c7df Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37