[SCM] supercollider/upstream: Imported Upstream version 3.4.2

danstowell-guest at users.alioth.debian.org danstowell-guest at users.alioth.debian.org
Mon Mar 28 21:36:38 UTC 2011


The following commit has been merged in the upstream branch:
commit c0429f9dcde5196046775eedb8cdc54397d60130
Author: Dan Stowell <danstowell at users.sourceforge.net>
Date:   Mon Mar 28 22:06:38 2011 +0100

    Imported Upstream version 3.4.2

diff --git a/README LINUX b/README LINUX
index 9e07107..8d07d06 100644
--- a/README LINUX	
+++ b/README LINUX	
@@ -1,7 +1,7 @@
 -*-text-*---------------------------------------------------------------
 supercollider 3 for linux
 ------------------------------------------------------------------------
-$Id: README LINUX 10144 2010-06-05 07:37:21Z danstowell $
+$Id$
 ------------------------------------------------------------------------
 
 ------------------------------------------------------------------------
diff --git a/VERSION b/VERSION
index 965e052..2d54055 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-3.4
-classvar scVersionMajor=3, scVersionMinor=4, scVersionPostfix="";
+3.4.2
+classvar scVersionMajor=3, scVersionMinor=4, scVersionPostfix=".2";
diff --git a/common/Headers/common/SC_DirUtils.h b/common/Headers/common/SC_DirUtils.h
index 3f24c5a..f094aba 100644
--- a/common/Headers/common/SC_DirUtils.h
+++ b/common/Headers/common/SC_DirUtils.h
@@ -58,7 +58,7 @@ bool sc_IsNonHostPlatformDir(const char *name);
 // Returns TRUE iff 'name' is to be ignored during compilation.
 bool sc_SkipDirectory(const char *name);
 
-void sc_ResolveIfAlias(const char *path, char *returnPath, bool &isAlias, int length);
+int sc_ResolveIfAlias(const char *path, char *returnPath, bool &isAlias, int length);
 
 extern char *gIdeName; // string used for conditional compilation according to which IDE is in use this session.
 // for example, if the value is "scapp" then folders "scide_scapp" will be included, all other "scide_*" excluded.
diff --git a/common/Headers/common/SC_StringBuffer.h b/common/Headers/common/SC_StringBuffer.h
index c850f2b..16bc78f 100644
--- a/common/Headers/common/SC_StringBuffer.h
+++ b/common/Headers/common/SC_StringBuffer.h
@@ -1,7 +1,7 @@
 // emacs:		-*- c++ -*-
 // file:		SC_StringBuffer.h
 // copyright:	2003 stefan kersten <steve at k-hornz.de>
-// cvs:			$Id: SC_StringBuffer.h 9082 2009-04-20 08:38:27Z danstowell $
+// cvs:			$Id$
 
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
diff --git a/common/Headers/common/SC_StringParser.h b/common/Headers/common/SC_StringParser.h
index 18e37e2..ac69950 100644
--- a/common/Headers/common/SC_StringParser.h
+++ b/common/Headers/common/SC_StringParser.h
@@ -1,7 +1,7 @@
 // emacs:		-*- c++ -*-
 // file:		SC_StringParser.h
 // copyright:	2003-2006 stefan kersten
-// cvs:			$Id: SC_StringParser.h 9082 2009-04-20 08:38:27Z danstowell $
+// cvs:			$Id$
 
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
diff --git a/common/Headers/lang/PyrLexer.h b/common/Headers/lang/PyrLexer.h
index ad886cd..e748426 100644
--- a/common/Headers/lang/PyrLexer.h
+++ b/common/Headers/lang/PyrLexer.h
@@ -76,7 +76,7 @@ int yylex() ;
 void yyerror(char *s) ;
 void fatal() ;
 bool isValidSourceFileName(char *filename);
-bool passOne_ProcessOneFile(char *filename, int level);
+bool passOne_ProcessOneFile(const char *filename, int level);
 
 extern void asRelativePath(char *inPath,char *outPath);
 
diff --git a/common/Headers/lang/PyrSlot32.h b/common/Headers/lang/PyrSlot32.h
index 8b67332..7c40fc5 100644
--- a/common/Headers/lang/PyrSlot32.h
+++ b/common/Headers/lang/PyrSlot32.h
@@ -194,6 +194,7 @@ inline bool IsFloat(PyrSlot* slot) { return (((slot)->utag & 0xFFFFFFF0) != 0x7F
 inline bool NotFloat(PyrSlot* slot) { return (((slot)->utag & 0xFFFFFFF0) == 0x7FF90000); }
 
 inline bool IsPtr(PyrSlot* slot) { return ((slot)->utag == tagPtr); }
+inline bool NotPtr(PyrSlot* slot) { return ((slot)->utag != tagPtr); }
 
 inline void SetRawChar(PyrSlot* slot, int val) { assert(IsChar(slot)); slot->uc = val; }
 inline void SetRaw(PyrSlot* slot, int val) { assert(IsInt(slot)); slot->ui = val; }
diff --git a/common/Headers/lang/SC_LibraryConfig.h b/common/Headers/lang/SC_LibraryConfig.h
index b521c11..5ebb1b7 100644
--- a/common/Headers/lang/SC_LibraryConfig.h
+++ b/common/Headers/lang/SC_LibraryConfig.h
@@ -1,6 +1,6 @@
 // emacs:		-*- c++ -*-
 // file:		SC_LibraryConfig.h
-// cvs:			$Id: SC_LibraryConfig.h 9417 2009-09-26 06:17:48Z timblech $
+// cvs:			$Id$
 
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
diff --git a/common/Packager/package b/common/Packager/package
index 96e1195..cf93a0d 100755
--- a/common/Packager/package
+++ b/common/Packager/package
@@ -32,19 +32,17 @@ do
 done
 shift $(($OPTIND - 1))
 
-revision=`svnversion -n ../../`
-if ( echo $revision | grep "M" > /dev/null 2>&1 ); then
-    echo "WARNING: The working copy has uncommitted changes which will be included in the package."
+revision=`git rev-list HEAD -1 | sed -E 's/([[:alnum:]]{1,10}).*/\1/'`
+if [ "`git status -s -uno`" != "" ]; then
+    echo "WARNING: The working copy has uncommitted changes which will NOT be included in the package."
 fi
 
-if ( echo $revision | grep ":" > /dev/null 2>&1 ); then
-    echo "WARNING: The working copy has mixed revision numbers (some folders had 'svn update' ran more recently than others)."
-fi
-revision=`echo $revision | sed -e 's/^[^:]*://;s/[A-Za-z]//'`
-
 if [ $package_type == "source" ]; then
     mkdir SuperCollider-Source
-    svn export -q --force ../../ SuperCollider-Source
+    returndir=`pwd`
+    cd ../../
+    git archive $revision | tar -x --exclude ".gitignore" -C "$returndir/SuperCollider-Source"
+    cd $returndir
     
     if $include_optionals; then
         cp -Rp optional SuperCollider-Source/optional_installs
@@ -57,7 +55,7 @@ if [ $package_type == "source" ]; then
     fi
         
     # Here we build a list of (many) files that are useless on linux, so as to build a slimline source.tar.gz
-    find SuperCollider-Source -iname windows -or -iname osx -or -name "*.xcodeproj" -or -name scide_scapp -or -name "iPhone*" > LinuxExclusions.txt
+    find SuperCollider-Source -iname windows -or -iname osx -or -name "*.xcodeproj" -or -name scide_scapp -or -iname "iPhone*" > LinuxExclusions.txt
 	echo 'SuperCollider-Source/SuperColliderAU
 SuperCollider-Source/Psycollider
 SuperCollider-Source/README OS X
@@ -69,6 +67,7 @@ SuperCollider-Source/common/include/icu
 SuperCollider-Source/mac
 SuperCollider-Source/iphone
 SuperCollider-Source/common/Source/lang/LangPrimSource/HID_Utilities
+SuperCollider-Source/common/Source/lang/LangPrimSource/WiiMote_OSX
 SuperCollider-Source/common/Headers/app
 SuperCollider-Source/common/Source/app' >> LinuxExclusions.txt
     
@@ -88,10 +87,14 @@ else
     about_version="$version (Revision $revision)"
     echo "About box version string:" $about_version
 
-    svn export -q --force ../../common/build SuperCollider
-    cp -R ../../common/build/SuperCollider.app ../../common/build/scsynth ../../common/build/sclang SuperCollider
-    cp ../../common/build/plugins/* SuperCollider/plugins/
-    cp ../../COPYING SuperCollider/COPYING
+    mkdir -p SuperCollider/plugins
+    returndir=`pwd`
+    cd ../../common/build
+    git archive $revision | tar -x -C "$returndir/SuperCollider"
+    cp -R SuperCollider.app scsynth sclang "$returndir/SuperCollider/"
+    cp plugins/* "$returndir/SuperCollider/plugins/"
+    cp ../../COPYING "$returndir/SuperCollider/"
+    cd $returndir
     find SuperCollider/help/ \( -name "*.htm" -or -name "*.html" \) -exec /Developer/Tools/SetFile -c SCjm {} \;
     defaults write $PWD/SuperCollider/SuperCollider.app/Contents/Info CFBundleVersion -string "$about_version"
     defaults write $PWD/SuperCollider/SuperCollider.app/Contents/Info CFBundleGetInfoString -string "$version"
diff --git a/common/SConstruct b/common/SConstruct
index 204f366..0b049de 100644
--- a/common/SConstruct
+++ b/common/SConstruct
@@ -51,7 +51,7 @@ PLATFORM = platform.uname()[0].lower()
 CPU = short_cpu_name(platform.uname()[4])
 
 ANY_FILE_RE = re.compile('.*')
-HELP_FILE_RE = re.compile('.*\.(rtf(d)?|scd|html)$')
+HELP_FILE_RE = re.compile('.*\.(rtf(d)?|scd|htm(l)?)$')
 SC_FILE_RE = re.compile('.*\.sc$')
 SRC_FILE_RE = re.compile('.*\.(c(pp)|h)$')
 
@@ -267,6 +267,26 @@ def make_static_object(env, source, postfix="_a"):
 def make_static_objects(env, sources, postfix="_a"):
     return map(lambda x: make_static_object(env, x, postfix), sources)
 
+# for linking libX.so => libX.so.1 on *nixy systems. Note, they must be in same dir.
+def make_local_symlink(target, source, env):
+    targetname = os.path.basename(str(target[0]))
+    if os.path.isfile(targetname):
+        if not os.path.islink(targetname):
+            liblog.error("ERROR: cannot create symlink %s because already exists as non-symlink." % (targetname))
+    else:
+	    os.symlink(os.path.basename(str(source[0])), targetname)
+    return None
+
+# for linking libX.so => libX.so.1 on *nixy systems. Note, they must be in same dir.
+def make_local_symlink(target, source, env):
+    targetname = os.path.basename(str(target[0]))
+    if os.path.isfile(targetname):
+        if not os.path.islink(targetname):
+            liblog.error("ERROR: cannot create symlink %s because already exists as non-symlink." % (targetname))
+    else:
+	    os.symlink(os.path.basename(str(source[0])), targetname)
+    return None
+
 # ======================================================================
 # command line options
 # ======================================================================
@@ -288,7 +308,8 @@ opts.AddOptions(
     BoolOption('DEBUG',
                'Build with debugging information', 0),
     PathOption('DESTDIR',
-               'Intermediate installation prefix for packaging', '/'),
+               'Intermediate installation prefix for packaging', '/',
+               PathOption.PathAccept),
     BoolOption('DEVELOPMENT',
                'Build and install the development files', 0),
     BoolOption('FFTW',
@@ -751,17 +772,6 @@ serverEnv.Append(
                '#Headers/server'],
     CPPDEFINES = [('SC_PLUGIN_DIR', '\\"' + pkg_lib_dir(FINAL_PREFIX, 'plugins') + '\\"'), ('SC_PLUGIN_EXT', '\\"' + PLUGIN_EXT + '\\"')],
     LIBPATH = 'build')
-libscsynthEnv = serverEnv.Clone(
-    PKGCONFIG_NAME = 'libscsynth',
-    PKGCONFIG_DESC = 'SuperCollider synthesis server library',
-    PKGCONFIG_PREFIX = FINAL_PREFIX,
-    PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile'],
-                                                 libraries['audioapi'],
-                                                 libraries['rendezvous']),
-    PKGCONFIG_LIBS = ['-lscsynth'],
-#     PKGCONFIG_LIBS_PRIVATE = ['-lm', '-lpthread', '-ldl'],
-    PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/server']
-    )
 
 # platform specific
 
@@ -797,6 +807,25 @@ if env['CURL']:
     serverEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
     merge_lib_info(serverEnv, libraries['libcurl'])
 
+libscsynthEnv = serverEnv.Clone(
+    PKGCONFIG_NAME = 'libscsynth',
+    PKGCONFIG_DESC = 'SuperCollider synthesis server library',
+    PKGCONFIG_PREFIX = FINAL_PREFIX,
+    PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile'],
+                                                 libraries['audioapi'],
+                                                 libraries['rendezvous']),
+    PKGCONFIG_LIBS = ['-lscsynth'],
+#     PKGCONFIG_LIBS_PRIVATE = ['-lm', '-lpthread', '-ldl'],
+    PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/server'],
+    SHLIBSUFFIX='.so.1.0.0',
+    LIBSUFFIXES=['.so.1.0.0']
+    )
+if PLATFORM == 'linux':
+    libscsynthEnv.Append(
+        LINKFLAGS = ['-Wl,-soname,libscsynth.so.1.0.0'])
+    # create local symlink for linker to follow (not installed)
+    libscsynthEnv.Command('build/libscsynth.so', 'build/libscsynth.so.1.0.0', make_local_symlink, chdir=1)
+
 libscsynthSources = Split('''
 Source/server/Rendezvous.cpp
 Source/server/Samp.cpp
@@ -824,8 +853,9 @@ Source/server/SC_World.cpp
 
 scsynthSources = ['Source/server/scsynth_main.cpp']
 
-libscsynth = serverEnv.SharedLibrary('build/scsynth', libscsynthSources)
+libscsynth = libscsynthEnv.SharedLibrary('build/scsynth', libscsynthSources)
 env.Alias('install-programs', env.Install(lib_dir(INSTALL_PREFIX), [libscsynth]))
+env.Alias('install-programs', env.Command(lib_dir(INSTALL_PREFIX) + '/libscsynth.so', lib_dir(INSTALL_PREFIX) + '/libscsynth.so.1.0.0', make_local_symlink, chdir=1))
 
 libscsynthStaticSources = libscsynthSources + make_static_objects(serverEnv, commonSources, "_libscsynthStatic");
 libscsynthStatic = serverEnv.StaticLibrary('build/scsynth', libscsynthStaticSources)
@@ -1033,11 +1063,16 @@ libsclangEnv = langEnv.Clone(
     PKGCONFIG_PREFIX = FINAL_PREFIX,
     PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile']) + ['libscsynth'],
     PKGCONFIG_LIBS = ['-lsclang'],
-    PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/lang', '-I${includedir}/server']
+    PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/lang', '-I${includedir}/server'],
+    SHLIBSUFFIX='.so.1.0.0',
+    LIBSUFFIXES=['.so.1.0.0']
     )
 if PLATFORM == 'linux':
     libsclangEnv.Append(
-        LINKFLAGS = ['-Wl,-soname,libsclang.so'])
+        LINKFLAGS = ['-Wl,-soname,libsclang.so.1.0.0'])
+    # create local symlink for linker to follow (not installed)
+    libsclangEnv.Command('build/libsclang.so', 'build/libsclang.so.1.0.0', make_local_symlink, chdir=1)
+    Requires('build/libsclang.so.1.0.0', 'build/libscsynth.so')
 
 # required libraries
 merge_lib_info(langEnv, libraries['sndfile'])
@@ -1140,8 +1175,9 @@ if PLATFORM == 'darwin':
 sclangSources = ['Source/lang/LangSource/cmdLineFuncs.cpp']
 
 if env['LANG']:
-    libsclang = langEnv.SharedLibrary('build/sclang', libsclangSources)
+    libsclang = libsclangEnv.SharedLibrary('build/sclang', libsclangSources)
     env.Alias('install-bin', env.Install(lib_dir(INSTALL_PREFIX), [libsclang]))
+    env.Alias('install-bin', env.Command(lib_dir(INSTALL_PREFIX) + '/libsclang.so', lib_dir(INSTALL_PREFIX) + '/libsclang.so.1.0.0', make_local_symlink, chdir=1))
     if PLATFORM == 'darwin':
         sclangLibs = ['scsynth', 'sclang']
     else:
diff --git a/common/Source/common/SC_DirUtils.cpp b/common/Source/common/SC_DirUtils.cpp
index d0de205..09a68a9 100644
--- a/common/Source/common/SC_DirUtils.cpp
+++ b/common/Source/common/SC_DirUtils.cpp
@@ -173,39 +173,44 @@ bool sc_SkipDirectory(const char *name)
 }
 
 
-void sc_ResolveIfAlias(const char *path, char *returnPath, bool &isAlias, int length)
+int sc_ResolveIfAlias(const char *path, char *returnPath, bool &isAlias, int length)
 {
 	isAlias = false;
-#ifdef SC_DARWIN
+#if defined(__APPLE__) && !defined(SC_IPHONE)
 	FSRef dirRef;
 	OSStatus osStatusErr = FSPathMakeRef ((const UInt8 *) path, &dirRef, NULL);
 	if ( !osStatusErr ) {
 		Boolean isFolder;
 		Boolean wasAliased;
 		OSErr err = FSResolveAliasFile (&dirRef, true, &isFolder, &wasAliased);
+		if (err)
+		{
+			return -1;
+		}
 		isAlias = wasAliased;
-		if ( !err && wasAliased ) {
+		if (wasAliased)
+		{
 			UInt8 resolvedPath[PATH_MAX];
 			osStatusErr = FSRefMakePath (&dirRef, resolvedPath, length);
-			if ( !osStatusErr ) {
-				strncpy(returnPath, (char *) resolvedPath, length);
-				return;
+			if (osStatusErr)
+			{
+				return -1;
 			}
+			strncpy(returnPath, (char *) resolvedPath, length);
+			return 0;
 		}
 	}
-#elif defined(SC_LINUX)
+#elif defined(__linux__) || defined(__FreeBSD__)
 	isAlias = sc_IsSymlink(path);
-	if (!realpath(path, returnPath))
-		strcpy(returnPath, path);
-	return;
-#elif defined(SC_FREEBSD)
-	isAlias = sc_IsSymlink(path);
-	if (!realpath(path, returnPath))
-		strcpy(returnPath, path);
-	return;
+	if (realpath(path, returnPath))
+	{
+		return 0;
+	}
+
+	return -1;
 #endif
 	strcpy(returnPath, path);
-	return;
+	return 0;
 }
 
 // Support for Bundles
@@ -544,16 +549,16 @@ bool downloadToFp(FILE* fp, const char* mFilename){
 	char* errstr = (char*)malloc(CURL_ERROR_SIZE);
 	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errstr);
 	if((ret = curl_easy_setopt(curl, CURLOPT_URL, mFilename)) != 0){
-		scprintf("CURL setopt error while setting URL. Error code %i\n%s\n", ret, errstr);
+		printf("CURL setopt error while setting URL. Error code %i\n%s\n", ret, errstr);
 		success = false;
 	}
 	if((ret = curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp)) != 0){
-		scprintf("CURL setopt error while setting temp file pointer. Error code %i\n%s\n", ret, errstr);
+		printf("CURL setopt error while setting temp file pointer. Error code %i\n%s\n", ret, errstr);
 		success = false;
 	}
 	//printf("Loading remote file %s...\n", mFilename);
 	if((ret = curl_easy_perform(curl)) != 0){
-		scprintf("CURL perform error while attempting to access remote file. Error code %i\n%s\n", ret, errstr);
+		printf("CURL perform error while attempting to access remote file. Error code %i\n%s\n", ret, errstr);
 		success = false;
 	//}else{
 	//	printf("...done.\n");
diff --git a/common/Source/common/SC_StringBuffer.cpp b/common/Source/common/SC_StringBuffer.cpp
index bb2523e..95192c0 100644
--- a/common/Source/common/SC_StringBuffer.cpp
+++ b/common/Source/common/SC_StringBuffer.cpp
@@ -1,7 +1,7 @@
 // emacs:		-*- c++ -*-
 // file:		SC_StringBuffer.cpp
 // copyright:	2003 stefan kersten <steve at k-hornz.de>
-// cvs:			$Id: SC_StringBuffer.cpp 9082 2009-04-20 08:38:27Z danstowell $
+// cvs:			$Id$
 
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
diff --git a/common/Source/common/scsynthsend.cpp b/common/Source/common/scsynthsend.cpp
index 8b95de3..4cf8018 100644
--- a/common/Source/common/scsynthsend.cpp
+++ b/common/Source/common/scsynthsend.cpp
@@ -34,8 +34,7 @@ void makeSockAddr(struct sockaddr_in &toaddr, int32 addr, int32 port)
 {
     toaddr.sin_family = AF_INET;     // host byte order
     toaddr.sin_port = htons(port); // short, network byte order
-	addr = htonl(addr);
-    toaddr.sin_addr = *((struct in_addr *)&addr);
+    toaddr.sin_addr.s_addr = htonl(addr);
     bzero(&(toaddr.sin_zero), 8);    // zero the rest of the struct
 }
 
diff --git a/common/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp b/common/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
index 5ece292..5335cb7 100644
--- a/common/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
+++ b/common/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
@@ -1782,7 +1782,7 @@ int prArrayAllTuples(struct VMGlobals *g, int numArgsPushed)
 	int newSize = 1;
 	int tupSize = obj1->size;
 	for (int i=0; i < tupSize; ++i) {
-		if (isKindOfSlot(slots1+i, class_arrayed_collection)) {
+		if (isKindOfSlot(slots1+i, class_array)) {
 			newSize *= slotRawObject(&slots1[i])->size;
 		}
 	}
@@ -1793,13 +1793,13 @@ int prArrayAllTuples(struct VMGlobals *g, int numArgsPushed)
 
 	for (int i=0; i < newSize; ++i) {
 		int k = i;
-		obj3 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, tupSize, false, true);
+		obj3 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, tupSize, false, false);
 		slots3 = obj3->slots;
 		for (int j=tupSize-1; j >= 0; --j) {
-			if (isKindOfSlot(slots1+j, class_arrayed_collection)) {
+			if (isKindOfSlot(slots1+j, class_array)) {
 				PyrObject *obj4 = slotRawObject(&slots1[j]);
 				slotCopy(&slots3[j],&obj4->slots[k % obj4->size]);
-				g->gc->GCWrite(obj3, obj3);
+				g->gc->GCWrite(obj3, obj4);
 				k /= obj4->size;
 			} else {
 				slotCopy(&slots3[j],&slots1[j]);
@@ -2336,7 +2336,7 @@ int prArrayUnlace(struct VMGlobals *g, int numArgsPushed)
 	if(size3 < 1) return errFailed;
 
 	for(i=0; i<numLists; ++i) {
-		obj3 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size3, false, true);
+		obj3 = (PyrObject*)instantiateObject(g->gc, obj1->classptr, size3, false, false);
 		obj3->size = size3;
 		slots3 = obj3->slots;
 		for(j=0; j<size3; j+=clump) {
diff --git a/common/Source/lang/LangPrimSource/PyrPrimitive.cpp b/common/Source/lang/LangPrimSource/PyrPrimitive.cpp
index b2e4cb4..a07872e 100644
--- a/common/Source/lang/LangPrimSource/PyrPrimitive.cpp
+++ b/common/Source/lang/LangPrimSource/PyrPrimitive.cpp
@@ -2982,6 +2982,8 @@ int prThreadInit(struct VMGlobals *g, int numArgsPushed)
 	err = slotIntVal(c, &stacksize);
 	if (err) return err;
 
+	stacksize = std::max(stacksize, EVALSTACKDEPTH);
+
 	initPyrThread(g, thread, b, stacksize, (PyrInt32Array*)(slotRawObject(&g->thread->randData)),
 	slotRawFloat(&g->thread->beats), slotRawFloat(&g->thread->seconds), &g->thread->clock, true);
 
diff --git a/common/Source/lang/LangPrimSource/PyrSched.cpp b/common/Source/lang/LangPrimSource/PyrSched.cpp
index 7eea7f2..023be1d 100644
--- a/common/Source/lang/LangPrimSource/PyrSched.cpp
+++ b/common/Source/lang/LangPrimSource/PyrSched.cpp
@@ -1119,6 +1119,7 @@ int prTempoClock_Sched(struct VMGlobals *g, int numArgsPushed)
 	err = slotDoubleVal(b, &delta);
 	if (err) return errNone; // return nil OK, just don't schedule
 	beats += delta;
+	if(beats == INFINITY) return errNone; // return nil OK, just don't schedule
 
 	clock->Add(beats, c);
 
@@ -1139,7 +1140,7 @@ int prTempoClock_SchedAbs(struct VMGlobals *g, int numArgsPushed)
 	}
 
 	double beats;
-	int err = slotDoubleVal(b, &beats);
+	int err = slotDoubleVal(b, &beats) || (beats == INFINITY);
 	if (err) return errNone; // return nil OK, just don't schedule
 
 	clock->Add(beats, c);
@@ -1298,6 +1299,7 @@ int prSystemClock_Sched(struct VMGlobals *g, int numArgsPushed)
 	err = slotDoubleVal(&g->thread->seconds, &seconds);
 	if (err) return errNone; // return nil OK, just don't schedule
 	seconds += delta;
+	if(seconds == INFINITY) return errNone; // return nil OK, just don't schedule
 	PyrObject* inQueue = slotRawObject(&g->process->sysSchedulerQueue);
 
 	schedAdd(g, inQueue, seconds, c);
@@ -1313,7 +1315,7 @@ int prSystemClock_SchedAbs(struct VMGlobals *g, int numArgsPushed)
 	PyrSlot *c = g->sp;
 
 	double time;
-	int err = slotDoubleVal(b, &time);
+	int err = slotDoubleVal(b, &time) || (time == INFINITY);
 	if (err) return errNone; // return nil OK, just don't schedule
 	PyrObject* inQueue = slotRawObject(&g->process->sysSchedulerQueue);
 
diff --git a/common/Source/lang/LangPrimSource/PyrSerialPrim.cpp b/common/Source/lang/LangPrimSource/PyrSerialPrim.cpp
index 25b15c5..6389de6 100644
--- a/common/Source/lang/LangPrimSource/PyrSerialPrim.cpp
+++ b/common/Source/lang/LangPrimSource/PyrSerialPrim.cpp
@@ -513,6 +513,8 @@ done:
 
 static SerialPort* getSerialPort(PyrSlot* slot)
 {
+	if (NotPtr(&slotRawObject(slot)->slots[0]))
+		return NULL;
 	return (SerialPort*)slotRawPtr(&slotRawObject(slot)->slots[0]);
 }
 
diff --git a/common/Source/lang/LangPrimSource/PyrUStringPrim.cpp b/common/Source/lang/LangPrimSource/PyrUStringPrim.cpp
index 83148d3..2e1b669 100644
--- a/common/Source/lang/LangPrimSource/PyrUStringPrim.cpp
+++ b/common/Source/lang/LangPrimSource/PyrUStringPrim.cpp
@@ -49,11 +49,8 @@ struct SCRegExRegion {
 };
 typedef struct SCRegExRegion SCRegExRegion;
 
-int prString_FindRegexp(struct VMGlobals *g, int numArgsPushed);
-int prString_FindRegexp(struct VMGlobals *g, int numArgsPushed)
+static int prString_FindRegexp(struct VMGlobals *g, int numArgsPushed)
 {
-	int err;
-
 	PyrSlot *a = g->sp - 2; // source string
 	PyrSlot *b = g->sp - 1; // pattern
 	PyrSlot *c = g->sp;     // offset
@@ -65,7 +62,7 @@ int prString_FindRegexp(struct VMGlobals *g, int numArgsPushed)
 	int stringsize = slotRawObject(a)->size + 1;
 	int patternsize =  slotRawObject(b)->size + 1;
 	char *string = (char*)malloc(slotRawObject(a)->size + 1);
-	err = slotStrVal(a, string, slotRawObject(a)->size + 1);
+	int err = slotStrVal(a, string, slotRawObject(a)->size + 1);
 	if (err){
 		free(string);
 		return err;
@@ -134,55 +131,52 @@ int prString_FindRegexp(struct VMGlobals *g, int numArgsPushed)
 				{
 					result_array->size++;
 					SetNil(result_array->slots+i);
-				}
-				else
-				{
-					result_array->size++;
-
+				} else {
 					int match_start =  what[i].start;
 					int match_length = what[i].end -  what[i].start;
 //					post("for i:%i, start %i, end %i\n",  i, what[i].start,  what[i].end);
-//					char *match = (char*)malloc(match_length);
-					char match[match_length];
+					char match[match_length+1];
 
 					strncpy(match, string + offset + match_start, match_length);
 					match[match_length] = 0;
 					PyrObject *array = newPyrArray(g->gc, 2, 0, true);
+
+					result_array->size++;
+					SetObject(result_array->slots + i, array);
+					g->gc->GCWrite(result_array, array);
+
+					PyrObject *matched_string = (PyrObject*)newPyrString(g->gc, match, 0, true);
+
 					array->size = 2;
 					SetInt(array->slots, match_start + offset);
 
-					PyrObject *matched_string = (PyrObject*)newPyrString(g->gc, match, 0, true);
 					SetObject(array->slots+1, matched_string);
-					g->gc->GCWrite(matched_string, array->slots + 1);
+					g->gc->GCWrite(array, matched_string);
 
-					SetObject(result_array->slots + i, array);
-					g->gc->GCWrite(array, result_array->slots + i);
 				}
 			}
 		}
 		else
-		{
 			SetNil(a);
-		}
-		 free(what);
-		 free(pattern);
-		 free(regexStr);
-		 free(ustring);
-		 free(string);
+
+		free(what);
+		free(pattern);
+		free(regexStr);
+		free(ustring);
+		free(string);
 		SetObject(a, result_array);
-		g->gc->GCWrite(result_array,a);
 		//uregex_close(expression);
 		return errNone;
 	}
 
-		nilout:
-			free(string);
-			free(what);
-			free(pattern);
-			free(regexStr);
-			free(ustring);
-			SetNil(a);
-			return errNone;
+nilout:
+	free(string);
+	free(what);
+	free(pattern);
+	free(regexStr);
+	free(ustring);
+	SetNil(a);
+	return errNone;
 }
 
 void initUStringPrimitives();
diff --git a/common/Source/lang/LangPrimSource/WiiMote_OSX/COPYRIGHT.txt b/common/Source/lang/LangPrimSource/WiiMote_OSX/COPYRIGHT.txt
deleted file mode 100644
index b33233c..0000000
--- a/common/Source/lang/LangPrimSource/WiiMote_OSX/COPYRIGHT.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Max porting by Masayuki Akamatsu
-Copyright (c) 2006, Masayuki Akamatsu
-Based on "DarwiinRemote" by Hiroaki Kimura
-Copyright (c) 2006, Hiroaki Kimura
-All rights reserved.
-
-   Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-3. Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/common/Source/lang/LangPrimSource/WiiMote_OSX/HISTORY.txt b/common/Source/lang/LangPrimSource/WiiMote_OSX/HISTORY.txt
deleted file mode 100644
index a705589..0000000
--- a/common/Source/lang/LangPrimSource/WiiMote_OSX/HISTORY.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-aka.wiiremote Version History
-
-1.0B6 : 2007.04.24
-
-- The Classic Controller is supported.
-- The help patch is updated.
-- The URLs in [info] subpatch are updated.
-
-- 'expansion' message enables to use the expansion controller(Nunchuk or Classic Controller).
-- 'nunchuk' message is obsolete.
-   You should use 'expansion' instead of it even though you can use it for the backward compatibility only.
-
-- The IR sensor and the expansion controller (ex. Nunchuk) can be used together.
-
-- The stability on PPC-Mac is a little improved.
-  You have to do the following steps every time you use the Wii Remote on PPC-Mac.
- (You would set up only once on Intel-Mac.)
-1: Delete "Nintendo RVL-CNT-01" on  "Device" tab in "Bluetooth" System Preference.
-2: Do the setup for Wii Remote. See http://max.iamas.ac.jp/2061/articles/121.html
-3: Open "aka.wiiremote.help" and connect it.
-
-
-1.0B5 : 2007.02.03
-
-- Nunchuk is supported.
-( Classic Controller is NOT supported.)
-- device address is supported.
-- outlets and output messages are changed.
-- some input messages are simplified.
-- help patch is expanded for Nunchuk.
-
-
-1.0B4 : 2006.12.24
-
-- multiple Wii remotes are supported.
-
-
-1.0B3 : 2006.12.20
-
-- data acquisition is improved.
-- unusual vibration sound is resolved.
-
-
-1.0B2 : 2006.12.15
-
-- connection/disconnection is improved.
-- IR sensor is supported.
-- status report is supported
-- help patch is rewritten.
-
-
-1.0B1 : 2006.12.12
-
-- first release
\ No newline at end of file
diff --git a/common/Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.c b/common/Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.c
deleted file mode 100644
index ec337d8..0000000
--- a/common/Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.c
+++ /dev/null
@@ -1,1083 +0,0 @@
-// wiiremote.c
-// Copyright by Masayuki Akamatsu
-// Based on "DarwiinRemote" by Hiroaki Kimura
-
-#include <unistd.h>
-#include "wiiremote.h"
-
-
-// this type is used a lot (data array):
-typedef unsigned char darr[];
-
-#define	kTrial	10
-#define kWait	10000
-//  the unit of kWait is microseconds, thus 10000 means 10ms
-
-#define kWiiIRPixelsWidth 1024.0
-#define kWiiIRPixelsHeight 768.0
-
-
-Boolean	requestUpdates(WiiRemoteRef wiiremote);
-void myEventListener(IOBluetoothL2CAPChannelRef channel, void *refCon, IOBluetoothL2CAPChannelEvent *event);
-
-
-//--------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------
-
-void wiiremote_init(WiiRemoteRef wiiremote)
-{
-	wiiremote->inquiry = nil;
-	wiiremote->device = nil;
-	wiiremote->ichan = nil;
-	wiiremote->cchan = nil;
-
-	wiiremote->address = nil;
-
-	wiiremote->accX = 0x10;
-	wiiremote->accY = 0x10;
-	wiiremote->accZ = 0x10;
-	wiiremote->buttonData = 0;
-
-	wiiremote->lowZ = 0;
-	wiiremote->lowX = 0;
-	wiiremote->leftPoint = -1;
-	wiiremote->tracking = false;
-
-	wiiremote->batteryLevel = 0;
-
-	wiiremote->readingRegister = false;
-	wiiremote->isMotionSensorEnabled = false;
-	wiiremote->isVibrationEnabled = false;
-	wiiremote->isIRSensorEnabled = false;
-	wiiremote->wiiIRMode = kWiiIRModeExtended;
-	wiiremote->isExpansionPortEnabled = false;
-	wiiremote->isExpansionPortAttached = false;
-	wiiremote->expType = WiiExpNotAttached;
-
-	wiiremote->isLED1Illuminated = false;
-	wiiremote->isLED2Illuminated = false;
-	wiiremote->isLED3Illuminated = false;
-	wiiremote->isLED4Illuminated = false;
-
-	wiiremote->nAccX = 0x10;
-	wiiremote->nAccY = 0x10;
-	wiiremote->nAccZ = 0x10;
-	wiiremote->nButtonData = 0;
-
-	wiiremote->nLowZ = 0;
-	wiiremote->nLowX = 0;
-
-}
-
-//--------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------
-
-Boolean	openCChan(WiiRemoteRef wiiremote)
-{
-	short		i;
-	IOReturn	ret;
-
-	// open L2CAPChannel : BluetoothL2CAPPSM = 17
-	for (i=0; i<kTrial; i++)
-	{
-		ret = IOBluetoothDeviceOpenL2CAPChannelSync(wiiremote->device, &(wiiremote->cchan), 17, myEventListener, (void *)wiiremote);
-		if ( ret == kIOReturnSuccess)
-			break;
-		usleep(kWait); //  wait 10ms
-	}
-	if (i==kTrial)
-	{
-		wiiremote->cchan = nil;
-		IOBluetoothDeviceCloseConnection(wiiremote->device);
-		return false;
-	}
-	IOBluetoothObjectRetain(wiiremote->cchan);
-
-	return (ret==kIOReturnSuccess);
-}
-
-Boolean	openIChan(WiiRemoteRef wiiremote)
-{
-	short		i;
-	IOReturn	ret;
-
-	// open L2CAPChannel : BluetoothL2CAPPSM = 19
-	for (i=0; i<kTrial; i++)
-	{
-		ret = IOBluetoothDeviceOpenL2CAPChannelSync(wiiremote->device, &(wiiremote->ichan), 19, myEventListener, (void *)wiiremote);
-		if ( ret == kIOReturnSuccess)
-			break;
-		usleep(kWait); //  wait 10ms
-	}
-	if (i==kTrial)
-	{
-		wiiremote->ichan = nil;
-		IOBluetoothL2CAPChannelCloseChannel(wiiremote->cchan);
-		IOBluetoothObjectRelease(wiiremote->cchan);
-		IOBluetoothDeviceCloseConnection(wiiremote->device);
-		return false;
-	}
-	IOBluetoothObjectRetain(wiiremote->ichan);
-
-	return (ret==kIOReturnSuccess);
-}
-
-//--------------------------------------------------------------------------------------------
-
-Boolean sendCommand(WiiRemoteRef wiiremote, unsigned char *data, unsigned short length)
-{
-	unsigned char buf[40];
-	IOReturn	ret;
-	int			i;
-
-	memset(buf,0,40);
-	buf[0] = 0x52;
-	memcpy(buf+1, data, length);
-	if (buf[1] == 0x16)
-		length=23;
-	else
-		length++;
-
-	usleep(kWait); //  wait 10ms	// Done to make sure commands don't happen too fast.
-
-	for (i = 0; i<kTrial; i++)
-	{
-		ret = IOBluetoothL2CAPChannelWriteSync(wiiremote->cchan, buf, length);
-		if (ret == kIOReturnSuccess)
-			break;
-		usleep(kWait);
-	}
-
-	if (ret != kIOReturnSuccess)
-		wiiremote_disconnect(wiiremote);
-
-	return (ret==kIOReturnSuccess);
-}
-
-Boolean	writeData(WiiRemoteRef wiiremote, const unsigned char *data, unsigned long address, unsigned short length)
-{
-	unsigned char cmd[22];
-	int i;
-	unsigned long addr = address;
-
-
-	for(i=0 ; i<length ; i++)
-		cmd[i+6] = data[i];
-
-	for(;i<16 ; i++)
-		cmd[i+6]= 0;
-
-	cmd[0] = 0x16;
-	cmd[1] = (addr>>24) & 0xFF;
-	cmd[2] = (addr>>16) & 0xFF;
-	cmd[3] = (addr>> 8) & 0xFF;
-	cmd[4] = (addr>> 0) & 0xFF;
-	cmd[5] = length;
-
-	// and of course the vibration flag, as usual
-	if (wiiremote->isVibrationEnabled)	cmd[1] |= 0x01;
-
-	data = cmd;
-
-	return sendCommand(wiiremote, cmd, 22);
-}
-
-Boolean readData(WiiRemoteRef wiiremote, unsigned long address, unsigned short length)
-{
-
-	unsigned char cmd[7];
-	unsigned long addr = address;
-	unsigned short len = length;
-
-	cmd[0] = 0x17;
-	cmd[1] = (addr>>24)&0xFF;
-	cmd[2] = (addr>>16)&0xFF;
-	cmd[3] = (addr>> 8)&0xFF;
-	cmd[4] = (addr>> 0)&0xFF;
-
-	cmd[5] = (len >> 8)&0xFF;
-	cmd[6] = (len >> 0)&0xFF;
-
-	if (wiiremote->isVibrationEnabled)	cmd[1] |= 0x01;
-	if (cmd[1] & 0x02) wiiremote->readingRegister = true;
-
-	return sendCommand(wiiremote, cmd, 7);
-}
-
-//--------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------
-
-void checkDevice(WiiRemoteRef wiiremote, IOBluetoothDeviceRef device)
-{
-	CFStringRef	name;
-	CFStringRef	address;
-
-	if (wiiremote_isconnected(wiiremote))
-		return;
-
-	name = IOBluetoothDeviceGetName(device);
-	address = IOBluetoothDeviceGetAddressString(device);
-	if (name != nil && address != nil)
-	{
-		if (CFStringCompare(name, CFSTR("Nintendo RVL-CNT-01"), 0) == kCFCompareEqualTo)
-		{
-			if ( CFStringGetLength(wiiremote->address) == 0
-			|| CFStringCompare(address, wiiremote->address, kCFCompareCaseInsensitive) == kCFCompareEqualTo)
-			{
-				wiiremote->device = IOBluetoothObjectRetain(device);
-				if ( wiiremote_connect(wiiremote) == false )
-					wiiremote_disconnect(wiiremote);
-			}
-		}
-	}
-}
-
-void myFoundFunc(void *refCon, IOBluetoothDeviceInquiryRef inquiry, IOBluetoothDeviceRef device)
-{
-	checkDevice((WiiRemoteRef)refCon, device);
-}
-
-void myUpdatedFunc(void *refCon, IOBluetoothDeviceInquiryRef inquiry, IOBluetoothDeviceRef device, uint32_t devicesRemaining)
-{
-	checkDevice((WiiRemoteRef)refCon, device);
-}
-
-void myCompleteFunc(void *refCon, IOBluetoothDeviceInquiryRef inquiry, IOReturn error, Boolean aborted)
-{
-	IOReturn	ret;
-
-	if (aborted) return; // called by stop ;)
-
-	if (error != kIOReturnSuccess)
-	{
-		wiiremote_stopsearch((WiiRemoteRef)refCon);
-		return;
-	}
-
-	/*
-	 ret = IOBluetoothDeviceInquiryStart(((WiiRemoteRef)refCon)->inquiry);
-	if (ret != kIOReturnSuccess)
-	{
-		wiiremote_stopsearch((WiiRemoteRef)refCon);
-	}
-	*/
-}
-
-//--------------------------------------------------------------------------------------------
-
-Boolean wiiremote_isconnected(WiiRemoteRef wiiremote)
-{
-	Boolean	result;
-
-	result = wiiremote->device != nil && IOBluetoothDeviceIsConnected(wiiremote->device);
-	return result;
-}
-
-Boolean wiiremote_search(WiiRemoteRef wiiremote, char *address)
-{
-	IOReturn	ret;
-
-	if (wiiremote->inquiry != nil)
-		return true;
-
-	wiiremote->inquiry = IOBluetoothDeviceInquiryCreateWithCallbackRefCon((void *)wiiremote);
-	IOBluetoothDeviceInquirySetDeviceFoundCallback(wiiremote->inquiry, myFoundFunc);
-	IOBluetoothDeviceInquirySetDeviceNameUpdatedCallback(wiiremote->inquiry, myUpdatedFunc);
-	IOBluetoothDeviceInquirySetCompleteCallback(wiiremote->inquiry, myCompleteFunc);
-
-	if (wiiremote->address != nil)
-		CFRelease(wiiremote->address);
-	wiiremote->address = CFStringCreateWithCString(nil, address, kCFStringEncodingMacRoman);
-
-	ret = IOBluetoothDeviceInquiryStart(wiiremote->inquiry);
-	if (ret != kIOReturnSuccess)
-	{
-		IOBluetoothDeviceInquiryDelete(wiiremote->inquiry);
-		wiiremote->inquiry = nil;
-		return false;
-	}
-	return true;
-}
-
-Boolean wiiremote_stopsearch(WiiRemoteRef wiiremote)
-{
-	IOReturn	ret;
-
-	if (wiiremote->inquiry == nil)
-	{
-		return true;	// already stopped
-	}
-
-	ret = IOBluetoothDeviceInquiryStop(wiiremote->inquiry);
-
-	if (ret != kIOReturnSuccess && ret != kIOReturnNotPermitted)
-	{
-		// kIOReturnNotPermitted is if it's already stopped
-	}
-
-	IOBluetoothDeviceInquiryDelete(wiiremote->inquiry);
-	wiiremote->inquiry = nil;
-
-	return (ret==kIOReturnSuccess);
-}
-
-//--------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------
-
-unsigned char decrypt(unsigned char data)
-{
-	return (data ^ 0x17) + 0x17;
-}
-
-//--------------------------------------------------------------------------------------------
-
-/**
-* Handle report 0x21 (Read Data) from wiimote.
- * dp[0] = Bluetooth header
- * dp[1] = (0x21) Report/Channel ID
- * dp[2] = Wiimote Buttons
- * dp[3] = Wiimote Buttons
- * dp[4] = High 4 bits = payload size; Low 4 bits = Error flag (0 = all good)
- * dp[5] = Offset of memory read
- * dp[6] = Offset of memory read
- * dp[7+] = the Data.
- **/
-
-void handleRAMData(WiiRemoteRef wiiremote, unsigned char *dp, size_t dataLength)
-{
-	// specify attached expasion device
-	if ((dp[5] == 0x00) && (dp[6] == 0xF0))
-	{
-		if (decrypt(dp[21]) == 0x00)
-		{
-			wiiremote->expType = WiiNunchuk;
-		}
-		else
-		if (decrypt(dp[21]) == 0x01)
-		{
-			wiiremote->expType = WiiClassicController;
-		}
-		else
-		{
-			wiiremote->expType = WiiExpNotAttached;
-		}
-		//		initExpPort = NO;
-		return;
-	}
-
-	// wiimote calibration data
-	if (!wiiremote->readingRegister && dp[5] == 0x00 && dp[6] == 0x20)
-	{
-		wiiremote->wiiCalibData.accX_zero = dp[7];
-		wiiremote->wiiCalibData.accY_zero = dp[8];
-		wiiremote->wiiCalibData.accZ_zero = dp[9];
-
-		//dp[10] - unknown/unused
-
-		wiiremote->wiiCalibData.accX_1g = dp[11];
-		wiiremote->wiiCalibData.accY_1g = dp[12];
-		wiiremote->wiiCalibData.accZ_1g = dp[13];
-		return;
-	}
-
-	// expansion device calibration data.
-	if (wiiremote->readingRegister && dp[5] == 0x00 && dp[6] == 0x20)
-	{
-		if (wiiremote->expType == WiiNunchuk)
-		{
-			//nunchuk calibration data
-			wiiremote->nunchukCalibData.accX_zero =  decrypt(dp[7]);
-			wiiremote->nunchukCalibData.accY_zero =  decrypt(dp[8]);
-			wiiremote->nunchukCalibData.accZ_zero =  decrypt(dp[9]);
-
-			wiiremote->nunchukCalibData.accX_1g =  decrypt(dp[11]);
-			wiiremote->nunchukCalibData.accY_1g =  decrypt(dp[12]);
-			wiiremote->nunchukCalibData.accZ_1g =  decrypt(dp[13]);
-
-			wiiremote->nunchukJoyStickCalibData.x_max =  decrypt(dp[15]);
-			wiiremote->nunchukJoyStickCalibData.x_min =  decrypt(dp[16]);
-			wiiremote->nunchukJoyStickCalibData.x_center =  decrypt(dp[17]);
-
-			wiiremote->nunchukJoyStickCalibData.y_max =  decrypt(dp[18]);
-			wiiremote->nunchukJoyStickCalibData.y_min =  decrypt(dp[19]);
-			wiiremote->nunchukJoyStickCalibData.y_center =  decrypt(dp[20]);
-
-			return;
-		}
-		else
-		if (wiiremote->expType == WiiClassicController)
-		{
-			//classic controller calibration data (probably)
-		}
-	}
-
-	// wii remote buttons
-	wiiremote->buttonData = ((short)dp[2] << 8) + dp[3];
-}
-
-void handleStatusReport(WiiRemoteRef wiiremote, unsigned char *dp, size_t dataLength)
-{
-	wiiremote->batteryLevel = (double)dp[7];
-	wiiremote->batteryLevel /= (double)0xC0; // C0 = fully charged.
-
-	if ((dp[4] & 0x02)) //some device attached to Wiimote
-	{
-		wiiremote->isExpansionPortAttached = true;
-		// initExpPort = YES;
-
-		Boolean ret = writeData(wiiremote, (darr){0x00}, 0x04A40040, 1); // Initialize the device
-
-		if (ret == false)
-		{
-			wiiremote->isExpansionPortAttached = false;
-			return;
-		}
-
-		usleep(kWait); // Give the write a chance to be processed.
-
-		ret = readData(wiiremote, 0x04A400F0, 16); // read expansion device type
-		if (ret == false)
-		{
-			wiiremote->isExpansionPortAttached = false;
-		}
-	}
-	else
-	{ // unplugged
-		wiiremote->isExpansionPortAttached = false;
-		wiiremote->expType = WiiExpNotAttached;
-	}
-
-	if (dp[4] & 0x10)
-		wiiremote->isLED1Illuminated = true;
-	else
-		wiiremote->isLED1Illuminated = false;
-
-	if (dp[4] & 0x20)
-		wiiremote->isLED2Illuminated = true;
-	else
-		wiiremote->isLED2Illuminated = false;
-
-	if (dp[4] & 0x40)
-		wiiremote->isLED3Illuminated = true;
-	else
-		wiiremote->isLED3Illuminated = false;
-
-	if (dp[4] & 0x80)
-		wiiremote->isLED4Illuminated = true;
-	else
-		wiiremote->isLED4Illuminated = false;
-}
-
-void handleExtensionData(WiiRemoteRef wiiremote, unsigned char *dp, size_t dataLength)
-{
-	unsigned char startByte;
-
-	switch (dp[1]) {
-		case 0x34 :
-			startByte = 4;
-			break;
-		case 0x35 :
-			startByte = 7;
-			break;
-		case 0x36 :
-			startByte = 14;
-			break;
-		case 0x37 :
-			startByte = 17;
-			break;
-		default:
-			return; // This shouldn't ever happen.
-			break;
-	}
-
-	if (wiiremote->expType == WiiNunchuk)
-	{
-		wiiremote->nStickX = decrypt(dp[startByte]);
-		wiiremote->nStickY = decrypt(dp[startByte +1]);
-		wiiremote->nAccX   = decrypt(dp[startByte +2]);
-		wiiremote->nAccY   = decrypt(dp[startByte +3]);
-		wiiremote->nAccZ   = decrypt(dp[startByte +4]);
-		wiiremote->nButtonData = decrypt(dp[startByte +5]);
-
-		wiiremote->nLowZ = wiiremote->nLowZ * .9 + wiiremote->nAccZ * .1;
-		wiiremote->nLowX = wiiremote->nLowX * .9 + wiiremote->nAccX * .1;
-
-		float absx = abs(wiiremote->nLowX - 128);
-		float absz = abs(wiiremote->nLowZ - 128);
-
-		if (wiiremote->nOrientation == 0 || wiiremote->nOrientation == 2) absx -= 5;
-		if (wiiremote->nOrientation == 1 || wiiremote->nOrientation == 3) absz -= 5;
-
-		if (absz >= absx)
-		{
-			if (absz > 5)
-				wiiremote->nOrientation = (wiiremote->nLowZ > 128) ? 0 : 2;
-		}
-		else
-		{
-			if (absx > 5)
-				wiiremote->nOrientation = (wiiremote->nLowX > 128) ? 3 : 1;
-		}
-	}
-	else
-	if (wiiremote->expType == WiiClassicController)
-	{
-		wiiremote->cButtonData = (unsigned short)(decrypt(dp[startByte + 4]) << 8) + decrypt(dp[startByte + 5]);
-		wiiremote->cButtonData = ~wiiremote->cButtonData;	// bit reverse
-
-		wiiremote->cStickX1 = decrypt(dp[startByte]) & 0x3F;
-		wiiremote->cStickY1 = decrypt(dp[startByte + 1]) & 0x3F;
-
-		wiiremote->cStickX2 = (((decrypt(dp[startByte +0]) & 0xC0) >> 3) |
-							   ((decrypt(dp[startByte +1]) & 0xC0) >> 5) |
-							   ((decrypt(dp[startByte +2]) & 0x80) >> 7)) & 0x1F;
-		wiiremote->cStickY2 = decrypt(dp[startByte + 2]) & 0x1F;
-
-		wiiremote->cAnalogL = (((decrypt(dp[startByte +2]) & 0x60) >> 2) |
-							   ((decrypt(dp[startByte +3]) & 0xE0) >> 5)) & 0x1F;
-		wiiremote->cAnalogR =  decrypt(dp[startByte + 3]) & 0x1F;
-	}
-}
-
-void handleIRData(WiiRemoteRef wiiremote, unsigned char *dp, size_t dataLength)
-{
-	int i;
-
-	if (dp[1] == 0x33)
-	{ // 12 IR bytes
-		int startByte = 0;
-		for(i=0 ; i < 4 ; i++)
-		{
-			startByte = 7 + 3 * i;
-			wiiremote->irData[i].x = (dp[startByte +0] | ((dp[startByte +2] & 0x30) << 4)) & 0x3FF;
-			wiiremote->irData[i].y = (dp[startByte +1] | ((dp[startByte +2] & 0xC0) << 2)) & 0x3FF;
-			wiiremote->irData[i].s =  dp[startByte +2] & 0x0F;
-		}
- 	}
-	else
-	{ // 10 IR bytes
-		int shift = (dp[1] == 0x36) ? 4 : 7;
-		int startByte = 0;
-		for (i=0; i < 2; i++) {
-			startByte = shift + 5 * i;
-			wiiremote->irData[2*i].x = (dp[startByte +0] | ((dp[startByte +2] & 0x30) << 4)) & 0x3FF;
-			wiiremote->irData[2*i].y = (dp[startByte +1] | ((dp[startByte +2] & 0xC0) << 2)) & 0x3FF;
-			wiiremote->irData[2*i].s = ((wiiremote->irData[2*i].x == wiiremote->irData[2*i].y) && (wiiremote->irData[2*i].x == 0x3FF)) ? 0x0F : 0x05;  // No size is given in 10 byte report.
-
-			wiiremote->irData[(2*i)+1].x = (dp[startByte +3] | ((dp[startByte +2] & 0x03) << 8)) & 0x3FF;
-			wiiremote->irData[(2*i)+1].y = (dp[startByte +4] | ((dp[startByte +2] & 0x0C) << 6)) & 0x3FF;
-			wiiremote->irData[(2*i)+1].s = ((wiiremote->irData[(2*i)+1].x == wiiremote->irData[(2*i)+1].y) && (wiiremote->irData[(2*i)+1].x == 0x3FF)) ? 0x0F : 0x05;  // No size is given in 10 byte report.
-		}
-	}
-
-	int p1 = -1;
-	int p2 = -1;
-	// we should modify this loop to take the points with the lowest s (the brightest ones)
-	for (i=0 ; i<4 ; i++) {
-		if (p1 == -1) {
-			if (wiiremote->irData [i].s < 0x0F)
-				p1 = i;
-		} else {
-			if (wiiremote->irData [i].s < 0x0F) {
-				p2 = i;
-				break;
-			}
-		}
-	}
-
-	double ox, oy;
-	if ((p1 > -1) && (p2 > -1))
-	{
-		int l = wiiremote->leftPoint;
-		if (wiiremote->leftPoint == -1)
-		{
-			switch (wiiremote->orientation)
-			{
-				case 0: l = (wiiremote->irData[p1].x < wiiremote->irData[p2].x) ? 0 : 1; break;
-				case 1: l = (wiiremote->irData[p1].y > wiiremote->irData[p2].y) ? 0 : 1; break;
-				case 2: l = (wiiremote->irData[p1].x > wiiremote->irData[p2].x) ? 0 : 1; break;
-				case 3: l = (wiiremote->irData[p1].y < wiiremote->irData[p2].y) ? 0 : 1; break;
-			}
-
-			wiiremote->leftPoint = l;
-		}
-
-		int r = 1-l;
-
-		double dx = wiiremote->irData[r].x - wiiremote->irData[l].x;
-		double dy = wiiremote->irData[r].y - wiiremote->irData[l].y;
-		double d = hypot (dx, dy);
-
-		dx /= d;
-		dy /= d;
-
-		double cx = (wiiremote->irData[l].x + wiiremote->irData[r].x)/kWiiIRPixelsWidth - 1;
-		double cy = (wiiremote->irData[l].y + wiiremote->irData[r].y)/kWiiIRPixelsHeight - 1;
-
-		ox = -dy*cy-dx*cx;
-		oy = -dx*cy+dy*cx;
-
-		// cam:
-		// Compensate for distance. There must be fewer than 0.75*768 pixels between the spots for this to work.
-		// In other words, you have to be far enough away from the sensor bar for the two spots to have enough
-		// space on the image sensor to travel without one of the points going off the image.
-		// note: it is working very well ...
-		double gain = 4;
-		if (d < (0.75 * kWiiIRPixelsHeight))
-			gain = 1 / (1 - d/kWiiIRPixelsHeight);
-
-		ox *= gain;
-		oy *= gain;
-
-		wiiremote->angle = atan2(dy, dx);
-		wiiremote->tracking = true;
-	}
-	else
-	{
-		ox = oy = -100;
-		wiiremote->leftPoint = -1;	// not tracking
-		wiiremote->angle = -100;
-		wiiremote->tracking = false;
-	}
-
-	wiiremote->posX = ox;
-	wiiremote->posY = oy;
-}
-
-void handleButtonReport(WiiRemoteRef wiiremote, unsigned char *dp, size_t dataLength)
-{
-	// wiimote buttons
-	wiiremote->buttonData = ((short)dp[2] << 8) + dp[3];
-
-	// report contains extension data
-	switch (dp[1])
-	{
-		case 0x34 :
-		case 0x35 :
-		case 0x36 :
-		case 0x37 :
-			handleExtensionData(wiiremote, dp, dataLength);
-			break;
-	}
-
-	// report contains IR data
-	if (dp[1] & 0x02)
-	{
-		handleIRData(wiiremote, dp, dataLength);
-	}
-
-	// report contains motion sensor data
-	if (dp[1] & 0x01)
-	{
-		wiiremote->accX = dp[4];
-		wiiremote->accY = dp[5];
-		wiiremote->accZ = dp[6];
-
-		wiiremote->lowZ = wiiremote->lowZ * 0.9 + wiiremote->accZ * 0.1;
-		wiiremote->lowX = wiiremote->lowX * 0.9 + wiiremote->accX * 0.1;
-
-		float absx = abs(wiiremote->lowX-128);
-		float absz = abs(wiiremote->lowZ-128);
-
-		if (wiiremote->orientation == 0 || wiiremote->orientation == 2) absx -= 5;
-		if (wiiremote->orientation == 1 || wiiremote->orientation == 3) absz -= 5;
-
-		if (absz >= absx)
-		{
-			if (absz > 5)
-				wiiremote->orientation = (wiiremote->lowZ > 128)?0:2;
-		}
-		else
-		{
-			if (absx > 5)
-				wiiremote->orientation = (wiiremote->lowX > 128)?3:1;
-		}
-	}
-}
-
-//--------------------------------------------------------------------------------------------
-
- void myDataListener(IOBluetoothL2CAPChannelRef channel, void *dataPointer, UInt16 dataLength, void *refCon)
-{
-	WiiRemoteRef	wiiremote = (WiiRemoteRef)refCon;
-	unsigned char* dp = (unsigned char*)dataPointer;
-
-	if (!wiiremote->device)
-		return;
-
-	//controller status (expansion port and battery level data) - received when report 0x15 sent to Wiimote (getCurrentStatus:) or status of expansion port changes.
-	if (dp[1] == 0x20 && dataLength >= 8)
-	{
-		handleStatusReport(wiiremote, dp, dataLength);
-		requestUpdates(wiiremote); // Make sure we keep getting state change reports.
-		return;
-	}
-
-	if (dp[1] == 0x21)
-	{
-		handleRAMData(wiiremote, dp, dataLength);
-		return;
-	}
-
-	if (dp[1] == 0x22)
-	{ // Write data response
-		//NSLog(@"Write data response: %00x %00x %00x %00x", dp[2], dp[3], dp[4], dp[5]);
-		return;
-	}
-
-	// report contains button info
-	if ((dp[1] & 0xF0) == 0x30)
-	{
-		handleButtonReport(wiiremote, dp, dataLength);
-	}
-}
-
-void myEventListener(IOBluetoothL2CAPChannelRef channel, void *refCon, IOBluetoothL2CAPChannelEvent *event)
-{
-	if (event->eventType == kIOBluetoothL2CAPChannelEventTypeData)
-	{
-		// In thise case:
-		// event->u.newData.dataPtr  is a pointer to the block of data received.
-		// event->u.newData.dataSize is the size of the block of data.
-		myDataListener(channel, event->u.data.dataPtr, event->u.data.dataSize, refCon);
-	}
-	else
-	if (event->eventType == kIOBluetoothL2CAPChannelEventTypeClosed)
-	{
-		// In this case:
-		// event->u.terminatedChannel is the channel that was terminated. It can be converted in an IOBluetoothL2CAPChannel
-		// object with [IOBluetoothL2CAPChannel withL2CAPChannelRef:]. (see below).
-	}
-}
-
-void myDisconnectedFunc(void * refCon, IOBluetoothUserNotificationRef inRef, IOBluetoothObjectRef objectRef)
-{
-	CFStringRef	itsAddress, myAddress;
-
-	itsAddress = IOBluetoothDeviceGetAddressString(objectRef);
-	if (itsAddress != nil)
-	{
-		myAddress = IOBluetoothDeviceGetAddressString(((WiiRemoteRef)refCon)->device);
-		if (myAddress != nil)
-		{
-			if (CFStringCompare(itsAddress, myAddress, 0) == kCFCompareEqualTo)
-			{
-				wiiremote_disconnect((WiiRemoteRef)refCon);
-			}
-			CFRelease(myAddress);
-		}
-		CFRelease(itsAddress);
-	}
-}
-
-//--------------------------------------------------------------------------------------------
-
-void wiiremote_getaddress(WiiRemoteRef wiiremote, char *address)
-{
-	CFStringRef	cfstring;
-
-	cfstring = IOBluetoothDeviceGetAddressString(wiiremote->device);
-	CFStringGetCString(cfstring, address, 32, kCFStringEncodingMacRoman);
-	CFRelease(cfstring);
-
-}
-
-//--------------------------------------------------------------------------------------------
-
-Boolean wiiremote_connect(WiiRemoteRef wiiremote)
-{
-	IOReturn	ret;
-	Boolean		result;
-	short		i;
-
-	if (wiiremote->device == nil)
-		return false;
-
-	// connect the device
-	for (i=0; i<kTrial; i++)
-	{
-		ret = IOBluetoothDeviceOpenConnection(wiiremote->device, nil, nil);
-		if ( ret == kIOReturnSuccess)
-			break;
-		usleep(kWait); //  wait 10ms
-	}
-	if (i==kTrial)
-		return false;
-
-	wiiremote->disconnectNotification = IOBluetoothDeviceRegisterForDisconnectNotification(wiiremote->device, myDisconnectedFunc, (void *)wiiremote);
-
-	// performs an SDP query
-	for (i=0; i<kTrial; i++)
-	{
-		ret = IOBluetoothDevicePerformSDPQuery(wiiremote->device, nil, nil);
-		if ( ret == kIOReturnSuccess)
-			break;
-		usleep(kWait); //  wait 10ms
-	}
-	if (i==kTrial)
-		return false;
-
-	result = openCChan(wiiremote);
-	result = openIChan(wiiremote);
-
-	if (result)
-	{
-		result = wiiremote_led(wiiremote, wiiremote->isLED1Illuminated, wiiremote->isLED2Illuminated, wiiremote->isLED3Illuminated, wiiremote->isLED4Illuminated);
-	}
-
-	if (result == false)
-	{
-		wiiremote_disconnect(wiiremote);
-		return result;
-	}
-
-	wiiremote_getstatus(wiiremote);
-	requestUpdates(wiiremote);
-
-	readData(wiiremote, 0x0020, 7);	//	Get Accelerometer callibration data
-
-	return true;
-}
-
-
-Boolean wiiremote_disconnect(WiiRemoteRef wiiremote)
-{
-	short	i;
-
-	if (wiiremote->cchan)
-	{
-		if (IOBluetoothDeviceIsConnected(wiiremote->device))
-		{
-			for (i=0; i<kTrial; i++)
-			{
-				if (IOBluetoothL2CAPChannelCloseChannel(wiiremote->cchan) == kIOReturnSuccess)
-					break;
-				usleep(kWait); //  wait 10ms
-			}
-		}
-		if (i==kTrial)	return false;
-		IOBluetoothObjectRelease(wiiremote->cchan);
-		wiiremote->cchan = nil;
-	}
-
-	if (wiiremote->ichan)
-	{
-		if (IOBluetoothDeviceIsConnected(wiiremote->device))
-		{
-			for (i=0; i<kTrial; i++)
-			{
-				if (IOBluetoothL2CAPChannelCloseChannel(wiiremote->ichan) == kIOReturnSuccess)
-					break;
-			}
-		}
-		if (i==kTrial)	return false;
-		IOBluetoothObjectRelease(wiiremote->ichan);
-		wiiremote->ichan = nil;
-	}
-
-	if (wiiremote->device)
-	{
-		if (IOBluetoothDeviceIsConnected(wiiremote->device))
-		{
-			for (i=0; i<kTrial; i++)
-			{
-				if (IOBluetoothDeviceCloseConnection(wiiremote->device) == kIOReturnSuccess)
-					break;
-			}
-		}
-		if (i==kTrial)	return false;
-		IOBluetoothObjectRelease(wiiremote->device);
-		wiiremote->device = nil;
-	}
-
-	if (wiiremote->disconnectNotification != nil)
-	{
-		IOBluetoothUserNotificationUnregister(wiiremote->disconnectNotification);
-		wiiremote->disconnectNotification = nil;
-	}
-
-	return true;
-}
-
-//--------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------
-
-Boolean	requestUpdates(WiiRemoteRef wiiremote)
-{
-	Boolean	result;
-
-	// Set the report type the Wiimote should send.
-	unsigned char cmd[] = {0x12, 0x02, 0x30}; // Just buttons.
-
-	if (wiiremote->isVibrationEnabled)	cmd[1] |= 0x01;
-
-	/*
-	 There are numerous status report types that can be requested.
-	 The IR reports must be matched with the data format set when initializing the IR camera:
-	 0x36, 0x37	- 10 IR bytes go with Basic mode
-	 0x33		- 12 IR bytes go with Extended mode
-	 0x3e/0x3f	- 36 IR bytes go with Full mode
-
-	 The Nunchuk and Classic controller use 6 bytes to report their state, so the reports that
-	 give more extension bytes don't provide any more info.
-
-	 Buttons		|	Accelerometer	|	IR		|	Extension
-	 --------------------+-------------------+-----------+-------------
-	 0x30: Core Buttons	|					|			|
-	 0x31: Core Buttons	|	Accelerometer	|			|
-	 0x32: Core Buttons	|					|			|	 8 bytes
-	 0x33: Core Buttons	|	Accelerometer	| 12 bytes	|
-	 0x34: Core Buttons	|					|			|	19 bytes
-	 0x35: Core Buttons	|	Accelerometer	|			|	16 bytes
-	 0x36: Core Buttons	|					| 10 bytes	|	 9 bytes
-	 0x37: Core Buttons	|	Accelerometer	| 10 bytes	|	 6 bytes
-	 ?? 0x38: Core Buttons and Accelerometer with 16 IR bytes ??
-	 0x3d:				|					|			|	21 bytes
-
-	 0x3e / 0x3f: Interleaved Core Buttons and Accelerometer with 16/36 IR bytes
-
-	 */
-
-	if (wiiremote->isIRSensorEnabled)
-	{
-		if (wiiremote->isExpansionPortEnabled)
-		{
-			cmd[2] = 0x36;	// Buttons, 10 IR Bytes, 9 Extension Bytes
-			wiiremote->wiiIRMode = kWiiIRModeBasic;
-		}
-		else
-		{
-			cmd[2] = 0x33; // Buttons, Accelerometer, and 12 IR Bytes.
-			wiiremote->wiiIRMode = kWiiIRModeExtended;
-		}
-
-		// Set IR Mode
-		writeData(wiiremote, (darr){ wiiremote->wiiIRMode }, 0x04B00033, 1);
-		usleep(kWait); //  wait 10ms
-	}
-	else
-	{
-		if (wiiremote->isExpansionPortEnabled)
-		{
-			cmd[2] = 0x34;	// Buttons, 19 Extension Bytes
-		}
-		else
-		{
-			cmd[2] = 0x30; // Buttons
-		}
-	}
-
-	if (wiiremote->isMotionSensorEnabled)	cmd[2] |= 0x01;	// Add Accelerometer
-
-	usleep(kWait); //  wait 10ms
-	result = sendCommand(wiiremote, cmd, 3);
-
-	return(result);
-}
-
-//--------------------------------------------------------------------------------------------
-
-Boolean wiiremote_motionsensor(WiiRemoteRef wiiremote, Boolean enabled)
-{
-	wiiremote->isMotionSensorEnabled = enabled;
-	return requestUpdates(wiiremote);
-}
-
-Boolean wiiremote_vibration(WiiRemoteRef wiiremote, Boolean enabled)
-{
-
-	wiiremote->isVibrationEnabled = enabled;
-	return requestUpdates(wiiremote);
-}
-
-Boolean wiiremote_led(WiiRemoteRef wiiremote, Boolean enabled1, Boolean enabled2, Boolean enabled3, Boolean enabled4)
-{
-	unsigned char cmd[] = {0x11, 0x00};
-	if (wiiremote->isVibrationEnabled)	cmd[1] |= 0x01;
-	if (enabled1)	cmd[1] |= 0x10;
-	if (enabled2)	cmd[1] |= 0x20;
-	if (enabled3)	cmd[1] |= 0x40;
-	if (enabled4)	cmd[1] |= 0x80;
-
-	wiiremote->isLED1Illuminated = enabled1;
-	wiiremote->isLED2Illuminated = enabled2;
-	wiiremote->isLED3Illuminated = enabled3;
-	wiiremote->isLED4Illuminated = enabled4;
-
-	return sendCommand(wiiremote, cmd, 2);
-}
-
-Boolean wiiremote_expansion(WiiRemoteRef wiiremote, Boolean enabled)
-{
-	wiiremote->isExpansionPortEnabled = enabled;
-	if (wiiremote->isExpansionPortAttached == false)
-	{
-		wiiremote->isExpansionPortEnabled = false;
-	}
-	else
-	{
-		readData(wiiremote, 0x04A40020, 16);	//get calbdata
-	}
-
-	return requestUpdates(wiiremote);
-}
-
-Boolean wiiremote_irsensor(WiiRemoteRef wiiremote, Boolean enabled)
-{
-	Boolean	ret;
-
-	wiiremote->isIRSensorEnabled = enabled;
-
-	// ir enable 1
-	unsigned char cmd[] = {0x13, 0x00};
-	if (wiiremote->isVibrationEnabled)	cmd[1] |= 0x01;
-	if (wiiremote->isIRSensorEnabled)	cmd[1] |= 0x04;
-	if ((ret = sendCommand(wiiremote, cmd, 2)) == false)
-		return ret;
-	usleep(kWait);
-
-	// set register 0x1a (ir enable 2)
-	unsigned char cmd2[] = {0x1a, 0x00};
-	if (enabled)	cmd2[1] |= 0x04;
-	if ((ret = sendCommand(wiiremote, cmd2, 2)) == false)
-		return ret;
-	usleep(kWait);
-
-	if(enabled)
-	{
-		// based on marcan's method, found on wiili wiki:
-		// tweaked to include some aspects of cliff's setup procedure in the hopes
-		// of it actually turning on 100% of the time (was seeing 30-40% failure rate before)
-		// the sleeps help it it seems
-		usleep(kWait);
-		if ((ret = writeData(wiiremote, (darr){0x01}, 0x04B00030, 1)) == false)	return ret;
-		usleep(kWait);
-		if ((ret = writeData(wiiremote, (darr){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0xC0}, 0x04B00000, 9)) == false)	return ret;
-		usleep(kWait);
-		if ((ret = writeData(wiiremote, (darr){0x40, 0x00}, 0x04B0001A, 2)) == false)	return ret;
-		usleep(kWait);
-		if ((ret = writeData(wiiremote, (darr){0x08}, 0x04B00030, 1)) == false)	return ret;
-		usleep(kWait);
-
-		requestUpdates(wiiremote);
-	}
-	else
-	{
-		// probably should do some writes to power down the camera, save battery
-		// but don't know how yet.
-
-		ret = wiiremote_motionsensor(wiiremote, wiiremote->isMotionSensorEnabled);
-		ret = wiiremote_vibration(wiiremote, wiiremote->isVibrationEnabled);
-		ret = wiiremote_expansion(wiiremote, wiiremote->isExpansionPortEnabled);
-	}
-
-	return ret;
-}
-
-Boolean wiiremote_getstatus(WiiRemoteRef wiiremote)
-{
-	unsigned char cmd[] = {0x15, 0x00};
-	return sendCommand(wiiremote, cmd, 2);
-}
-
-
diff --git a/common/Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.h b/common/Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.h
deleted file mode 100644
index b957a98..0000000
--- a/common/Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.h
+++ /dev/null
@@ -1,170 +0,0 @@
-// wiiremote.h
-// Copyright by Masayuki Akamatsu
-// Based on "DarwiinRemote" by Hiroaki Kimura
-
-#define BLUETOOTH_VERSION_USE_CURRENT
-//#include <AvailabilityMacros.h>
-#include <math.h>
-#include <CoreFoundation/CoreFoundation.h>
-//#include <CoreFoundation/CFMachPort.h>
-#include <IOBluetooth/IOBluetoothUserLib.h>
-
-typedef unsigned char WiiIRModeType;
-enum {
-	kWiiIRModeBasic			= 0x01,
-	kWiiIRModeExtended		= 0x03,
-	kWiiIRModeFull			= 0x05
-};
-
-typedef struct {
-	int x, y, s;
-} IRData;
-
-typedef struct {
-	unsigned char accX_zero, accY_zero, accZ_zero, accX_1g, accY_1g, accZ_1g;
-} WiiAccCalibData;
-
-typedef struct {
-	unsigned char x_min, x_max, x_center, y_min, y_max, y_center;
-} WiiJoyStickCalibData;
-
-typedef UInt16 WiiButtonType;
-enum {
-	WiiRemoteAButton,
-	WiiRemoteBButton,
-	WiiRemoteOneButton,
-	WiiRemoteTwoButton,
-	WiiRemoteMinusButton,
-	WiiRemoteHomeButton,
-	WiiRemotePlusButton,
-	WiiRemoteUpButton,
-	WiiRemoteDownButton,
-	WiiRemoteLeftButton,
-	WiiRemoteRightButton,
-
-	WiiNunchukZButton,
-	WiiNunchukCButton,
-
-	WiiClassicControllerXButton,
-	WiiClassicControllerYButton,
-	WiiClassicControllerAButton,
-	WiiClassicControllerBButton,
-	WiiClassicControllerLButton,
-	WiiClassicControllerRButton,
-	WiiClassicControllerZLButton,
-	WiiClassicControllerZRButton,
-	WiiClassicControllerUpButton,
-	WiiClassicControllerDownButton,
-	WiiClassicControllerLeftButton,
-	WiiClassicControllerRightButton,
-	WiiClassicControllerMinusButton,
-	WiiClassicControllerHomeButton,
-	WiiClassicControllerPlusButton
-};
-
-
-typedef UInt16 WiiExpansionPortType;
-enum{
-	WiiExpNotAttached,
-	WiiNunchuk,
-	WiiClassicController
-};
-
-typedef UInt16 WiiAccelerationSensorType;
-enum{
-	WiiRemoteAccelerationSensor,
-	WiiNunchukAccelerationSensor
-};
-
-
-typedef UInt16 WiiJoyStickType;
-enum{
-	WiiNunchukJoyStick,
-	WiiClassicControllerLeftJoyStick,
-	WiiClassicControllerRightJoyStick
-};
-
-
-typedef struct _WiiRemoteRec
-{
-	IOBluetoothDeviceInquiryRef	inquiry;
-	IOBluetoothDeviceRef		device;
-	IOBluetoothL2CAPChannelRef	ichan;
-	IOBluetoothL2CAPChannelRef	cchan;
-
-	CFStringRef		address;
-
-	unsigned char	accX;
-	unsigned char	accY;
-	unsigned char	accZ;
-	unsigned short	buttonData;
-
-	float			lowZ;
-	float			lowX;
-	int				orientation;
-	int				leftPoint; // is point 0 or 1 on the left. -1 when not tracking.
-
-	float			posX;
-	float			posY;
-	float			angle;
-	Boolean			tracking;
-
-	WiiExpansionPortType expType;
-	WiiAccCalibData	wiiCalibData, nunchukCalibData;
-	WiiJoyStickCalibData nunchukJoyStickCalibData;
-	WiiIRModeType	wiiIRMode;
-	IRData			irData[4];
-	double			batteryLevel;
-
-	Boolean			readingRegister;
-	Boolean			isMotionSensorEnabled;
-	Boolean			isIRSensorEnabled;
-	Boolean			isVibrationEnabled;
-	Boolean			isExpansionPortEnabled;
-	Boolean			initExpPort;
-	Boolean			isLED1Illuminated;
-	Boolean			isLED2Illuminated;
-	Boolean			isLED3Illuminated;
-	Boolean			isLED4Illuminated;
-
-	Boolean			isExpansionPortAttached;
-
-	IOBluetoothUserNotificationRef	disconnectNotification;
-
-	//nunchuk
-	unsigned char	nStickX;
-	unsigned char	nStickY;
-	unsigned char	nAccX;
-	unsigned char	nAccY;
-	unsigned char	nAccZ;
-	unsigned char	nButtonData;
-
-	float			nLowZ;
-	float			nLowX;
-	int				nOrientation;
-
-	//classic controller
-	unsigned short	cButtonData;
-	unsigned char	cStickX1;
-	unsigned char	cStickY1;
-	unsigned char	cStickX2;
-	unsigned char	cStickY2;
-	unsigned char	cAnalogL;
-	unsigned char	cAnalogR;
-
-}	WiiRemoteRec, *WiiRemoteRef;
-
-void			wiiremote_init(WiiRemoteRef wiiremote);
-Boolean			wiiremote_isconnected(WiiRemoteRef wiiremote);
-Boolean			wiiremote_search(WiiRemoteRef wiiremote, char *address);
-Boolean			wiiremote_stopsearch(WiiRemoteRef wiiremote);
-Boolean			wiiremote_connect(WiiRemoteRef wiiremote);
-Boolean			wiiremote_disconnect(WiiRemoteRef wiiremote);
-void			wiiremote_getaddress(WiiRemoteRef wiiremote, char *address);
-Boolean			wiiremote_motionsensor(WiiRemoteRef wiiremote, Boolean enabled);
-Boolean			wiiremote_irsensor(WiiRemoteRef wiiremote, Boolean enabled);
-Boolean			wiiremote_vibration(WiiRemoteRef wiiremote, Boolean enabled);
-Boolean			wiiremote_led(WiiRemoteRef wiiremote, Boolean enabled1, Boolean enabled2, Boolean enabled3, Boolean enabled4);
-Boolean			wiiremote_expansion(WiiRemoteRef wiiremote, Boolean enabled);
-Boolean			wiiremote_getstatus(WiiRemoteRef wiiremote);
-
diff --git a/common/Source/lang/LangSource/PyrLexer.cpp b/common/Source/lang/LangSource/PyrLexer.cpp
index dd691ca..f96a31d 100644
--- a/common/Source/lang/LangSource/PyrLexer.cpp
+++ b/common/Source/lang/LangSource/PyrLexer.cpp
@@ -2045,11 +2045,11 @@ bool passOne_ProcessDir(char *dirname, int level)
 		if (!validItem) break;
 		if (skipItem) continue;
 
-        if (sc_DirectoryExists(diritem)) {
-            success = passOne_ProcessDir(diritem, level + 1);
-        } else {
-            success = passOne_ProcessOneFile(diritem, level + 1);
-        }
+		if (sc_DirectoryExists(diritem)) {
+			success = passOne_ProcessDir(diritem, level + 1);
+		} else {
+			success = passOne_ProcessOneFile(diritem, level + 1);
+		}
 
 		if (!success) break;
 	}
@@ -2125,14 +2125,19 @@ bool isValidSourceFileName(char *filename)
 }
 
 // sekhar's replacement
-bool passOne_ProcessOneFile(char *filenamearg, int level)
+bool passOne_ProcessOneFile(const char * filenamearg, int level)
 {
 	bool success = true;
 
 	bool isAlias = false;
 	// on non-Darwin, sc_ResolveIfAlias always returns original path
 	char filename[MAXPATHLEN];
-	sc_ResolveIfAlias(filenamearg, filename, isAlias, MAXPATHLEN);
+	int status = sc_ResolveIfAlias(filenamearg, filename, isAlias, MAXPATHLEN);
+
+	if (status<0) {
+		printf("WARNING: skipping invalid symbolic link: %s\n", filenamearg);
+		return success;
+	}
 
 #ifdef ENABLE_LIBRARY_CONFIGURATOR
  	if (gLibraryConfig && gLibraryConfig->pathIsExcluded(filename)) {
@@ -2141,10 +2146,9 @@ bool passOne_ProcessOneFile(char *filenamearg, int level)
  	}
 #endif
 
-	PyrSymbol *fileSym;
 	if (isValidSourceFileName(filename)) {
 		gNumCompiledFiles++;
-		fileSym = getsym(filename);
+		PyrSymbol * fileSym = getsym(filename);
 		fileSym->u.source = NULL;
 		if (startLexer(fileSym, -1, -1, -1)) {
 			while (parseOneClass(fileSym)) { };
@@ -2154,21 +2158,9 @@ bool passOne_ProcessOneFile(char *filenamearg, int level)
 			success = false;
 		}
 	} else {
-#ifndef SC_WIN32
-    // check if this is a symlink
-		char realpathname[MAXPATHLEN];
-		realpath(filename, realpathname);
-		if (strncmp(filename, realpathname, strlen(filename))) {
-			if (sc_DirectoryExists(realpathname))
-				success = passOne_ProcessDir(realpathname, level);
-		}
-#else
-    // under window, we're sure it's a file so wer don't do anything...
-    // maybe processing .lnk files could be interesting...
-    // $$$todo fixme add .lnk file parsing...
-    // (see http://www.thecodeproject.com/managedcpp/mcppshortcuts.asp)
-#endif
-  }
+		if (sc_DirectoryExists(filename))
+			success = passOne_ProcessDir(filename, level);
+	}
 	return success;
 }
 
diff --git a/common/Source/lang/LangSource/PyrObject.cpp b/common/Source/lang/LangSource/PyrObject.cpp
index b621867..214cf49 100644
--- a/common/Source/lang/LangSource/PyrObject.cpp
+++ b/common/Source/lang/LangSource/PyrObject.cpp
@@ -1273,7 +1273,7 @@ PyrClass* makeIntrinsicClass(PyrSymbol *className, PyrSymbol *superClassName,
 			sizeof(PyrSlot) * classClassNumInstVars);
 		memcpy(slotRawSymbolArray(&metaclassobj->instVarNames)->symbols,
 			slotRawSymbolArray(&metaSuperClass->instVarNames)->symbols,
-			sizeof(PyrSlot) * classClassNumInstVars);
+			sizeof(PyrSymbol*) * classClassNumInstVars);
 		slotRawObject(&metaclassobj->iprototype)->size = classClassNumInstVars;
 		slotRawObject(&metaclassobj->instVarNames)->size = classClassNumInstVars;
 		//dumpObject((PyrObject*)metaclassobj);
@@ -1290,7 +1290,7 @@ PyrClass* makeIntrinsicClass(PyrSymbol *className, PyrSymbol *superClassName,
 			sizeof(PyrSlot) * superInstVars);
 		memcpy(slotRawSymbolArray(&classobj->instVarNames)->symbols,
 			slotRawSymbolArray(&superClass->instVarNames)->symbols,
-			sizeof(PyrSlot) * superInstVars);
+			sizeof(PyrSymbol*) * superInstVars);
 		slotRawObject(&classobj->iprototype)->size = superInstVars;
 		slotRawObject(&classobj->instVarNames)->size = superInstVars;
 	}
@@ -1487,7 +1487,7 @@ void initClasses()
 
 		addIntrinsicVar(class_thread, "environment", &o_nil);
 		addIntrinsicVar(class_thread, "exceptionHandler", &o_nil);
-	
+
 		addIntrinsicVar(class_thread, "executingPath", &o_nil);
 		addIntrinsicVar(class_thread, "oldExecutingPath", &o_nil);
 
diff --git a/common/Source/plugins/BinaryOpUGens.cpp b/common/Source/plugins/BinaryOpUGens.cpp
index 6b96889..b9f2e5e 100644
--- a/common/Source/plugins/BinaryOpUGens.cpp
+++ b/common/Source/plugins/BinaryOpUGens.cpp
@@ -2012,7 +2012,7 @@ void div_ia_nova(BinaryOpUGen *unit, int inNumSamples)
 {
 	float xa = ZIN0(0);
 
-	nova::over_vec_simd(OUT(0), IN(1), xa, inNumSamples);
+	nova::over_vec_simd(OUT(0), xa, IN(1), inNumSamples);
 	unit->mPrevA = xa;
 }
 
diff --git a/common/Source/plugins/GrainUGens.cpp b/common/Source/plugins/GrainUGens.cpp
index a82893c..62a314a 100644
--- a/common/Source/plugins/GrainUGens.cpp
+++ b/common/Source/plugins/GrainUGens.cpp
@@ -167,6 +167,9 @@ inline float grain_in_at(Unit* unit, int index, int offset)
 {
 	if (full_rate)
 		return GRAIN_IN_AT(unit, index, offset);
+
+	if (INRATE(index) == calc_DemandRate)
+		return DEMANDINPUT_A(index, offset + 1);
 	else
 		return IN0(index);
 }
@@ -1177,7 +1180,7 @@ inline void GrainBuf_next_start_new(GrainBuf *unit, int inNumSamples, int positi
 
 	// end add //
 
-	int nsmps = sc_min(grain->counter, inNumSamples);
+	int nsmps = sc_min(grain->counter, inNumSamples - position);
 
 	if (grain->winType < 0.)
 		GRAIN_BUF_PLAY_GRAIN(INTERNAL);
diff --git a/common/Source/plugins/IOUGens.cpp b/common/Source/plugins/IOUGens.cpp
index 4921808..bec8f9b 100644
--- a/common/Source/plugins/IOUGens.cpp
+++ b/common/Source/plugins/IOUGens.cpp
@@ -58,8 +58,8 @@ const int kMaxLags = 16;
 
 struct LagControl : public IOUnit
 {
-	float m_b1[kMaxLags];
-	float m_y1[kMaxLags];
+	float * m_b1;
+	float * m_y1;
 };
 
 
@@ -352,20 +352,31 @@ void LagControl_next_1(LagControl *unit, int inNumSamples)
 
 void LagControl_Ctor(LagControl* unit)
 {
-	if (unit->mNumOutputs == 1) {
-		SETCALC(LagControl_next_1);
-		LagControl_next_1(unit, 1);
-	} else {
-		SETCALC(LagControl_next_k);
-		LagControl_next_k(unit, 1);
-	}
 	int numChannels = unit->mNumInputs;
 	float **mapin = unit->mParent->mMapControls + unit->mSpecialIndex;
+
+	char * chunk = (char*)RTAlloc(unit->mWorld, numChannels * 2 * sizeof(float));
+	unit->m_y1 = (float*)chunk;
+	unit->m_b1 = unit->m_y1 + numChannels;
+
 	for (int i=0; i<numChannels; ++i, mapin++) {
 		unit->m_y1[i] = **mapin;
 		float lag = ZIN0(i);
 		unit->m_b1[i] = lag == 0.f ? 0.f : (float)exp(log001 / (lag * unit->mRate->mSampleRate));
 	}
+
+	if (unit->mNumOutputs == 1) {
+		SETCALC(LagControl_next_1);
+		LagControl_next_1(unit, 1);
+	} else {
+		SETCALC(LagControl_next_k);
+		LagControl_next_k(unit, 1);
+	}
+}
+
+void LagControl_Dtor(LagControl* unit)
+{
+	RTFree(unit->mWorld, unit->m_y1);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1932,7 +1943,7 @@ PluginLoad(IO)
 	DefineDtorUnit(OffsetOut);
 	DefineDtorUnit(LocalIn);
 	DefineSimpleUnit(XOut);
-	DefineSimpleUnit(LagControl);
+	DefineDtorUnit(LagControl);
 	DefineDtorUnit(AudioControl);
 	DefineUnit("Control", sizeof(Unit), (UnitCtorFunc)&Control_Ctor, 0, 0);
 	DefineUnit("TrigControl", sizeof(Unit), (UnitCtorFunc)&TrigControl_Ctor, 0, 0);
diff --git a/common/Source/plugins/LFUGens.cpp b/common/Source/plugins/LFUGens.cpp
index df4aa50..92d240e 100644
--- a/common/Source/plugins/LFUGens.cpp
+++ b/common/Source/plugins/LFUGens.cpp
@@ -638,7 +638,9 @@ void LFPar_next_a(LFPar *unit, int inNumSamples)
 			float z = phase;
 			ZXP(out) = 1.f - z*z;
 		}
-		phase += ZXP(freq) * freqmul;
+		// Note: the following two lines were originally one, but seems to compile wrong on mac
+		float phaseadd = ZXP(freq) * freqmul;
+		phase += phaseadd;
 	);
 
 	unit->mPhase = phase;
@@ -703,7 +705,8 @@ void LFCub_next_a(LFCub *unit, int inNumSamples)
 			z = phase;
 		}
 		ZXP(out) = z * z * (6.f - 4.f * z) - 1.f;
-		phase += ZXP(freq) * freqmul;
+		float phaseadd = ZXP(freq);
+		phase += phaseadd * freqmul;
 	);
 
 	unit->mPhase = phase;
diff --git a/common/Source/plugins/TriggerUGens.cpp b/common/Source/plugins/TriggerUGens.cpp
index 5d8fca3..04b7df7 100644
--- a/common/Source/plugins/TriggerUGens.cpp
+++ b/common/Source/plugins/TriggerUGens.cpp
@@ -1076,7 +1076,7 @@ void Latch_Ctor(Latch *unit)
 	unit->m_prevtrig = 0.f;
 	unit->mLevel = 0.f;
 
-	ZOUT0(0) = 0.f;
+	ZOUT0(0) = ZIN0(1) > 0.f ? ZIN0(0) : 0.f;
 }
 
 
diff --git a/common/Source/plugins/UnaryOpUGens.cpp b/common/Source/plugins/UnaryOpUGens.cpp
index efe2dab..52f7928 100644
--- a/common/Source/plugins/UnaryOpUGens.cpp
+++ b/common/Source/plugins/UnaryOpUGens.cpp
@@ -166,7 +166,7 @@ extern "C" void name##_d(UnaryOpUGen *unit, int inNumSamples)	\
 {													\
 	if (inNumSamples) {								\
 		float x = DEMANDINPUT_A(0, inNumSamples);	\
-		OUT0(0) = sc_isnan(x) ? NAN : sc_cpsoct(x);	\
+		OUT0(0) = sc_isnan(x) ? NAN : function(x);	\
 	} else {										\
 		RESETINPUT(0);								\
 	}												\
diff --git a/common/Source/plugins/configure.in b/common/Source/plugins/configure.in
index 17be8ac..9bdf760 100644
--- a/common/Source/plugins/configure.in
+++ b/common/Source/plugins/configure.in
@@ -2,7 +2,7 @@ dnl ===================================================================
 dnl file:	configure.in
 dnl contents:	autoconf template
 dnl author:	stefan kersten <steve at k-hornz.de>
-dnl CVS:	$Id: configure.in 2231 2003-11-28 11:06:57Z kersten $
+dnl CVS:	$Id$
 dnl ===================================================================
 
 # initialize autoconf
diff --git a/common/Source/server/SC_Carbon.cpp b/common/Source/server/SC_Carbon.cpp
index c1ef84b..9e795ef 100644
--- a/common/Source/server/SC_Carbon.cpp
+++ b/common/Source/server/SC_Carbon.cpp
@@ -68,6 +68,7 @@ bool sc_HasVectorUnit()
 void sc_SetDenormalFlags()
 {
 	// all Macs have SSE
+	_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
 	_mm_setcsr(_mm_getcsr() | 0x40);
 }
 
diff --git a/common/Source/server/SC_CoreAudio.cpp b/common/Source/server/SC_CoreAudio.cpp
index 216f5dc..0541f24 100644
--- a/common/Source/server/SC_CoreAudio.cpp
+++ b/common/Source/server/SC_CoreAudio.cpp
@@ -253,7 +253,10 @@ bool ProcessOSCPacket(World *inWorld, OSC_Packet *inPacket)
 	bool result;
 	inWorld->mDriverLock->Lock();
 		SC_AudioDriver *driver = AudioDriver(inWorld);
-		if (!driver) return false;
+		if (!driver) {
+			inWorld->mDriverLock->Unlock();
+			return false;
+		}
 		inPacket->mIsBundle = gIsBundle.checkIsBundle((int32*)inPacket->mData);
 		FifoMsg fifoMsg;
 		fifoMsg.Set(inWorld, Perform_ToEngine_Msg, FreeOSCPacket, (void*)inPacket);
diff --git a/common/Source/server/SC_MiscCmds.cpp b/common/Source/server/SC_MiscCmds.cpp
index 55d21dd..f30780e 100644
--- a/common/Source/server/SC_MiscCmds.cpp
+++ b/common/Source/server/SC_MiscCmds.cpp
@@ -1294,7 +1294,9 @@ SCErr meth_quit(World *inWorld, int inSize, char *inData, ReplyAddress *inReply)
 SCErr meth_clearSched(World *inWorld, int inSize, char *inData, ReplyAddress *inReply);
 SCErr meth_clearSched(World *inWorld, int inSize, char *inData, ReplyAddress *inReply)
 {
-	inWorld->hw->mAudioDriver->ClearSched();
+	if(inWorld->mRealTime){
+		inWorld->hw->mAudioDriver->ClearSched();
+	}
 	return kSCErr_None;
 }
 
diff --git a/common/build/ChangeLog b/common/build/ChangeLog
index 558d647..d5b7226 100644
--- a/common/build/ChangeLog
+++ b/common/build/ChangeLog
@@ -1,5 +1,97 @@
 Changes are listed below, grouped under each point release of SuperCollider.
 
+SuperCollider v3.4.2, released 2011-03
+======================================
+
+Bugfixes:
+---------
+
+* 2010-06-05 fix Latch first sample output bug: if trigger > 0 initially, latch should not output 0 - jh
+* 2010-09-04 fix firstArg behavior in BinaryOpUGen by a list-approved hack - jh
+* 2010-10-01 fix SConstruct so that libscsynth and libsclang get SONAME entries - ds
+* 2010-11-13 grainBuf: audio-rate trigger fix - tb
+* 2010-11-15 generate libsclang and libscsynth with .so.1 extension (and soname) on linux - ds
+* 2010-11-15 scons create symlinks from libX.so to libX.so.1 on linux, and install them - ds
+* 2010-11-16 added .htm files to SConstruct as approved help file extension - mb
+* 2010-11-28 compile fix for curl support - tb
+* 2010-11-28 prevent asBus from breaking when called with no numChannels - jh
+* 2010-12-03 grain ugens: demand ugen input fix - tb
+* 2010-12-05 SystemClock and TempoClock sched and schedAbs with inf time doesn't schedule the task in the first place. backported from master - tb
+* 2010-12-08 prString_FindRegexp fix: match char array was too short to hold null termination - jl
+* 2010-12-11 fix classbrowser colors bugs. backported from master - tb
+* 2010-12-12 fixes the bug where installed quark help files would not be detected - tb/ar
+* 2010-12-13 mark inherited methods in class browser by background colour. backported from master - tb
+* 2010-12-30 Pipe does not remove closed pipes from openFiles - jh
+* 2010-12-30 fix String:rotate - pb
+* 2011-01-02 unit generators: LagControl - fix initialization order - jh
+* 2011-01-02 unit generators: LagControl - dynamically allocate buffer for filter states - tb
+* 2011-01-07 fixed iOS compilation and backported changes from master branch - ab
+* 2011-01-06 array primitives: fix allTuples and unlace - pb
+* 2011-01-07 sclang: makeIntrinsicClass - correct bounds for memcpy - tb
+* 2011-01-08 sclang: prString_FindRegexp - fill array after allocating objects - tb
+* 2011-01-14 sclang: prString_FindRegexp ensure correct size of results array during gc calls - tb
+* 2011-02-27 sclang: ensure minimum stack size - tb
+* 2011-03-09 SCVim: avoid generating scvim help cache if not currently in scvim - ds
+* 2011-03-11 fix the Event type 'note' (fixes rendering patterns to audio files) - rk
+
+
+
+SuperCollider v3.4.1, released 2010-11
+======================================
+
+* 2010-07-12 remove accidental debug messages from SCView (on mac, posted a lot of info to Console, could affect performance) - ds
+* 2010-09-11 bug in audio rate mapping fixed, when new source object was inserted in a mapped node proxy - jr
+* 2010-07-11 Collections should behave as reasonably as possible when empty - some fixes to better this - jr
+* 2010-07-11 SynthDef:add now sends to all running servers if no libname is given. SynthDescs are still added to the global SynthDescLib. If you want to handle multiple SynthDesc libs, you have to add the servers to each of them explicitly - jr
+* 2010-07-12 PanAz: added support for audio-rate pos arg - lfsaw
+* 2010-07-18 improved the sclang syntax highlighting parses - Patrick Borgeat
+* 2010-07-30 Dreset UGen allows to reset the child UGens on its input - jr
+* 2010-08-05 storeOn / asCompileString now simplifies its output. Default arguments that are given in the *new method anyhow are omitted - jr
+* 2010-08-06 Dictionary merge and blend methods - jr
+* 2010-08-09 method overwrite messages not posted by default, rather a message inviting people to run Main:overwriteMsg for the info - ds
+* 2010-08-13 MethodOverride class to encapsule information on overridden messages, inviting people to run MethodOverride.printAll  - jr
+* 2010-08-13 add size arg to Signal:zeroPad - jr and jh
+* 2010-08-18 Pevent now uses default event if no event is passed in - jr
+* 2010-08-18 added a shortcut to the rather tedious .asCompileString method. In analogy to object.postcs, object.cs returns the compile string - jr
+* 2010-08-20 audio driver for scsynth running on Android (through JNI) - ds
+* 2010-08-24 un-deprecate scsynth's ability to use internal "green" FFT lib, for embedded devices etc - ds
+* 2010-08-28 no 'record' button for remote server GUIs, since path not generally known - ds
+* 2010-09-02 token threading for sclang interpreter - tb
+* 2010-09-07 when looking for a code file (openCodeFile) or cmd-J, it is now enough to select a full line, instead of having to select both words around the colon - jr
+* 2010-09-07 added methods for better navigation in the class tree (findOverriddenMethod) - jr
+* 2010-09-10 add method: Complex:abs to fit common usage - jr
+* 2010-09-12 added Dwrand UGen - jr
+* 2010-09-15 SystemClock and TempoClock sched and schedAbs with inf time doesn't schedule the task in the first place - jr
+* 2010-10-07 change the mac HID error-handler code to output errors to sc post window rather than to mac log; removes a pascal-string issue - ds
+* 2010-10-19 Ndef now releses its bus when server was quit or just booted - jr
+* 2010-10-20 retain the path to the file in which an error has occurred and post it - jr
+
+
+Bugfixes:
+---------
+* 2010-07-10 protecting the server against malformatted SynthDef names - jr
+* 2010-06-28 syntaxColorize fix for double-backslashes, thanks Patrick Borgeat for the patch - ds
+* 2010-07-24 catch crash in the case that one tries to define a unique method using a return value directly - jr
+* 2010-09-07 UGen:clip, :wrap, :fold now apply correctly to scalar-rate signals; also methodSelectorForRate tweak for which class is asked - ds
+* 2010-09-09 fix a bug for trigger signals in Demand.kr that hold longer than one control period - jr
+* 2010-09-12 fix bug: 2994009. LFPar and LFCub audio rate modulation frequency argument work now - jr
+* 2010-09-19 fix to JITGui, when numItems is not supplied - jr
+* 2010-10-10 remove more crufty NSLog debug messages - ds
+* 2010-10-13 fix SCUserView:receiveDrag to receive mouse co-ordinates; thanks Daniel van den Eijkel - ds
+* 2010-10-19 debian-style scvim-check-if-plugin-is-active, brought upstream - ds
+* 2010-10-19 bug in audio rate mapping fixed, when new source object was inserted in a mapped node proxy - jr
+* 2010-10-19 partial fix for bugs item #2994009 - seems to fix LFPar but not LFCub. More work needed - ds
+* 2010-10-19 DC: fix multichannel expansion - tb
+* 2010-10-19 fix to demand rate unary op ugens, thanks james harkins - tb
+* 2010-10-19 Ugens: LinLin/LinExp fixes - tb
+* 2010-10-19 only /clearSched if RT - to fix tracker item #3033454 - tb
+* 2010-10-19 UGens: binary operators - fix scalar/signal division - tb
+* 2010-10-19 fix bug 2988525: SynthDef:writeDefFile appends path correctly - tb
+* 2010-10-19 ProcessOSCPacket: fix possible deadlock - tb
+* 2010-10-19 fix network address handling - albert graef
+* 2010-11-05 fix memory issues in regular expressions: correct memory management in prString_FindRegexp - tb
+* 2010-11-07 sclang: correct symlink handling - tb, ar
+
 SuperCollider v3.4, released 2010-07
 ====================================
 
@@ -30,7 +122,7 @@ Headlines:
 * 2010-02-18 scvim: now compatible with gnu screen, opens post window using screen, making it compatible with a pure-CLI environment - ds
 * 2010-02-xx add the Deployment32-64 build style for building on OS X (10.5 and greater) - jp
 * 2010-03-10 SynthDef:memStore deprecated in favour of the more coherent and typeable SynthDef:add - jr
-* 2010-04-11 Moved some more experimental JITLib classes to ÒJITLib extensions" Quark - jr
+* 2010-04-11 Moved some more experimental JITLib classes to "JITLib extensions" Quark - jr
 
 
 Bugfixes:
@@ -69,6 +161,7 @@ Bugfixes:
 * 2010-03-11 SequenceableCollection:reduce no longer returns nil if the collection has only 1 element - ds
 * 2010-03-28 fix memory leak of empty command line, for interactive sclang mode - tb
 * 2010-03-29 main menu for Mac lang editor app: correction to key for evaluate selection, used to be return, now return+shift - nc
+* 2010-04-19 fix missing font issue in Plotter -jr
 
 Other additions/improvements:
 -----------------------------
diff --git a/common/build/SCClassLibrary/Common/Audio/BasicOpsUGen.sc b/common/build/SCClassLibrary/Common/Audio/BasicOpsUGen.sc
index c76270c..5229cb8 100644
--- a/common/build/SCClassLibrary/Common/Audio/BasicOpsUGen.sc
+++ b/common/build/SCClassLibrary/Common/Audio/BasicOpsUGen.sc
@@ -15,9 +15,15 @@ BasicOpUGen : UGen {
 //	}
 	operator_ { arg op;
 		operator = op;
-		specialIndex = operator.specialIndex;
-			// 'firstArg' check is necessary for audio-rate Demand units
-		if(specialIndex < 0 and: { operator != 'firstArg' }) {
+			// 'firstArg' exists in the server
+			// but the 'specialIndex' primitive doesn't report the right value
+			// admittedly this is a hack, but the hack was approved on sc-dev
+		if(operator == 'firstArg') {
+			specialIndex = 46
+		} {
+			specialIndex = operator.specialIndex;
+		};
+		if(specialIndex < 0) {
 			Error("Operator '%' applied to a UGen is not supported in scsynth".format(operator)).throw
 		}
 	}
diff --git a/common/build/SCClassLibrary/Common/Audio/Line.sc b/common/build/SCClassLibrary/Common/Audio/Line.sc
index 1bc60d8..f535189 100644
--- a/common/build/SCClassLibrary/Common/Audio/Line.sc
+++ b/common/build/SCClassLibrary/Common/Audio/Line.sc
@@ -17,6 +17,7 @@ XLine : UGen {
 }
 
 LinExp : UGen {
+	checkInputs { ^this.checkSameRateAsFirstInput }
 	*ar { arg in=0.0, srclo = 0.0, srchi = 1.0, dstlo = 1.0, dsthi = 2.0;
 		^this.multiNew('audio', in, srclo, srchi, dstlo, dsthi)
 	}
@@ -26,6 +27,7 @@ LinExp : UGen {
 }
 
 LinLin : UGen {
+	checkInputs { ^this.checkSameRateAsFirstInput }
 	*ar { arg in=0.0, srclo = 0.0, srchi = 1.0, dstlo = 1.0, dsthi = 2.0;
 		^this.multiNew('audio', in, srclo, srchi, dstlo, dsthi)
 	}
@@ -88,10 +90,10 @@ T2A : K2A { // control rate to audio rate trigger converter.
 
 DC : MultiOutUGen {
 	*ar { arg in=0.0;
-		^this.multiNewList(['audio'] ++ in)
+		^this.multiNew('audio', in)
 	}
 	*kr { arg in=0.0;
-		^this.multiNewList(['control'] ++ in)
+		^this.multiNew('control', in)
 	}
 	init { arg ... argInputs;
 		inputs = argInputs;
diff --git a/common/build/SCClassLibrary/Common/Collections/Event.sc b/common/build/SCClassLibrary/Common/Collections/Event.sc
index 90c3597..ef84366 100644
--- a/common/build/SCClassLibrary/Common/Collections/Event.sc
+++ b/common/build/SCClassLibrary/Common/Collections/Event.sc
@@ -507,24 +507,22 @@ Event : Environment {
 							};
 
 							// schedule when the bundles are sent
-							
 							if (strum == 0) {
-								schedBundleArrayOnClock(
-									offset, thisThread.clock, bndl, lag, server, ~latency);
+								~schedBundleArray.(lag, offset, server, bndl, ~latency);
 								if (sendGate) {
-									schedBundleArrayOnClock(
-										sustain + offset, thisThread.clock, 
-										[\n_set, ids, \gate, 0].flop, 
-										lag, server, ~latency
+									~schedBundleArray.(
+										lag,
+										sustain + offset,
+										server,
+										[\n_set, ids, \gate, 0].flop,
+										~latency
 									);
 								}
 							} {
-								
 								if (strum < 0) { bndl = bndl.reverse };
 								strumOffset = offset + Array.series(bndl.size, 0, strum.abs);
-								schedBundleArrayOnClock(
-									strumOffset, thisThread.clock, bndl, 
-									lag, server, ~latency
+								~schedBundleArray.(
+									lag, strumOffset, server, bndl, ~latency
 								);
 								if (sendGate) {
 									if (~strumEndsTogether) {
@@ -532,10 +530,10 @@ Event : Environment {
 									} {
 											strumOffset = sustain + strumOffset
 									};
-									schedBundleArrayOnClock(
-										strumOffset, thisThread.clock, 
-										[\n_set, ids, \gate, 0].flop, 
-										lag, server, ~latency
+									~schedBundleArray.(
+										lag, strumOffset, server,
+										[\n_set, ids, \gate, 0].flop,
+										~latency
 									);
 								}
 							}
diff --git a/common/build/SCClassLibrary/Common/Collections/String.sc b/common/build/SCClassLibrary/Common/Collections/String.sc
index c16c49c..b121823 100644
--- a/common/build/SCClassLibrary/Common/Collections/String.sc
+++ b/common/build/SCClassLibrary/Common/Collections/String.sc
@@ -278,7 +278,7 @@ String[char] : RawArray {
 		^this.as(Array).scramble.as(String)
 	}
 
-	rotate { |n|
+	rotate { arg n = 1;
 		^this.as(Array).rotate(n).as(String)
 	}
 
diff --git a/common/build/SCClassLibrary/Common/Control/asBus.sc b/common/build/SCClassLibrary/Common/Control/asBus.sc
index 4468f04..d2d0f5a 100644
--- a/common/build/SCClassLibrary/Common/Control/asBus.sc
+++ b/common/build/SCClassLibrary/Common/Control/asBus.sc
@@ -1,6 +1,6 @@
 
 + Server {
-	asBus { arg rate,numChannels;
+	asBus { arg rate,numChannels=1;
 		^Bus.alloc(rate,this,numChannels)
 	}
 }
@@ -16,7 +16,7 @@
 }
 
 + Nil {
-	asBus { arg rate,numChannels,server;
+	asBus { arg rate,numChannels=1,server;
 		^if(rate == \audio,{
 			Bus(\audio,0,numChannels,server); // out yer speakers
 		},{
diff --git a/common/build/SCClassLibrary/Common/Core/Nil.sc b/common/build/SCClassLibrary/Common/Core/Nil.sc
index 5e019fb..7fd1f78 100644
--- a/common/build/SCClassLibrary/Common/Core/Nil.sc
+++ b/common/build/SCClassLibrary/Common/Core/Nil.sc
@@ -110,5 +110,7 @@ Nil {
 	}
 
 	archiveAsCompileString { ^true }
+
+	superclassesDo {}
 }
 
diff --git a/common/build/SCClassLibrary/Common/Core/Object.sc b/common/build/SCClassLibrary/Common/Core/Object.sc
index 4adeb79..f97efc5 100644
--- a/common/build/SCClassLibrary/Common/Core/Object.sc
+++ b/common/build/SCClassLibrary/Common/Core/Object.sc
@@ -585,7 +585,7 @@ Object  {
 			var file;
 			dir = dir ? SynthDef.synthDefDir;
 			if (name.isNil) { error("missing SynthDef file name") } {
-				name = dir ++ name ++ ".scsyndef";
+				name = dir +/+ name ++ ".scsyndef";
 				if(overwrite or: { pathMatch(name).isEmpty })
 					{
 					file = File(name, "w");
diff --git a/common/build/SCClassLibrary/Common/Core/Thread.sc b/common/build/SCClassLibrary/Common/Core/Thread.sc
index b06d5f1..d797a65 100644
--- a/common/build/SCClassLibrary/Common/Core/Thread.sc
+++ b/common/build/SCClassLibrary/Common/Core/Thread.sc
@@ -17,10 +17,10 @@ Thread : Stream {
 	var <>exceptionHandler;
 	var <executingPath, <oldExecutingPath;
 
-	*new { arg func, stackSize=64;
+	*new { arg func, stackSize=512;
 		^super.new.init(func, stackSize)
 	}
-	init { arg argFunc, argStackSize=64;
+	init { arg argFunc, argStackSize=512;
 		_Thread_Init
 		^this.primitiveFailed
 	}
diff --git a/common/build/SCClassLibrary/Common/Files/File.sc b/common/build/SCClassLibrary/Common/Files/File.sc
index 9febac7..98f0570 100644
--- a/common/build/SCClassLibrary/Common/Files/File.sc
+++ b/common/build/SCClassLibrary/Common/Files/File.sc
@@ -121,7 +121,12 @@ Pipe : UnixFILE {
 		});
 	}
 
-	close { // close the file
+	close {
+		this.prClose;
+		openFiles.remove(this);
+	}
+
+	prClose { // close the file
 		// the GC will not call this for you
 		_PipeClose
 		^this.primitiveFailed;
diff --git a/common/build/SCClassLibrary/Common/GUI/PlusGUI/Core/ClassBrowser.sc b/common/build/SCClassLibrary/Common/GUI/PlusGUI/Core/ClassBrowser.sc
index 85eae26..12dc49b 100644
--- a/common/build/SCClassLibrary/Common/GUI/PlusGUI/Core/ClassBrowser.sc
+++ b/common/build/SCClassLibrary/Common/GUI/PlusGUI/Core/ClassBrowser.sc
@@ -409,10 +409,27 @@ ClassBrowser {
 					},
 					methodTitle: { |v| v.string_("methods") },
 					methodView: { |v|
-						~methodView.items_(~classMethodNames ++ ~methodNames)
+						var colorFunc = { |class, name|
+							if(class.findOverriddenMethod(name.asSymbol).isNil) {
+								Color.clear
+							} {
+								Color.grey(0.8)
+							}
+						};
+						var classMethodColors = ~classMethodNames.collect { |name|
+							colorFunc.value(~currentClass.class, name)
+						};
+						var methodColors = ~methodNames.collect { |name|
+							colorFunc.value(~currentClass, name)
+						};
+						var methodNames = ~classMethodNames ++ ~methodNames;
+						var colors = classMethodColors ++ methodColors;
+
+						~methodView.items_(methodNames)
 							.value_(~methodViewIndex ? 0)
 							.action_(~displayCurrentMethodArgsAction)
-							.mouseDownAction_(~listViewDoubleClickAction);
+							.mouseDownAction_(~listViewDoubleClickAction)
+							.tryPerform(\colors_, colors)
 					},
 					argView: { |v|
 						if (~currentMethod.isNil or: { ~currentMethod.argNames.isNil }) {
diff --git a/common/build/SCClassLibrary/Common/GUI/iphone/Base/GUIScreen.sc b/common/build/SCClassLibrary/Common/GUI/iphone/Base/GUIScreen.sc
deleted file mode 100644
index 692c7e4..0000000
--- a/common/build/SCClassLibrary/Common/GUI/iphone/Base/GUIScreen.sc
+++ /dev/null
@@ -1,273 +0,0 @@
-SCWindow {
-	classvar <>allWindows, <currentFullScreen, <>initAction;
-
-	var dataptr, <name, <>onClose, <view, <userCanClose=true;
-	var <alwaysOnTop=false;
-	var <>drawHook;
-	var <acceptsMouseOver=false;
-	var <isClosed = false;
-	var <acceptsClickThrough = true;
-	var <> toFrontAction, <> endFrontAction;
-	var <editable=false, <>constructionView;
-	var <currentSheet; // current modal sheet attached to this window, if it exists
-
-	*initClass {
-		UI.registerForShutdown({ this.closeAll });
-	}
-
-	*new { arg name = "panel", bounds, resizable = true, border = true, server, scroll = false;
-		^super.new.initSCWindow(name, bounds, resizable, border, scroll)
-	}
-	// appmodal is a private flag used to disable the close button
-	initSCWindow { arg argName, argBounds, resizable, border, scroll, appmodal = false;
-		name = argName.asString;
-		argBounds = argBounds ?? {Rect(128, 64, 400, 400)};
-		allWindows = allWindows.add(this);
-		scroll.if({
-			view = SCScrollTopView(nil, argBounds.moveTo(0,0));
-		},{
-			view = SCTopView(nil, argBounds.moveTo(0,0));
-		});
-		this.prInit(name, argBounds, resizable, border, scroll, view, appmodal);
-		initAction.value(this);
-	}
-
-	asView { ^view }
-	add { arg aView; view.add(aView) }
-
-	addFlowLayout { |margin, gap|
-		view.relativeOrigin.if
-			{view.decorator_( FlowLayout( view.bounds.moveTo(0,0), margin, gap ) )}
-			{view.decorator_( FlowLayout( view.bounds, margin, gap ) )};
-		^this.view.decorator;
-		 }
-
-	*closeAll {
-		var list;
-		list = allWindows.copy;
-		allWindows = Array.new(8);
-		list.do({ arg window; window.close; });
-	}
-
-	close {
-		if (isClosed) { ^this };
-		this.prClose;
-	}
-	closed {
-		isClosed = true;
-		onClose.value; // call user function
-		dataptr = nil;
-		view.prClose;
-		allWindows.remove(this);
-	}
-
-	addToOnClose { | function | onClose = onClose.addFunc(function) }
-
-	removeFromOnClose { | function | onClose = onClose.removeFunc(function) }
-
-	fullScreen {
-		currentFullScreen.notNil.if({currentFullScreen.endFullScreen});
-		this.prFullScreen;
-		currentFullScreen = this;
-	}
-	endFullScreen {
-		this.prEndFullScreen;
-		currentFullScreen = nil;
-	}
-
-	prFullScreen {
-		_SCWindow_BeginFullScreen
-		^this.primitiveFailed
-	}
-	prEndFullScreen {
-		_SCWindow_EndFullScreen
-		^this.primitiveFailed
-	}
-	userCanClose_ { arg boo;
-		_SCWindow_SetShouldClose
-		^this.primitiveFailed
-	}
-	acceptsMouseOver_{arg bool;
-		acceptsMouseOver = bool;
-		this.prSetAcceptMouseOver(bool);
-	}
-	front {
-		_SCWindow_ToFront
-		^this.primitiveFailed
-	}
-
-	alwaysOnTop_{|bool=true|
-		alwaysOnTop = bool;
-		this.prSetAlwaysOnTop(bool);
-	}
-
-	prSetAlwaysOnTop{|boolean=true|
-		_SCWindow_AlwaysOnTop
-	}
-
-	acceptsClickThrough_{|boolean=true|
-		acceptsClickThrough = boolean;
-		this.prSetAcceptsClickThrough(boolean);
-	}
-
-	prSetAcceptsClickThrough{|boolean=true|
-		_SCWindow_AcceptsClickThrough
-	}
-
-	refresh {
-		_SCWindow_Refresh
-		^this.primitiveFailed
-	}
-	minimize {
-		_SCWindow_Minimize
-		^this.primitiveFailed
-	}
-	alpha_ { arg alpha;
-		_SCWindow_SetAlpha
-		^this.primitiveFailed
-	}
-
-	name_ { arg argName;
-		name = argName;
-		this.prSetName(argName);
-	}
-	// bounds are relative to the bottom left corner origin
-	bounds_ { arg argBounds;
-		this.prSetBounds(argBounds);
-	}
-	// set bounds relative to top left corner
-	setTopLeftBounds { |rect,menuSpacer=45|
-		rect = rect.copy;
-		// 45 is the height of the mac os menu
-		// if you are in full screen mode you would want to pass in 0
-		rect.top = SCWindow.screenBounds.height - rect.height - rect.top - menuSpacer;
-		this.bounds = rect
-	}
-	setInnerExtent { arg w,h; // resize window keeping top left corner fixed
-		var b;
-		b = this.bounds;
-		w = w ? b.width;
-		h = h ? b.height;
-		this.bounds = Rect(b.left,b.top + (b.height - h), w,h);
-	}
-	bounds {
-		^this.prGetBounds(Rect.new);
-	}
-	*screenBounds {
-		^this.prGetScreenBounds(Rect.new);
-	}
-	play { arg function;
-		AppClock.play({
-			if (dataptr.notNil, {
-				function.value;
-			});
-		});
-
-	}
-
-	findByID { arg id;
-		^view.findByID(id)
-	}
-
-	// PRIVATE
-	// primitives
-	prInit { arg argName, argBounds, resizable, border, scroll, view, appmodal = false;
-		_SCWindow_New
-		^this.primitiveFailed
-	}
-	prClose {
-		_SCWindow_Close
-		^this.primitiveFailed
-	}
-	prSetName { arg argName;
-		_SCWindow_SetName
-		^this.primitiveFailed
-	}
-	prGetBounds { arg argBounds;
-		_SCWindow_GetBounds
-		^this.primitiveFailed
-	}
-	prSetBounds { arg argBounds;
-		_SCWindow_SetBounds
-		^this.primitiveFailed
-	}
-	prSetAcceptMouseOver{arg bool;
-		_SCWindow_SetAcceptMouseOver
-		^this.primitiveFailed
-	}
-	*prGetScreenBounds { arg argBounds;
-		_SCWindow_GetScreenBounds
-		^this.primitiveFailed
-	}
-	callDrawHook {
-		drawHook.value(this);
-	}
-
-	didBecomeKey {
-		toFrontAction.value(this);
-	}
-
-	didResignKey {
-		endFrontAction.value(this);
-	}
-
-	toggleEditMode{
-		var panel;
-		editable = editable.not;
-		if(editable){
-			SCIBToolboxWindow.front.addWindow(this);
-			this.refresh;
-		}{
-			SCIBToolboxWindow.front.removeWindow(this);
-		}
-	}
-	setCurrentSheet {|sheet| currentSheet = sheet;}
-	/*
-	*viewPalette {|win|
-		var w, v, f, c;
-		w = SCWindow("View Palette", Rect(532, 64, 300, 320),  scroll: true).front;
-		w.view.decorator = f = FlowLayout(w.view.bounds);
-		SCButton(w, 300 at 20).states_([ ["-> CODE"]])
-			.canFocus_(false).action_{
-				Document("window construction code", win.asConstructionCompileString);
-				};
-		w.view.decorator.nextLine;
-//		c = [SCSlider, SCRangeSlider, SC2DSlider, SCPopUpMenu, SCButton,
-//			SCNumberBox, SCMultiSliderView,
-//			SCStaticText, SCDragSource, SCDragSink, SCDragBoth,
-//		];
-		c = SCView.allSubclasses.reject{|it|
-			(it.superclasses.indexOf(SCContainerView).notNil
-			or: (it.name === 'SCContainerView')
-			or: (it.name ==='SCStaticTextBase')
-			or: (it.name === 'SCSliderBase')
-			or: (it.name === 'SCControlView'))
-		};
-
-		c.do({ arg item;
-			var n;
-			n = SCDragSource(w, Rect(0, 0, 140, 24));
-			n.object = item;
-
-			try{
-				item.paletteExample(w, Rect(0,0,140,24));
-			}{
-				"no paletteExample found".warn;
-			};
-			w.view.decorator.nextLine;
-
-		});
-		win.onClose_{
-			Document("window construction code", win.asConstructionCompileString);
-			w.close
-			};
-		^w
-	}
-	*/
-
-	storeArgs{^[name, this.bounds]}
-	storeModifiersOn{|stream|
-		stream << ".front;";
-	}
-}
-
diff --git a/common/build/SCClassLibrary/Common/GUI/iphone/Base/SCFont.sc b/common/build/SCClassLibrary/Common/GUI/iphone/Base/SCFont.sc
deleted file mode 100644
index bb350f2..0000000
--- a/common/build/SCClassLibrary/Common/GUI/iphone/Base/SCFont.sc
+++ /dev/null
@@ -1,40 +0,0 @@
-SCFont {
-	classvar <>default;
-	var <>name, <>size;
-
-	*new { arg name, size;
-		^super.newCopyArgs(name, size);
-	}
-	setDefault { default = this }
-
-	*availableFonts {
-		// returns an Array of font names.
-		_Font_AvailableFonts
-		^this.primitiveFailed
-	}
-	*antiAliasing_ { arg flag = false;
-		_Font_SetAntiAliasing;
-		^this.primitiveFailed
-	}
-	*smoothing_ { arg flag = false;
-		_Font_SetSmoothing;
-		^this.primitiveFailed
-	}
-	storeArgs { ^[name,size] }
-
-	boldVariant {
-		^if( name.endsWith( "-Bold" ), this, { this.class.new( name ++ "-Bold", size )});
-	}
-
-	*defaultSansFace {
-		^"Helvetica";
-	}
-
-	*defaultSerifFace {
-		^"Times";
-	}
-
-	*defaultMonoFace {
-		^"Monaco";
-	}
-}
\ No newline at end of file
diff --git a/common/build/SCClassLibrary/Common/GUI/iphone/Base/SCView.sc b/common/build/SCClassLibrary/Common/GUI/iphone/Base/SCView.sc
deleted file mode 100644
index cff523c..0000000
--- a/common/build/SCClassLibrary/Common/GUI/iphone/Base/SCView.sc
+++ /dev/null
@@ -1,1006 +0,0 @@
-
-SCView {  // abstract class
-	classvar <>currentDrag, <>currentDragString;
-	classvar <>globalKeyDownAction, <>globalKeyUpAction;
-
-	var dataptr, <parent, <>action, <background;
-	var <>mouseDownAction, <>mouseUpAction, <>mouseOverAction, <>mouseMoveAction;
-	var <>keyDownAction, <>keyUpAction, <>keyTyped, <> keyModifiersChangedAction;
-	var <>beginDragAction,<>canReceiveDragHandler,<>receiveDragHandler;
-	var <>onClose;
-
-	*new { arg parent, bounds;
-		^super.new.init(parent, bounds);
-	}
-	*viewClass { ^this }
-	*paletteExample { arg parent, bounds;
-		^this.new(parent, bounds);
-	}
-
-	init { arg argParent, argBounds;
-		parent = argParent.asView; // actual view
-		background = Color.clear;
-			// call asView again because parent by this point might be a FlowView
-		this.prInit(parent.asView, argBounds.asRect,this.class.viewClass);
-		argParent.add(this);//maybe window or viewadapter
-	}
-
-	asView { ^this }
-
-	bounds {
-		^this.getProperty(\bounds, Rect.new)
-	}
-	bounds_ { arg rect;
-		this.setProperty(\bounds, rect)
-	}
-
-	visible {
-		^this.getProperty(\visible)
-	}
-	visible_ { arg bool;
-		this.setProperty(\visible, bool)
-	}
-
-	enabled {
-		^this.getProperty(\enabled)
-	}
-	enabled_ { arg bool;
-		this.setProperty(\enabled, bool)
-	}
-
-	canFocus {
-		^this.getProperty(\canFocus)
-	}
-	canFocus_ { arg bool;
-		this.setProperty(\canFocus, bool)
-	}
-	focus { arg flag=true;
-		_SCView_Focus
-		^this.primitiveFailed
-	}
-	hasFocus{
-		_SCView_HasFocus
-		^this.primitiveFailed
-	}
-
-	focusColor_{|color|
-		this.setProperty(\focusColor, color);
-	}
-
-	focusColor{
-		^this.getProperty(\focusColor, Color.new);
-	}
-
-	id {
-		^this.getProperty(\id)
-	}
-	id_ { arg id;
-		this.setProperty(\id, id)
-	}
-
-	dragLabel_ { arg string;
-		this.setProperty(\dragLabel, string)
-	}
-
-	refresh {
-		_SCView_Refresh
-		^this.primitiveFailed
-	}
-	findByID { arg id;
-		_SCView_FindByID
-		^this.primitiveFailed
-	}
-
-	isClosed { ^dataptr.isNil }
-	notClosed { ^dataptr.notNil }
-	remove {
-		if(dataptr.notNil,{
-			parent.prRemoveChild(this);
-			this.prRemove;
-			this.prClose;
-		},{
-			"SCView-remove : this view already removed.".debug(this);
-		});
-	}
-	/*
-	resize behaviour in an SCCompositeView:
-		1  2  3
-		4  5  6
-		7  8  9
-
-		1 - fixed to left, fixed to top
-		2 - horizontally elastic, fixed to top
-		3 - fixed to right, fixed to top
-
-		4 - fixed to left, vertically elastic
-		5 - horizontally elastic, vertically elastic
-		6 - fixed to right, vertically elastic
-
-		7 - fixed to left, fixed to bottom
-		8 - horizontally elastic, fixed to bottom
-		9 - fixed to right, fixed to bottom
-	*/
-	resize {
-		^this.getProperty(\resize)
-	}
-	resize_ { arg resize;
-		this.setProperty(\resize, resize)
-	}
-
-	background_ { arg color;
-		background = color;
-		this.setProperty(\background, color)
-	}
-	addAction { arg func, selector=\action;
-		this.perform(selector.asSetter, this.perform(selector).addFunc(func));
-	}
-	removeAction { arg func, selector=\action;
-		this.perform(selector.asSetter, this.perform(selector).removeFunc(func));
-	}
-	mouseDown{arg x, y, modifiers, buttonNumber, clickCount;
-		mouseDownAction.value(this, x, y, modifiers, buttonNumber, clickCount);
-	}
-	mouseUp{arg x, y, modifiers;
-		mouseUpAction.value(this, x, y, modifiers);
-	}
-	mouseMove{arg x, y, modifiers;
-		mouseMoveAction.value(this, x, y, modifiers);
-	}
-	mouseOver{arg x, y;
-		mouseOverAction.value(this, x, y);
-	}
-
-	keyDown { arg char, modifiers, unicode,keycode;
-		globalKeyDownAction.value(this, char, modifiers, unicode, keycode);
-		this.handleKeyDownBubbling(this, char, modifiers, unicode, keycode);
-	}
-
-	keyModifiersChanged{arg modifiers;
-		this.handleKeyModifiersChangedBubbling(this,modifiers)
-	}
-
-	handleKeyModifiersChangedBubbling { arg view, modifiers;
-		var result;
-		// nil from keyDownAction --> pass it on
-		if (keyModifiersChangedAction.isNil) {
-//			this.defaultKeyDownAction(char,modifiers,unicode,keycode);
-			result = nil;
-		}{
-			result = keyModifiersChangedAction.value(view, modifiers);
-		};
-		if(result.isNil) {
-			// call keydown action of parent view
-			parent.handleKeyModifiersChangedBubbling(view, modifiers);
-		};
-	}
-
-	defaultKeyDownAction { ^nil }
-	handleKeyDownBubbling { arg view, char, modifiers, unicode, keycode;
-		var result;
-		// nil from keyDownAction --> pass it on
-		if (keyDownAction.isNil) {
-			result = this.defaultKeyDownAction(char,modifiers,unicode,keycode);
-		}{
-			result = keyDownAction.value(view, char, modifiers, unicode, keycode);
-		};
-		if(result.isNil) {
-			// call keydown action of parent view
-			parent.handleKeyDownBubbling(view, char, modifiers, unicode, keycode);
-		};
-	}
-
-	// sc.solar addition
-	keyUp { arg char, modifiers, unicode,keycode;
-		this.keyTyped = char;
-		// always call global keydown action first
-		globalKeyUpAction.value(this, char, modifiers, unicode, keycode);
-		this.handleKeyUpBubbling(this, char, modifiers, unicode, keycode);
-	}
-	defaultKeyUpAction { ^nil }
-	handleKeyUpBubbling { arg view, char, modifiers,unicode,keycode;
-		var result;
-		// nil from keyDownAction --> pass it on
-		if (keyUpAction.isNil) {
-			result = this.defaultKeyUpAction(char,modifiers,unicode,keycode);
-		}{
-			result = keyUpAction.value(view, char, modifiers, unicode, keycode);
-		};
-		if(result.isNil) {
-			// call keydown action of parent view
-			parent.handleKeyUpBubbling(view, char, modifiers, unicode, keycode);
-		};
-	}
-
-
-	beginDrag {
-		currentDrag = if (beginDragAction.notNil)
-		{
-			beginDragAction.value(this)
-		}{
-			this.defaultGetDrag
-		};
-		currentDragString = currentDrag.asCompileString;
-	}
-	defaultGetDrag { ^nil }
-	canReceiveDrag {
-		^if(canReceiveDragHandler.notNil,{ canReceiveDragHandler.value(this) },{ this.defaultCanReceiveDrag })
-	}
-	defaultCanReceiveDrag { ^false }
-	receiveDrag {|x,y|
-		if(receiveDragHandler.notNil,{ receiveDragHandler.value(this, x, y) },{ this.defaultReceiveDrag(x,y) });
-		currentDrag = currentDragString = nil;
-	}
-
-	// get the view parent tree up to the SCTopView
-	getParents {
-		var parents, view;
-		view = this;
-		parents = List.new;
-		while({(view = view.parent).notNil},{ parents.add(view)});
-		^parents
-	}
-
-	doAction {
-		action.value(this);
-	}
-
-	properties {
-		^#[\bounds, \visible, \enabled, \canFocus, \resize, \background,
-				\minWidth,\maxWidth,\minHeight,\maxHeight,\focusColor]
-	}
-	getPropertyList {
-		^this.properties.collect({ arg name;
-			[name, this.perform(name)]
-		});
-	}
-	setPropertyList { arg list;
-		list.do({ arg item;
-			var name, value;
-			#name, value = item;
-			this.perform(name.asSetter, value);
-		});
-	}
-
-	// private
-	prInit { arg argParent, argBounds,argViewClass;
-		_SCView_New
-		^this.primitiveFailed
-	}
-	prClose { dataptr = nil; onClose.value(this); }
-	prRemove {
-		_SCView_Remove
-		^this.primitiveFailed
-	}
-	setProperty { arg key, value;
-		_SCView_SetProperty
-		^this.primitiveFailed
-	}
-	getProperty { arg key, value;
-		_SCView_GetProperty
-		^this.primitiveFailed
-	}
-	setPropertyWithAction { arg symbol, obj;
-		// setting some properties may need to have the action called.
-		if (this.setProperty(symbol, obj), {
-			// setProperty returns true if action needs to be called.
-			this.doAction;
-		});
-	}
-
-//	*importDrag {
-//		// this is called when an NSString is the drag object
-//		// from outside of the SC app
-//		// we compile it to an SCObject.
-//		currentDragString = currentDrag;
-//		currentDrag = currentDrag.interpret;
-//	}
-
-	absoluteBounds {
-		^this.getProperty(\absoluteBounds,Rect.new)
-	}
-}
-
-SCContainerView : SCView { // abstract class
-	var <children, <decorator, < relativeOrigin = true;
-
-	add { arg child;
-		children = children.add(child);
-		if (decorator.notNil, { decorator.place(child); });
-	}
-
-	init { |argParent, argBounds|
-		super.init(argParent, argBounds);
-			// if user changed default relativeOrigin to true,
-			// the client would be out of sync with the cocoa widget
-			// without resetting the view property
-		this.relativeOrigin = relativeOrigin;
-	}
-
-	removeAll {
-		children.copy.do {|child| child.remove };
-	}
-
-	relativeOrigin_{ |bool|
-		relativeOrigin = bool;
-		this.setProperty(\relativeOrigin, bool);
-	}
-
-	addFlowLayout { |margin, gap|
-		this.relativeOrigin.if
-			{this.decorator_( FlowLayout( this.bounds.moveTo(0,0), margin, gap ) )}
-			{this.decorator_( FlowLayout( this.bounds, margin, gap ) )};
-		^this.decorator;
-		}
-
-	decorator_ {|decor|
-		if(relativeOrigin, {
-			decor.bounds = decor.bounds.moveTo(0, 0);
-			decor.reset;
-		});
-		decorator = decor;
-	}
-
-	prRemoveChild { arg child;
-		children.remove(child);
-		// ... decorator should re-place all
-	}
-
-	//bounds_  ... replace all
-
-	prClose {
-		super.prClose;
-		children.do({ arg item; item.prClose });
-	}
-}
-
-SCCompositeView : SCContainerView {
-}
-
-SCTopView : SCCompositeView {
-	// created by SCWindow
-	handleKeyModifiersChangedBubbling { arg view, modifiers;
-		keyModifiersChangedAction.value(view, modifiers);
-	}
-	handleKeyDownBubbling { arg view, char, modifiers, unicode, keycode;
-		var currentAppModal, window;
-		keyDownAction.value(view, char, modifiers, unicode, keycode);
-	}
-	handleKeyUpBubbling { arg view, char, modifiers, unicode, keycode;
-		keyUpAction.value(view, char, modifiers, unicode, keycode);
-	}
-
-	//only in construction mode, handled internally
-	canReceiveDrag { ^currentDrag.isKindOf(Class)}
-//	remove { this.removeAll }
-
-	findWindow{
-		SCWindow.allWindows.do {|win|
-			if(win.view == this){
-				^win
-			}
-		}
-	}
-
-	/* construction mode */
-
-	constructionGrid_{ arg point;
-		this.setProperty( \constructionGrid, point );
-	}
-
-	constructionGrid {
-		^this.getProperty( \constructionGrid, Point.new );
-	}
-
-	enableConstructionGrid_{arg flag;
-		this.setProperty( \enableConstructionGrid, flag );
-	}
-
-	enableConstructionGrid{
-		^this.getProperty( \enableConstructionGrid );
-	}
-
-	//private called from lang
-	setConstructionMode {|flag|
-		this.setProperty( \setConstructionMode, flag )
-	}
-
-	defaultReceiveDrag{|x,y|
-		var win, view;
-		win = this.findWindow;
-		view = currentDrag.paletteExample(win, Rect(x,y,140,24)).enabled_(false);
-		view.keyDownAction_({|view, char, modifiers, unicode, keycode|
-			if(keycode == 51){
-				view.remove;
-			}
-		});
-	}
-}
-
-SCScrollTopView : SCTopView {
-	var <autohidesScrollers = true, <hasHorizontalScroller = true, <hasVerticalScroller = true;
-	var <autoScrolls = true;
-
-	autohidesScrollers_{|bool|
-		autohidesScrollers = bool;
-		this.setProperty(\setAutohidesScrollers, bool);
-	}
-
-	hasHorizontalScroller_{|bool|
-		hasHorizontalScroller = bool;
-		this.setProperty(\setHasHorizontalScroller, bool);
-	}
-
-	hasVerticalScroller_{|bool|
-		hasVerticalScroller = bool;
-		this.setProperty(\setHasVerticalScroller, bool);
-	}
-
-	visibleOrigin_ { arg point;
-		this.setProperty( \clipViewOrigin, point );
-	}
-
-	visibleOrigin { ^this.getProperty( \clipViewOrigin, Point.new );}
-
-	autoScrolls_ {|bool|
-		autoScrolls = bool;
-		this.setProperty(\setAutoScrolls, bool);
-	}
-
-	innerBounds {
-		^this.getProperty(\innerBounds, Rect.new)
-	}
-
-	bounds {
-		var	bounds = this.absoluteBounds;
-		this.getParents.do({ |parent|
-			(parent.tryPerform(\relativeOrigin) == true).if({
-				bounds = bounds.moveBy(parent.bounds.left.neg, parent.bounds.top.neg)
-			}, {
-				^bounds
-			});
-		});
-		^bounds
-	}
-
-//	handleKeyModifiersChangedBubbling { arg view, modifiers;
-//		var result;
-//		// nil from keyDownAction --> pass it on
-//		if (keyModifiersChangedAction.isNil) {
-//			result = nil;
-//		}{
-//			result = keyModifiersChangedAction.value(view, modifiers);
-//		};
-//		if(result.isNil) {
-//			// call keydown action of parent view
-//			parent.handleKeyModifiersChangedBubbling(view, modifiers);
-//		};
-//	}
-//
-//	handleKeyDownBubbling { arg view, char, modifiers, unicode, keycode;
-//		var result;
-//		// nil from keyDownAction --> pass it on
-//		if (keyDownAction.isNil) {
-//			result = this.defaultKeyDownAction(char,modifiers,unicode,keycode);
-//		}{
-//			result = keyDownAction.value(view, char, modifiers, unicode, keycode);
-//		};
-//		if(result.isNil) {
-//			// call keydown action of parent view
-//			parent.handleKeyDownBubbling(view, char, modifiers, unicode, keycode);
-//		};
-//	}
-//
-//	handleKeyUpBubbling { arg view, char, modifiers,unicode,keycode;
-//		var result;
-//		// nil from keyDownAction --> pass it on
-//		if (keyUpAction.isNil) {
-//			result = this.defaultKeyUpAction(char,modifiers,unicode,keycode);
-//		}{
-//			result = keyUpAction.value(view, char, modifiers, unicode, keycode);
-//		};
-//		if(result.isNil) {
-//			// call keydown action of parent view
-//			parent.handleKeyUpBubbling(view, char, modifiers, unicode, keycode);
-//		};
-//	}
-
-}
-
-SCScrollView : SCScrollTopView {
-	var <hasBorder = false;
-
-	hasBorder_ { arg bool = true;
-		this.setProperty(\border, bool);
-	}
-
-	init { |argParent, argBounds|
-		super.init(argParent, argBounds);
-
-		relativeOrigin = false; // scroll views are never relative, although they really are ;-)
-	}
-
-	relativeOrigin_ {  }
-
-	handleKeyModifiersChangedBubbling { arg view, modifiers;
-		var result;
-		// nil from keyDownAction --> pass it on
-		if (keyModifiersChangedAction.isNil) {
-			result = nil;
-		}{
-			result = keyModifiersChangedAction.value(view, modifiers);
-		};
-		if(result.isNil) {
-			// call keydown action of parent view
-			parent.handleKeyModifiersChangedBubbling(view, modifiers);
-		};
-	}
-
-	handleKeyDownBubbling { arg view, char, modifiers, unicode, keycode;
-		var result;
-		// nil from keyDownAction --> pass it on
-		if (keyDownAction.isNil) {
-			result = this.defaultKeyDownAction(char,modifiers,unicode,keycode);
-		}{
-			result = keyDownAction.value(view, char, modifiers, unicode, keycode);
-		};
-		if(result.isNil) {
-			// call keydown action of parent view
-			parent.handleKeyDownBubbling(view, char, modifiers, unicode, keycode);
-		};
-	}
-
-	handleKeyUpBubbling { arg view, char, modifiers,unicode,keycode;
-		var result;
-		// nil from keyDownAction --> pass it on
-		if (keyUpAction.isNil) {
-			result = this.defaultKeyUpAction(char,modifiers,unicode,keycode);
-		}{
-			result = keyUpAction.value(view, char, modifiers, unicode, keycode);
-		};
-		if(result.isNil) {
-			// call keydown action of parent view
-			parent.handleKeyUpBubbling(view, char, modifiers, unicode, keycode);
-		};
-	}
-
-}
-
-SCLayoutView : SCContainerView {
-	properties { ^super.properties ++ #[\spacing] }
-
-	spacing {
-		^this.getProperty(\spacing, 0)
-	}
-	spacing_ { arg distance;
-		this.setProperty(\spacing, distance)
-	}
-	setProperty { |key, value|
-			// layout views don't recognize relativeOrigin in the backend
-		if(key != \relativeOrigin) {
-			super.setProperty(key, value);
-		};
-	}
-}
-
-SCHLayoutView : SCLayoutView {}
-SCVLayoutView : SCLayoutView {}
-
-
-SCControlView : SCView { // abstract class
-}
-
-SCSliderBase : SCControlView {
-
-	knobColor {
-		^this.getProperty(\knobColor, Color.new)
-	}
-	knobColor_ { arg color;
-		this.setProperty(\knobColor, color)
-	}
-
-	step_ { arg stepSize;
-		this.setPropertyWithAction(\step, stepSize);
-	}
-	step {
-		^this.getProperty(\step)
-	}
-
-	properties {
-		^super.properties ++ #[\knobColor, \step]
-	}
-
-}
-
-SCSlider : SCSliderBase
-{
-	value {
-		^this.getProperty(\value)
-	}
-	value_ { arg val;
-		this.setProperty(\value, val);
-	}
-	valueAction_ { arg val;
-		this.setPropertyWithAction(\value, val);
-	}
-
-	increment { |zoom=1| ^this.valueAction = this.value + (max(this.step, this.pixelStep) * zoom) }
-	decrement { |zoom=1| ^this.valueAction = this.value - (max(this.step, this.pixelStep) * zoom) }
-
-	pixelStep {
-		var bounds = this.bounds;
-		^(bounds.width.max(bounds.height) - this.thumbSize).reciprocal
-	}
-
-	defaultKeyDownAction { arg char, modifiers, unicode,keycode;
-		// standard keydown
-		if (char == $r, { this.valueAction = 1.0.rand; ^this });
-		if (char == $n, { this.valueAction = 0.0; ^this });
-		if (char == $x, { this.valueAction = 1.0; ^this });
-		if (char == $c, { this.valueAction = 0.5; ^this });
-		if (char == $], { this.increment; ^this });
-		if (char == $[, { this.decrement; ^this });
-		if (unicode == 16rF700, { this.increment; ^this });
-		if (unicode == 16rF703, { this.increment; ^this });
-		if (unicode == 16rF701, { this.decrement; ^this });
-		if (unicode == 16rF702, { this.decrement; ^this });
-		^nil		// bubble if it's an invalid key
-	}
-
-	defaultGetDrag {
-		^this.value
-	}
-	defaultCanReceiveDrag {
-		^currentDrag.isNumber
-	}
-	defaultReceiveDrag {
-		this.valueAction = currentDrag;
-	}
-
-	thumbSize {
-		^this.getProperty(\thumbSize, 12);
-	}
-	thumbSize_ { arg size;
-		this.setProperty(\thumbSize, size);
-	}
-
-	properties {
-		^super.properties ++ #[\thumbSize];
-	}
-}
-
-SCRangeSlider : SCSliderBase {
-
-	*paletteExample { arg parent, bounds;
-		var v;
-		v = this.new(parent, bounds);
-		v.lo = 0.2;
-		v.hi = 0.7;
-		^v
-	}
-
-	lo {
-		^this.getProperty(\lo)
-	}
-	lo_ { arg val;
-		this.setProperty(\lo, val);
-	}
-	activeLo_ { arg val;
-		this.setPropertyWithAction(\lo, val);
-	}
-	hi {
-		^this.getProperty(\hi)
-	}
-	hi_ { arg val;
-		this.setProperty(\hi, val);
-	}
-	activeHi_ { arg val;
-		this.setPropertyWithAction(\hi, val);
-	}
-	range {
-		^this.getProperty(\range)
-	}
-	range_ { arg val;
-		this.setProperty(\range, val);
-	}
-	activeRange_ { arg val;
-		this.setPropertyWithAction(\range, val);
-	}
-
-	setSpan { arg lo, hi;
-		this.lo = lo;
-		this.hi = hi;
-	}
-
-	setSpanActive { arg lo, hi;
-		this.setSpan( lo, hi );
-		this.doAction;
-	}
-
-	setDeviation { arg deviation, average;
-			var lo = ( 1 - deviation ) * average;
-			this.setSpan(lo, lo + deviation);
-	}
-
-	properties {
-		^super.properties ++ #[\lo, \hi]
-	}
-
-	pixelStep {
-		var bounds = this.bounds;
-		^(bounds.width.max(bounds.height)).reciprocal
-	}
-
-	increment { |zoom=1|
-		var inc = (max(this.step, this.pixelStep) * zoom);
-		var newHi = (this.hi + inc);
-		if (newHi > 1) {
-			inc = 1 - this.hi;
-			newHi = 1;
-		};
-		this.lo_(this.lo + inc).activeHi_(newHi);
-	}
-
-	decrement { |zoom=1|
-		var inc = (max(this.step, this.pixelStep) * zoom);
-		var newLo = (this.lo - inc);
-		if (newLo < 0) {
-			inc =  this.lo;
-			newLo = 0;
-		};
-		this.lo_(newLo).activeHi_(this.hi - inc);
-	}
-
-	defaultKeyDownAction { arg char, modifiers, unicode;
-		var a, b;
-		// standard keydown
-		if (char == $r, {
-			a = 1.0.rand;
-			b = 1.0.rand;
-			this.activeLo_(min(a, b));
-			this.activeHi_(max(a, b));
-			^this
-		});
-		if (char == $n, { this.activeLo_(0.0); this.activeHi_(0.0); ^this });
-		if (char == $x, { this.activeLo_(1.0); this.activeHi_(1.0); ^this });
-		if (char == $c, { this.activeLo_(0.5); this.activeHi_(0.5); ^this });
-		if (char == $a, { this.activeLo_(0.0); this.activeHi_(1.0); ^this });
-		if (unicode == 16rF700, { this.increment; ^this });
-		if (unicode == 16rF703, { this.increment; ^this });
-		if (unicode == 16rF701, { this.decrement; ^this });
-		if (unicode == 16rF702, { this.decrement; ^this });
-		^nil		// bubble if it's an invalid key
-	}
-	defaultGetDrag { ^Point(this.lo, this.hi) }
-	defaultCanReceiveDrag {
-		^currentDrag.isKindOf(Point);
-	}
-	defaultReceiveDrag {
-		// changed to x,y instead of lo, hi
-		this.lo = currentDrag.x;
-		this.hi = currentDrag.y;
-		this.doAction
-	}
-}
-
-SCButton : SCControlView {
-	var <font, <states;
-
-	*paletteExample { arg parent, bounds;
-		var v;
-		v = this.new(parent, bounds);
-		v.states = [
-			["Push", Color.black, Color.red],
-			["Pop", Color.white, Color.blue]];
-		^v
-	}
-
-	value {
-		^this.getProperty(\value)
-	}
-	value_ { arg val;
-		this.setProperty(\value, val);
-	}
-	valueAction_ { arg val;
-		this.setPropertyWithAction(\value, val);
-	}
-
-	doAction { arg modifiers;
-		action.value(this, modifiers);
-	}
-
-	defaultKeyDownAction { arg char, modifiers, unicode;
-		if (char == $ , { this.valueAction = this.value + 1; ^this });
-		if (char == $\r, { this.valueAction = this.value + 1; ^this });
-		if (char == $\n, { this.valueAction = this.value + 1; ^this });
-		if (char == 3.asAscii, { this.valueAction = this.value + 1; ^this });
-		^nil		// bubble if it's an invalid key
-	}
-
-	font_ { arg argFont;
-		font = argFont;
-		this.setProperty(\font, font)
-	}
-
-	states_ { arg array;
-		states = array;
-		this.setProperty(\states, states);
-	}
-
-	properties {
-		^super.properties ++ #[\value, \font, \states]
-	}
-
-	defaultGetDrag {
-		^this.value
-	}
-	defaultCanReceiveDrag {
-		^currentDrag.isNumber or: { currentDrag.isKindOf(Function) };
-	}
-	defaultReceiveDrag {
-		if (currentDrag.isNumber) {
-			this.valueAction = currentDrag;
-		}{
-			this.action = currentDrag;
-		};
-	}
-}
-
-SCStaticTextBase : SCView {
-	var <string, <font, <object, <>setBoth=true;
-
-	font_ { arg argFont;
-		font = argFont;
-		this.setProperty(\font, font)
-	}
-
-	string_ { arg argString;
-		string = argString.asString;
-		this.setProperty(\string, string)
-	}
-	align_ { arg align;
-		this.setProperty(\align, align)
-	}
-
-	stringColor {
-		^this.getProperty(\stringColor, Color.new)
-	}
-	stringColor_ { arg color;
-		this.setProperty(\stringColor, color)
-	}
-
-	object_ { arg obj;
-		object = obj;
-		if (setBoth) { this.string = object.asString(80); };
-	}
-
-	properties {
-		^super.properties ++ #[\string, \font, \stringColor]
-	}
-}
-
-SCStaticText : SCStaticTextBase {
-	*paletteExample { arg parent, bounds;
-		var v;
-		v = this.new(parent, bounds);
-		v.string = "The lazy brown fox";
-		^v
-	}
-}
-
-
-SCNumberBox : SCStaticTextBase {
-	var <> keyString, <>step=1;
-	var <>typingColor, <>normalColor;
-	var <>clipLo = -inf, <>clipHi = inf, hit, inc=1.0, <>scroll=true, <>shift_step=0.1, <>ctrl_step=10;
-
-	*paletteExample { arg parent, bounds;
-		var v;
-		v = this.new(parent, bounds);
-		v.value = 123.456;
-		^v
-	}
-
-	init { arg argParent, argBounds;
-		typingColor = Color.red;
-		normalColor = Color.black;
-		background = Color.white;
-		parent = argParent.asView; // actual view
-		this.prInit(parent.asView, argBounds.asRect,this.class.viewClass);
-		argParent.add(this);//maybe window or viewadapter
-	}
-
-	increment { this.valueAction = this.value + step; }
-	decrement { this.valueAction = this.value - step; }
-
-	defaultKeyDownAction { arg char, modifiers, unicode;
-		// standard chardown
-		if (unicode == 16rF700, { this.increment; ^this });
-		if (unicode == 16rF703, { this.increment; ^this });
-		if (unicode == 16rF701, { this.decrement; ^this });
-		if (unicode == 16rF702, { this.decrement; ^this });
-		if ((char == 3.asAscii) || (char == $\r) || (char == $\n), { // enter key
-			if (keyString.notNil,{ // no error on repeated enter
-				this.valueAction_(keyString.asFloat);
-			});
-			^this
-		});
-		if (char == 127.asAscii, { // delete key
-			keyString = nil;
-			this.string = object.asString;
-			this.stringColor = normalColor;
-			^this
-		});
-		if (char.isDecDigit || "+-.eE".includes(char), {
-			if (keyString.isNil, {
-				keyString = String.new;
-				this.stringColor = typingColor;
-			});
-			keyString = keyString.add(char);
-			this.string = keyString;
-			^this
-		});
-		^nil		// bubble if it's an invalid key
-	}
-
-	value { ^object }
-	value_ { arg val;
-		keyString = nil;
-		this.stringColor = normalColor;
-		object = val !? { val.clip(clipLo, clipHi) };
-		this.string = object.asString;
-	}
-	valueAction_ { arg val;
-		var prev;
-		prev = object;
-		this.value = val !? { val.clip(clipLo, clipHi) };
-		if (object != prev, { this.doAction });
-	}
-
-	boxColor {
-		this.deprecated(thisMethod, SCView.findMethod(\background));
-		^this.background;
-	}
-	boxColor_ { arg color;
-		this.deprecated(thisMethod, SCView.findMethod(\background_));
-		this.background_(color)
-	}
-
-	properties {
-		^super.properties ++ #[\boxColor]
-	}
-	defaultGetDrag {
-		^object.asFloat
-	}
-	defaultCanReceiveDrag {
-		^currentDrag.isNumber;
-	}
-	defaultReceiveDrag {
-		this.valueAction = currentDrag;
-	}
-
-	mouseDown { arg x, y, modifiers, buttonNumber, clickCount;
-		hit = Point(x,y);
-		if (scroll == true, {
-			inc = 1.0;
-			case
-				{ modifiers & 131072 == 131072 } // shift defaults to step x 0.1
-					{ inc = shift_step }
-				{ modifiers & 262144 == 262144 } // control defaults to step x 10
-					{ inc = ctrl_step };
-		});
-		mouseDownAction.value(this, x, y, modifiers, buttonNumber, clickCount)
-	}
-
-	mouseMove { arg x, y, modifiers;
-		var direction;
-		if (scroll == true, {
-			direction = 1.0;
-				// horizontal or vertical scrolling:
-			if ( (x - hit.x) < 0 or: { (y - hit.y) > 0 }) { direction = -1.0; };
-
-			this.valueAction = (this.value + (inc * this.step * direction));
-			hit = Point(x, y);
-		});
-		mouseMoveAction.value(this, x, y, modifiers);
-	}
-}
diff --git a/common/build/SCClassLibrary/DefaultLibrary/Main.sc b/common/build/SCClassLibrary/DefaultLibrary/Main.sc
index aa0854d..da35282 100644
--- a/common/build/SCClassLibrary/DefaultLibrary/Main.sc
+++ b/common/build/SCClassLibrary/DefaultLibrary/Main.sc
@@ -1,7 +1,7 @@
 Main : Process {
 	// do not change the next lines manually:
 	//==== replace with new version from bash script ====
-classvar scVersionMajor=3, scVersionMinor=4, scVersionPostfix="";
+classvar scVersionMajor=3, scVersionMinor=4, scVersionPostfix=".2";
 	//==== end replace ====
 
 	var <platform, argv;
diff --git a/common/build/SCClassLibrary/JITLib/ProxySpace/NodeProxy.sc b/common/build/SCClassLibrary/JITLib/ProxySpace/NodeProxy.sc
index d9fba00..0861b33 100644
--- a/common/build/SCClassLibrary/JITLib/ProxySpace/NodeProxy.sc
+++ b/common/build/SCClassLibrary/JITLib/ProxySpace/NodeProxy.sc
@@ -146,6 +146,7 @@ NodeProxy : BusPlug {
 					container.wakeUpParentsToBundle(bundle);
 					this.sendObjectToBundle(bundle, container, extraArgs, index);
 				};
+				nodeMap.wakeUpParentsToBundle(bundle);
 				bundle.schedSend(server, clock ? TempoClock.default, quant);
 			} {
 				loaded = false;
@@ -405,11 +406,11 @@ NodeProxy : BusPlug {
 		var ctl, rate, numChannels, canBeMapped;
 		if(proxy.isNil) { ^this.unmap(key) };
 		ctl = this.controlNames.detect { |x| x.name == key };
-		rate = ctl.rate ?? { 
-				if(proxy.isNeutral) { 
+		rate = ctl.rate ?? {
+				if(proxy.isNeutral) {
 					if(this.isNeutral) { \audio } { this.rate } 
-				} { 
-					proxy.rate 
+				} {
+					proxy.rate
 				}
 		};
 		numChannels = ctl !? { ctl.defaultValue.asArray.size };		canBeMapped = proxy.initBus(rate, numChannels);
@@ -419,7 +420,7 @@ NodeProxy : BusPlug {
 		} {
 			"Could not link node proxies, no matching input found.".warn 
 		};
-		^proxy; // returns first argument for further chaining
+		^proxy // returns first argument for further chaining
 	}
 
 
@@ -802,7 +803,7 @@ NodeProxy : BusPlug {
 			if(loaded.not) { this.loadToBundle(bundle) };
 			if(awake and: { this.isPlaying.not }) {
 				this.prepareToBundle(nil, bundle, \addToHead);
-				this.sendAllToBundle(bundle)
+				this.sendAllToBundle(bundle);
 			};
 		};
 
@@ -810,7 +811,7 @@ NodeProxy : BusPlug {
 
 	wakeUpParentsToBundle { | bundle, checkedAlready |
 			nodeMap.wakeUpParentsToBundle(bundle, checkedAlready);
-			objects.do{ arg item; item.wakeUpParentsToBundle(bundle, checkedAlready) };
+			objects.do { arg item; item.wakeUpParentsToBundle(bundle, checkedAlready) };
 	}
 
 
diff --git a/common/build/SCClassLibrary/Platform/iphone/extMain.sc b/common/build/SCClassLibrary/Platform/iphone/extMain.sc
deleted file mode 100644
index 9901b5f..0000000
--- a/common/build/SCClassLibrary/Platform/iphone/extMain.sc
+++ /dev/null
@@ -1,4 +0,0 @@
-+ Main
-{
-	platformClass { ^IPhonePlatform }
-}
diff --git a/common/build/SCClassLibrary/Platform/iphone/extString.sc b/common/build/SCClassLibrary/Platform/iphone/extString.sc
deleted file mode 100644
index 92b540f..0000000
--- a/common/build/SCClassLibrary/Platform/iphone/extString.sc
+++ /dev/null
@@ -1,26 +0,0 @@
-+ String
-{
-	loadPath { arg warnIfNotFound=true;
-		var obj,path;
-		path = this.standardizePath;
-		if(File.exists(path),{
-			{
-				obj = thisProcess.interpreter.executeFile(path);
-				//obj.didLoadFromPath(this);
-			}.try({ arg err;
-				("In file: " + this).postln;
-				err.throw;
-			});
-		},{
-			if(warnIfNotFound,{
-				warn("String:loadPath file not found " + this + path);
-			});
-		});
-		if(obj.isNil and: warnIfNotFound, {
-			warn("String:loadPath found nil, empty contents or parse error in " + path);
-
-			//^ObjectNotFound.new(path)
-		});
-		^obj
-	}
-}
\ No newline at end of file
diff --git a/editors/scvim/bin/scvim b/editors/scvim/bin/scvim
index a254782..27d8c29 100755
--- a/editors/scvim/bin/scvim
+++ b/editors/scvim/bin/scvim
@@ -31,6 +31,25 @@ graphical = false
 #the location of the rc file to source
 rcloc = nil
 
+# debian-based systems do not activate vim plugins automatically, we must check
+if %x[which vim-addons]!="" && %x[vim-addons -q status supercollider | grep installed]==""
+  puts "scvim has detected that you haven't activated the vim supercollider plugin."
+  puts "to enable scvim to work, please execute either "
+  puts "    vim-addons install supercollider"
+  puts "to enable it for the current user, or "
+  puts "    sudo vim-addons -w install supercollider"
+  puts "to enable it system-wide."
+  puts ""
+  puts "Would you like me to run \"vim-addons install supercollider\" for you?"
+  puts "Press 'y' and then Enter if so.  Otherwise just press Enter to exit."
+  userreply = gets.chomp
+  if userreply == 'y'
+    %x[vim-addons install supercollider]
+  else
+    exit
+  end
+end
+
 opts = OptionParser.new do |opts|
   #the usage banner
   opts.banner = "Usage: #{$0} [OPTION]... [FILE]..."
diff --git a/editors/scvim/scclasses/SCVim.sc b/editors/scvim/scclasses/SCVim.sc
index 7271295..94109af 100644
--- a/editors/scvim/scclasses/SCVim.sc
+++ b/editors/scvim/scclasses/SCVim.sc
@@ -27,19 +27,19 @@ classvar <scvim_dir, <scvim_cache_dir,
 	if(scvim_cache_dir_env.isNil){
 		scvim_cache_dir = "~/.scvim".standardizePath;
 		setenv("SCVIM_CACHE_DIR", scvim_cache_dir);
-		//inform("SCVim: I've set the cache dir based on the scvim dir");
 	}{
 		scvim_cache_dir = scvim_cache_dir_env;
-		//inform("SCVim: I've set the cache dir based on the environment variable");
 	};
 	StartUp.add{
-		if(autoFirstRun and:{ File.exists(scvim_cache_dir).not }){
-			Task{
-				"SCVim: generating help docs, it will take a few moments. (This only happens the first time you launch scvim. See SCVim help file for more info.)".inform;
-				this.updateCaches;
-				this.updateHelpCache;
-				"SCVim: finished generating help docs".inform;
-			}.play;
+		if(Platform.ideName=="scvim"){
+			if(autoFirstRun and:{ File.exists(scvim_cache_dir).not }){
+				Task{
+					"SCVim: generating help docs, it will take a few moments. (This only happens the first time you launch scvim. See SCVim help file for more info.)".inform;
+					this.updateCaches;
+					this.updateHelpCache;
+					"SCVim: finished generating help docs".inform;
+				}.play;
+			};
 		};
 	};
 }

-- 
supercollider packaging



More information about the pkg-multimedia-commits mailing list