Cleanup of signed/unsigned
Make all functions overloadable.
Change-Id: I443c83afcf9a7acfae394585201f081681f309db
Update examples.
Change-Id: I100d6fa8dd1af376bcee0b2c42c5aabe9c03bb6e
force rebuild of all .rs files to pick up core header changes.
Change-Id: I6231a8a024388481ca231507e83b108ebdbc3500
diff --git a/scriptc/rs_math.rsh b/scriptc/rs_math.rsh
index 309a952..66171d8 100644
--- a/scriptc/rs_math.rsh
+++ b/scriptc/rs_math.rsh
@@ -4,11 +4,14 @@
#include "rs_cl.rsh"
#include "rs_core.rsh"
-
-
// Allocations
+
+// Return the rs_allocation associated with a bound data
+// pointer.
extern rs_allocation __attribute__((overloadable))
rsGetAllocation(const void *);
+
+// Return the dimensions associated with an allocation.
extern uint32_t __attribute__((overloadable))
rsAllocationGetDimX(rs_allocation);
extern uint32_t __attribute__((overloadable))
@@ -20,6 +23,7 @@
extern uint32_t __attribute__((overloadable))
rsAllocationGetDimFaces(rs_allocation);
+// Extract a single element from an allocation.
extern const void * __attribute__((overloadable))
rsGetElementAt(rs_allocation, uint32_t x);
extern const void * __attribute__((overloadable))
@@ -28,41 +32,79 @@
rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
-// Debugging
-extern void __attribute__((overloadable))rsDebug(const char *, float);
-extern void __attribute__((overloadable))rsDebug(const char *, float2);
-extern void __attribute__((overloadable))rsDebug(const char *, float3);
-extern void __attribute__((overloadable))rsDebug(const char *, float4);
-extern void __attribute__((overloadable))rsDebug(const char *, int);
-extern void __attribute__((overloadable))rsDebug(const char *, uint);
-extern void __attribute__((overloadable))rsDebug(const char *, const void *);
+// Debugging, print to the LOG a description string and a value.
+extern void __attribute__((overloadable))
+ rsDebug(const char *, float);
+extern void __attribute__((overloadable))
+ rsDebug(const char *, float2);
+extern void __attribute__((overloadable))
+ rsDebug(const char *, float3);
+extern void __attribute__((overloadable))
+ rsDebug(const char *, float4);
+extern void __attribute__((overloadable))
+ rsDebug(const char *, int);
+extern void __attribute__((overloadable))
+ rsDebug(const char *, uint);
+extern void __attribute__((overloadable))
+ rsDebug(const char *, const void *);
#define RS_DEBUG(a) rsDebug(#a, a)
#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
-// RS Math
-extern int __attribute__((overloadable))rsRand(int);
-extern int __attribute__((overloadable))rsRand(int, int);
-extern float __attribute__((overloadable))rsRand(float);
-extern float __attribute__((overloadable))rsRand(float, float);
+// Return a random value between 0 (or min_value) and max_malue.
+extern int __attribute__((overloadable))
+ rsRand(int max_value);
+extern int __attribute__((overloadable))
+ rsRand(int min_value, int max_value);
+extern float __attribute__((overloadable))
+ rsRand(float max_value);
+extern float __attribute__((overloadable))
+ rsRand(float min_value, float max_value);
-extern float __attribute__((overloadable)) rsFrac(float);
+// return the fractional part of a float
+// min(v - ((int)floor(v)), 0x1.fffffep-1f);
+extern float __attribute__((overloadable))
+ rsFrac(float);
// time
-extern int32_t /*__attribute__((overloadable))*/rsSecond();
-extern int32_t /*__attribute__((overloadable))*/rsMinute();
-extern int32_t /*__attribute__((overloadable))*/rsHour();
-extern int32_t /*__attribute__((overloadable))*/rsDay();
-extern int32_t /*__attribute__((overloadable))*/rsMonth();
-extern int32_t /*__attribute__((overloadable))*/rsYear();
-extern int64_t /*__attribute__((overloadable))*/rsUptimeMillis();
-extern int64_t /*__attribute__((overloadable))*/rsStartTimeMillis();
-extern int64_t /*__attribute__((overloadable))*/rsElapsedTimeMillis();
-extern float /*__attribute__((overloadable))*/rsGetDt();
+extern int32_t __attribute__((overloadable))
+ rsSecond(void);
+extern int32_t __attribute__((overloadable))
+ rsMinute(void);
+extern int32_t __attribute__((overloadable))
+ rsHour(void);
+extern int32_t __attribute__((overloadable))
+ rsDay(void);
+extern int32_t __attribute__((overloadable))
+ rsMonth(void);
+extern int32_t __attribute__((overloadable))
+ rsYear(void);
-extern bool __attribute__((overloadable))rsSendToClient(int cmdID);
-extern bool __attribute__((overloadable))rsSendToClient(int cmdID, const void *data, uint len);
-extern void __attribute__((overloadable))rsSendToClientBlocking(int cmdID);
-extern void __attribute__((overloadable))rsSendToClientBlocking(int cmdID, const void *data, uint len);
+// Return the current system clock in milliseconds
+extern int64_t __attribute__((overloadable))
+ rsUptimeMillis(void);
+
+// Return the current system clock in nanoseconds
+extern int64_t __attribute__((overloadable))
+ rsUptimeNanos(void);
+
+// Return the time in seconds since function was last called in this script.
+extern float __attribute__((overloadable))
+ rsGetDt(void);
+
+// Send a message back to the client. Will not block and returns true
+// if the message was sendable and false if the fifo was full.
+// A message ID is required. Data payload is optional.
+extern bool __attribute__((overloadable))
+ rsSendToClient(int cmdID);
+extern bool __attribute__((overloadable))
+ rsSendToClient(int cmdID, const void *data, uint len);
+
+// Send a message back to the client, blocking until the message is queued.
+// A message ID is required. Data payload is optional.
+extern void __attribute__((overloadable))
+ rsSendToClientBlocking(int cmdID);
+extern void __attribute__((overloadable))
+ rsSendToClientBlocking(int cmdID, const void *data, uint len);
// Script to Script
typedef struct rs_script_call {
@@ -77,15 +119,13 @@
} rs_script_call_t;
-extern void __attribute__((overloadable))rsForEach(rs_script script,
- rs_allocation input,
- rs_allocation output,
- const void * usrData);
+extern void __attribute__((overloadable))
+ rsForEach(rs_script script, rs_allocation input,
+ rs_allocation output, const void * usrData);
-extern void __attribute__((overloadable))rsForEach(rs_script script,
- rs_allocation input,
- rs_allocation output,
- const void * usrData,
- const rs_script_call_t *);
+extern void __attribute__((overloadable))
+ rsForEach(rs_script script, rs_allocation input,
+ rs_allocation output, const void * usrData,
+ const rs_script_call_t *);
#endif