blob: b4b32bbec1e83292a69becad307114d869fc5aab [file] [log] [blame]
Jason Samsc97bb882009-07-20 14:31:06 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "rsContext.h"
18#include "rsScriptC.h"
19#include "rsMatrix.h"
20
Joe Onorato3370ec92009-08-09 11:39:02 -070021#include "utils/Timers.h"
Jason Samsc97bb882009-07-20 14:31:06 -070022
Romain Guy584a3752009-07-30 18:45:01 -070023#include <time.h>
Romain Guy584a3752009-07-30 18:45:01 -070024
Jason Samsc97bb882009-07-20 14:31:06 -070025using namespace android;
26using namespace android::renderscript;
27
28#define GET_TLS() Context::ScriptTLSStruct * tls = \
29 (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
30 Context * rsc = tls->mContext; \
31 ScriptC * sc = (ScriptC *) tls->mScript
32
Jason Sams4d339932010-05-11 14:03:58 -070033
Jason Samsc97bb882009-07-20 14:31:06 -070034//////////////////////////////////////////////////////////////////////////////
35// Math routines
36//////////////////////////////////////////////////////////////////////////////
37
Romain Guycac80a62009-08-18 11:39:17 -070038static float SC_sinf_fast(float x)
39{
40 const float A = 1.0f / (2.0f * M_PI);
41 const float B = -16.0f;
42 const float C = 8.0f;
Jason Samsea84a7c2009-09-04 14:42:41 -070043
Romain Guycac80a62009-08-18 11:39:17 -070044 // scale angle for easy argument reduction
45 x *= A;
Jason Samsea84a7c2009-09-04 14:42:41 -070046
Romain Guycac80a62009-08-18 11:39:17 -070047 if (fabsf(x) >= 0.5f) {
48 // argument reduction
49 x = x - ceilf(x + 0.5f) + 1.0f;
50 }
Jason Samsea84a7c2009-09-04 14:42:41 -070051
Romain Guycac80a62009-08-18 11:39:17 -070052 const float y = B * x * fabsf(x) + C * x;
53 return 0.2215f * (y * fabsf(y) - y) + y;
54}
55
56static float SC_cosf_fast(float x)
57{
58 x += float(M_PI / 2);
59
60 const float A = 1.0f / (2.0f * M_PI);
61 const float B = -16.0f;
62 const float C = 8.0f;
Jason Samsea84a7c2009-09-04 14:42:41 -070063
Romain Guycac80a62009-08-18 11:39:17 -070064 // scale angle for easy argument reduction
65 x *= A;
Jason Samsea84a7c2009-09-04 14:42:41 -070066
Romain Guycac80a62009-08-18 11:39:17 -070067 if (fabsf(x) >= 0.5f) {
68 // argument reduction
69 x = x - ceilf(x + 0.5f) + 1.0f;
70 }
Jason Samsea84a7c2009-09-04 14:42:41 -070071
Romain Guycac80a62009-08-18 11:39:17 -070072 const float y = B * x * fabsf(x) + C * x;
73 return 0.2215f * (y * fabsf(y) - y) + y;
74}
75
Jason Samsd79b2e92010-05-19 17:22:57 -070076
Jason Samsc97bb882009-07-20 14:31:06 -070077static float SC_randf(float max)
78{
79 float r = (float)rand();
80 return r / RAND_MAX * max;
81}
82
Romain Guy8839ca52009-07-31 11:20:59 -070083static float SC_randf2(float min, float max)
84{
85 float r = (float)rand();
86 return r / RAND_MAX * (max - min) + min;
87}
88
Jason Samsd79b2e92010-05-19 17:22:57 -070089static int SC_randi(int max)
90{
91 return (int)SC_randf(max);
92}
93
94static int SC_randi2(int min, int max)
95{
96 return (int)SC_randf2(min, max);
97}
98
Jason Sams4d339932010-05-11 14:03:58 -070099static float SC_frac(float v)
100{
101 int i = (int)floor(v);
102 return fmin(v - i, 0x1.fffffep-1f);
103}
104
Romain Guy584a3752009-07-30 18:45:01 -0700105//////////////////////////////////////////////////////////////////////////////
106// Time routines
107//////////////////////////////////////////////////////////////////////////////
Jason Samsc97bb882009-07-20 14:31:06 -0700108
Joe Onorato3370ec92009-08-09 11:39:02 -0700109static int32_t SC_second()
Romain Guy584a3752009-07-30 18:45:01 -0700110{
111 GET_TLS();
112
113 time_t rawtime;
114 time(&rawtime);
115
Romain Guybaed7272009-11-11 15:36:06 -0800116 struct tm *timeinfo;
117 timeinfo = localtime(&rawtime);
118 return timeinfo->tm_sec;
Romain Guy584a3752009-07-30 18:45:01 -0700119}
120
Joe Onorato3370ec92009-08-09 11:39:02 -0700121static int32_t SC_minute()
Romain Guy584a3752009-07-30 18:45:01 -0700122{
123 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700124
Romain Guy584a3752009-07-30 18:45:01 -0700125 time_t rawtime;
126 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700127
Romain Guybaed7272009-11-11 15:36:06 -0800128 struct tm *timeinfo;
129 timeinfo = localtime(&rawtime);
130 return timeinfo->tm_min;
Jason Sams1bada8c2009-08-09 17:01:55 -0700131}
Romain Guy584a3752009-07-30 18:45:01 -0700132
Joe Onorato3370ec92009-08-09 11:39:02 -0700133static int32_t SC_hour()
Romain Guy584a3752009-07-30 18:45:01 -0700134{
135 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700136
Romain Guy584a3752009-07-30 18:45:01 -0700137 time_t rawtime;
138 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700139
Romain Guybaed7272009-11-11 15:36:06 -0800140 struct tm *timeinfo;
141 timeinfo = localtime(&rawtime);
142 return timeinfo->tm_hour;
Romain Guy8839ca52009-07-31 11:20:59 -0700143}
144
Joe Onorato3370ec92009-08-09 11:39:02 -0700145static int32_t SC_day()
Romain Guy8839ca52009-07-31 11:20:59 -0700146{
147 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700148
Romain Guy8839ca52009-07-31 11:20:59 -0700149 time_t rawtime;
150 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700151
Romain Guybaed7272009-11-11 15:36:06 -0800152 struct tm *timeinfo;
153 timeinfo = localtime(&rawtime);
154 return timeinfo->tm_mday;
Jason Sams1bada8c2009-08-09 17:01:55 -0700155}
Jason Samsc97bb882009-07-20 14:31:06 -0700156
Joe Onorato3370ec92009-08-09 11:39:02 -0700157static int32_t SC_month()
Romain Guy8839ca52009-07-31 11:20:59 -0700158{
159 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700160
Romain Guy8839ca52009-07-31 11:20:59 -0700161 time_t rawtime;
162 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700163
Romain Guybaed7272009-11-11 15:36:06 -0800164 struct tm *timeinfo;
165 timeinfo = localtime(&rawtime);
166 return timeinfo->tm_mon;
Jason Sams1bada8c2009-08-09 17:01:55 -0700167}
Romain Guy8839ca52009-07-31 11:20:59 -0700168
Joe Onorato3370ec92009-08-09 11:39:02 -0700169static int32_t SC_year()
Romain Guy8839ca52009-07-31 11:20:59 -0700170{
171 GET_TLS();
Jason Sams1bada8c2009-08-09 17:01:55 -0700172
Romain Guy8839ca52009-07-31 11:20:59 -0700173 time_t rawtime;
174 time(&rawtime);
Jason Sams1bada8c2009-08-09 17:01:55 -0700175
Romain Guybaed7272009-11-11 15:36:06 -0800176 struct tm *timeinfo;
177 timeinfo = localtime(&rawtime);
178 return timeinfo->tm_year;
Romain Guy8839ca52009-07-31 11:20:59 -0700179}
180
Jason Sams17966512010-07-28 11:17:53 -0700181static int64_t SC_uptimeMillis()
Jason Samsd79b2e92010-05-19 17:22:57 -0700182{
183 return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
184}
185
Jason Samsf0690c42010-07-29 17:31:14 -0700186static int64_t SC_uptimeNanos()
Jason Samsd79b2e92010-05-19 17:22:57 -0700187{
Jason Samsf0690c42010-07-29 17:31:14 -0700188 return systemTime(SYSTEM_TIME_MONOTONIC);
Jason Samsd79b2e92010-05-19 17:22:57 -0700189}
190
Jason Sams17966512010-07-28 11:17:53 -0700191static float SC_getDt()
Joe Onorato3370ec92009-08-09 11:39:02 -0700192{
193 GET_TLS();
Jason Sams17966512010-07-28 11:17:53 -0700194 int64_t l = sc->mEnviroment.mLastDtTime;
195 sc->mEnviroment.mLastDtTime = systemTime(SYSTEM_TIME_MONOTONIC);
196 return ((float)(sc->mEnviroment.mLastDtTime - l)) / 1.0e9;
Jason Samsc97bb882009-07-20 14:31:06 -0700197}
198
199
Jason Samsc97bb882009-07-20 14:31:06 -0700200//////////////////////////////////////////////////////////////////////////////
201//
202//////////////////////////////////////////////////////////////////////////////
203
Jason Sams4d339932010-05-11 14:03:58 -0700204static uint32_t SC_allocGetDimX(RsAllocation va)
205{
206 GET_TLS();
207 const Allocation *a = static_cast<const Allocation *>(va);
208 //LOGE("SC_allocGetDimX a=%p", a);
209 //LOGE(" type=%p", a->getType());
210 return a->getType()->getDimX();
211}
212
213static uint32_t SC_allocGetDimY(RsAllocation va)
214{
215 GET_TLS();
216 const Allocation *a = static_cast<const Allocation *>(va);
217 return a->getType()->getDimY();
218}
219
220static uint32_t SC_allocGetDimZ(RsAllocation va)
221{
222 GET_TLS();
223 const Allocation *a = static_cast<const Allocation *>(va);
224 return a->getType()->getDimZ();
225}
226
227static uint32_t SC_allocGetDimLOD(RsAllocation va)
228{
229 GET_TLS();
230 const Allocation *a = static_cast<const Allocation *>(va);
231 return a->getType()->getDimLOD();
232}
233
234static uint32_t SC_allocGetDimFaces(RsAllocation va)
235{
236 GET_TLS();
237 const Allocation *a = static_cast<const Allocation *>(va);
238 return a->getType()->getDimFaces();
239}
240
Jason Sams02f62aa2010-08-16 12:41:48 -0700241static const void * SC_getElementAtX(RsAllocation va, uint32_t x)
Jason Sams8e6c17f2010-07-19 15:38:19 -0700242{
243 const Allocation *a = static_cast<const Allocation *>(va);
244 const Type *t = a->getType();
245 const uint8_t *p = (const uint8_t *)a->getPtr();
246 return &p[t->getElementSizeBytes() * x];
247}
248
Jason Sams02f62aa2010-08-16 12:41:48 -0700249static const void * SC_getElementAtXY(RsAllocation va, uint32_t x, uint32_t y)
Jason Sams8e6c17f2010-07-19 15:38:19 -0700250{
251 const Allocation *a = static_cast<const Allocation *>(va);
252 const Type *t = a->getType();
253 const uint8_t *p = (const uint8_t *)a->getPtr();
254 return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
255}
256
Jason Sams02f62aa2010-08-16 12:41:48 -0700257static const void * SC_getElementAtXYZ(RsAllocation va, uint32_t x, uint32_t y, uint32_t z)
Jason Sams8e6c17f2010-07-19 15:38:19 -0700258{
259 const Allocation *a = static_cast<const Allocation *>(va);
260 const Type *t = a->getType();
261 const uint8_t *p = (const uint8_t *)a->getPtr();
262 return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
263}
Jason Sams4d339932010-05-11 14:03:58 -0700264
Jason Sams02f62aa2010-08-16 12:41:48 -0700265static void SC_setObject(void **vdst, void * vsrc) {
266 static_cast<ObjectBase *>(vsrc)->incSysRef();
267 static_cast<ObjectBase *>(vdst[0])->decSysRef();
268 *vdst = vsrc;
269}
270static void SC_clearObject(void **vdst) {
271 static_cast<ObjectBase *>(vdst[0])->decSysRef();
272 *vdst = NULL;
273}
274static bool SC_isObject(RsAllocation vsrc) {
275 return vsrc != NULL;
276}
277
278
Jason Samsc97bb882009-07-20 14:31:06 -0700279
Jason Samsd79b2e92010-05-19 17:22:57 -0700280static void SC_debugF(const char *s, float f) {
281 LOGE("%s %f, 0x%08x", s, f, *((int *) (&f)));
Jason Samsb0ec1b42009-07-28 12:02:16 -0700282}
Jason Samsd64188a2010-08-06 16:22:50 -0700283static void SC_debugFv2(const char *s, float f1, float f2) {
284 LOGE("%s {%f, %f}", s, f1, f2);
Romain Guyd22fff72009-08-20 17:08:33 -0700285}
Jason Samsd64188a2010-08-06 16:22:50 -0700286static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
287 LOGE("%s {%f, %f, %f}", s, f1, f2, f3);
Jason Samsb0ec1b42009-07-28 12:02:16 -0700288}
Jason Samsd64188a2010-08-06 16:22:50 -0700289static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
290 LOGE("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
Jason Samsd79b2e92010-05-19 17:22:57 -0700291}
Jason Samsd64188a2010-08-06 16:22:50 -0700292static void SC_debugFM4v4(const char *s, const float *f) {
293 LOGE("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
294 LOGE("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
295 LOGE("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
296 LOGE("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
297}
298static void SC_debugFM3v3(const char *s, const float *f) {
299 LOGE("%s {%f, %f, %f", s, f[0], f[3], f[6]);
300 LOGE("%s %f, %f, %f", s, f[1], f[4], f[7]);
301 LOGE("%s %f, %f, %f}",s, f[2], f[5], f[8]);
302}
303static void SC_debugFM2v2(const char *s, const float *f) {
304 LOGE("%s {%f, %f", s, f[0], f[2]);
305 LOGE("%s %f, %f}",s, f[1], f[3]);
306}
307
Jason Samsd79b2e92010-05-19 17:22:57 -0700308static void SC_debugI32(const char *s, int32_t i) {
309 LOGE("%s %i 0x%x", s, i, i);
Romain Guyd22fff72009-08-20 17:08:33 -0700310}
Jason Sams17966512010-07-28 11:17:53 -0700311static void SC_debugU32(const char *s, uint32_t i) {
312 LOGE("%s %i 0x%x", s, i, i);
313}
Romain Guyd22fff72009-08-20 17:08:33 -0700314
Jason Sams8e6c17f2010-07-19 15:38:19 -0700315static void SC_debugP(const char *s, const void *p) {
316 LOGE("%s %p", s, p);
317}
318
Jason Sams17966512010-07-28 11:17:53 -0700319static uint32_t SC_toClient2(int cmdID, void *data, int len)
Jason Sams516c3192009-10-06 13:58:47 -0700320{
321 GET_TLS();
Jason Sams17966512010-07-28 11:17:53 -0700322 //LOGE("SC_toClient %i %i %i", cmdID, len);
323 return rsc->sendMessageToClient(data, cmdID, len, false);
Jason Sams516c3192009-10-06 13:58:47 -0700324}
325
Jason Sams17966512010-07-28 11:17:53 -0700326static uint32_t SC_toClient(int cmdID)
Jason Samsbd2197f2009-10-07 18:14:01 -0700327{
328 GET_TLS();
Jason Sams17966512010-07-28 11:17:53 -0700329 //LOGE("SC_toClient %i", cmdID);
330 return rsc->sendMessageToClient(NULL, cmdID, 0, false);
331}
332
333static uint32_t SC_toClientBlocking2(int cmdID, void *data, int len)
334{
335 GET_TLS();
336 //LOGE("SC_toClientBlocking %i %i", cmdID, len);
337 return rsc->sendMessageToClient(data, cmdID, len, true);
338}
339
340static uint32_t SC_toClientBlocking(int cmdID)
341{
342 GET_TLS();
343 //LOGE("SC_toClientBlocking %i", cmdID);
344 return rsc->sendMessageToClient(NULL, cmdID, 0, true);
Jason Samsbd2197f2009-10-07 18:14:01 -0700345}
346
Jason Sams4d339932010-05-11 14:03:58 -0700347int SC_divsi3(int a, int b)
348{
349 return a / b;
350}
Jason Samsbd2197f2009-10-07 18:14:01 -0700351
Jason Sams1de0b872010-05-17 14:55:34 -0700352int SC_getAllocation(const void *ptr)
353{
354 GET_TLS();
355 const Allocation *alloc = sc->ptrToAllocation(ptr);
356 return (int)alloc;
357}
358
359
Jason Sams8f8a5722010-07-15 17:11:13 -0700360void SC_ForEach(RsScript vs,
361 RsAllocation vin,
362 RsAllocation vout,
363 const void *usr)
Jason Samsf17bccc2010-05-28 18:23:22 -0700364{
365 GET_TLS();
Jason Sams8f8a5722010-07-15 17:11:13 -0700366 const Allocation *ain = static_cast<const Allocation *>(vin);
Jason Samsf17bccc2010-05-28 18:23:22 -0700367 Allocation *aout = static_cast<Allocation *>(vout);
Jason Sams8f8a5722010-07-15 17:11:13 -0700368 Script *s = static_cast<Script *>(vs);
369 s->runForEach(rsc, ain, aout, usr);
Jason Samsf17bccc2010-05-28 18:23:22 -0700370}
371
Jason Sams8f8a5722010-07-15 17:11:13 -0700372void SC_ForEach2(RsScript vs,
373 RsAllocation vin,
374 RsAllocation vout,
375 const void *usr,
376 const RsScriptCall *call)
Jason Samsf17bccc2010-05-28 18:23:22 -0700377{
378 GET_TLS();
Jason Sams8f8a5722010-07-15 17:11:13 -0700379 const Allocation *ain = static_cast<const Allocation *>(vin);
Jason Samsf17bccc2010-05-28 18:23:22 -0700380 Allocation *aout = static_cast<Allocation *>(vout);
Jason Samsf17bccc2010-05-28 18:23:22 -0700381 Script *s = static_cast<Script *>(vs);
Jason Sams8f8a5722010-07-15 17:11:13 -0700382 s->runForEach(rsc, ain, aout, usr, call);
Jason Samsf17bccc2010-05-28 18:23:22 -0700383}
384
Jason Samsc97bb882009-07-20 14:31:06 -0700385//////////////////////////////////////////////////////////////////////////////
386// Class implementation
387//////////////////////////////////////////////////////////////////////////////
388
Jason Sams4d339932010-05-11 14:03:58 -0700389// llvm name mangling ref
390// <builtin-type> ::= v # void
391// ::= b # bool
392// ::= c # char
393// ::= a # signed char
394// ::= h # unsigned char
395// ::= s # short
396// ::= t # unsigned short
397// ::= i # int
398// ::= j # unsigned int
399// ::= l # long
400// ::= m # unsigned long
401// ::= x # long long, __int64
402// ::= y # unsigned long long, __int64
403// ::= f # float
404// ::= d # double
Jason Samsc97bb882009-07-20 14:31:06 -0700405
Jason Sams536923d2010-05-18 13:35:45 -0700406static ScriptCState::SymbolTable_t gSyms[] = {
Jason Sams4d339932010-05-11 14:03:58 -0700407 { "__divsi3", (void *)&SC_divsi3 },
408
Jason Samsd79b2e92010-05-19 17:22:57 -0700409 // allocation
Jason Sams17966512010-07-28 11:17:53 -0700410 { "_Z19rsAllocationGetDimX13rs_allocation", (void *)&SC_allocGetDimX },
411 { "_Z19rsAllocationGetDimY13rs_allocation", (void *)&SC_allocGetDimY },
412 { "_Z19rsAllocationGetDimZ13rs_allocation", (void *)&SC_allocGetDimZ },
413 { "_Z21rsAllocationGetDimLOD13rs_allocation", (void *)&SC_allocGetDimLOD },
414 { "_Z23rsAllocationGetDimFaces13rs_allocation", (void *)&SC_allocGetDimFaces },
415 { "_Z15rsGetAllocationPKv", (void *)&SC_getAllocation },
Jason Samsd79b2e92010-05-19 17:22:57 -0700416
Jason Sams8e6c17f2010-07-19 15:38:19 -0700417 { "_Z14rsGetElementAt13rs_allocationj", (void *)&SC_getElementAtX },
418 { "_Z14rsGetElementAt13rs_allocationjj", (void *)&SC_getElementAtXY },
419 { "_Z14rsGetElementAt13rs_allocationjjj", (void *)&SC_getElementAtXYZ },
420
Jason Sams02f62aa2010-08-16 12:41:48 -0700421 { "_Z11rsSetObjectP13rs_allocation13rs_allocation", (void *)&SC_setObject },
422 { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_clearObject },
423 { "_Z10rsIsObject13rs_allocation", (void *)&SC_isObject },
424
425
Jason Samsd79b2e92010-05-19 17:22:57 -0700426 // Debug
427 { "_Z7rsDebugPKcf", (void *)&SC_debugF },
Jason Samsd64188a2010-08-06 16:22:50 -0700428 { "_Z7rsDebugPKcff", (void *)&SC_debugFv2 },
429 { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3 },
430 { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4 },
431 { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4 },
432 { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3 },
433 { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2 },
Jason Samsd79b2e92010-05-19 17:22:57 -0700434 { "_Z7rsDebugPKci", (void *)&SC_debugI32 },
Jason Sams17966512010-07-28 11:17:53 -0700435 { "_Z7rsDebugPKcj", (void *)&SC_debugU32 },
Jason Sams8e6c17f2010-07-19 15:38:19 -0700436 { "_Z7rsDebugPKcPKv", (void *)&SC_debugP },
Jason Samsd79b2e92010-05-19 17:22:57 -0700437
438 // RS Math
439 { "_Z6rsRandi", (void *)&SC_randi },
440 { "_Z6rsRandii", (void *)&SC_randi2 },
441 { "_Z6rsRandf", (void *)&SC_randf },
442 { "_Z6rsRandff", (void *)&SC_randf2 },
443 { "_Z6rsFracf", (void *)&SC_frac },
444
445 // time
Jason Samsf0690c42010-07-29 17:31:14 -0700446 { "_Z8rsSecondv", (void *)&SC_second },
447 { "_Z8rsMinutev", (void *)&SC_minute },
448 { "_Z6rsHourv", (void *)&SC_hour },
449 { "_Z5rsDayv", (void *)&SC_day },
450 { "_Z7rsMonthv", (void *)&SC_month },
451 { "_Z6rsYearv", (void *)&SC_year },
452 { "_Z14rsUptimeMillisv", (void*)&SC_uptimeMillis },
453 { "_Z13rsUptimeNanosv", (void*)&SC_uptimeNanos },
454 { "_Z7rsGetDtv", (void*)&SC_getDt },
Jason Samsd79b2e92010-05-19 17:22:57 -0700455
Jason Sams17966512010-07-28 11:17:53 -0700456 { "_Z14rsSendToClienti", (void *)&SC_toClient },
457 { "_Z14rsSendToClientiPKvj", (void *)&SC_toClient2 },
458 { "_Z22rsSendToClientBlockingi", (void *)&SC_toClientBlocking },
459 { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_toClientBlocking2 },
Jason Samsd79b2e92010-05-19 17:22:57 -0700460
Jason Sams8f8a5722010-07-15 17:11:13 -0700461 { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach },
462 //{ "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach2 },
Jason Samsd79b2e92010-05-19 17:22:57 -0700463
464////////////////////////////////////////////////////////////////////
465
Jason Sams4d339932010-05-11 14:03:58 -0700466 //{ "sinf_fast", (void *)&SC_sinf_fast },
467 //{ "cosf_fast", (void *)&SC_cosf_fast },
Jason Samsc97bb882009-07-20 14:31:06 -0700468
Jason Sams4d339932010-05-11 14:03:58 -0700469 { NULL, NULL }
Jason Samsc97bb882009-07-20 14:31:06 -0700470};
471
472const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbol(const char *sym)
473{
474 ScriptCState::SymbolTable_t *syms = gSyms;
475
476 while (syms->mPtr) {
477 if (!strcmp(syms->mName, sym)) {
478 return syms;
479 }
480 syms++;
481 }
482 return NULL;
483}
484