Mercurial > repos > rhope
annotate 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 |
rev | line source |
---|---|
74 | 1 |
2 object * _internal_worker_alloc(int16_t size) | |
3 { | |
4 t_Worker * worker = (t_Worker *)new_multisize(TYPE_WORKER, sizeof(nt_Worker)+sizeof(object *)*size); | |
5 worker->payload.Size = size; | |
6 return (object *)worker; | |
7 } | |
8 | |
9 void _internal_worker_setinput(object * worker, int16_t num, object * val) | |
10 { | |
11 //Client code is responsible for checking if we've allocated enough space | |
12 object **params = (object **)(((t_Worker *)worker)+1); | |
13 params[num] = val; | |
14 } | |
15 | |
16 object * _internal_worker_getinput(object * worker, int16_t num) | |
17 { | |
18 //Client code MUST check if input is populated before calling this function | |
19 object **params = (object **)(((t_Worker *)worker)+1); | |
20 object * ret = add_ref(params[num]); | |
21 release_ref(worker); | |
22 return ret; | |
23 } | |
24 | |
25 int32_t _internal_worker_hasinput(object * worker, int16_t num) | |
26 { | |
27 object **params = (object **)(((t_Worker *)worker)+1); | |
28 if(params[num]) | |
29 { | |
30 release_ref(worker); | |
31 return 1; | |
32 } else { | |
33 release_ref(worker); | |
34 return 0; | |
35 } | |
36 } | |
37 | |
103
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
38 void internalworkercopy(object * obj) |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
39 { |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
40 int32_t idx; |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
41 t_Worker * worker = (t_Worker *)obj; |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
42 object **params = (object **)(worker+1); |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
43 for(idx = 0; idx < worker->payload.Size; ++idx) |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
44 { |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
45 if(params[idx]) |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
46 { |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
47 add_ref(params[idx]); |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
48 } |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
49 } |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
50 } |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
51 |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
52 void internalworkercleanup(object * obj) |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
53 { |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
54 int32_t idx; |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
55 t_Worker * worker = (t_Worker *)obj; |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
56 object **params = (object **)(worker+1); |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
57 for(idx = 0; idx < worker->payload.Size; ++idx) |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
58 { |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
59 if(params[idx]) |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
60 { |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
61 release_ref(params[idx]); |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
62 } |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
63 } |
7428aa5d6ade
Compiler compiled by compiler sort of working
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
64 } |