summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxant <xant@dyne.org>2012-12-10 17:25:49 (GMT)
committer xant <xant@dyne.org>2012-12-10 17:25:49 (GMT)
commit2f5f1026b018345836c4841c47ad1de9af6099d6 (patch)
treead354ac57a522bb212d18a0971b0b02d4de5bcaa
parent1cdd5eb85a575ed51db2615d8eb92c11a79f46c1 (diff)
minor cleanings and adjustments to avoid warnings in the new xcode
-rw-r--r--core/JMXThreadedEntity.h2
-rw-r--r--core/JMXThreadedEntity.mm22
-rw-r--r--entities/JMXScriptEntity.mm8
-rw-r--r--entities/JMXScriptFile.mm4
-rw-r--r--entities/JMXScriptLive.h2
-rw-r--r--entities/JMXScriptLive.mm44
-rw-r--r--entities/audio/JMXAudioToneGenerator.mm4
-rw-r--r--javascript_examples/canvas_sample1.js2
-rwxr-xr-xjavascript_examples/processing_sample3.js6
-rw-r--r--node.js/uv/src/ares/ares_process.c2
-rw-r--r--node.js/uv/src/unix/eio/eio.c23
-rw-r--r--node.js/uv/src/unix/fs.c2
12 files changed, 73 insertions, 48 deletions
diff --git a/core/JMXThreadedEntity.h b/core/JMXThreadedEntity.h
index 3490864..33849c5 100644
--- a/core/JMXThreadedEntity.h
+++ b/core/JMXThreadedEntity.h
@@ -138,6 +138,8 @@
*/
@property (readwrite, assign) BOOL quit;
+@property (readonly, retain) NSThread *worker;
+
/*!
@method threadedEntity:
@param entity The entity
diff --git a/core/JMXThreadedEntity.mm b/core/JMXThreadedEntity.mm
index c03b5f1..0a802bf 100644
--- a/core/JMXThreadedEntity.mm
+++ b/core/JMXThreadedEntity.mm
@@ -40,7 +40,7 @@
@implementation JMXThreadedEntity
-@synthesize frequency, previousTimeStamp, quit, realEntity;
+@synthesize frequency, previousTimeStamp, quit, realEntity, worker;
+ (id)threadedEntity:(JMXEntity *)entity
{
@@ -161,6 +161,7 @@
[realEntity addPrivateData:self forKey:@"threadedEntity"];
NSDebug(@"Thread %@ starting", self);
worker = [[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil];
+ [worker setName:realEntity.name];
[worker setThreadPriority:1.0];
[worker start];
quit = NO;
@@ -237,17 +238,6 @@
- (void)run
{
-#if 0
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- double maxDelta = 1.0/[self.frequency doubleValue];
- timer = [NSTimer timerWithTimeInterval:maxDelta target:self selector:@selector(signalTick:) userInfo:nil repeats:YES];
- realEntity.active = YES;
- NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
- [runLoop addTimer:timer forMode:NSRunLoopCommonModes];
- [runLoop run];
- realEntity.active = NO;
- [pool drain];
-#else
NSThread *currentThread = [NSThread currentThread];
realEntity.active = YES;
while (![currentThread isCancelled]) {
@@ -266,7 +256,6 @@
uint64_t sleepTime = (delta && delta < maxDelta) ? maxDelta - delta : 0;
if (sleepTime) {
-#if 1
// using nanosleep is a good portable way, but since we are running
// on OSX only, we should try relying on the NSThread API.
// We will switch back to nanosleep if we notice that 'sleepForTimeInterval'
@@ -279,12 +268,6 @@
remainder.tv_nsec = 0;
nanosleep(&time, &remainder);
} while (remainder.tv_sec || remainder.tv_nsec);
-#else
- // let's try if NSThread facilities are reliable (in terms of time precision)
- do {
- [NSThread sleepForTimeInterval:0.001];
- } while (CVGetCurrentHostTime() - timeStamp <= sleepTime); // we need to be as precise as possible
-#endif
} else {
// mmm ... no sleep time ... perhaps we are out of resources and slowing down mixing
// TODO - produce a warning in this case
@@ -292,7 +275,6 @@
[pool drain];
}
realEntity.active = NO;
-#endif
}
- (void)setActive:(BOOL)value
diff --git a/entities/JMXScriptEntity.mm b/entities/JMXScriptEntity.mm
index 1d89a50..3b892ef 100644
--- a/entities/JMXScriptEntity.mm
+++ b/entities/JMXScriptEntity.mm
@@ -58,10 +58,6 @@ using namespace v8;
return self;
}
-- (id)retain
-{
- return [super retain];
-}
- (void)dealloc
{
[self resetContext];
@@ -184,14 +180,14 @@ using namespace v8;
- (NSString *)code
{
- @synchronized(jsContext) {
+ @synchronized(self) {
return [[code copy] autorelease];
}
}
- (void)setCode:(NSString *)someCode
{
- @synchronized(jsContext) {
+ @synchronized(self) {
if (code == someCode)
return;
[code release];
diff --git a/entities/JMXScriptFile.mm b/entities/JMXScriptFile.mm
index f3e2e29..d1ee966 100644
--- a/entities/JMXScriptFile.mm
+++ b/entities/JMXScriptFile.mm
@@ -106,8 +106,8 @@ extern void JSExit(int code);
[self exec];
}
}
- if (isRunning && jsContext)
- [jsContext nodejsRun];
+// if (isRunning && jsContext)
+// [jsContext nodejsRun];
[super tick:timeStamp];
}
diff --git a/entities/JMXScriptLive.h b/entities/JMXScriptLive.h
index 104ee9d..2d37569 100644
--- a/entities/JMXScriptLive.h
+++ b/entities/JMXScriptLive.h
@@ -16,6 +16,8 @@
JMXInputPin *codeInputPin;
}
+@property (readonly) NSThread *scriptThread;
+
- (void)execCode:(NSString *)code;
@end
diff --git a/entities/JMXScriptLive.mm b/entities/JMXScriptLive.mm
index 5a81024..28b27df 100644
--- a/entities/JMXScriptLive.mm
+++ b/entities/JMXScriptLive.mm
@@ -11,6 +11,24 @@
#import "JMXScript.h"
@implementation JMXScriptLive
+@synthesize scriptThread;
+
+- (id)initWithName:(NSString *)name
+{
+ self = [super initWithName:name];
+ if (self) {
+ codeInputPin = [self registerInputPin:@"code" withType:kJMXCodePin andSelector:@"execCode:"];
+ JMXThreadedEntity *threadedEntity = [[JMXThreadedEntity threadedEntity:self] retain];
+ if (threadedEntity) {
+ scriptThread = threadedEntity.worker;
+ return (JMXScriptLive *)threadedEntity;
+ } else {
+ [self release];
+ return nil;
+ }
+ }
+ return self;
+}
- (id)init
{
@@ -19,13 +37,18 @@
self.label = @"JMXScriptLive";
codeInputPin = [self registerInputPin:@"code" withType:kJMXCodePin andSelector:@"execCode:"];
JMXThreadedEntity *threadedEntity = [[JMXThreadedEntity threadedEntity:self] retain];
- if (threadedEntity)
+ if (threadedEntity) {
+ scriptThread = threadedEntity.worker;
return (JMXScriptLive *)threadedEntity;
+ } else {
+ [self release];
+ return nil;
+ }
}
return self;
}
-- (void)execCode:(NSString *)jsCode
+- (void)execCodeInternal:(NSString *)jsCode
{
@synchronized(self) {
if ([self exec:jsCode]) {
@@ -37,6 +60,15 @@
}
}
+- (void)execCode:(NSString *)jsCode
+{
+ [self performSelector:@selector(execCodeInternal:)
+ onThread:[self scriptThread]
+ withObject:jsCode
+ waitUntilDone:YES
+ modes:nil];
+}
+
- (void)dealloc
{
[super dealloc];
@@ -44,10 +76,10 @@
- (void)tick:(uint64_t)timeStamp
{
- @synchronized(self) {
- if (jsContext)
- [jsContext nodejsRun];
- }
+// @synchronized(self) {
+// if (jsContext)
+// [jsContext nodejsRun];
+// }
[super tick:timeStamp];
}
diff --git a/entities/audio/JMXAudioToneGenerator.mm b/entities/audio/JMXAudioToneGenerator.mm
index 924f23e..3657e3f 100644
--- a/entities/audio/JMXAudioToneGenerator.mm
+++ b/entities/audio/JMXAudioToneGenerator.mm
@@ -69,9 +69,9 @@
UInt32 nFrames = 512;
UInt32 dataSize = nFrames * theOutputFormat.mBytesPerFrame;
- data = malloc(dataSize);
+ data = (Float32 *)malloc(dataSize);
- AudioBufferList *theDataBuffer = calloc(1, sizeof(AudioBufferList));
+ AudioBufferList *theDataBuffer = (AudioBufferList *)calloc(1, sizeof(AudioBufferList));
theDataBuffer->mNumberBuffers = 1;
theDataBuffer->mBuffers[0].mDataByteSize = dataSize;
theDataBuffer->mBuffers[0].mNumberChannels = 2;
diff --git a/javascript_examples/canvas_sample1.js b/javascript_examples/canvas_sample1.js
index 7f21ca4..2e2168d 100644
--- a/javascript_examples/canvas_sample1.js
+++ b/javascript_examples/canvas_sample1.js
@@ -44,7 +44,7 @@ function line() {
setInterval(line, 50);
function blank() {
- context.fillStyle = 'rgba(0, 0, 0, 0.1)';
+ context.fillStyle = 'rgba(0,0,0,0.1)';
context.fillRect(0, 0, canvas.width, canvas.height);
}
setInterval(blank, 40);
diff --git a/javascript_examples/processing_sample3.js b/javascript_examples/processing_sample3.js
index 0811279..278b9f9 100755
--- a/javascript_examples/processing_sample3.js
+++ b/javascript_examples/processing_sample3.js
@@ -60,6 +60,12 @@ function sketchProc(processing) {
// Draw circle
processing.ellipse( X, Y, radius, radius );
};
+
+ processing.mouseMoved = function() {
+ nX = processing.mouseX;
+ nY = processing.mouseY;
+ };
+
}
//var canvas = $('canvas:first', drawer).get(0);
diff --git a/node.js/uv/src/ares/ares_process.c b/node.js/uv/src/ares/ares_process.c
index e5efa5f..4efa499 100644
--- a/node.js/uv/src/ares/ares_process.c
+++ b/node.js/uv/src/ares/ares_process.c
@@ -478,7 +478,7 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
else
fromlen = sizeof(from.sa6);
count = (ssize_t)recvfrom(server->udp_socket, (void *)buf, sizeof(buf),
- 0, &from.sa, &fromlen);
+ 0, &from.sa, (socklen_t *)&fromlen);
#else
count = sread(server->udp_socket, buf, sizeof(buf));
#endif
diff --git a/node.js/uv/src/unix/eio/eio.c b/node.js/uv/src/unix/eio/eio.c
index 9a075b9..d1e3674 100644
--- a/node.js/uv/src/unix/eio/eio.c
+++ b/node.js/uv/src/unix/eio/eio.c
@@ -56,6 +56,7 @@
#endif
#include "xthread.h"
+#include <stdio.h>
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
@@ -1055,10 +1056,10 @@ eio__futimes (int fd, const struct timeval tv[2])
#endif
-#if !HAVE_FDATASYNC
+//#if !HAVE_FDATASYNC
# undef fdatasync
# define fdatasync(fd) fsync (fd)
-#endif
+//#endif
static int
eio__syncfs (int fd)
@@ -1405,11 +1406,13 @@ eio__mtouch (eio_req *req)
intptr_t end = addr + len;
intptr_t page = eio_pagesize ();
- if (addr < end)
- if (flags & EIO_MT_MODIFY) /* modify */
+ if (addr < end) {
+ if (flags & EIO_MT_MODIFY) {/* modify */
do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len && !EIO_CANCELLED (req));
- else
+ } else {
do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len && !EIO_CANCELLED (req));
+ }
+ }
}
return 0;
@@ -1851,12 +1854,12 @@ eio__scandir (eio_req *req, etp_worker *self)
req->int1 = flags;
req->result = dentoffs;
- if (flags & EIO_READDIR_STAT_ORDER)
+ if (flags & EIO_READDIR_STAT_ORDER) {
eio_dent_sort (dents, dentoffs, flags & EIO_READDIR_DIRS_FIRST ? 7 : 0, inode_bits);
- else if (flags & EIO_READDIR_DIRS_FIRST)
- if (flags & EIO_READDIR_FOUND_UNKNOWN)
+ } else if (flags & EIO_READDIR_DIRS_FIRST) {
+ if (flags & EIO_READDIR_FOUND_UNKNOWN) {
eio_dent_sort (dents, dentoffs, 7, inode_bits); /* sort by score and inode */
- else
+ } else
{
/* in this case, all is known, and we just put dirs first and sort them */
eio_dirent *oth = dents + dentoffs;
@@ -1879,7 +1882,7 @@ eio__scandir (eio_req *req, etp_worker *self)
/* now sort the dirs only (dirs all have the same score) */
eio_dent_sort (dents, dir - dents, 0, inode_bits);
}
-
+ }
break;
}
diff --git a/node.js/uv/src/unix/fs.c b/node.js/uv/src/unix/fs.c
index 57664c8..a37223f 100644
--- a/node.js/uv/src/unix/fs.c
+++ b/node.js/uv/src/unix/fs.c
@@ -34,6 +34,8 @@
#include <utime.h>
#include <sys/time.h>
+# undef fdatasync
+# define fdatasync(fd) fsync (fd)
#define ARGS1(a) (a)
#define ARGS2(a,b) (a), (b)