From 9a64dfd0fb6956f8c58dc8238011fb793e62c179 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Mon, 31 Dec 2012 17:17:46 +0100 Subject: [PATCH 01/10] include: split public and private headers & prototype libsclang interface Signed-off-by: Tim Blechmann --- common/SC_Errors.cpp | 62 ++++ {include/server => common}/SC_Errors.h | 0 include/lang/FIFOT.h | 77 ----- include/lang/PriorityQueue.h | 90 ------ include/lang/PyrSymbol.h | 304 ------------------ include/lang/SC_LanguageClient.h | 80 +---- include/lang/SC_TerminalClient.h | 4 +- include/server/SC_Complex.h | 142 -------- include/server/SC_Samp.h | 36 --- lang/CMakeLists.txt | 4 +- lang/LangPrimSource/OSCData.cpp | 5 +- .../lang => lang/LangPrimSource}/OSCData.h | 1 - .../LangPrimSource}/PyrArchiverT.h | 0 .../LangPrimSource}/PyrDeepCopier.h | 0 .../LangPrimSource}/PyrDeepFreezer.h | 0 .../LangPrimSource}/PyrFilePrim.h | 0 .../LangPrimSource}/PyrListPrim.h | 0 .../LangPrimSource}/PyrMathPrim.h | 0 lang/LangPrimSource/PyrSerialPrim.cpp | 2 +- .../LangPrimSource}/PyrSignalPrim.h | 0 lang/LangPrimSource/PyrSymbolPrim.cpp | 251 +++++++++++++++ .../LangPrimSource}/ReadWriteMacros.h | 0 .../lang => lang/LangPrimSource}/SC_ComPort.h | 0 .../lang => lang/LangPrimSource}/SC_Msg.h | 0 .../LangSource}/AdvancingAllocPool.h | 0 .../lang => lang/LangSource}/AllocPools.h | 0 .../lang => lang/LangSource}/ByteCodeArray.h | 0 {include/lang => lang/LangSource}/GC.h | 0 {include/lang => lang/LangSource}/HashTable.h | 0 {include/lang => lang/LangSource}/InitAlloc.h | 0 .../lang => lang/LangSource}/MiscInlineMath.h | 0 {include/lang => lang/LangSource}/Opcodes.h | 0 .../LangSource}/PowerOfTwoAllocPool.h | 0 .../LangSource}/PredefinedSymbols.h | 0 {include/lang => lang/LangSource}/PyrErrors.h | 0 .../lang => lang/LangSource}/PyrInterpreter.h | 0 {include/lang => lang/LangSource}/PyrKernel.h | 0 .../lang => lang/LangSource}/PyrKernelProto.h | 0 {include/lang => lang/LangSource}/PyrLexer.h | 0 .../lang => lang/LangSource}/PyrMessage.h | 0 {include/lang => lang/LangSource}/PyrObject.h | 0 .../lang => lang/LangSource}/PyrObjectProto.h | 0 .../lang => lang/LangSource}/PyrParseNode.h | 0 .../lang => lang/LangSource}/PyrPrimitive.h | 0 .../LangSource}/PyrPrimitiveProto.h | 0 {include/lang => lang/LangSource}/PyrSched.h | 50 +++ {include/lang => lang/LangSource}/PyrSignal.h | 0 {include/lang => lang/LangSource}/PyrSlot.h | 0 {include/lang => lang/LangSource}/PyrSlot32.h | 0 {include/lang => lang/LangSource}/PyrSlot64.h | 0 .../Samp.h => lang/LangSource/PyrSymbol.h | 42 ++- .../lang => lang/LangSource}/PyrSymbolTable.h | 0 {include/lang => lang/LangSource}/SCBase.h | 0 lang/LangSource/SC_LanguageClient.cpp | 22 +- lang/LangSource/Samp.cpp | 101 ------ .../lang => lang/LangSource}/SimpleStack.h | 0 {include/lang => lang/LangSource}/VMGlobals.h | 0 platform/mac/CMakeLists.txt | 2 +- server/scsynth/CMakeLists.txt | 8 +- .../server => server/scsynth}/HashTable.h | 0 .../server => server/scsynth}/OSC_Packet.h | 0 .../server => server/scsynth}/PriorityQueue.h | 0 .../scsynth}/ReadWriteMacros.h | 0 .../server => server/scsynth}/Rendezvous.h | 0 {include/server => server/scsynth}/SC_AU.h | 0 server/scsynth/SC_Complex.cpp | 148 --------- .../server => server/scsynth}/SC_CoreAudio.h | 0 server/scsynth/SC_Errors.cpp | 62 ---- .../server => server/scsynth}/SC_GraphDef.h | 0 {include/server => server/scsynth}/SC_Group.h | 0 .../scsynth}/SC_HiddenWorld.h | 0 {include/server => server/scsynth}/SC_Lib.h | 0 .../server => server/scsynth}/SC_Lib_Cintf.h | 0 .../server => server/scsynth}/SC_Prototypes.h | 0 .../scsynth}/SC_SequencedCommand.h | 0 {include/server => server/scsynth}/SC_Str4.h | 0 .../server => server/scsynth}/SC_SynthDef.h | 0 .../server => server/scsynth}/SC_UnitDef.h | 0 .../server => server/scsynth}/SC_UnitSpec.h | 0 .../server => server/scsynth}/SC_WireSpec.h | 0 server/scsynth/SC_World.cpp | 2 +- server/scsynth/Samp.cpp | 88 ----- server/supernova/CMakeLists.txt | 5 +- server/supernova/sc/sc_plugin_interface.cpp | 3 +- server/supernova/sc/sc_plugin_interface.hpp | 2 - server/supernova/server/nrt_synthesis.hpp | 2 + 86 files changed, 445 insertions(+), 1150 deletions(-) create mode 100644 common/SC_Errors.cpp rename {include/server => common}/SC_Errors.h (100%) delete mode 100644 include/lang/FIFOT.h delete mode 100644 include/lang/PriorityQueue.h delete mode 100644 include/lang/PyrSymbol.h delete mode 100644 include/server/SC_Complex.h delete mode 100644 include/server/SC_Samp.h rename {include/lang => lang/LangPrimSource}/OSCData.h (98%) rename {include/lang => lang/LangPrimSource}/PyrArchiverT.h (100%) rename {include/lang => lang/LangPrimSource}/PyrDeepCopier.h (100%) rename {include/lang => lang/LangPrimSource}/PyrDeepFreezer.h (100%) rename {include/lang => lang/LangPrimSource}/PyrFilePrim.h (100%) rename {include/lang => lang/LangPrimSource}/PyrListPrim.h (100%) rename {include/lang => lang/LangPrimSource}/PyrMathPrim.h (100%) rename {include/lang => lang/LangPrimSource}/PyrSignalPrim.h (100%) rename {include/lang => lang/LangPrimSource}/ReadWriteMacros.h (100%) rename {include/lang => lang/LangPrimSource}/SC_ComPort.h (100%) rename {include/lang => lang/LangPrimSource}/SC_Msg.h (100%) rename {include/lang => lang/LangSource}/AdvancingAllocPool.h (100%) rename {include/lang => lang/LangSource}/AllocPools.h (100%) rename {include/lang => lang/LangSource}/ByteCodeArray.h (100%) rename {include/lang => lang/LangSource}/GC.h (100%) rename {include/lang => lang/LangSource}/HashTable.h (100%) rename {include/lang => lang/LangSource}/InitAlloc.h (100%) rename {include/lang => lang/LangSource}/MiscInlineMath.h (100%) rename {include/lang => lang/LangSource}/Opcodes.h (100%) rename {include/lang => lang/LangSource}/PowerOfTwoAllocPool.h (100%) rename {include/lang => lang/LangSource}/PredefinedSymbols.h (100%) rename {include/lang => lang/LangSource}/PyrErrors.h (100%) rename {include/lang => lang/LangSource}/PyrInterpreter.h (100%) rename {include/lang => lang/LangSource}/PyrKernel.h (100%) rename {include/lang => lang/LangSource}/PyrKernelProto.h (100%) rename {include/lang => lang/LangSource}/PyrLexer.h (100%) rename {include/lang => lang/LangSource}/PyrMessage.h (100%) rename {include/lang => lang/LangSource}/PyrObject.h (100%) rename {include/lang => lang/LangSource}/PyrObjectProto.h (100%) rename {include/lang => lang/LangSource}/PyrParseNode.h (100%) rename {include/lang => lang/LangSource}/PyrPrimitive.h (100%) rename {include/lang => lang/LangSource}/PyrPrimitiveProto.h (100%) rename {include/lang => lang/LangSource}/PyrSched.h (64%) rename {include/lang => lang/LangSource}/PyrSignal.h (100%) rename {include/lang => lang/LangSource}/PyrSlot.h (100%) rename {include/lang => lang/LangSource}/PyrSlot32.h (100%) rename {include/lang => lang/LangSource}/PyrSlot64.h (100%) rename include/lang/Samp.h => lang/LangSource/PyrSymbol.h (59%) rename {include/lang => lang/LangSource}/PyrSymbolTable.h (100%) rename {include/lang => lang/LangSource}/SCBase.h (100%) delete mode 100644 lang/LangSource/Samp.cpp rename {include/lang => lang/LangSource}/SimpleStack.h (100%) rename {include/lang => lang/LangSource}/VMGlobals.h (100%) rename {include/server => server/scsynth}/HashTable.h (100%) rename {include/server => server/scsynth}/OSC_Packet.h (100%) rename {include/server => server/scsynth}/PriorityQueue.h (100%) rename {include/server => server/scsynth}/ReadWriteMacros.h (100%) rename {include/server => server/scsynth}/Rendezvous.h (100%) rename {include/server => server/scsynth}/SC_AU.h (100%) delete mode 100644 server/scsynth/SC_Complex.cpp rename {include/server => server/scsynth}/SC_CoreAudio.h (100%) delete mode 100644 server/scsynth/SC_Errors.cpp rename {include/server => server/scsynth}/SC_GraphDef.h (100%) rename {include/server => server/scsynth}/SC_Group.h (100%) rename {include/server => server/scsynth}/SC_HiddenWorld.h (100%) rename {include/server => server/scsynth}/SC_Lib.h (100%) rename {include/server => server/scsynth}/SC_Lib_Cintf.h (100%) rename {include/server => server/scsynth}/SC_Prototypes.h (100%) rename {include/server => server/scsynth}/SC_SequencedCommand.h (100%) rename {include/server => server/scsynth}/SC_Str4.h (100%) rename {include/server => server/scsynth}/SC_SynthDef.h (100%) rename {include/server => server/scsynth}/SC_UnitDef.h (100%) rename {include/server => server/scsynth}/SC_UnitSpec.h (100%) rename {include/server => server/scsynth}/SC_WireSpec.h (100%) delete mode 100644 server/scsynth/Samp.cpp diff --git a/common/SC_Errors.cpp b/common/SC_Errors.cpp new file mode 100644 index 00000000000..fe6c6ebfcd2 --- /dev/null +++ b/common/SC_Errors.cpp @@ -0,0 +1,62 @@ +/* + SuperCollider real time audio synthesis system + Copyright (c) 2002 James McCartney. All rights reserved. + http://www.audiosynth.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#include "SC_Errors.h" + +#include "stdio.h" + +int gMissingNodeID; + +void SC_ErrorString(SCErr err, char returnString[]) +{ + switch (err) { + case kSCErr_None : sprintf(returnString, "none"); break; + case kSCErr_Failed : sprintf(returnString, "failed"); break; + case kSCErr_NodeNotFound : sprintf(returnString, "Node %i not found", gMissingNodeID); break; + case kSCErr_TargetNodeNotFound : sprintf(returnString, "target Node %i not found", gMissingNodeID); break; + case kSCErr_GroupNotFound : sprintf(returnString, "Group %i not found", gMissingNodeID); break; + case kSCErr_SynthDefNotFound : sprintf(returnString, "SynthDef not found"); break; + case kSCErr_NoSuchCommand : sprintf(returnString, "no such command"); break; + case kSCErr_WrongArgType : sprintf(returnString, "wrong argument type"); break; + case kSCErr_IndexOutOfRange : sprintf(returnString, "index out of range"); break; + case kSCErr_AccessDenied : sprintf(returnString, "access denied"); break; + case kSCErr_NoReplyPort : sprintf(returnString, "no reply port"); break; + case kSCErr_InvalidControlIndex : sprintf(returnString, "invalid control index"); break; + + case kSCErr_AlreadyLoggedIn : sprintf(returnString, "already logged in"); break; + case kSCErr_NotLoggedIn : sprintf(returnString, "not logged in"); break; + case kSCErr_TooManyUsers : sprintf(returnString, "too many users"); break; + case kSCErr_TooManyNodes : sprintf(returnString, "too many nodes"); break; + case kSCErr_DuplicateNodeID : sprintf(returnString, "duplicate node ID"); break; + case kSCErr_ReservedNodeID : sprintf(returnString, "negative node IDs are reserved"); break; + case kSCErr_OutOfRealTimeMemory : sprintf(returnString, "out of real time memory"); break; + + case kSCErr_UnsupportedHeaderFormat : sprintf(returnString, "unsupported header format"); break; + case kSCErr_UnsupportedSampleFormat : sprintf(returnString, "unsupported sample format"); break; + + case kSCErr_BufGenNotFound : sprintf(returnString, "buf gen routine not found"); break; + + default : sprintf(returnString, "unknown error"); + + } +} + + diff --git a/include/server/SC_Errors.h b/common/SC_Errors.h similarity index 100% rename from include/server/SC_Errors.h rename to common/SC_Errors.h diff --git a/include/lang/FIFOT.h b/include/lang/FIFOT.h deleted file mode 100644 index ef31915d37b..00000000000 --- a/include/lang/FIFOT.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ -/* - -A Fifo for sending/receiving some type of object. - -*/ - -#ifndef _FIFOT_ -#define _FIFOT_ - -#include "SCBase.h" - -template class FIFOT -{ -public: - FIFOT() - : mMask(N-1), mReadHead(0), mWriteHead(0) - { - } - void MakeEmpty() { mReadHead = mWriteHead; } - bool IsEmpty() { return mReadHead == mWriteHead; } - int CanGet() { - int diff = mWriteHead - mReadHead; - return diff >= 0 ? diff : N - diff; - } - int CanPut() { return N-1-CanGet(); } - - int NextPos(int inPos) { return (inPos + 1) & mMask; } - - bool Put(const T& inItem) - { - long next = NextPos(mWriteHead); - if (next == mReadHead) return false; // fifo is full - mItems[next] = inItem; - mWriteHead = next; - return true; - } - - bool Get(T& outItem) // get next and advance - { - if (IsEmpty()) return false; - long next = NextPos(mReadHead); - outItem = mItems[next]; - mReadHead = next; - return true; - } - void DebugDump() - { - post("FIFO N %d mMask %d mReadHead %d mWriteHead%d\n", - N, mMask, mReadHead, mWriteHead); - } - -private: - long mMask; - volatile long mReadHead, mWriteHead;// mReclaimHead; - T mItems[N]; -}; - -#endif diff --git a/include/lang/PriorityQueue.h b/include/lang/PriorityQueue.h deleted file mode 100644 index c20a5fe476c..00000000000 --- a/include/lang/PriorityQueue.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _PriorityQueue_ -#define _PriorityQueue_ - -#include - -template -class PriorityQueueT -{ -public: - PriorityQueueT() { - Empty(); - } - - bool Add(Event& inEvent) - { - if (mSize >= N) return false; - long mom = mSize++; - long me = mom; - for (; mom>0;) { /* percolate up heap */ - mom = mom - 1 >> 1; - if (inEvent.mTime < mEvents[mom].mTime) { - mEvents[me] = mEvents[mom]; - me = mom; - } else break; - } - mEvents[me] = inEvent; - return true; - } - void Perform(TimeType inNow) - { - while (NextTime() <= inNow) { - Event event = Remove(); - event.Perform(); - } - } - TimeType NextTime() { return mEvents[0].mTime; } - bool Ready(TimeType inTime) { return NextTime() <= inTime; } - void Flush() { Perform(std::numeric_limits::max()); } - void Empty() { mSize = 0; SetEmptyTime(); } - void SetEmptyTime() { mEvents[0].mTime = std::numeric_limits::max(); } - - Event Remove() - { - Event event = mEvents[0]; - if (--mSize == 0) SetEmptyTime(); - else { - Event temp = mEvents[mSize]; - long mom = 0; - long me = 1; - for (;me < mSize;) { /* demote heap */ - if (me+1 < mSize && mEvents[me].mTime > mEvents[me+1].mTime) { - me ++; - } - if (temp.mTime > mEvents[me].mTime) { - mEvents[mom] = mEvents[me]; - mom = me; - me = (me << 1) + 1; - } else break; - } - mEvents[mom] = temp; - } - return event; - } - -private: - long mSize; - Event mEvents[N]; -}; - -#endif \ No newline at end of file diff --git a/include/lang/PyrSymbol.h b/include/lang/PyrSymbol.h deleted file mode 100644 index 5be6af8d565..00000000000 --- a/include/lang/PyrSymbol.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ -/* - -A PyrSymbol is a unique string that resides in a global hash table. - -*/ - -#ifndef _PYRSYMBOL_H_ -#define _PYRSYMBOL_H_ - -#include "SC_Types.h" - -struct PyrSymbol { - char *name; - long hash; - short specialIndex; - uint8 flags; - uint8 length; - union { - long index; // index in row table or primitive table - struct PyrClass *classobj; // pointer to class with this name. - char *source; // source code for sym_Filename; used only during compilation. - } u; - struct classdep *classdep; -}; - -enum { - sym_Selector = 1, - sym_Class = 2, - sym_Compiled = 4, - sym_Called = 8, - sym_Primitive = 16, - sym_Setter = 32, - sym_MetaClass = 64, - sym_Filename = 128 -}; - -// following function lifted from liblo: http://sourceforge.net/projects/liblo/ - -/* Open SoundControl kit in C++ */ -/* Copyright (C) 2002-2004 libOSC++ contributors. See AUTHORS */ -/* */ -/* This library is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU Lesser General Public */ -/* License as published by the Free Software Foundation; either */ -/* version 2.1 of the License, or (at your option) any later version. */ -/* */ -/* This library is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ -/* Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public */ -/* License along with this library; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* */ -/* For questions regarding this program contact */ -/* Daniel Holth or visit */ -/* http://wiretap.stetson.edu/ */ - -/* In the sprit of the public domain, my modifications to this file are also */ -/* dedicated to the public domain. Daniel Holth, Oct. 2004 */ - -/* ChangeLog: - * - * 2004-10-29 Import, convert to C++, begin OSC syntax changes. -dwh - * OSC syntax changes are now working, needs more testing. - * - */ - -// Original header and syntax: - -/* - * robust glob pattern matcher - * ozan s. yigit/dec 1994 - * public domain - * - * glob patterns: - * * matches zero or more characters - * ? matches any single character - * [set] matches any character in the set - * [^set] matches any character NOT in the set - * where a set is a group of characters or ranges. a range - * is written as two characters seperated with a hyphen: a-z denotes - * all characters between a to z inclusive. - * [-set] set matches a literal hypen and any character in the set - * []set] matches a literal close bracket and any character in the set - * - * char matches itself except where char is '*' or '?' or '[' - * \char matches char, including any pattern character - * - * examples: - * a*c ac abc abbc ... - * a?c acc abc aXc ... - * a[a-z]c aac abc acc ... - * a[-a-z]c a-c aac abc ... - * - * $Log$ - * Revision 1.1 2004/11/19 23:00:57 theno23 - * Added lo_send_timestamped - * - * Revision 1.3 1995/09/14 23:24:23 oz - * removed boring test/main code. - * - * Revision 1.2 94/12/11 10:38:15 oz - * cset code fixed. it is now robust and interprets all - * variations of cset [i think] correctly, including [z-a] etc. - * - * Revision 1.1 94/12/08 12:45:23 oz - * Initial revision - */ - - -#ifndef lo_NEGATE -#define lo_NEGATE '!' -#endif - -#ifndef lo_true -#define lo_true 1 -#endif -#ifndef lo_false -#define lo_false 0 -#endif - -inline int lo_pattern_match(const char *str, const char *p) -{ - int negate; - int match; - char c; - - while (*p) { - if (!*str && *p != '*') - return lo_false; - - switch (c = *p++) { - - case '*': - while (*p == '*' && *p != '/') - p++; - - if (!*p) - return lo_true; - - // if (*p != '?' && *p != '[' && *p != '\\') - if (*p != '?' && *p != '[' && *p != '{') - while (*str && *p != *str) - str++; - - while (*str) { - if (lo_pattern_match(str, p)) - return lo_true; - str++; - } - return lo_false; - - case '?': - if (*str) - break; - return lo_false; - /* - * set specification is inclusive, that is [a-z] is a, z and - * everything in between. this means [z-a] may be interpreted - * as a set that contains z, a and nothing in between. - */ - case '[': - if (*p != lo_NEGATE) - negate = lo_false; - else { - negate = lo_true; - p++; - } - - match = lo_false; - - while (!match && (c = *p++)) { - if (!*p) - return lo_false; - if (*p == '-') { /* c-c */ - if (!*++p) - return lo_false; - if (*p != ']') { - if (*str == c || *str == *p || - (*str > c && *str < *p)) - match = lo_true; - } else { /* c-] */ - if (*str >= c) - match = lo_true; - break; - } - } else { /* cc or c] */ - if (c == *str) - match = lo_true; - if (*p != ']') { - if (*p == *str) - match = lo_true; - } else - break; - } - } - - if (negate == match) - return lo_false; - /* - * if there is a match, skip past the cset and continue on - */ - while (*p && *p != ']') - p++; - if (!*p++) /* oops! */ - return lo_false; - break; - - /* - * {astring,bstring,cstring} - */ - case '{': - { - // *p is now first character in the {brace list} - const char *place = str; // to backtrack - const char *remainder = p; // to forwardtrack - - // find the end of the brace list - while (*remainder && *remainder != '}') - remainder++; - if (!*remainder++) /* oops! */ - return lo_false; - - c = *p++; - - while (c) { - if (c == ',') { - if (lo_pattern_match(str, remainder)) { - return lo_true; - } else { - // backtrack on test string - str = place; - // continue testing, - // skip comma - if (!*p++) // oops - return lo_false; - } - } else if (c == '}') { - // continue normal pattern matching - if (!*p && !*str) - return lo_true; - str--; // str is incremented again below - break; - } else if (c == *str) { - str++; - if (!*str && *remainder) - return lo_false; - } else { // skip to next comma - str = place; - while (*p != ',' && *p != '}' && *p) - p++; - if (*p == ',') - p++; - else if (*p == '}') { - return lo_false; - } - } - c = *p++; - } - } - - break; - - /* Not part of OSC pattern matching - case '\\': - if (*p) - c = *p++; - */ - - default: - if (c != *str) - return lo_false; - break; - - } - str++; - } - - return !*str; -} - -#endif - diff --git a/include/lang/SC_LanguageClient.h b/include/lang/SC_LanguageClient.h index 14eb87cb8cb..bd5385bd7f6 100644 --- a/include/lang/SC_LanguageClient.h +++ b/include/lang/SC_LanguageClient.h @@ -43,63 +43,6 @@ struct PyrSymbol; struct VMGlobals; -extern bool compiledOK; - -extern pthread_mutex_t gLangMutex; -extern VMGlobals* gMainVMGlobals; - - -// lock language, -// if shouldBeRunning == false, return EINTR -// if language has been locked, return 0 -template -static inline int lockLanguageOrQuit(FlagType const & shouldBeRunning) -{ -#ifdef __linux__ - // we have pthread_mutex_timedlock - - int status = pthread_mutex_trylock(&gLangMutex); - if (status == 0) { - if (shouldBeRunning == false) { - pthread_mutex_unlock(&gLangMutex); - return EINTR; - } - } else if (status == EBUSY) { - do { - struct timespec now; - clock_gettime(CLOCK_REALTIME, &now); - now.tv_sec += 1; - - status = pthread_mutex_timedlock(&gLangMutex, &now); - if (shouldBeRunning == false) { - if (status == 0) - pthread_mutex_unlock(&gLangMutex); - return EINTR; - } - } while (status == ETIMEDOUT); - } - return status; -#else - int status; - do { - status = pthread_mutex_trylock (&gLangMutex); - if (shouldBeRunning == false) { - if (status == 0) - pthread_mutex_unlock(&gLangMutex); - return EINTR; - } - if (status == EBUSY) { - struct timespec sleepTime, remain; - sleepTime.tv_sec = 0; - sleepTime.tv_nsec = 100000; - nanosleep(&sleepTime, &remain); - } - } while (status); - return 0; -#endif -} - - class SC_DLLEXPORT SC_LanguageClient { public: @@ -124,8 +67,8 @@ class SC_DLLEXPORT SC_LanguageClient virtual ~SC_LanguageClient(); // singleton instance access locking - static void lockInstance() { gInstanceMutex.Lock(); } - static void unlockInstance() { gInstanceMutex.Unlock(); } + static void lockInstance(); + static void unlockInstance(); // return the singleton instance static SC_LanguageClient* instance() { return gInstance; } @@ -139,17 +82,17 @@ class SC_DLLEXPORT SC_LanguageClient const char* getName() const { return mName; } // library startup/shutdown - bool isLibraryCompiled() { return compiledOK; } + bool isLibraryCompiled(); void compileLibrary(); void shutdownLibrary(); void recompileLibrary(); // interpreter access - void lock() { pthread_mutex_lock(&gLangMutex); } - bool trylock() { return pthread_mutex_trylock(&gLangMutex) == 0; } - void unlock() { pthread_mutex_unlock(&gLangMutex); } + void lock(); + bool trylock(); + void unlock(); - VMGlobals* getVMGlobals() { return gMainVMGlobals; } + struct VMGlobals* getVMGlobals(); void setCmdLine(const char* buf, size_t size); void setCmdLine(const char* str); @@ -157,11 +100,11 @@ class SC_DLLEXPORT SC_LanguageClient void setCmdLinef(const char* fmt, ...); void runLibrary(PyrSymbol* pyrSymbol); void runLibrary(const char* methodName); - void interpretCmdLine() { runLibrary(s_interpretCmdLine); } - void interpretPrintCmdLine() { runLibrary(s_interpretPrintCmdLine); } + void interpretCmdLine(); + void interpretPrintCmdLine(); void executeFile(const char* fileName); - void runMain() { runLibrary(s_run); } - void stopMain() { runLibrary(s_stop); } + void runMain(); + void stopMain(); // post file access FILE* getPostFile() { return mPostFile; } @@ -219,7 +162,6 @@ class SC_DLLEXPORT SC_LanguageClient SC_StringBuffer mScratch; bool mRunning; static SC_LanguageClient* gInstance; - static SC_Lock gInstanceMutex; }; // ===================================================================== diff --git a/include/lang/SC_TerminalClient.h b/include/lang/SC_TerminalClient.h index adc2ce7f19a..4b387358b76 100644 --- a/include/lang/SC_TerminalClient.h +++ b/include/lang/SC_TerminalClient.h @@ -27,12 +27,12 @@ #define SC_TERMINALCLIENT_H_INCLUDED #include "SC_LanguageClient.h" -#include "SC_StringBuffer.h" // ===================================================================== // SC_TerminalClient - command line sclang client. // ===================================================================== +// TODO: move locks out of the header, possibly using pimpl class SC_DLLEXPORT SC_TerminalClient : public SC_LanguageClient { public: @@ -91,7 +91,7 @@ class SC_DLLEXPORT SC_TerminalClient : public SC_LanguageClient bool parseOptions(int& argc, char**& argv, Options& opt); void printUsage(); - void interpretCmdLine(PyrSymbol* method, SC_StringBuffer& cmdLine); + void interpretCmdLine(PyrSymbol* method, class SC_StringBuffer& cmdLine); void interpretCmdLine(PyrSymbol* method, const char* cmdLine); void interpretCmdLine(PyrSymbol* method, const char *buf, size_t size); diff --git a/include/server/SC_Complex.h b/include/server/SC_Complex.h deleted file mode 100644 index 39738519e27..00000000000 --- a/include/server/SC_Complex.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#ifndef _SC_Complex_ -#define _SC_Complex_ - -#include "SC_Types.h" -#include "float.h" - -//////////////////////////////////////////////////////////////////////////////// - -struct Polar; - -struct Complex -{ - Complex() {} - Complex(float r, float i) : real(r), imag(i) {} - void Set(float r, float i) { real = r; imag = i; } - - Complex& operator=(Complex b) { real = b.real; imag = b.imag; return *this; } - Complex& operator=(float b) { real = b; imag = 0.; return *this; } - - Polar ToPolar(); - Polar ToPolarApx(); - - void ToPolarInPlace(); - void ToPolarApxInPlace(); - - float real, imag; -}; - -struct Polar -{ - Polar() {} - Polar(float m, float p) : mag(m), phase(p) {} - void Set(float m, float p) { mag = m; phase = p; } - - Complex ToComplex(); - Complex ToComplexApx(); - - void ToComplexInPlace(); - void ToComplexApxInPlace(); - - float mag, phase; -}; - -struct ComplexFT -{ - float dc, nyq; - Complex complex[1]; -}; - -struct PolarFT -{ - float dc, nyq; - Polar polar[1]; -}; - -void ToComplex(Polar in, Complex& out); - -inline Complex operator+(Complex a, Complex b) { return Complex(a.real + b.real, a.imag + b.imag); } -inline Complex operator+(Complex a, float b) { return Complex(a.real + b, a.imag); } -inline Complex operator+(float a, Complex b) { return Complex(a + b.real, b.imag); } - -inline Complex& operator+=(Complex& a, const Complex& b) { a.real += b.real, a.imag += b.imag; return a; } -inline Complex& operator+=(Complex& a, float b) { a.real += b; return a; } - -inline Complex operator-(Complex a, Complex b) { return Complex(a.real - b.real, a.imag - b.imag); } -inline Complex operator-(Complex a, float b) { return Complex(a.real - b, a.imag); } -inline Complex operator-(float a, Complex b) { return Complex(a - b.real, b.imag); } - -inline Complex operator-=(Complex a, Complex b) { a.real -= b.real, a.imag -= b.imag; return a; } -inline Complex operator-=(Complex a, float b) { a.real -= b; return a; } - -inline Complex operator*(Complex a, Complex b) -{ - return Complex(a.real * b.real - a.imag * b.imag, a.real * b.imag + a.imag * b.real); -} - -inline Complex operator*(Complex a, float b) -{ - return Complex(a.real * b, a.imag * b); -} - -inline Complex operator*(float a, Complex b) -{ - return Complex(b.real * a, b.imag * a); -} - -inline Complex operator*=(Complex a, Complex b) -{ - a.Set( - a.real * b.real - a.imag * b.imag, - a.real * b.imag + a.imag * b.real - ); - return a; -} - -inline Complex operator*=(Complex a, float b) -{ - a.real *= b; - a.imag *= b; - return a; -} - - -inline Polar operator*(Polar a, float b) -{ - return Polar(a.mag * b, a.phase); -} - -inline Polar operator*(float a, Polar b) -{ - return Polar(a * b.mag, b.phase); -} - -inline Polar operator*=(Polar a, float b) -{ - a.mag *= b; - return a; -} - - -#endif diff --git a/include/server/SC_Samp.h b/include/server/SC_Samp.h deleted file mode 100644 index 6e3fb732550..00000000000 --- a/include/server/SC_Samp.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#ifndef _SC_Samp_ -#define _SC_Samp_ - -#include "SC_Types.h" - -const int kSineSize = 8192; -const int kSineMask = kSineSize - 1; - -extern float32 gSine[kSineSize+1]; -extern float32 gInvSine[kSineSize+1]; -extern float32 gSineWavetable[2*kSineSize]; - -void SignalAsWavetable(float32* signal, float32* wavetable, long inSize); - -#endif diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index e6288294291..ba21e7aefd4 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -9,6 +9,8 @@ include_directories(${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/external_libraries/boost-lockfree ${CMAKE_SOURCE_DIR}/external_libraries/threadpool ${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src + LangSource + LangPrimSource LangSource/Bison) if (Boost_FOUND) @@ -64,7 +66,6 @@ set(sclang_sources LangSource/SC_LanguageClient.cpp LangSource/SC_LanguageConfig.cpp LangSource/SC_TerminalClient.cpp - LangSource/Samp.cpp LangSource/SimpleStack.cpp LangSource/VMGlobals.cpp LangSource/dumpByteCodes.cpp @@ -78,6 +79,7 @@ set(sclang_sources ${CMAKE_SOURCE_DIR}/common/SC_StringBuffer.cpp ${CMAKE_SOURCE_DIR}/common/SC_StringParser.cpp ${CMAKE_SOURCE_DIR}/common/SC_TextUtils.cpp + ${CMAKE_SOURCE_DIR}/common/Samp.cpp ${CMAKE_SOURCE_DIR}/common/scsynthsend.cpp ${CMAKE_SOURCE_DIR}/common/sc_popen.cpp diff --git a/lang/LangPrimSource/OSCData.cpp b/lang/LangPrimSource/OSCData.cpp index f868ce738da..f40384f2b38 100644 --- a/lang/LangPrimSource/OSCData.cpp +++ b/lang/LangPrimSource/OSCData.cpp @@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "OSCData.h" #include "PyrPrimitive.h" #include "PyrKernel.h" #include "PyrInterpreter.h" @@ -46,6 +45,7 @@ typedef int socklen_t; #include #include "scsynthsend.h" #include "sc_msg_iter.h" +#include "SCBase.h" #include "SC_ComPort.h" #include "SC_WorldOptions.h" #include "SC_SndBuf.h" @@ -59,6 +59,9 @@ typedef int socklen_t; #include "../../../common/server_shm.hpp" +#include "../common/SC_Endian.h" + + struct InternalSynthServerGlobals { struct World *mWorld; diff --git a/include/lang/OSCData.h b/lang/LangPrimSource/OSCData.h similarity index 98% rename from include/lang/OSCData.h rename to lang/LangPrimSource/OSCData.h index 8fdbf061332..83aee0c3596 100644 --- a/include/lang/OSCData.h +++ b/lang/LangPrimSource/OSCData.h @@ -22,7 +22,6 @@ #define _OSCData_ #include "PyrObject.h" -#include "FIFOT.h" #include "../common/SC_Endian.h" diff --git a/include/lang/PyrArchiverT.h b/lang/LangPrimSource/PyrArchiverT.h similarity index 100% rename from include/lang/PyrArchiverT.h rename to lang/LangPrimSource/PyrArchiverT.h diff --git a/include/lang/PyrDeepCopier.h b/lang/LangPrimSource/PyrDeepCopier.h similarity index 100% rename from include/lang/PyrDeepCopier.h rename to lang/LangPrimSource/PyrDeepCopier.h diff --git a/include/lang/PyrDeepFreezer.h b/lang/LangPrimSource/PyrDeepFreezer.h similarity index 100% rename from include/lang/PyrDeepFreezer.h rename to lang/LangPrimSource/PyrDeepFreezer.h diff --git a/include/lang/PyrFilePrim.h b/lang/LangPrimSource/PyrFilePrim.h similarity index 100% rename from include/lang/PyrFilePrim.h rename to lang/LangPrimSource/PyrFilePrim.h diff --git a/include/lang/PyrListPrim.h b/lang/LangPrimSource/PyrListPrim.h similarity index 100% rename from include/lang/PyrListPrim.h rename to lang/LangPrimSource/PyrListPrim.h diff --git a/include/lang/PyrMathPrim.h b/lang/LangPrimSource/PyrMathPrim.h similarity index 100% rename from include/lang/PyrMathPrim.h rename to lang/LangPrimSource/PyrMathPrim.h diff --git a/lang/LangPrimSource/PyrSerialPrim.cpp b/lang/LangPrimSource/PyrSerialPrim.cpp index 3abbbcdd577..f6d7a81ef92 100644 --- a/lang/LangPrimSource/PyrSerialPrim.cpp +++ b/lang/LangPrimSource/PyrSerialPrim.cpp @@ -41,7 +41,7 @@ #include "GC.h" #include "PyrKernel.h" #include "PyrPrimitive.h" -#include "SC_LanguageClient.h" +#include "PyrSched.h" #include "SCBase.h" #include "SC_FIFO.h" diff --git a/include/lang/PyrSignalPrim.h b/lang/LangPrimSource/PyrSignalPrim.h similarity index 100% rename from include/lang/PyrSignalPrim.h rename to lang/LangPrimSource/PyrSignalPrim.h diff --git a/lang/LangPrimSource/PyrSymbolPrim.cpp b/lang/LangPrimSource/PyrSymbolPrim.cpp index 280047d8f5c..3987e635fad 100644 --- a/lang/LangPrimSource/PyrSymbolPrim.cpp +++ b/lang/LangPrimSource/PyrSymbolPrim.cpp @@ -222,6 +222,257 @@ int prSymbol_AsFloat(struct VMGlobals *g, int numArgsPushed) return errNone; } +// following function lifted from liblo: http://sourceforge.net/projects/liblo/ + +/* Open SoundControl kit in C++ */ +/* Copyright (C) 2002-2004 libOSC++ contributors. See AUTHORS */ +/* */ +/* This library is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU Lesser General Public */ +/* License as published by the Free Software Foundation; either */ +/* version 2.1 of the License, or (at your option) any later version. */ +/* */ +/* This library is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ +/* Lesser General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with this library; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* For questions regarding this program contact */ +/* Daniel Holth or visit */ +/* http://wiretap.stetson.edu/ */ + +/* In the sprit of the public domain, my modifications to this file are also */ +/* dedicated to the public domain. Daniel Holth, Oct. 2004 */ + +/* ChangeLog: + * + * 2004-10-29 Import, convert to C++, begin OSC syntax changes. -dwh + * OSC syntax changes are now working, needs more testing. + * + */ + +// Original header and syntax: + +/* + * robust glob pattern matcher + * ozan s. yigit/dec 1994 + * public domain + * + * glob patterns: + * * matches zero or more characters + * ? matches any single character + * [set] matches any character in the set + * [^set] matches any character NOT in the set + * where a set is a group of characters or ranges. a range + * is written as two characters seperated with a hyphen: a-z denotes + * all characters between a to z inclusive. + * [-set] set matches a literal hypen and any character in the set + * []set] matches a literal close bracket and any character in the set + * + * char matches itself except where char is '*' or '?' or '[' + * \char matches char, including any pattern character + * + * examples: + * a*c ac abc abbc ... + * a?c acc abc aXc ... + * a[a-z]c aac abc acc ... + * a[-a-z]c a-c aac abc ... + * + * $Log$ + * Revision 1.1 2004/11/19 23:00:57 theno23 + * Added lo_send_timestamped + * + * Revision 1.3 1995/09/14 23:24:23 oz + * removed boring test/main code. + * + * Revision 1.2 94/12/11 10:38:15 oz + * cset code fixed. it is now robust and interprets all + * variations of cset [i think] correctly, including [z-a] etc. + * + * Revision 1.1 94/12/08 12:45:23 oz + * Initial revision + */ + + +#ifndef lo_NEGATE +#define lo_NEGATE '!' +#endif + +#ifndef lo_true +#define lo_true 1 +#endif +#ifndef lo_false +#define lo_false 0 +#endif + +inline int lo_pattern_match(const char *str, const char *p) +{ + int negate; + int match; + char c; + + while (*p) { + if (!*str && *p != '*') + return lo_false; + + switch (c = *p++) { + + case '*': + while (*p == '*' && *p != '/') + p++; + + if (!*p) + return lo_true; + + // if (*p != '?' && *p != '[' && *p != '\\') + if (*p != '?' && *p != '[' && *p != '{') + while (*str && *p != *str) + str++; + + while (*str) { + if (lo_pattern_match(str, p)) + return lo_true; + str++; + } + return lo_false; + + case '?': + if (*str) + break; + return lo_false; + /* + * set specification is inclusive, that is [a-z] is a, z and + * everything in between. this means [z-a] may be interpreted + * as a set that contains z, a and nothing in between. + */ + case '[': + if (*p != lo_NEGATE) + negate = lo_false; + else { + negate = lo_true; + p++; + } + + match = lo_false; + + while (!match && (c = *p++)) { + if (!*p) + return lo_false; + if (*p == '-') { /* c-c */ + if (!*++p) + return lo_false; + if (*p != ']') { + if (*str == c || *str == *p || + (*str > c && *str < *p)) + match = lo_true; + } else { /* c-] */ + if (*str >= c) + match = lo_true; + break; + } + } else { /* cc or c] */ + if (c == *str) + match = lo_true; + if (*p != ']') { + if (*p == *str) + match = lo_true; + } else + break; + } + } + + if (negate == match) + return lo_false; + /* + * if there is a match, skip past the cset and continue on + */ + while (*p && *p != ']') + p++; + if (!*p++) /* oops! */ + return lo_false; + break; + + /* + * {astring,bstring,cstring} + */ + case '{': + { + // *p is now first character in the {brace list} + const char *place = str; // to backtrack + const char *remainder = p; // to forwardtrack + + // find the end of the brace list + while (*remainder && *remainder != '}') + remainder++; + if (!*remainder++) /* oops! */ + return lo_false; + + c = *p++; + + while (c) { + if (c == ',') { + if (lo_pattern_match(str, remainder)) { + return lo_true; + } else { + // backtrack on test string + str = place; + // continue testing, + // skip comma + if (!*p++) // oops + return lo_false; + } + } else if (c == '}') { + // continue normal pattern matching + if (!*p && !*str) + return lo_true; + str--; // str is incremented again below + break; + } else if (c == *str) { + str++; + if (!*str && *remainder) + return lo_false; + } else { // skip to next comma + str = place; + while (*p != ',' && *p != '}' && *p) + p++; + if (*p == ',') + p++; + else if (*p == '}') { + return lo_false; + } + } + c = *p++; + } + } + + break; + + /* Not part of OSC pattern matching + case '\\': + if (*p) + c = *p++; + */ + + default: + if (c != *str) + return lo_false; + break; + + } + str++; + } + + return !*str; +} + +// end: following function lifted from liblo + + + int prSymbol_matchOSCPattern(struct VMGlobals *g, int numArgsPushed); int prSymbol_matchOSCPattern(struct VMGlobals *g, int numArgsPushed) { diff --git a/include/lang/ReadWriteMacros.h b/lang/LangPrimSource/ReadWriteMacros.h similarity index 100% rename from include/lang/ReadWriteMacros.h rename to lang/LangPrimSource/ReadWriteMacros.h diff --git a/include/lang/SC_ComPort.h b/lang/LangPrimSource/SC_ComPort.h similarity index 100% rename from include/lang/SC_ComPort.h rename to lang/LangPrimSource/SC_ComPort.h diff --git a/include/lang/SC_Msg.h b/lang/LangPrimSource/SC_Msg.h similarity index 100% rename from include/lang/SC_Msg.h rename to lang/LangPrimSource/SC_Msg.h diff --git a/include/lang/AdvancingAllocPool.h b/lang/LangSource/AdvancingAllocPool.h similarity index 100% rename from include/lang/AdvancingAllocPool.h rename to lang/LangSource/AdvancingAllocPool.h diff --git a/include/lang/AllocPools.h b/lang/LangSource/AllocPools.h similarity index 100% rename from include/lang/AllocPools.h rename to lang/LangSource/AllocPools.h diff --git a/include/lang/ByteCodeArray.h b/lang/LangSource/ByteCodeArray.h similarity index 100% rename from include/lang/ByteCodeArray.h rename to lang/LangSource/ByteCodeArray.h diff --git a/include/lang/GC.h b/lang/LangSource/GC.h similarity index 100% rename from include/lang/GC.h rename to lang/LangSource/GC.h diff --git a/include/lang/HashTable.h b/lang/LangSource/HashTable.h similarity index 100% rename from include/lang/HashTable.h rename to lang/LangSource/HashTable.h diff --git a/include/lang/InitAlloc.h b/lang/LangSource/InitAlloc.h similarity index 100% rename from include/lang/InitAlloc.h rename to lang/LangSource/InitAlloc.h diff --git a/include/lang/MiscInlineMath.h b/lang/LangSource/MiscInlineMath.h similarity index 100% rename from include/lang/MiscInlineMath.h rename to lang/LangSource/MiscInlineMath.h diff --git a/include/lang/Opcodes.h b/lang/LangSource/Opcodes.h similarity index 100% rename from include/lang/Opcodes.h rename to lang/LangSource/Opcodes.h diff --git a/include/lang/PowerOfTwoAllocPool.h b/lang/LangSource/PowerOfTwoAllocPool.h similarity index 100% rename from include/lang/PowerOfTwoAllocPool.h rename to lang/LangSource/PowerOfTwoAllocPool.h diff --git a/include/lang/PredefinedSymbols.h b/lang/LangSource/PredefinedSymbols.h similarity index 100% rename from include/lang/PredefinedSymbols.h rename to lang/LangSource/PredefinedSymbols.h diff --git a/include/lang/PyrErrors.h b/lang/LangSource/PyrErrors.h similarity index 100% rename from include/lang/PyrErrors.h rename to lang/LangSource/PyrErrors.h diff --git a/include/lang/PyrInterpreter.h b/lang/LangSource/PyrInterpreter.h similarity index 100% rename from include/lang/PyrInterpreter.h rename to lang/LangSource/PyrInterpreter.h diff --git a/include/lang/PyrKernel.h b/lang/LangSource/PyrKernel.h similarity index 100% rename from include/lang/PyrKernel.h rename to lang/LangSource/PyrKernel.h diff --git a/include/lang/PyrKernelProto.h b/lang/LangSource/PyrKernelProto.h similarity index 100% rename from include/lang/PyrKernelProto.h rename to lang/LangSource/PyrKernelProto.h diff --git a/include/lang/PyrLexer.h b/lang/LangSource/PyrLexer.h similarity index 100% rename from include/lang/PyrLexer.h rename to lang/LangSource/PyrLexer.h diff --git a/include/lang/PyrMessage.h b/lang/LangSource/PyrMessage.h similarity index 100% rename from include/lang/PyrMessage.h rename to lang/LangSource/PyrMessage.h diff --git a/include/lang/PyrObject.h b/lang/LangSource/PyrObject.h similarity index 100% rename from include/lang/PyrObject.h rename to lang/LangSource/PyrObject.h diff --git a/include/lang/PyrObjectProto.h b/lang/LangSource/PyrObjectProto.h similarity index 100% rename from include/lang/PyrObjectProto.h rename to lang/LangSource/PyrObjectProto.h diff --git a/include/lang/PyrParseNode.h b/lang/LangSource/PyrParseNode.h similarity index 100% rename from include/lang/PyrParseNode.h rename to lang/LangSource/PyrParseNode.h diff --git a/include/lang/PyrPrimitive.h b/lang/LangSource/PyrPrimitive.h similarity index 100% rename from include/lang/PyrPrimitive.h rename to lang/LangSource/PyrPrimitive.h diff --git a/include/lang/PyrPrimitiveProto.h b/lang/LangSource/PyrPrimitiveProto.h similarity index 100% rename from include/lang/PyrPrimitiveProto.h rename to lang/LangSource/PyrPrimitiveProto.h diff --git a/include/lang/PyrSched.h b/lang/LangSource/PyrSched.h similarity index 64% rename from include/lang/PyrSched.h rename to lang/LangSource/PyrSched.h index aafcfadb776..ba7388e48f1 100644 --- a/include/lang/PyrSched.h +++ b/lang/LangSource/PyrSched.h @@ -24,6 +24,7 @@ #include "VMGlobals.h" #include "SC_Export.h" #include +#include extern pthread_mutex_t gLangMutex; @@ -56,4 +57,53 @@ const double kNanosToOSC = 4.294967296; // pow(2,32)/1e9 const double kOSCtoSecs = 2.328306436538696e-10; // 1/pow(2,32) const double kOSCtoNanos = 0.2328306436538696; // 1e9/pow(2,32) +// lock language, +// if shouldBeRunning == false, return EINTR +// if language has been locked, return 0 +inline int lockLanguageOrQuit(bool shouldBeRunning) +{ +#ifdef __linux__ + // we have pthread_mutex_timedlock + + int status = pthread_mutex_trylock(&gLangMutex); + if (status == 0) { + if (shouldBeRunning == false) { + pthread_mutex_unlock(&gLangMutex); + return EINTR; + } + } else if (status == EBUSY) { + do { + struct timespec now; + clock_gettime(CLOCK_REALTIME, &now); + now.tv_sec += 1; + + status = pthread_mutex_timedlock(&gLangMutex, &now); + if (shouldBeRunning == false) { + if (status == 0) + pthread_mutex_unlock(&gLangMutex); + return EINTR; + } + } while (status == ETIMEDOUT); + } + return status; +#else + int status; + do { + status = pthread_mutex_trylock (&gLangMutex); + if (shouldBeRunning == false) { + if (status == 0) + pthread_mutex_unlock(&gLangMutex); + return EINTR; + } + if (status == EBUSY) { + struct timespec sleepTime, remain; + sleepTime.tv_sec = 0; + sleepTime.tv_nsec = 100000; + nanosleep(&sleepTime, &remain); + } + } while (status); + return 0; +#endif +} + #endif diff --git a/include/lang/PyrSignal.h b/lang/LangSource/PyrSignal.h similarity index 100% rename from include/lang/PyrSignal.h rename to lang/LangSource/PyrSignal.h diff --git a/include/lang/PyrSlot.h b/lang/LangSource/PyrSlot.h similarity index 100% rename from include/lang/PyrSlot.h rename to lang/LangSource/PyrSlot.h diff --git a/include/lang/PyrSlot32.h b/lang/LangSource/PyrSlot32.h similarity index 100% rename from include/lang/PyrSlot32.h rename to lang/LangSource/PyrSlot32.h diff --git a/include/lang/PyrSlot64.h b/lang/LangSource/PyrSlot64.h similarity index 100% rename from include/lang/PyrSlot64.h rename to lang/LangSource/PyrSlot64.h diff --git a/include/lang/Samp.h b/lang/LangSource/PyrSymbol.h similarity index 59% rename from include/lang/Samp.h rename to lang/LangSource/PyrSymbol.h index 53768698dde..2657baf6ef1 100644 --- a/include/lang/Samp.h +++ b/lang/LangSource/PyrSymbol.h @@ -17,30 +17,42 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - /* -Samp is a typedef for the output sample type. -Should be defined to be either float or double. +A PyrSymbol is a unique string that resides in a global hash table. */ -#ifndef _Samp_ -#define _Samp_ +#ifndef _PYRSYMBOL_H_ +#define _PYRSYMBOL_H_ #include "SC_Types.h" -const long kSineSize = 8192; -const long kSineMask = kSineSize - 1; -const double kSinePhaseScale = kSineSize / (2.0 * 3.1415926535897932384626433832795); - -extern float32 gSine[kSineSize+1]; -extern float32 gPMSine[kSineSize+1]; -extern float32 gInvSine[kSineSize+1]; -extern float32 gSineWavetable[2*kSineSize]; +struct PyrSymbol { + char *name; + long hash; + short specialIndex; + uint8 flags; + uint8 length; + union { + long index; // index in row table or primitive table + struct PyrClass *classobj; // pointer to class with this name. + char *source; // source code for sym_Filename; used only during compilation. + } u; + struct classdep *classdep; +}; + +enum { + sym_Selector = 1, + sym_Class = 2, + sym_Compiled = 4, + sym_Called = 8, + sym_Primitive = 16, + sym_Setter = 32, + sym_MetaClass = 64, + sym_Filename = 128 +}; -void SignalAsWavetable(float32* signal, float32* wavetable, long inSize); -void WavetableAsSignal(float32* wavetable, float32* signal, long inSize); #endif diff --git a/include/lang/PyrSymbolTable.h b/lang/LangSource/PyrSymbolTable.h similarity index 100% rename from include/lang/PyrSymbolTable.h rename to lang/LangSource/PyrSymbolTable.h diff --git a/include/lang/SCBase.h b/lang/LangSource/SCBase.h similarity index 100% rename from include/lang/SCBase.h rename to lang/LangSource/SCBase.h diff --git a/lang/LangSource/SC_LanguageClient.cpp b/lang/LangSource/SC_LanguageClient.cpp index 3b67c1bba8d..2a4cb78a20b 100644 --- a/lang/LangSource/SC_LanguageClient.cpp +++ b/lang/LangSource/SC_LanguageClient.cpp @@ -43,6 +43,7 @@ #include "PyrObject.h" #include "PyrKernel.h" #include "PyrPrimitive.h" +#include "PyrSched.h" #include "GC.h" #include "VMGlobals.h" #include "SC_DirUtils.h" @@ -59,7 +60,7 @@ extern PyrString* newPyrStringN(class PyrGC *gc, long length, long flags, long c // ===================================================================== SC_LanguageClient* SC_LanguageClient::gInstance = 0; -SC_Lock SC_LanguageClient::gInstanceMutex; +SC_Lock gInstanceMutex; PyrSymbol* SC_LanguageClient::s_interpretCmdLine = 0; PyrSymbol* SC_LanguageClient::s_interpretPrintCmdLine = 0; @@ -314,6 +315,25 @@ void SC_LanguageClient::onInterpStartup() { } +// runLibrary methods +void SC_LanguageClient::interpretCmdLine() { runLibrary(s_interpretCmdLine); } +void SC_LanguageClient::interpretPrintCmdLine() { runLibrary(s_interpretPrintCmdLine); } +void SC_LanguageClient::runMain() { runLibrary(s_run); } +void SC_LanguageClient::stopMain() { runLibrary(s_stop); } + +// locks +void SC_LanguageClient::lock() { pthread_mutex_lock(&gLangMutex); } +bool SC_LanguageClient::trylock() { return pthread_mutex_trylock(&gLangMutex) == 0; } +void SC_LanguageClient::unlock() { pthread_mutex_unlock(&gLangMutex); } + +void SC_LanguageClient::lockInstance() { gInstanceMutex.Lock(); } +void SC_LanguageClient::unlockInstance() { gInstanceMutex.Unlock(); } + +extern bool compiledOK; + +bool SC_LanguageClient::isLibraryCompiled() { return compiledOK; } + + // ===================================================================== // library functions // ===================================================================== diff --git a/lang/LangSource/Samp.cpp b/lang/LangSource/Samp.cpp deleted file mode 100644 index 3cf1ca6d4d1..00000000000 --- a/lang/LangSource/Samp.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "Samp.h" -#include "SC_Constants.h" -#include -#include - -float32 gSine[kSineSize+1]; -float32 gPMSine[kSineSize+1]; -float32 gInvSine[kSineSize+1]; -float32 gSineWavetable[2*kSineSize]; - -void SignalAsWavetable(float32* signal, float32* wavetable, long inSize) -{ - float32 val1, val2; - - float32* in = signal; - float32* out = wavetable - 1; - for (int i=0; i>1; - for (int i=1; i<=8; ++i) { - gInvSine[i] = gInvSine[sz-i] = kBadValue; - gInvSine[sz2-i] = gInvSine[sz2+i] = kBadValue; - } - //SignalAsWavetable(gInvSine, gInvSineWavetable, kSineSize); -} - - - diff --git a/include/lang/SimpleStack.h b/lang/LangSource/SimpleStack.h similarity index 100% rename from include/lang/SimpleStack.h rename to lang/LangSource/SimpleStack.h diff --git a/include/lang/VMGlobals.h b/lang/LangSource/VMGlobals.h similarity index 100% rename from include/lang/VMGlobals.h rename to lang/LangSource/VMGlobals.h diff --git a/platform/mac/CMakeLists.txt b/platform/mac/CMakeLists.txt index eb03fdf0dec..3fbd93977eb 100644 --- a/platform/mac/CMakeLists.txt +++ b/platform/mac/CMakeLists.txt @@ -75,7 +75,6 @@ set(scapp_sources ${CMAKE_SOURCE_DIR}/lang/LangSource/PyrSignal.cpp ${CMAKE_SOURCE_DIR}/lang/LangSource/PyrSymbolTable.cpp ${CMAKE_SOURCE_DIR}/lang/LangSource/SC_LanguageConfig.cpp - ${CMAKE_SOURCE_DIR}/lang/LangSource/Samp.cpp ${CMAKE_SOURCE_DIR}/lang/LangSource/SimpleStack.cpp ${CMAKE_SOURCE_DIR}/lang/LangSource/VMGlobals.cpp ${CMAKE_SOURCE_DIR}/lang/LangSource/dumpByteCodes.cpp @@ -89,6 +88,7 @@ set(scapp_sources ${CMAKE_SOURCE_DIR}/lang/LangPrimSource/SC_CoreAudioPrim.cpp ${CMAKE_SOURCE_DIR}/common/fftlib.c + ${CMAKE_SOURCE_DIR}/common/Samp.cpp ${CMAKE_SOURCE_DIR}/common/SC_fftlib.cpp ${CMAKE_SOURCE_DIR}/common/SC_AllocPool.cpp ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp diff --git a/server/scsynth/CMakeLists.txt b/server/scsynth/CMakeLists.txt index 94e0e6aa58a..dcab68b182a 100644 --- a/server/scsynth/CMakeLists.txt +++ b/server/scsynth/CMakeLists.txt @@ -62,13 +62,11 @@ endif() message(STATUS "Audio API: ${AUDIOAPI}") set(scsynth_sources - Samp.cpp SC_BufGen.cpp SC_Carbon.cpp SC_ComPort.cpp SC_CoreAudio.cpp - SC_Errors.cpp SC_Graph.cpp SC_GraphDef.cpp SC_Group.cpp @@ -87,11 +85,13 @@ set(scsynth_sources ${CMAKE_SOURCE_DIR}/common/SC_fftlib.cpp ${CMAKE_SOURCE_DIR}/common/SC_AllocPool.cpp ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp + ${CMAKE_SOURCE_DIR}/common/SC_Errors.cpp ${CMAKE_SOURCE_DIR}/common/SC_Reply.cpp ${CMAKE_SOURCE_DIR}/common/SC_Sem.cpp ${CMAKE_SOURCE_DIR}/common/SC_StandAloneInfo_Darwin.cpp ${CMAKE_SOURCE_DIR}/common/SC_StringBuffer.cpp ${CMAKE_SOURCE_DIR}/common/SC_StringParser.cpp + ${CMAKE_SOURCE_DIR}/common/Samp.cpp ${CMAKE_SOURCE_DIR}/common/scsynthsend.cpp ${CMAKE_SOURCE_DIR}/common/sc_popen.cpp @@ -114,7 +114,9 @@ endif() include_directories(${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/include/server - ${CMAKE_SOURCE_DIR}/include/plugin_interface) + ${CMAKE_SOURCE_DIR}/include/plugin_interface + . +) include_directories (${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src) diff --git a/include/server/HashTable.h b/server/scsynth/HashTable.h similarity index 100% rename from include/server/HashTable.h rename to server/scsynth/HashTable.h diff --git a/include/server/OSC_Packet.h b/server/scsynth/OSC_Packet.h similarity index 100% rename from include/server/OSC_Packet.h rename to server/scsynth/OSC_Packet.h diff --git a/include/server/PriorityQueue.h b/server/scsynth/PriorityQueue.h similarity index 100% rename from include/server/PriorityQueue.h rename to server/scsynth/PriorityQueue.h diff --git a/include/server/ReadWriteMacros.h b/server/scsynth/ReadWriteMacros.h similarity index 100% rename from include/server/ReadWriteMacros.h rename to server/scsynth/ReadWriteMacros.h diff --git a/include/server/Rendezvous.h b/server/scsynth/Rendezvous.h similarity index 100% rename from include/server/Rendezvous.h rename to server/scsynth/Rendezvous.h diff --git a/include/server/SC_AU.h b/server/scsynth/SC_AU.h similarity index 100% rename from include/server/SC_AU.h rename to server/scsynth/SC_AU.h diff --git a/server/scsynth/SC_Complex.cpp b/server/scsynth/SC_Complex.cpp deleted file mode 100644 index b3e88667b8a..00000000000 --- a/server/scsynth/SC_Complex.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "SC_Complex.h" -#include "SC_Constants.h" -#include "SC_Samp.h" -#include - -//////////////////////////////////////////////////////////////////////////////// - -const int32 kPolarLUTSize = 2049; -const int32 kPolarLUTSize2 = kPolarLUTSize >> 1; -const double kSinePhaseScale = (double)kSineSize / twopi; -float gMagLUT[kPolarLUTSize]; -float gPhaseLUT[kPolarLUTSize]; - -void BuildPolarLUT(); -void BuildPolarLUT() -{ - double rPolarLUTSize2 = 1. / kPolarLUTSize2; - for (int i=0; i < kPolarLUTSize; ++i) { - double slope = (i - kPolarLUTSize2) * rPolarLUTSize2; - double angle = atan(slope); - gPhaseLUT[i] = (float)angle; - gMagLUT[i] = 1.f / (float)cos(angle); - } -} - -Polar Complex::ToPolar() -{ - return Polar(hypot(imag, real), atan2(imag, real)); -} - -Complex Polar::ToComplex() -{ - return Complex(mag * cos(phase), mag * sin(phase)); -} - -/* -float fhypotx(float real, float imag); -float fhypotx(float real, float imag) -{ - - int32 index; - float absreal = fabs(real); - float absimag = fabs(imag); - float slope; - if (absreal > absimag) { - slope = imag/real; - index = kPolarLUTSize2 + kPolarLUTSize2 * slope; - return gMagLUT[index] * absreal; - } else { - slope = real/imag; - index = kPolarLUTSize2 + kPolarLUTSize2 * slope; - return gMagLUT[index] * absimag; - } -} -*/ - -/** -* Converts cartesian to polar representation, using lookup tables. -* Note: in this implementation the phase values returned lie in the range [-pi/4, 7pi/4] -* rather than the more conventional [0, 2pi] or [-pi, pi]. -*/ -Polar Complex::ToPolarApx() -{ - int32 index; - float absreal = fabs(real); - float absimag = fabs(imag); - float mag, phase, slope; - if (absreal > absimag) { - slope = imag/real; - index = (int32)(kPolarLUTSize2 + kPolarLUTSize2 * slope); - mag = gMagLUT[index] * absreal; - phase = gPhaseLUT[index]; - if (real > 0) { - return Polar(mag, phase); - } else { - return Polar(mag, (float)(pi + phase)); - } - } else { - slope = real/imag; - index = (int32)(kPolarLUTSize2 + kPolarLUTSize2 * slope); - mag = gMagLUT[index] * absimag; - phase = gPhaseLUT[index]; - if (imag > 0) { - return Polar(mag, (float)(pi2 - phase)); - } else { - return Polar(mag, (float)(pi32 - phase)); - } - } -} - -void Complex::ToPolarInPlace() -{ - Polar polar = ToPolar(); - real = polar.mag; - imag = polar.phase; -} - -void Polar::ToComplexInPlace() -{ - Complex complx = ToComplex(); - mag = complx.real; - phase = complx.imag; -} - -Complex Polar::ToComplexApx() -{ - uint32 sinindex = (int32)(kSinePhaseScale * phase) & kSineMask; - uint32 cosindex = (sinindex + (kSineSize>>2)) & kSineMask; - return Complex(mag * gSine[cosindex], mag * gSine[sinindex]); -} - -void Complex::ToPolarApxInPlace() -{ - Polar polar = ToPolarApx(); - real = polar.mag; - imag = polar.phase; -} - -void Polar::ToComplexApxInPlace() -{ - Complex complx = ToComplexApx(); - mag = complx.real; - phase = complx.imag; -} - -//////////////////////////////////////////////////////////////////////////////// - diff --git a/include/server/SC_CoreAudio.h b/server/scsynth/SC_CoreAudio.h similarity index 100% rename from include/server/SC_CoreAudio.h rename to server/scsynth/SC_CoreAudio.h diff --git a/server/scsynth/SC_Errors.cpp b/server/scsynth/SC_Errors.cpp deleted file mode 100644 index b277148bf88..00000000000 --- a/server/scsynth/SC_Errors.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "SC_Errors.h" - -#include "stdio.h" - -int gMissingNodeID; - -void SC_ErrorString(SCErr err, char returnString[]) -{ - switch (err) { - case kSCErr_None : sprintf(returnString, "none"); break; - case kSCErr_Failed : sprintf(returnString, "failed"); break; - case kSCErr_NodeNotFound : sprintf(returnString, "Node %i not found", gMissingNodeID); break; - case kSCErr_TargetNodeNotFound : sprintf(returnString, "target Node %i not found", gMissingNodeID); break; - case kSCErr_GroupNotFound : sprintf(returnString, "Group %i not found", gMissingNodeID); break; - case kSCErr_SynthDefNotFound : sprintf(returnString, "SynthDef not found"); break; - case kSCErr_NoSuchCommand : sprintf(returnString, "no such command"); break; - case kSCErr_WrongArgType : sprintf(returnString, "wrong argument type"); break; - case kSCErr_IndexOutOfRange : sprintf(returnString, "index out of range"); break; - case kSCErr_AccessDenied : sprintf(returnString, "access denied"); break; - case kSCErr_NoReplyPort : sprintf(returnString, "no reply port"); break; - case kSCErr_InvalidControlIndex : sprintf(returnString, "invalid control index"); break; - - case kSCErr_AlreadyLoggedIn : sprintf(returnString, "already logged in"); break; - case kSCErr_NotLoggedIn : sprintf(returnString, "not logged in"); break; - case kSCErr_TooManyUsers : sprintf(returnString, "too many users"); break; - case kSCErr_TooManyNodes : sprintf(returnString, "too many nodes"); break; - case kSCErr_DuplicateNodeID : sprintf(returnString, "duplicate node ID"); break; - case kSCErr_ReservedNodeID : sprintf(returnString, "negative node IDs are reserved"); break; - case kSCErr_OutOfRealTimeMemory : sprintf(returnString, "out of real time memory"); break; - - case kSCErr_UnsupportedHeaderFormat : sprintf(returnString, "unsupported header format"); break; - case kSCErr_UnsupportedSampleFormat : sprintf(returnString, "unsupported sample format"); break; - - case kSCErr_BufGenNotFound : sprintf(returnString, "buf gen routine not found"); break; - - default : sprintf(returnString, "unknown error"); - - } -} - - diff --git a/include/server/SC_GraphDef.h b/server/scsynth/SC_GraphDef.h similarity index 100% rename from include/server/SC_GraphDef.h rename to server/scsynth/SC_GraphDef.h diff --git a/include/server/SC_Group.h b/server/scsynth/SC_Group.h similarity index 100% rename from include/server/SC_Group.h rename to server/scsynth/SC_Group.h diff --git a/include/server/SC_HiddenWorld.h b/server/scsynth/SC_HiddenWorld.h similarity index 100% rename from include/server/SC_HiddenWorld.h rename to server/scsynth/SC_HiddenWorld.h diff --git a/include/server/SC_Lib.h b/server/scsynth/SC_Lib.h similarity index 100% rename from include/server/SC_Lib.h rename to server/scsynth/SC_Lib.h diff --git a/include/server/SC_Lib_Cintf.h b/server/scsynth/SC_Lib_Cintf.h similarity index 100% rename from include/server/SC_Lib_Cintf.h rename to server/scsynth/SC_Lib_Cintf.h diff --git a/include/server/SC_Prototypes.h b/server/scsynth/SC_Prototypes.h similarity index 100% rename from include/server/SC_Prototypes.h rename to server/scsynth/SC_Prototypes.h diff --git a/include/server/SC_SequencedCommand.h b/server/scsynth/SC_SequencedCommand.h similarity index 100% rename from include/server/SC_SequencedCommand.h rename to server/scsynth/SC_SequencedCommand.h diff --git a/include/server/SC_Str4.h b/server/scsynth/SC_Str4.h similarity index 100% rename from include/server/SC_Str4.h rename to server/scsynth/SC_Str4.h diff --git a/include/server/SC_SynthDef.h b/server/scsynth/SC_SynthDef.h similarity index 100% rename from include/server/SC_SynthDef.h rename to server/scsynth/SC_SynthDef.h diff --git a/include/server/SC_UnitDef.h b/server/scsynth/SC_UnitDef.h similarity index 100% rename from include/server/SC_UnitDef.h rename to server/scsynth/SC_UnitDef.h diff --git a/include/server/SC_UnitSpec.h b/server/scsynth/SC_UnitSpec.h similarity index 100% rename from include/server/SC_UnitSpec.h rename to server/scsynth/SC_UnitSpec.h diff --git a/include/server/SC_WireSpec.h b/server/scsynth/SC_WireSpec.h similarity index 100% rename from include/server/SC_WireSpec.h rename to server/scsynth/SC_WireSpec.h diff --git a/server/scsynth/SC_World.cpp b/server/scsynth/SC_World.cpp index 4b88242a841..8048aa16570 100644 --- a/server/scsynth/SC_World.cpp +++ b/server/scsynth/SC_World.cpp @@ -33,9 +33,9 @@ #include "SC_Errors.h" #include #include "SC_Prototypes.h" -#include "SC_Samp.h" #include "SC_DirUtils.h" #include "../../common/SC_SndFileHelpers.hpp" +#include "../../common/Samp.hpp" #include "SC_StringParser.h" #ifdef _WIN32 # include diff --git a/server/scsynth/Samp.cpp b/server/scsynth/Samp.cpp deleted file mode 100644 index 9f92a09c766..00000000000 --- a/server/scsynth/Samp.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - SuperCollider real time audio synthesis system - Copyright (c) 2002 James McCartney. All rights reserved. - http://www.audiosynth.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "SC_Samp.h" -#include "SC_Constants.h" -#include - -float32 gSine[kSineSize+1]; -float32 gInvSine[kSineSize+1]; -float32 gSineWavetable[2*kSineSize]; - -void SignalAsWavetable(float32* signal, float32* wavetable, long inSize) -{ - float32 val1, val2; - - float32* in = signal; - float32* out = wavetable - 1; - for (int i=0; i>1; - for (int i=1; i<=32; ++i) { - gInvSine[i] = gInvSine[sz-i] = kBadValue; - gInvSine[sz2-i] = gInvSine[sz2+i] = kBadValue; - } - //SignalAsWavetable(gInvSine, gInvSineWavetable, kSineSize); -} - - - diff --git a/server/supernova/CMakeLists.txt b/server/supernova/CMakeLists.txt index 394e59cfef8..e51954836ec 100644 --- a/server/supernova/CMakeLists.txt +++ b/server/supernova/CMakeLists.txt @@ -62,8 +62,9 @@ if(APPLE) endif() include_directories(${CMAKE_SOURCE_DIR}/include/plugin_interface - ${CMAKE_SOURCE_DIR}/include/server ${CMAKE_SOURCE_DIR}/include/common + ${CMAKE_SOURCE_DIR}/include/server + ${CMAKE_SOURCE_DIR}/server/scsynth . ) @@ -74,7 +75,7 @@ set(libsupernova_src sc/sc_synth.cpp sc/sc_synthdef.cpp sc/sc_ugen_factory.cpp - ../scsynth/Samp.cpp + ${CMAKE_SOURCE_DIR}/common/Samp.cpp ${CMAKE_SOURCE_DIR}/common/SC_fftlib.cpp ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp ${CMAKE_SOURCE_DIR}/common/SC_StringParser.cpp diff --git a/server/supernova/sc/sc_plugin_interface.cpp b/server/supernova/sc/sc_plugin_interface.cpp index 7d5b116bf78..4c9cc3c8ed1 100644 --- a/server/supernova/sc/sc_plugin_interface.cpp +++ b/server/supernova/sc/sc_plugin_interface.cpp @@ -33,12 +33,11 @@ #include "../utilities/malloc_aligned.hpp" #include "../utilities/sized_array.hpp" -#include "SC_Samp.h" #include "SC_Prototypes.h" -#include "SC_Errors.h" #include "SC_Unit.h" #include "clz.h" #include "SC_fftlib.h" +#include "../../common/Samp.hpp" #include "../../common/SC_SndFileHelpers.hpp" #include diff --git a/server/supernova/sc/sc_plugin_interface.hpp b/server/supernova/sc/sc_plugin_interface.hpp index 79e420afe2e..547d0188cdb 100644 --- a/server/supernova/sc/sc_plugin_interface.hpp +++ b/server/supernova/sc/sc_plugin_interface.hpp @@ -32,8 +32,6 @@ #include -#include "../../common/SC_SndFileHelpers.hpp" - namespace nova { class sc_done_action_handler diff --git a/server/supernova/server/nrt_synthesis.hpp b/server/supernova/server/nrt_synthesis.hpp index 27c5f4277df..d4718750476 100644 --- a/server/supernova/server/nrt_synthesis.hpp +++ b/server/supernova/server/nrt_synthesis.hpp @@ -29,6 +29,8 @@ #include "audio_backend/sndfile_backend.hpp" #include "sc/sc_plugin_interface.hpp" +#include "../../common/SC_SndFileHelpers.hpp" + namespace nova { struct non_rt_functor From 8807e9ec300a358fa9ff72fc5a759ac813219c83 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Wed, 2 Jan 2013 14:01:49 +0100 Subject: [PATCH 02/10] sclang: SC_LanguageClient - move symbols out of the interface Signed-off-by: Tim Blechmann --- include/lang/SC_LanguageClient.h | 11 ++--------- include/lang/SC_TerminalClient.h | 6 +++--- lang/LangSource/PyrObject.cpp | 9 ++++++++- lang/LangSource/PyrObject.h | 3 ++- lang/LangSource/SC_LanguageClient.cpp | 10 ---------- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/include/lang/SC_LanguageClient.h b/include/lang/SC_LanguageClient.h index bd5385bd7f6..8893d14fb8e 100644 --- a/include/lang/SC_LanguageClient.h +++ b/include/lang/SC_LanguageClient.h @@ -40,7 +40,6 @@ // SC_LanguageClient - abstract sclang client. // ===================================================================== -struct PyrSymbol; struct VMGlobals; class SC_DLLEXPORT SC_LanguageClient @@ -98,7 +97,6 @@ class SC_DLLEXPORT SC_LanguageClient void setCmdLine(const char* str); void setCmdLine(const SC_StringBuffer& strBuf); void setCmdLinef(const char* fmt, ...); - void runLibrary(PyrSymbol* pyrSymbol); void runLibrary(const char* methodName); void interpretCmdLine(); void interpretPrintCmdLine(); @@ -119,13 +117,6 @@ class SC_DLLEXPORT SC_LanguageClient // only called from the main language thread. virtual void flush() = 0; - // common symbols - // only valid after the library has been compiled. - static PyrSymbol* s_interpretCmdLine; - static PyrSymbol* s_interpretPrintCmdLine; - static PyrSymbol* s_run; - static PyrSymbol* s_stop; - // command line argument handling utilities static void snprintMemArg(char* dst, size_t size, int arg); static bool parseMemArg(const char* arg, int* res); @@ -151,6 +142,8 @@ class SC_DLLEXPORT SC_LanguageClient // called after the interpreter has been started virtual void onInterpStartup(); + void runLibrary(struct PyrSymbol* pyrSymbol); + private: friend void closeAllGUIScreens(); friend void initGUIPrimitives(); diff --git a/include/lang/SC_TerminalClient.h b/include/lang/SC_TerminalClient.h index 4b387358b76..7f15a07fe58 100644 --- a/include/lang/SC_TerminalClient.h +++ b/include/lang/SC_TerminalClient.h @@ -91,9 +91,9 @@ class SC_DLLEXPORT SC_TerminalClient : public SC_LanguageClient bool parseOptions(int& argc, char**& argv, Options& opt); void printUsage(); - void interpretCmdLine(PyrSymbol* method, class SC_StringBuffer& cmdLine); - void interpretCmdLine(PyrSymbol* method, const char* cmdLine); - void interpretCmdLine(PyrSymbol* method, const char *buf, size_t size); + void interpretCmdLine(struct PyrSymbol* method, class SC_StringBuffer& cmdLine); + void interpretCmdLine(struct PyrSymbol* method, const char* cmdLine); + void interpretCmdLine(struct PyrSymbol* method, const char *buf, size_t size); void lockInput() { pthread_mutex_lock(&mInputMutex); } void unlockInput() { pthread_mutex_unlock(&mInputMutex); } diff --git a/lang/LangSource/PyrObject.cpp b/lang/LangSource/PyrObject.cpp index ea452891304..29862ea3af1 100644 --- a/lang/LangSource/PyrObject.cpp +++ b/lang/LangSource/PyrObject.cpp @@ -124,12 +124,13 @@ PyrSymbol *s_awake; PyrSymbol *s_appclock; PyrSymbol *s_systemclock; PyrSymbol *s_server_shm_interface; +PyrSymbol *s_interpretCmdLine, *s_interpretPrintCmdLine; PyrSymbol *s_nocomprendo; PyrSymbol *s_curProcess, *s_curMethod, *s_curBlock, *s_curClosure, *s_curThread; //PyrSymbol *s_sampleRate; //PyrSymbol *s_audioClock, *s_logicalClock; -PyrSymbol *s_run; +PyrSymbol *s_run, *s_stop, *s_tick; PyrSymbol *s_startup; PyrSymbol *s_docmdline; PyrSymbol *s_audio; @@ -237,6 +238,10 @@ void initSymbols() s_hardwaresetup = getsym("hardwareSetup"); s_shutdown = getsym("shutdown"); + s_interpretCmdLine = getsym("interpretCmdLine"); + s_interpretPrintCmdLine = getsym("interpretPrintCmdLine"); + + s_nocomprendo = getsym("doesNotUnderstand"); s_curProcess = getsym("thisProcess"); @@ -251,6 +256,8 @@ void initSymbols() s_control = getsym("control"); s_scalar = getsym("scalar"); s_run = getsym("run"); + s_stop = getsym("stop"); + s_tick = getsym("tick"); s_startup = getsym("startup"); s_docmdline = getsym("doCmdLine"); s_next = getsym("next"); diff --git a/lang/LangSource/PyrObject.h b/lang/LangSource/PyrObject.h index f541286a7bd..b062f4561f1 100644 --- a/lang/LangSource/PyrObject.h +++ b/lang/LangSource/PyrObject.h @@ -209,7 +209,7 @@ extern PyrSymbol *s_linear, *s_exponential, *s_gate; extern PyrSymbol *s_env; extern PyrSymbol *s_audio, *s_control, *s_scalar; -extern PyrSymbol *s_run; +extern PyrSymbol *s_run, *s_stop, *s_tick; extern PyrSymbol *s_next; extern PyrSymbol *s_at; extern PyrSymbol *s_put; @@ -226,6 +226,7 @@ extern PyrSymbol *s_awake; extern PyrSymbol *s_appclock; extern PyrSymbol *s_systemclock; extern PyrSymbol *s_server_shm_interface; +extern PyrSymbol *s_interpretCmdLine, *s_interpretPrintCmdLine; extern int gFormatElemSize[NUMOBJFORMATS]; diff --git a/lang/LangSource/SC_LanguageClient.cpp b/lang/LangSource/SC_LanguageClient.cpp index 2a4cb78a20b..7d5a45111c9 100644 --- a/lang/LangSource/SC_LanguageClient.cpp +++ b/lang/LangSource/SC_LanguageClient.cpp @@ -62,11 +62,6 @@ extern PyrString* newPyrStringN(class PyrGC *gc, long length, long flags, long c SC_LanguageClient* SC_LanguageClient::gInstance = 0; SC_Lock gInstanceMutex; -PyrSymbol* SC_LanguageClient::s_interpretCmdLine = 0; -PyrSymbol* SC_LanguageClient::s_interpretPrintCmdLine = 0; -PyrSymbol* SC_LanguageClient::s_run = 0; -PyrSymbol* SC_LanguageClient::s_stop = 0; -static PyrSymbol* s_tick = 0; SC_LanguageClient::SC_LanguageClient(const char* name) : mName(0), @@ -419,11 +414,6 @@ void initGUI() void initGUIPrimitives() { - SC_LanguageClient::s_interpretCmdLine = getsym("interpretCmdLine"); - SC_LanguageClient::s_interpretPrintCmdLine = getsym("interpretPrintCmdLine"); - SC_LanguageClient::s_run = getsym("run"); - SC_LanguageClient::s_stop = getsym("stop"); - s_tick = getsym("tick"); SC_LanguageClient::instance()->onLibraryStartup(); } From 76a04da4bb6adae9106617efb178ed7fc8a64e76 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 3 Jan 2013 00:01:19 +0100 Subject: [PATCH 03/10] sclang: terminal client - move PyrSymbol out of the interface Signed-off-by: Tim Blechmann --- include/lang/SC_TerminalClient.h | 6 +++--- lang/LangSource/SC_TerminalClient.cpp | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/lang/SC_TerminalClient.h b/include/lang/SC_TerminalClient.h index 7f15a07fe58..7962f4bf877 100644 --- a/include/lang/SC_TerminalClient.h +++ b/include/lang/SC_TerminalClient.h @@ -91,9 +91,9 @@ class SC_DLLEXPORT SC_TerminalClient : public SC_LanguageClient bool parseOptions(int& argc, char**& argv, Options& opt); void printUsage(); - void interpretCmdLine(struct PyrSymbol* method, class SC_StringBuffer& cmdLine); - void interpretCmdLine(struct PyrSymbol* method, const char* cmdLine); - void interpretCmdLine(struct PyrSymbol* method, const char *buf, size_t size); + void interpretCmdLine(class SC_StringBuffer& cmdLine, bool silent); + void interpretCmdLine(const char* cmdLine, bool silent); + void interpretCmdLine(const char *buf, size_t size, bool silent); void lockInput() { pthread_mutex_lock(&mInputMutex); } void unlockInput() { pthread_mutex_unlock(&mInputMutex); } diff --git a/lang/LangSource/SC_TerminalClient.cpp b/lang/LangSource/SC_TerminalClient.cpp index eb4d4e79752..d9058cd7b9b 100644 --- a/lang/LangSource/SC_TerminalClient.cpp +++ b/lang/LangSource/SC_TerminalClient.cpp @@ -290,26 +290,34 @@ void SC_TerminalClient::quit(int code) mShouldBeRunning = false; } -void SC_TerminalClient::interpretCmdLine(PyrSymbol* method, SC_StringBuffer& cmdLine) +static PyrSymbol * resolveMethodSymbol(bool silent) +{ + if (silent) + return s_interpretCmdLine; + else + return s_interpretPrintCmdLine; +} + +void SC_TerminalClient::interpretCmdLine(SC_StringBuffer& cmdLine, bool silent) { setCmdLine(cmdLine); cmdLine.reset(); - runLibrary(method); + runLibrary(resolveMethodSymbol(silent)); flush(); } -void SC_TerminalClient::interpretCmdLine(PyrSymbol* method, const char* cmdLine) +void SC_TerminalClient::interpretCmdLine(const char* cmdLine, bool silent) { setCmdLine(cmdLine); - runLibrary(method); + runLibrary(resolveMethodSymbol(silent)); flush(); } -void SC_TerminalClient::interpretCmdLine(PyrSymbol* method, const char *cmdLine, size_t size) +void SC_TerminalClient::interpretCmdLine(const char *cmdLine, size_t size, bool silent) { setCmdLine(cmdLine, size); - runLibrary(method); + runLibrary(resolveMethodSymbol(silent)); flush(); } @@ -322,10 +330,10 @@ void SC_TerminalClient::interpretInput() while( i < c ) { switch (data[i]) { case kInterpretCmdLine: - interpretCmdLine(s_interpretCmdLine, data, i); + interpretCmdLine(data, i, true); break; case kInterpretPrintCmdLine: - interpretCmdLine(s_interpretPrintCmdLine, data, i); + interpretCmdLine(data, i, false); break; case kRecompileLibrary: From 0aa87fceda649bbb36ca954c6a572dac1640d153 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 3 Jan 2013 00:08:28 +0100 Subject: [PATCH 04/10] sclang: language client - move private members to hidden class Signed-off-by: Tim Blechmann --- include/lang/SC_LanguageClient.h | 20 +++++--------- include/lang/SC_TerminalClient.h | 2 ++ lang/LangSource/SC_LanguageClient.cpp | 39 +++++++++++++++++++-------- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/include/lang/SC_LanguageClient.h b/include/lang/SC_LanguageClient.h index 8893d14fb8e..eb7dc5c4bf2 100644 --- a/include/lang/SC_LanguageClient.h +++ b/include/lang/SC_LanguageClient.h @@ -26,15 +26,10 @@ #ifndef SC_LANGUAGECLIENT_H_INCLUDED #define SC_LANGUAGECLIENT_H_INCLUDED -#include "SC_StringBuffer.h" #include "SC_Export.h" -#include "SC_Lock.h" -#include "SC_Win32Utils.h" +#include "SC_StringBuffer.h" -#include -#include -#include -#include +#include // ===================================================================== // SC_LanguageClient - abstract sclang client. @@ -78,7 +73,7 @@ class SC_DLLEXPORT SC_LanguageClient void shutdownRuntime(); // return application name - const char* getName() const { return mName; } + const char* getName() const; // library startup/shutdown bool isLibraryCompiled(); @@ -105,8 +100,8 @@ class SC_DLLEXPORT SC_LanguageClient void stopMain(); // post file access - FILE* getPostFile() { return mPostFile; } - void setPostFile(FILE* file) { mPostFile = file; } + FILE* getPostFile(); + void setPostFile(FILE* file); // post buffer output (subclass responsibility) // should be thread-save. @@ -150,10 +145,7 @@ class SC_DLLEXPORT SC_LanguageClient friend void initGUI(); private: - char* mName; - FILE* mPostFile; - SC_StringBuffer mScratch; - bool mRunning; + struct HiddenLanguageClient * mHiddenClient; static SC_LanguageClient* gInstance; }; diff --git a/include/lang/SC_TerminalClient.h b/include/lang/SC_TerminalClient.h index 7962f4bf877..b98f95e67e6 100644 --- a/include/lang/SC_TerminalClient.h +++ b/include/lang/SC_TerminalClient.h @@ -27,6 +27,8 @@ #define SC_TERMINALCLIENT_H_INCLUDED #include "SC_LanguageClient.h" +#include "SC_Lock.h" +#include // ===================================================================== // SC_TerminalClient - command line sclang client. diff --git a/lang/LangSource/SC_LanguageClient.cpp b/lang/LangSource/SC_LanguageClient.cpp index 7d5a45111c9..ebd70cbe352 100644 --- a/lang/LangSource/SC_LanguageClient.cpp +++ b/lang/LangSource/SC_LanguageClient.cpp @@ -25,6 +25,7 @@ #include "SC_LanguageClient.h" #include "SC_LanguageConfig.hpp" +#include "SC_Lock.h" #include #include #include @@ -62,13 +63,25 @@ extern PyrString* newPyrStringN(class PyrGC *gc, long length, long flags, long c SC_LanguageClient* SC_LanguageClient::gInstance = 0; SC_Lock gInstanceMutex; +class HiddenLanguageClient +{ +public: + HiddenLanguageClient(): + mPostFile(0), + mScratch(0), + mRunning(false) + {} + + std::string mName; + FILE* mPostFile; + SC_StringBuffer mScratch; + bool mRunning; +}; SC_LanguageClient::SC_LanguageClient(const char* name) - : mName(0), - mPostFile(0), - mScratch(0), - mRunning(false) { + mHiddenClient = new HiddenLanguageClient; + lockInstance(); if (gInstance) { @@ -77,7 +90,7 @@ SC_LanguageClient::SC_LanguageClient(const char* name) abort(); } - mName = strdup(name); + mHiddenClient->mName = name; gInstance = this; unlockInstance(); @@ -86,7 +99,6 @@ SC_LanguageClient::SC_LanguageClient(const char* name) SC_LanguageClient::~SC_LanguageClient() { lockInstance(); - free(mName); gInstance = 0; unlockInstance(); } @@ -94,7 +106,7 @@ SC_LanguageClient::~SC_LanguageClient() void SC_LanguageClient::initRuntime(const Options& opt) { // start virtual machine - if (!mRunning) { + if (!mHiddenClient->mRunning) { #ifdef __linux__ char deprecatedSupportDirectory[PATH_MAX]; sc_GetUserHomeDirectory(deprecatedSupportDirectory, PATH_MAX); @@ -110,7 +122,7 @@ void SC_LanguageClient::initRuntime(const Options& opt) } #endif - mRunning = true; + mHiddenClient->mRunning = true; if (opt.mRuntimeDir) { int err = chdir(opt.mRuntimeDir); if (err) @@ -176,10 +188,10 @@ void SC_LanguageClient::setCmdLinef(const char* fmt, ...) { va_list ap; va_start(ap, fmt); - mScratch.reset(); - mScratch.vappendf(fmt, ap); + mHiddenClient->mScratch.reset(); + mHiddenClient->mScratch.vappendf(fmt, ap); va_end(ap); - setCmdLine(mScratch); + setCmdLine(mHiddenClient->mScratch); } void SC_LanguageClient::runLibrary(PyrSymbol* symbol) @@ -326,6 +338,11 @@ void SC_LanguageClient::unlockInstance() { gInstanceMutex.Unlock(); } extern bool compiledOK; +const char* SC_LanguageClient::getName() const { return mHiddenClient->mName.c_str(); } + +FILE* SC_LanguageClient::getPostFile() { return mHiddenClient->mPostFile; } +void SC_LanguageClient::setPostFile(FILE* file) { mHiddenClient->mPostFile = file; } + bool SC_LanguageClient::isLibraryCompiled() { return compiledOK; } From 1bae10e6ed0f77077c4cb66aeecb77f83573827e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 3 Jan 2013 00:26:16 +0100 Subject: [PATCH 05/10] sclang: use SC_APP preprocessor symbol to configure scapp build cleans up the initialization code for primitives Signed-off-by: Tim Blechmann --- lang/CMakeLists.txt | 1 - lang/LangPrimSource/PyrPrimitive.cpp | 32 +++++++++++++-------------- lang/LangSource/SC_LanguageClient.cpp | 27 ---------------------- lang/LangSource/cmdLineFuncs.cpp | 21 ------------------ platform/mac/CMakeLists.txt | 4 +++- 5 files changed, 19 insertions(+), 66 deletions(-) diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index ba21e7aefd4..76bfed6eef2 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -126,7 +126,6 @@ if(UNIX) LangPrimSource/SC_CoreAudioPrim.cpp LangPrimSource/SC_Speech.M ) - add_definitions(-DHAVE_SPEECH) if (CMAKE_COMPILER_IS_GNUCXX) set_source_files_properties(LangPrimSource/SC_Speech.M PROPERTIES COMPILE_FLAGS "-x objective-c++ -fobjc-exceptions") diff --git a/lang/LangPrimSource/PyrPrimitive.cpp b/lang/LangPrimSource/PyrPrimitive.cpp index 1c69e55ce4d..f373c2c1693 100644 --- a/lang/LangPrimSource/PyrPrimitive.cpp +++ b/lang/LangPrimSource/PyrPrimitive.cpp @@ -4161,14 +4161,23 @@ void initUnixPrimitives(); void init_OSC_primitives(); init_OSC_primitives(); -/* these probably should be moved out of the Lang code -into an App init primitives section */ +#ifdef SC_APP void initGUIPrimitives(); initGUIPrimitives(); void initSCViewPrimitives(); initSCViewPrimitives(); +void initRendezvousPrimitives(); + initRendezvousPrimitives(); + +void initCocoaFilePrimitives(); + initCocoaFilePrimitives(); + +void initCocoaBridgePrimitives(); + initCocoaBridgePrimitives(); +#endif + void initSchedPrimitives(); initSchedPrimitives(); @@ -4181,15 +4190,6 @@ void initMIDIPrimitives(); void initHIDPrimitives(); initHIDPrimitives(); -void initSpeechPrimitives(); - initSpeechPrimitives(); - -void initCocoaFilePrimitives(); - initCocoaFilePrimitives(); - -void initCocoaBridgePrimitives(); - initCocoaBridgePrimitives(); - void initSerialPrimitives(); initSerialPrimitives(); @@ -4202,15 +4202,16 @@ void initCoreAudioPrimitives(); initCoreAudioPrimitives(); #endif -// CR ADDED -void initRendezvousPrimitives(); - initRendezvousPrimitives(); - #ifdef SCOGL_COMPILE void initOpenGLPrimitives(); initOpenGLPrimitives(); #endif +#ifdef __APPLE__ + void initSpeechPrimitives(); + initSpeechPrimitives(); +#endif + #ifdef SC_QT QtCollider::initPrimitives(); #endif @@ -4224,7 +4225,6 @@ void initOpenGLPrimitives(); s_recvmsg = getsym("receiveMsg"); post("\tNumPrimitives = %d\n", nextPrimitiveIndex()); - } diff --git a/lang/LangSource/SC_LanguageClient.cpp b/lang/LangSource/SC_LanguageClient.cpp index ebd70cbe352..72d5a728ebc 100644 --- a/lang/LangSource/SC_LanguageClient.cpp +++ b/lang/LangSource/SC_LanguageClient.cpp @@ -434,33 +434,6 @@ void initGUIPrimitives() SC_LanguageClient::instance()->onLibraryStartup(); } -void initSCViewPrimitives(); -void initSCViewPrimitives() -{ -} - -void initCocoaFilePrimitives(); -void initCocoaFilePrimitives() -{ -} - -void initCocoaBridgePrimitives(); -void initCocoaBridgePrimitives() -{ -} - -void initRendezvousPrimitives(); -void initRendezvousPrimitives() -{ -} - -#if !defined(HAVE_SPEECH) -void initSpeechPrimitives(); -void initSpeechPrimitives() -{ -} -#endif // HAVE_SPEECH - long scMIDIout(int port, int len, int statushi, int chan, int data1, int data2); long scMIDIout(int port, int len, int statushi, int chan, int data1, int data2) { diff --git a/lang/LangSource/cmdLineFuncs.cpp b/lang/LangSource/cmdLineFuncs.cpp index d8666dc587f..0b6c825549f 100644 --- a/lang/LangSource/cmdLineFuncs.cpp +++ b/lang/LangSource/cmdLineFuncs.cpp @@ -147,27 +147,6 @@ void initGUIPrimitives() { } -void initSCViewPrimitives(); -void initSCViewPrimitives() -{ -} - -void initCocoaFilePrimitives(); -void initCocoaFilePrimitives() -{ -} - -void initCocoaBridgePrimitives(); -void initCocoaBridgePrimitives() -{ -} - -// CR ADDED -void initRendezvousPrimitives(); -void initRendezvousPrimitives() -{ -} - int main(); int main() { diff --git a/platform/mac/CMakeLists.txt b/platform/mac/CMakeLists.txt index 3fbd93977eb..3d22c6aae9e 100644 --- a/platform/mac/CMakeLists.txt +++ b/platform/mac/CMakeLists.txt @@ -198,7 +198,9 @@ endif() set(scapp_parser_source ${CMAKE_SOURCE_DIR}/lang/LangSource/Bison/lang11d_tab.cpp) -add_definitions(-DYYSTACK_USE_ALLOCA -DHAVE_SPEECH) +add_definitions(-DYYSTACK_USE_ALLOCA) + +add_definitions(-DSC_APP) # configure sclang for scapp # set how it shows up in the Info.plist file SET(MACOSX_BUNDLE_ICON_FILE SCcube.icns) From 3692243cb0ac20d92edebefd167ac0f8d98250b2 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 3 Jan 2013 10:29:20 +0100 Subject: [PATCH 06/10] sclang: LanguageClient - move SC_StringBuffer out of the public interface --- include/lang/SC_LanguageClient.h | 4 +--- include/lang/SC_TerminalClient.h | 3 +-- lang/LangSource/SC_LanguageClient.cpp | 13 +++++-------- lang/LangSource/SC_TerminalClient.cpp | 8 -------- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/include/lang/SC_LanguageClient.h b/include/lang/SC_LanguageClient.h index eb7dc5c4bf2..e9d903167c0 100644 --- a/include/lang/SC_LanguageClient.h +++ b/include/lang/SC_LanguageClient.h @@ -1,6 +1,7 @@ /* -*- c++ -*- Abstract interpreter interface. Copyright (c) 2003 2004 stefan kersten. + Copyright (c) 2013 tim blechmann. ==================================================================== @@ -27,8 +28,6 @@ #define SC_LANGUAGECLIENT_H_INCLUDED #include "SC_Export.h" -#include "SC_StringBuffer.h" - #include // ===================================================================== @@ -90,7 +89,6 @@ class SC_DLLEXPORT SC_LanguageClient void setCmdLine(const char* buf, size_t size); void setCmdLine(const char* str); - void setCmdLine(const SC_StringBuffer& strBuf); void setCmdLinef(const char* fmt, ...); void runLibrary(const char* methodName); void interpretCmdLine(); diff --git a/include/lang/SC_TerminalClient.h b/include/lang/SC_TerminalClient.h index b98f95e67e6..9eb19ef9cbe 100644 --- a/include/lang/SC_TerminalClient.h +++ b/include/lang/SC_TerminalClient.h @@ -27,7 +27,7 @@ #define SC_TERMINALCLIENT_H_INCLUDED #include "SC_LanguageClient.h" -#include "SC_Lock.h" +#include "SC_StringBuffer.h" #include // ===================================================================== @@ -93,7 +93,6 @@ class SC_DLLEXPORT SC_TerminalClient : public SC_LanguageClient bool parseOptions(int& argc, char**& argv, Options& opt); void printUsage(); - void interpretCmdLine(class SC_StringBuffer& cmdLine, bool silent); void interpretCmdLine(const char* cmdLine, bool silent); void interpretCmdLine(const char *buf, size_t size, bool silent); diff --git a/lang/LangSource/SC_LanguageClient.cpp b/lang/LangSource/SC_LanguageClient.cpp index 72d5a728ebc..a91dc281277 100644 --- a/lang/LangSource/SC_LanguageClient.cpp +++ b/lang/LangSource/SC_LanguageClient.cpp @@ -49,6 +49,7 @@ #include "VMGlobals.h" #include "SC_DirUtils.h" #include "SCBase.h" +#include "SC_StringBuffer.h" void closeAllGUIScreens(); void initGUI(); @@ -179,19 +180,15 @@ void SC_LanguageClient::setCmdLine(const char* str) setCmdLine(str, strlen(str)); } -void SC_LanguageClient::setCmdLine(const SC_StringBuffer& strBuf) -{ - setCmdLine(strBuf.getData(), strBuf.getSize()); -} - void SC_LanguageClient::setCmdLinef(const char* fmt, ...) { + SC_StringBuffer & scratch = mHiddenClient->mScratch; va_list ap; va_start(ap, fmt); - mHiddenClient->mScratch.reset(); - mHiddenClient->mScratch.vappendf(fmt, ap); + scratch.reset(); + scratch.vappendf(fmt, ap); va_end(ap); - setCmdLine(mHiddenClient->mScratch); + setCmdLine(scratch.getData()); } void SC_LanguageClient::runLibrary(PyrSymbol* symbol) diff --git a/lang/LangSource/SC_TerminalClient.cpp b/lang/LangSource/SC_TerminalClient.cpp index d9058cd7b9b..0d525fd5697 100644 --- a/lang/LangSource/SC_TerminalClient.cpp +++ b/lang/LangSource/SC_TerminalClient.cpp @@ -298,14 +298,6 @@ static PyrSymbol * resolveMethodSymbol(bool silent) return s_interpretPrintCmdLine; } -void SC_TerminalClient::interpretCmdLine(SC_StringBuffer& cmdLine, bool silent) -{ - setCmdLine(cmdLine); - cmdLine.reset(); - runLibrary(resolveMethodSymbol(silent)); - flush(); -} - void SC_TerminalClient::interpretCmdLine(const char* cmdLine, bool silent) { setCmdLine(cmdLine); From 67d225a717a1a3774f95fa42be5224172aef32e0 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 3 Jan 2013 11:50:51 +0100 Subject: [PATCH 07/10] sclang: LanguageClient - provide factory function Signed-off-by: Tim Blechmann --- include/lang/SC_LanguageClient.h | 10 +- lang/LangSource/SC_LanguageClient.cpp | 4 + lang/LangSource/SC_TerminalClient.cpp | 20 ++++ lang/LangSource/cmdLineFuncs.cpp | 149 ++------------------------ 4 files changed, 39 insertions(+), 144 deletions(-) diff --git a/include/lang/SC_LanguageClient.h b/include/lang/SC_LanguageClient.h index e9d903167c0..c59ce18a721 100644 --- a/include/lang/SC_LanguageClient.h +++ b/include/lang/SC_LanguageClient.h @@ -34,7 +34,8 @@ // SC_LanguageClient - abstract sclang client. // ===================================================================== -struct VMGlobals; +SC_DLLEXPORT class SC_LanguageClient * createLanguageClient(const char * name); +SC_DLLEXPORT void destroyLanguageClient(class SC_LanguageClient *); class SC_DLLEXPORT SC_LanguageClient { @@ -54,11 +55,13 @@ class SC_DLLEXPORT SC_LanguageClient char* mRuntimeDir; // runtime directory }; -public: +protected: // create singleton instance SC_LanguageClient(const char* name); virtual ~SC_LanguageClient(); + friend void destroyLanguageClient(class SC_LanguageClient *); +public: // singleton instance access locking static void lockInstance(); static void unlockInstance(); @@ -101,6 +104,9 @@ class SC_DLLEXPORT SC_LanguageClient FILE* getPostFile(); void setPostFile(FILE* file); + // run (in case of a terminal client) + virtual int run(int argc, char** argv); + // post buffer output (subclass responsibility) // should be thread-save. virtual void postText(const char* str, size_t len) = 0; diff --git a/lang/LangSource/SC_LanguageClient.cpp b/lang/LangSource/SC_LanguageClient.cpp index a91dc281277..3e1e1e05f4d 100644 --- a/lang/LangSource/SC_LanguageClient.cpp +++ b/lang/LangSource/SC_LanguageClient.cpp @@ -342,6 +342,10 @@ void SC_LanguageClient::setPostFile(FILE* file) { mHiddenClient->mPostFile = fi bool SC_LanguageClient::isLibraryCompiled() { return compiledOK; } +int SC_LanguageClient::run(int argc, char **argv) +{ + throw std::runtime_error("SC_LanguageClient::run only supported on terminal client"); +} // ===================================================================== // library functions diff --git a/lang/LangSource/SC_TerminalClient.cpp b/lang/LangSource/SC_TerminalClient.cpp index 0d525fd5697..b010d6f8e03 100644 --- a/lang/LangSource/SC_TerminalClient.cpp +++ b/lang/LangSource/SC_TerminalClient.cpp @@ -24,6 +24,7 @@ */ #include "SC_TerminalClient.h" +#include "../../QtCollider/LanguageClient.h" #include #include @@ -874,4 +875,23 @@ int SC_TerminalClient::prRecompile(struct VMGlobals *, int) static_cast(instance())->sendSignal(sig_recompile); return errNone; } + +SC_DLLEXPORT SC_LanguageClient * createLanguageClient(const char * name) +{ + if (SC_LanguageClient::instance()) + return NULL; + +#ifdef SC_QT + return new QtCollider::LangClient(name); +#else + return new SC_TerminalClient(name); +#endif +} + +SC_DLLEXPORT void destroyLanguageClient(class SC_LanguageClient * languageClient) +{ + delete languageClient; +} + + // EOF diff --git a/lang/LangSource/cmdLineFuncs.cpp b/lang/LangSource/cmdLineFuncs.cpp index 0b6c825549f..3db1583fba7 100644 --- a/lang/LangSource/cmdLineFuncs.cpp +++ b/lang/LangSource/cmdLineFuncs.cpp @@ -18,149 +18,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -// #ifdef SC_DARWIN -// # define USE_SC_TERMINAL_CLIENT 0 -// #else -// # define USE_SC_TERMINAL_CLIENT 1 -// #endif - -#if USE_SC_TERMINAL_CLIENT - -#include "SC_TerminalClient.h" - -#ifdef SC_QT -# include "QtCollider.h" -#endif - -#include +#include "SC_LanguageClient.h" int main(int argc, char** argv) { -#ifdef SC_QT - return QtCollider::run(argc, argv); -#else - SC_TerminalClient app("sclang"); - return app.run(argc, argv); -#endif -} - -#else // !USE_SC_TERMINAL_CLIENT - -#include "PyrSymbol.h" -#include "PyrObject.h" -#include "InitAlloc.h" -#include -#include "SCBase.h" - - -static FILE *postfile = stdout; - -void setPostFile(FILE *file) { postfile = file; } - - -void postfl(const char *fmt, ...); -void postfl(const char *fmt, ...) -{ - va_list vargs; - va_start(vargs, fmt); - vfprintf(postfile, fmt, vargs); - fflush(postfile); -} - -extern "C" { - int vpost(const char *fmt, va_list vargs); + SC_LanguageClient * client = createLanguageClient("sclang"); + if (!client) + return 1; + int returnCode = client->run(argc, argv); + destroyLanguageClient(client); + return returnCode; } - -int vpost(const char *fmt, va_list vargs) -{ - return vfprintf(postfile, fmt, vargs); - fflush(postfile); -} - -void post(const char *fmt, ...); -void post(const char *fmt, ...) -{ - va_list vargs; - va_start(vargs, fmt); - vfprintf(postfile, fmt, vargs); - //fflush(postfile); -} - -void error(const char *fmt, ...); -void error(const char *fmt, ...) -{ - fprintf(postfile, "ERROR: "); - va_list vargs; - va_start(vargs, fmt); - vfprintf(postfile, fmt, vargs); - fflush(postfile); -} - -void postText(const char *text, long length); -void postText(const char *text, long length) -{ - fwrite(text, sizeof(char), length, postfile); -} - -void postChar(char c); -void postChar(char c) -{ - fputc(c, postfile); -} - -void flushPostBuf(); -void flushPostBuf() -{ - fflush(postfile); -} - -long scMIDIout(int port, int len, int statushi, int chan, int data1, int data2); -long scMIDIout(int port, int len, int statushi, int chan, int data1, int data2) -{ - return 0; -} - -/* -void tellPlugInsAboutToCompile(); -void tellPlugInsAboutToCompile() -{ -} - -void tellPlugInsAboutToRun(); -void tellPlugInsAboutToRun() -{ -} -*/ - -void closeAllGUIScreens(); -void closeAllGUIScreens() -{ -} - -void initGUI(); -void initGUI() -{ -} - -void initGUIPrimitives(); -void initGUIPrimitives() -{ -} - -int main(); -int main() -{ - - pyr_init_mem_pools(2*1024*1024, 256*1024); - init_OSC(57120); - schedInit(); - - compileLibrary(); - runLibrary(s_run); fflush(postfile); - - cleanup_OSC(); - - return 0; -} - -#endif // USE_SC_TERMINAL_CLIENT From 098c32bff80fe12abd4cf610b48bbdc70519ddf5 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 3 Jan 2013 12:23:01 +0100 Subject: [PATCH 08/10] common: move private headers from include/common to common Signed-off-by: Tim Blechmann --- {include/common => common}/MsgFifo.h | 0 {include/common => common}/SC_AllocPool.h | 0 {include/common => common}/SC_DirUtils.h | 0 {include/common => common}/SC_List.h | 0 {include/common => common}/SC_Sem.h | 0 .../SC_StandAloneInfo_Darwin.h | 0 {include/common => common}/SC_StringParser.h | 0 {include/common => common}/SC_SyncCondition.h | 0 {include/common => common}/SC_VFP11.h | 0 {include/common => common}/SC_Win32Utils.h | 0 {include/common => common}/fftlib.h | 0 {include/common => common}/sc_popen.h | 0 {include/common => common}/scsynthsend.h | 0 editors/sc-ide/CMakeLists.txt | 1 + .../sc-ide/widgets/settings/sclang_page.cpp | 2 +- include/common/dfftlib.h | 62 ------------------- .../common => lang/LangPrimSource}/SC_FIFO.h | 0 server/plugins/CMakeLists.txt | 1 + .../common => server/plugins}/SC_Altivec.h | 0 server/supernova/CMakeLists.txt | 1 + 20 files changed, 4 insertions(+), 63 deletions(-) rename {include/common => common}/MsgFifo.h (100%) rename {include/common => common}/SC_AllocPool.h (100%) rename {include/common => common}/SC_DirUtils.h (100%) rename {include/common => common}/SC_List.h (100%) rename {include/common => common}/SC_Sem.h (100%) rename {include/common => common}/SC_StandAloneInfo_Darwin.h (100%) rename {include/common => common}/SC_StringParser.h (100%) rename {include/common => common}/SC_SyncCondition.h (100%) rename {include/common => common}/SC_VFP11.h (100%) rename {include/common => common}/SC_Win32Utils.h (100%) rename {include/common => common}/fftlib.h (100%) rename {include/common => common}/sc_popen.h (100%) rename {include/common => common}/scsynthsend.h (100%) delete mode 100644 include/common/dfftlib.h rename {include/common => lang/LangPrimSource}/SC_FIFO.h (100%) rename {include/common => server/plugins}/SC_Altivec.h (100%) diff --git a/include/common/MsgFifo.h b/common/MsgFifo.h similarity index 100% rename from include/common/MsgFifo.h rename to common/MsgFifo.h diff --git a/include/common/SC_AllocPool.h b/common/SC_AllocPool.h similarity index 100% rename from include/common/SC_AllocPool.h rename to common/SC_AllocPool.h diff --git a/include/common/SC_DirUtils.h b/common/SC_DirUtils.h similarity index 100% rename from include/common/SC_DirUtils.h rename to common/SC_DirUtils.h diff --git a/include/common/SC_List.h b/common/SC_List.h similarity index 100% rename from include/common/SC_List.h rename to common/SC_List.h diff --git a/include/common/SC_Sem.h b/common/SC_Sem.h similarity index 100% rename from include/common/SC_Sem.h rename to common/SC_Sem.h diff --git a/include/common/SC_StandAloneInfo_Darwin.h b/common/SC_StandAloneInfo_Darwin.h similarity index 100% rename from include/common/SC_StandAloneInfo_Darwin.h rename to common/SC_StandAloneInfo_Darwin.h diff --git a/include/common/SC_StringParser.h b/common/SC_StringParser.h similarity index 100% rename from include/common/SC_StringParser.h rename to common/SC_StringParser.h diff --git a/include/common/SC_SyncCondition.h b/common/SC_SyncCondition.h similarity index 100% rename from include/common/SC_SyncCondition.h rename to common/SC_SyncCondition.h diff --git a/include/common/SC_VFP11.h b/common/SC_VFP11.h similarity index 100% rename from include/common/SC_VFP11.h rename to common/SC_VFP11.h diff --git a/include/common/SC_Win32Utils.h b/common/SC_Win32Utils.h similarity index 100% rename from include/common/SC_Win32Utils.h rename to common/SC_Win32Utils.h diff --git a/include/common/fftlib.h b/common/fftlib.h similarity index 100% rename from include/common/fftlib.h rename to common/fftlib.h diff --git a/include/common/sc_popen.h b/common/sc_popen.h similarity index 100% rename from include/common/sc_popen.h rename to common/sc_popen.h diff --git a/include/common/scsynthsend.h b/common/scsynthsend.h similarity index 100% rename from include/common/scsynthsend.h rename to common/scsynthsend.h diff --git a/editors/sc-ide/CMakeLists.txt b/editors/sc-ide/CMakeLists.txt index 06fb2de77af..3b3bafa95d7 100644 --- a/editors/sc-ide/CMakeLists.txt +++ b/editors/sc-ide/CMakeLists.txt @@ -127,6 +127,7 @@ elseif(WIN32) endif() include_directories(${CMAKE_SOURCE_DIR}/include/common) +include_directories(${CMAKE_SOURCE_DIR}/common) include_directories(${CMAKE_SOURCE_DIR}/include/plugin_interface) include_directories(${YAMLCPP_INCLUDE_DIR}) include_directories(${CMAKE_SOURCE_DIR}/external_libraries/boost) diff --git a/editors/sc-ide/widgets/settings/sclang_page.cpp b/editors/sc-ide/widgets/settings/sclang_page.cpp index 57c1dc6fabc..d216b13d3fa 100644 --- a/editors/sc-ide/widgets/settings/sclang_page.cpp +++ b/editors/sc-ide/widgets/settings/sclang_page.cpp @@ -27,7 +27,7 @@ #include "ui_settings_sclang.h" #include "../../core/settings/manager.hpp" -#include "include/common/SC_DirUtils.h" +#include "common/SC_DirUtils.h" #include "yaml-cpp/yaml.h" diff --git a/include/common/dfftlib.h b/include/common/dfftlib.h deleted file mode 100644 index 409267e7a6f..00000000000 --- a/include/common/dfftlib.h +++ /dev/null @@ -1,62 +0,0 @@ -long dFFTInit(long *fftMptr, long fftN, double *Utbl); -/* Compute cosine table and check size for complex ffts */ -/* INPUTS */ -/* fftN = size of fft */ -/* OUTPUTS */ -/* *fftMptr = log2 of fft size */ -/* *Utbl = cosine table with fftN/4 + 1 entries (angles = 0 to pi/2 inclusive) */ -/* RETURNS */ -/* 1 if fftN is invalid, 0 otherwise */ - -long drFFTInit(long *fftMptr, long fftN, double *Utbl); -/* Compute cosine table and check size for a real input fft */ -/* INPUTS */ -/* fftN = size of fft */ -/* OUTPUTS */ -/* *fftMptr = log2 of fft size */ -/* *Utbl = cosine table with fftN/4 + 1 entries (angles = 0 to pi/2 inclusive) */ -/* RETURNS */ -/* 1 if fftN is invalid, 0 otherwise */ - -void dffts(double *ioptr, long M, long Rows, double *Utbl); -/* Compute in-place complex fft on the rows of the input array */ -/* INPUTS */ -/* M = log2 of fft size */ -/* *ioptr = input data array */ -/* *Utbl = cosine table */ -/* Rows = number of rows in ioptr array (use Rows of 1 if ioptr is a 1 dimensional array) */ -/* OUTPUTS */ -/* *ioptr = output data array */ - -void diffts(double *ioptr, long M, long Rows, double *Utbl); -/* Compute in-place inverse complex fft on the rows of the input array */ -/* INPUTS */ -/* M = log2 of fft size */ -/* *ioptr = input data array */ -/* *Utbl = cosine table */ -/* Rows = number of rows in ioptr array (use Rows of 1 if ioptr is a 1 dimensional array) */ -/* OUTPUTS */ -/* *ioptr = output data array */ - -void drffts(double *ioptr, long M, long Rows, double *Utbl); -/* Compute in-place real fft on the rows of the input array */ -/* INPUTS */ -/* M = log2 of fft size */ -/* *ioptr = real input data array */ -/* *Utbl = cosine table */ -/* Rows = number of rows in ioptr array (use Rows of 1 if ioptr is a 1 dimensional array) */ -/* OUTPUTS */ -/* *ioptr = output data array in the following order */ -/* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ - - -void driffts(double *ioptr, long M, long Rows, double *Utbl); -/* Compute in-place real ifft on the rows of the input array */ -/* INPUTS */ -/* M = log2 of fft size */ -/* *ioptr = input data array in the following order */ -/* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ -/* *Utbl = cosine table */ -/* Rows = number of rows in ioptr array (use Rows of 1 if ioptr is a 1 dimensional array) */ -/* OUTPUTS */ -/* *ioptr = real output data array */ diff --git a/include/common/SC_FIFO.h b/lang/LangPrimSource/SC_FIFO.h similarity index 100% rename from include/common/SC_FIFO.h rename to lang/LangPrimSource/SC_FIFO.h diff --git a/server/plugins/CMakeLists.txt b/server/plugins/CMakeLists.txt index a3840d7ba7d..abf9682e1eb 100644 --- a/server/plugins/CMakeLists.txt +++ b/server/plugins/CMakeLists.txt @@ -6,6 +6,7 @@ else() endif() include_directories(${CMAKE_SOURCE_DIR}/include/common + ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/include/plugin_interface) if (NOVA_SIMD) diff --git a/include/common/SC_Altivec.h b/server/plugins/SC_Altivec.h similarity index 100% rename from include/common/SC_Altivec.h rename to server/plugins/SC_Altivec.h diff --git a/server/supernova/CMakeLists.txt b/server/supernova/CMakeLists.txt index e51954836ec..d92513dc31a 100644 --- a/server/supernova/CMakeLists.txt +++ b/server/supernova/CMakeLists.txt @@ -63,6 +63,7 @@ endif() include_directories(${CMAKE_SOURCE_DIR}/include/plugin_interface ${CMAKE_SOURCE_DIR}/include/common + ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/include/server ${CMAKE_SOURCE_DIR}/server/scsynth . From 55af999c74a86642b24a5c7b27ad7c6b17d0567e Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 3 Jan 2013 12:25:59 +0100 Subject: [PATCH 09/10] plugin interface: move struct SC_Lock out of the public interface plugins only acquire the NRT lock, but should to that via the interface table Signed-off-by: Tim Blechmann --- {include/common => common}/SC_Lock.h | 0 include/plugin_interface/SC_World.h | 5 ++--- server/plugins/UIUGens.cpp | 1 + server/supernova/sc/sc_plugin_interface.cpp | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) rename {include/common => common}/SC_Lock.h (100%) diff --git a/include/common/SC_Lock.h b/common/SC_Lock.h similarity index 100% rename from include/common/SC_Lock.h rename to common/SC_Lock.h diff --git a/include/plugin_interface/SC_World.h b/include/plugin_interface/SC_World.h index 668abdb3aaf..a10cceb83be 100644 --- a/include/plugin_interface/SC_World.h +++ b/include/plugin_interface/SC_World.h @@ -26,7 +26,6 @@ #include "SC_Rate.h" #include "SC_SndBuf.h" #include "SC_RGen.h" -#include "SC_Lock.h" #ifdef SUPERNOVA namespace nova @@ -82,7 +81,7 @@ struct World uint32 mNumUnits, mNumGraphs, mNumGroups; int mSampleOffset; // offset in the buffer of current event time. - SC_Lock* mNRTLock; + struct SC_Lock* mNRTLock; uint32 mNumSharedControls; float *mSharedControls; @@ -91,7 +90,7 @@ struct World bool mRunning; int mDumpOSC; - SC_Lock* mDriverLock; + struct SC_Lock* mDriverLock; float mSubsampleOffset; // subsample accurate offset in the buffer of current event time. diff --git a/server/plugins/UIUGens.cpp b/server/plugins/UIUGens.cpp index 42deacb678a..ddb4b530cd9 100644 --- a/server/plugins/UIUGens.cpp +++ b/server/plugins/UIUGens.cpp @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #ifdef __APPLE__ #include diff --git a/server/supernova/sc/sc_plugin_interface.cpp b/server/supernova/sc/sc_plugin_interface.cpp index 4c9cc3c8ed1..856dcab0186 100644 --- a/server/supernova/sc/sc_plugin_interface.cpp +++ b/server/supernova/sc/sc_plugin_interface.cpp @@ -37,6 +37,7 @@ #include "SC_Unit.h" #include "clz.h" #include "SC_fftlib.h" +#include "SC_Lock.h" #include "../../common/Samp.hpp" #include "../../common/SC_SndFileHelpers.hpp" From fa5cf49508f680b973e5abbb8a0a748a3c3b7d80 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 3 Jan 2013 12:28:45 +0100 Subject: [PATCH 10/10] scapp: add include dirs for private headers Signed-off-by: Tim Blechmann --- platform/mac/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/mac/CMakeLists.txt b/platform/mac/CMakeLists.txt index 3d22c6aae9e..e7b4dc2ef7d 100644 --- a/platform/mac/CMakeLists.txt +++ b/platform/mac/CMakeLists.txt @@ -24,6 +24,10 @@ include_directories( ${CMAKE_SOURCE_DIR}/include/plugin_interface ${CMAKE_SOURCE_DIR}/include/server ${CMAKE_SOURCE_DIR}/common + ${CMAKE_SOURCE_DIR}/server/scsynth + ${CMAKE_SOURCE_DIR}/lang/LangSource + ${CMAKE_SOURCE_DIR}/lang/LangPrimSource + ${CMAKE_SOURCE_DIR}/editors/scapp/include ${CMAKE_SOURCE_DIR}/editors/scapp/include/SMLAdvancedFind ${CMAKE_SOURCE_DIR}/editors/scapp/include/SMLAdvancedFind/ICU