Unified · Split
| @@ -120,9 +120,17 @@ CK_DLL_TICK(bitcrusher_tick) · 119 unmodified lines | ||
| 120 | 120 | |
| 121 | 121 | // convert to 32-bit int |
| 122 | 122 | t_CKINT shift = 32-bcdata->bits; |
| 123 | − int q32 = theSample * INT_MAX; | |
| 123 | + // cast to double for avoid floating point precision warning/error | (ge) 2023.4.14 | |
| 124 | + // "implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648" | |
| 125 | + // https://stackoverflow.com/questions/23420783/convert-int-max-to-float-and-then-back-to-integer | |
| 126 | + // for example... | |
| 127 | + // int i = ((float)(INT_MAX)); // on mac (intel and arm64) seem to produce arbitrary and different values | |
| 128 | + // int i = ((float)(INT_MAX)-64); // on mac appears stable | |
| 129 | + // int i = ((double)(INT_MAX)); // on mac appears stable | |
| 130 | + // int i = ((double)(INT_MAX)+.1); // on mac appears stable | |
| 131 | + // int i = ((double)(INT_MAX)+1); // on mac not stable | |
| 132 | + int q32 = ((double)theSample) * INT_MAX; | |
| 124 | 133 | q32 = (q32 >> shift) << shift; |
| 125 | − | |
| 126 | 134 | *out = q32 / ((float) INT_MAX); |
| 127 | 135 | |
| 128 | 136 | return TRUE; |
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | |
| 2 | −ARCHS?=x86_64 | |
| 2 | +ARCHS?=arm64 | |
| 3 | 3 | ARCHOPTS=$(addprefix -arch ,$(ARCHS)) |
| 4 | 4 | |
| 5 | 5 | FLAGS+=-mmacosx-version-min=10.9 -D__MACOSX_CORE__ -I$(CK_SRC_PATH) $(ARCHOPTS) -fPIC -I/usr/local/include |
| 6 | −LDFLAGS+=-mmacosx-version-min=10.9 -L/usr/local/lib -shared -lc++ $(ARCHOPTS) -lfaust `llvm-config-mp-3.5 --ldflags --libs all` -lcrypto -lz -lcurses -lc++ | |
| 6 | +LDFLAGS+=-mmacosx-version-min=10.9 -L/usr/local/lib -shared -lc++ $(ARCHOPTS) -lfaust `llvm-config --ldflags --libs all` -lz -lcurses -lc++ | |
| 7 | 7 | |
| 8 | 8 | LD=clang++ |
| 9 | 9 | CXX=clang++ |
| @@ -175,12 +175,10 @@ protected: · 174 unmodified lines | ||
| 175 | 175 | public: // static functions |
| 176 | 176 | // chuck version |
| 177 | 177 | static const char * version(); |
| 178 | − #ifndef __DISABLE_OTF_SERVER__ | |
| 179 | 178 | // chuck int size (in bits) |
| 180 | − // (this depends on machine, which depends on OTF, so | |
| 181 | − // disable it if we don't have OTF) | |
| 179 | + // (this depends on machine, which depends on OTF, so disable it if we don't have OTF) | |
| 180 | + // 1.5.0.0 (ge) | reinstated for non-OTF, along with parts of machine | |
| 182 | 181 | static t_CKUINT intSize(); |
| 183 | − #endif | |
| 184 | 182 | // number of ChucK's |
| 185 | 183 | static t_CKUINT numVMs() { return o_numVMs; }; |
| 186 | 184 | // --poop compatibilty |
| @@ -67,7 +67,6 @@ public: // get protected data · 66 unmodified lines | ||
| 67 | 67 | // set carrier |
| 68 | 68 | t_CKBOOL setCarrier( Chuck_Carrier * c ) { m_carrier = c; return TRUE; } |
| 69 | 69 | |
| 70 | − | |
| 71 | 70 | public: // data |
| 72 | 71 | // emitter |
| 73 | 72 | Chuck_Emitter * emitter; |
| @@ -79,9 +78,15 @@ public: // data · 5 unmodified lines | ||
| 79 | 78 | // recent map |
| 80 | 79 | std::map<std::string, Chuck_Context *> m_recent; |
| 81 | 80 | |
| 81 | + // chugins | |
| 82 | 82 | std::list<Chuck_DLL *> m_dlls; |
| 83 | + // libraries (ck code) to import | |
| 83 | 84 | std::list<std::string> m_cklibs_to_preload; |
| 84 | 85 | |
| 86 | + // origin hint; this flag is set to different te_Origin values | |
| 87 | + // to denote where new entities originate | 1.5.0.0 (ge) added | |
| 88 | + te_Origin m_originHint; | |
| 89 | + | |
| 85 | 90 | public: // to all |
| 86 | 91 | // contructor |
| 87 | 92 | Chuck_Compiler(); |
| @@ -154,6 +154,8 @@ typedef struct { SAMPLE re ; SAMPLE im ; } t_CKCOMPLEX_SAMPLE; · 153 unmodified lines | ||
| 154 | 154 | #define SAFE_RELEASE(x) do { if(x){ x->release(); x = NULL; } } while(0) |
| 155 | 155 | #define SAFE_ADD_REF(x) do { if(x){ x->add_ref(); } } while(0) |
| 156 | 156 | #define SAFE_REF_ASSIGN(lhs,rhs) do { SAFE_RELEASE(lhs); (lhs) = (rhs); SAFE_ADD_REF(lhs); } while(0) |
| 157 | +#define SAFE_FREE(x) do { if(x){ free(x); x = NULL; } } while(0) | |
| 158 | +#define SAFE_UNLOCK_DELETE(x) do { if(x){ x->unlock(); delete x; x = NULL; } } while(0) | |
| 157 | 159 | #endif |
| 158 | 160 | |
| 159 | 161 | // max + min |
| @@ -191,7 +193,12 @@ typedef struct { SAMPLE re ; SAMPLE im ; } t_CKCOMPLEX_SAMPLE; · 31 unmodified lines | ||
| 191 | 193 | |
| 192 | 194 | #ifdef __PLATFORM_WIN32__ |
| 193 | 195 | #ifndef usleep |
| 194 | −#define usleep(x) Sleep( (x / 1000 <= 0 ? 1 : x / 1000) ) | |
| 196 | + #define usleep(x) Sleep( (x / 1000 <= 0 ? 1 : x / 1000) ) | |
| 197 | +#endif | |
| 198 | +// 1.4.2.0 (ge and spencer) | added for legacy windows, as part of switch to snprintf | |
| 199 | +// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 | |
| 200 | +#if defined(_MSC_VER) && _MSC_VER < 1900 | |
| 201 | + #define snprintf(buf,len, format,...) _snprintf_s(buf, len,len, format, __VA_ARGS__) | |
| 195 | 202 | #endif |
| 196 | 203 | #pragma warning (disable : 4996) // stdio deprecation |
| 197 | 204 | #pragma warning (disable : 4786) // stl debug info |
| @@ -161,7 +161,7 @@ namespace Chuck_DL_Api { struct Api; } · 160 unmodified lines | ||
| 161 | 161 | #endif |
| 162 | 162 | |
| 163 | 163 | // calling convention of functions provided by chuck to the dll |
| 164 | −#if defined(__WINDOWS_DS__) | |
| 164 | +#if defined(__PLATFORM_WIN32__) | |
| 165 | 165 | #define CK_DLL_CALL _cdecl |
| 166 | 166 | #else |
| 167 | 167 | #define CK_DLL_CALL |
| @@ -676,7 +676,7 @@ public: · 508 unmodified lines | ||
| 676 | 676 | { |
| 677 | 677 | ObjectApi(); |
| 678 | 678 | |
| 679 | − // 1.4.2.1 (nshaheed and ge and anonymous pr-lab member) | changed from private to public | |
| 679 | + // 1.5.0.0 (nshaheed and ge and anonymous pr-lab member) | changed from private to public | |
| 680 | 680 | // also changed all std::string & in this section to const char * |
| 681 | 681 | // intent: this allows for chugins to access member variables and create chuck strings |
| 682 | 682 | public: |
| @@ -724,7 +724,7 @@ private: · 41 unmodified lines | ||
| 724 | 724 | |
| 725 | 725 | #error ChucK not support on Mac OS X 10.3 or lower |
| 726 | 726 | |
| 727 | −#elif defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) | |
| 727 | +#elif defined(__PLATFORM_WIN32__) | |
| 728 | 728 | |
| 729 | 729 | #ifdef __cplusplus |
| 730 | 730 | extern "C" { |
| @@ -148,7 +148,9 @@ struct Chuck_Emitter : public Chuck_VM_Object · 147 unmodified lines | ||
| 148 | 148 | // add references to locals on current scope (added 1.3.0.0) |
| 149 | 149 | void addref_on_scope(); |
| 150 | 150 | // pop scope |
| 151 | − void pop_scope( ); | |
| 151 | + void pop_scope(); | |
| 152 | + // traverse scope on jumps such as 'return' 'break' 'continue' | 1.5.0.0 (ge) | |
| 153 | + void traverse_scope_on_jump(); | |
| 152 | 154 | |
| 153 | 155 | // default durations |
| 154 | 156 | t_CKBOOL find_dur( const std::string & name, t_CKDUR * out ); |
| @@ -53,7 +53,7 @@ extern t_CKINT EM_extLineNum; · 52 unmodified lines | ||
| 53 | 53 | void EM_newline( ); |
| 54 | 54 | |
| 55 | 55 | // levels |
| 56 | −#define CK_LOG_CRAZY 10 // set this to log everything | |
| 56 | +#define CK_LOG_ALL 10 // set this to log everything | |
| 57 | 57 | #define CK_LOG_FINEST 9 |
| 58 | 58 | #define CK_LOG_FINER 8 |
| 59 | 59 | #define CK_LOG_FINE 7 |
| @@ -92,7 +92,7 @@ public: · 91 unmodified lines | ||
| 92 | 92 | Chuck_Local * alloc_local( t_CKUINT size, const std::string & name, |
| 93 | 93 | t_CKBOOL is_ref, t_CKBOOL is_obj, t_CKBOOL is_global ); |
| 94 | 94 | // get the current scope (added 1.3.0.0) |
| 95 | − void get_scope( std::vector<Chuck_Local *> & out ) const; | |
| 95 | + void get_scope( std::vector<Chuck_Local *> & out, bool localOnly = true ) const; | |
| 96 | 96 | // pop scope |
| 97 | 97 | void pop_scope( std::vector<Chuck_Local *> & out ); |
| 98 | 98 | }; |
| @@ -58,7 +58,7 @@ struct Chuck_Instr · 57 unmodified lines | ||
| 58 | 58 | { |
| 59 | 59 | public: |
| 60 | 60 | Chuck_Instr(); |
| 61 | − virtual ~Chuck_Instr() { } | |
| 61 | + virtual ~Chuck_Instr() { SAFE_DELETE(m_codestr); } | |
| 62 | 62 | |
| 63 | 63 | public: |
| 64 | 64 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) = 0; |
| @@ -69,8 +69,14 @@ public: · 4 unmodified lines | ||
| 69 | 69 | { return ""; } |
| 70 | 70 | |
| 71 | 71 | public: |
| 72 | + // store line position for error messages | |
| 72 | 73 | void set_linepos( t_CKUINT linepos ); |
| 73 | 74 | t_CKUINT m_linepos; |
| 75 | + | |
| 76 | + // set codestr associated with this instruction | |
| 77 | + void set_codestr( const std::string & str ); | |
| 78 | + // (used in instruction dump) | 1.5.0.0 (ge) added | |
| 79 | + std::string * m_codestr; | |
| 74 | 80 | }; |
| 75 | 81 | |
| 76 | 82 | |
| @@ -2017,6 +2023,23 @@ protected: · 1940 unmodified lines | ||
| 2017 | 2023 | |
| 2018 | 2024 | |
| 2019 | 2025 | |
| 2026 | +//----------------------------------------------------------------------------- | |
| 2027 | +// name: struct Chuck_Instr_Reg_Push_Zero | |
| 2028 | +// desc: push immediate value 0 to reg stack with specific width | |
| 2029 | +//----------------------------------------------------------------------------- | |
| 2030 | +struct Chuck_Instr_Reg_Push_Zero : public Chuck_Instr_Unary_Op | |
| 2031 | +{ | |
| 2032 | +public: | |
| 2033 | + Chuck_Instr_Reg_Push_Zero( t_CKUINT sizeInBytes ) | |
| 2034 | + { this->set( sizeInBytes ); } | |
| 2035 | + | |
| 2036 | +public: | |
| 2037 | + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); | |
| 2038 | +}; | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2020 | 2043 | //----------------------------------------------------------------------------- |
| 2021 | 2044 | // name: struct Chuck_Instr_Reg_Dup_Last |
| 2022 | 2045 | // desc: duplicate last value on reg stack |
| @@ -2960,6 +2983,7 @@ public: · 937 unmodified lines | ||
| 2960 | 2983 | //----------------------------------------------------------------------------- |
| 2961 | 2984 | // name: struct Chuck_Instr_Reg_AddRef_Object3 |
| 2962 | 2985 | // desc: added 1.3.0.0 -- does the ref add in-place |
| 2986 | +// operates on top of the register stack | |
| 2963 | 2987 | //----------------------------------------------------------------------------- |
| 2964 | 2988 | struct Chuck_Instr_Reg_AddRef_Object3 : public Chuck_Instr |
| 2965 | 2989 | { |
| @@ -2972,7 +2996,7 @@ public: · 6 unmodified lines | ||
| 2972 | 2996 | |
| 2973 | 2997 | //----------------------------------------------------------------------------- |
| 2974 | 2998 | // name: struct Chuck_Instr_Release_Object |
| 2975 | −// desc: ... | |
| 2999 | +// desc: release object on stack by its offset | |
| 2976 | 3000 | //----------------------------------------------------------------------------- |
| 2977 | 3001 | struct Chuck_Instr_Release_Object : public Chuck_Instr |
| 2978 | 3002 | { |
| @@ -3001,6 +3025,38 @@ public: · 22 unmodified lines | ||
| 3001 | 3025 | |
| 3002 | 3026 | |
| 3003 | 3027 | |
| 3028 | +//----------------------------------------------------------------------------- | |
| 3029 | +// name: struct Chuck_Instr_Release_Object3_Pop_Word | |
| 3030 | +// desc: release object reference + pop from reg stack | 1.5.0.0 (ge) added | |
| 3031 | +// the variant assumes object pointer directly on stack (not offset) | |
| 3032 | +//----------------------------------------------------------------------------- | |
| 3033 | +struct Chuck_Instr_Release_Object3_Pop_Word : public Chuck_Instr | |
| 3034 | +{ | |
| 3035 | +public: | |
| 3036 | + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); | |
| 3037 | +}; | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | +//----------------------------------------------------------------------------- | |
| 3043 | +// name: struct Chuck_Instr_Release_Object4 | |
| 3044 | +// desc: release object reference from reg stack (no pop) | 1.5.0.0 (ge) added | |
| 3045 | +// the variant assumes object pointer directly on stack (not offset) | |
| 3046 | +//----------------------------------------------------------------------------- | |
| 3047 | +struct Chuck_Instr_Release_Object4 : public Chuck_Instr_Unary_Op | |
| 3048 | +{ | |
| 3049 | +public: | |
| 3050 | + Chuck_Instr_Release_Object4( t_CKUINT offset ) | |
| 3051 | + { this->set( offset ); } | |
| 3052 | + | |
| 3053 | +public: | |
| 3054 | + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); | |
| 3055 | +}; | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3004 | 3060 | //----------------------------------------------------------------------------- |
| 3005 | 3061 | // name: struct Chuck_Instr_Func_To_Code |
| 3006 | 3062 | // desc: Chuck_Func * to Chuck_VM_Code * |
| @@ -3034,11 +3090,14 @@ public: · 27 unmodified lines | ||
| 3034 | 3090 | struct Chuck_Instr_Func_Call_Member : public Chuck_Instr_Unary_Op |
| 3035 | 3091 | { |
| 3036 | 3092 | public: |
| 3037 | − Chuck_Instr_Func_Call_Member( t_CKUINT ret_size ) | |
| 3038 | − { this->set( ret_size ); } | |
| 3093 | + Chuck_Instr_Func_Call_Member( t_CKUINT ret_size, Chuck_Func * func_ref ) | |
| 3094 | + { this->set( ret_size ); m_func_ref = func_ref; } | |
| 3039 | 3095 | |
| 3040 | 3096 | public: |
| 3041 | 3097 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3098 | + | |
| 3099 | +public: | |
| 3100 | + Chuck_Func * m_func_ref; // 1.5.0.0 (ge) | added for arg list cleanup | |
| 3042 | 3101 | }; |
| 3043 | 3102 | |
| 3044 | 3103 | |
| @@ -3051,11 +3110,14 @@ public: · 6 unmodified lines | ||
| 3051 | 3110 | struct Chuck_Instr_Func_Call_Static : public Chuck_Instr_Unary_Op |
| 3052 | 3111 | { |
| 3053 | 3112 | public: |
| 3054 | − Chuck_Instr_Func_Call_Static( t_CKUINT ret_size ) | |
| 3055 | − { this->set( ret_size ); } | |
| 3113 | + Chuck_Instr_Func_Call_Static( t_CKUINT ret_size, Chuck_Func * func_ref ) | |
| 3114 | + { this->set( ret_size ); m_func_ref = func_ref; } | |
| 3056 | 3115 | |
| 3057 | 3116 | public: |
| 3058 | 3117 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3118 | + | |
| 3119 | +public: | |
| 3120 | + Chuck_Func * m_func_ref; // 1.5.0.0 (ge) | added for arg list cleanup | |
| 3059 | 3121 | }; |
| 3060 | 3122 | |
| 3061 | 3123 | |
| @@ -3162,8 +3224,9 @@ protected: · 100 unmodified lines | ||
| 3162 | 3224 | struct Chuck_Instr_Array_Alloc : public Chuck_Instr |
| 3163 | 3225 | { |
| 3164 | 3226 | public: // REFACTOR-2017: added env |
| 3165 | − Chuck_Instr_Array_Alloc( Chuck_Env * env, t_CKUINT depth, Chuck_Type * the_type, | |
| 3166 | − t_CKUINT offset, t_CKBOOL ref ); | |
| 3227 | + Chuck_Instr_Array_Alloc( Chuck_Env * env, t_CKUINT depth, | |
| 3228 | + Chuck_Type * contentType, t_CKUINT offset, t_CKBOOL ref, | |
| 3229 | + Chuck_Type * arrayType ); | |
| 3167 | 3230 | virtual ~Chuck_Instr_Array_Alloc(); |
| 3168 | 3231 | |
| 3169 | 3232 | public: |
| @@ -3172,7 +3235,8 @@ public: · 2 unmodified lines | ||
| 3172 | 3235 | |
| 3173 | 3236 | protected: |
| 3174 | 3237 | t_CKUINT m_depth; |
| 3175 | − Chuck_Type * m_type_ref; | |
| 3238 | + Chuck_Type * m_type_ref_content; | |
| 3239 | + Chuck_Type * m_type_ref_array; // 1.5.0.0 (ge) added | |
| 3176 | 3240 | t_CKBOOL m_is_obj; |
| 3177 | 3241 | char * m_param_str; |
| 3178 | 3242 | t_CKUINT m_stack_offset; |
| @@ -53,9 +53,9 @@ t_CKBOOL init_class_MidiRW( Chuck_Env * env ); · 52 unmodified lines | ||
| 53 | 53 | t_CKBOOL init_class_HID( Chuck_Env * env ); |
| 54 | 54 | #endif |
| 55 | 55 | t_CKBOOL init_class_io( Chuck_Env * env, Chuck_Type * type ); |
| 56 | −#ifndef __DISABLE_FILEIO__ | |
| 56 | +// #ifndef __DISABLE_FILEIO__ | |
| 57 | 57 | t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type ); |
| 58 | −#endif | |
| 58 | +// #endif | |
| 59 | 59 | // added 1.3.0.0 -- moved to be full-fledged class |
| 60 | 60 | t_CKBOOL init_class_chout( Chuck_Env * env, Chuck_Type * type ); |
| 61 | 61 | // added 1.3.0.0 -- moved to be full-fledged class |
| @@ -77,7 +77,7 @@ CK_DLL_SFUN( io_newline ); · 15 unmodified lines | ||
| 77 | 77 | CK_DLL_SFUN( io_openfile ); |
| 78 | 78 | |
| 79 | 79 | |
| 80 | −#ifndef __DISABLE_FILEIO__ | |
| 80 | +// #ifndef __DISABLE_FILEIO__ | |
| 81 | 81 | //----------------------------------------------------------------------------- |
| 82 | 82 | // fileio API |
| 83 | 83 | //----------------------------------------------------------------------------- |
| @@ -99,6 +99,9 @@ CK_DLL_MFUN( fileio_read ); · 15 unmodified lines | ||
| 99 | 99 | CK_DLL_MFUN( fileio_readline ); |
| 100 | 100 | CK_DLL_MFUN( fileio_readint ); |
| 101 | 101 | CK_DLL_MFUN( fileio_readintflags ); |
| 102 | +CK_DLL_MFUN( fileio_readint8 ); | |
| 103 | +CK_DLL_MFUN( fileio_readint16 ); | |
| 104 | +CK_DLL_MFUN( fileio_readint32 ); | |
| 102 | 105 | CK_DLL_MFUN( fileio_readfloat ); |
| 103 | 106 | CK_DLL_MFUN( fileio_eof ); |
| 104 | 107 | CK_DLL_MFUN( fileio_more ); |
| @@ -106,7 +109,7 @@ CK_DLL_MFUN( fileio_writestring ); · 1 unmodified line | ||
| 106 | 109 | CK_DLL_MFUN( fileio_writeint ); |
| 107 | 110 | CK_DLL_MFUN( fileio_writeintflags ); |
| 108 | 111 | CK_DLL_MFUN( fileio_writefloat ); |
| 109 | −#endif | |
| 112 | +// #endif // __DISABLE_FILEIO__ | |
| 110 | 113 | |
| 111 | 114 | |
| 112 | 115 | //----------------------------------------------------------------------------- |
| @@ -58,7 +58,8 @@ t_CKBOOL init_class_string( Chuck_Env * env, Chuck_Type * type ); · 57 unmodified lines | ||
| 58 | 58 | t_CKBOOL init_class_array( Chuck_Env * env, Chuck_Type * type ); |
| 59 | 59 | t_CKBOOL init_class_vec3( Chuck_Env * env, Chuck_Type * type ); // 1.3.5.3 |
| 60 | 60 | t_CKBOOL init_class_vec4( Chuck_Env * env, Chuck_Type * type ); // 1.3.5.3 |
| 61 | − | |
| 61 | +t_CKBOOL init_class_type( Chuck_Env * env, Chuck_Type * type ); // 1.5.0.0 | |
| 62 | +t_CKBOOL init_primitive_types( Chuck_Env * env ); // 1.5.0.0 | |
| 62 | 63 | |
| 63 | 64 | |
| 64 | 65 | |
| @@ -69,11 +70,11 @@ t_CKBOOL init_class_vec4( Chuck_Env * env, Chuck_Type * type ); // 1.3.5.3 · 4 unmodified lines | ||
| 69 | 70 | CK_DLL_CTOR( object_ctor ); |
| 70 | 71 | CK_DLL_DTOR( object_dtor ); |
| 71 | 72 | CK_DLL_MFUN( object_equals ); |
| 72 | −CK_DLL_MFUN( object_getType ); | |
| 73 | 73 | CK_DLL_MFUN( object_hashCode ); |
| 74 | 74 | CK_DLL_MFUN( object_toString ); |
| 75 | 75 | CK_DLL_MFUN( object_dump ); |
| 76 | 76 | CK_DLL_SFUN( object_help ); |
| 77 | +CK_DLL_SFUN( object_typeInfo ); | |
| 77 | 78 | |
| 78 | 79 | |
| 79 | 80 | //----------------------------------------------------------------------------- |
| @@ -187,7 +188,10 @@ CK_DLL_MFUN( array_find ); · 107 unmodified lines | ||
| 187 | 188 | CK_DLL_MFUN( array_erase ); |
| 188 | 189 | CK_DLL_MFUN( array_clear ); |
| 189 | 190 | CK_DLL_MFUN( array_reset ); |
| 191 | +CK_DLL_MFUN( array_zero ); | |
| 190 | 192 | CK_DLL_MFUN( array_get_keys ); |
| 193 | +CK_DLL_MFUN( array_reverse ); | |
| 194 | +CK_DLL_MFUN( array_shuffle ); | |
| 191 | 195 | |
| 192 | 196 | |
| 193 | 197 | //----------------------------------------------------------------------------- |
| @@ -256,6 +260,37 @@ CK_DLL_MFUN( vec4_magnitude ); · 62 unmodified lines | ||
| 256 | 260 | CK_DLL_MFUN( vec4_normalize ); |
| 257 | 261 | |
| 258 | 262 | |
| 263 | +//----------------------------------------------------------------------------- | |
| 264 | +// type API | 1.5.0.0 (ge) added | |
| 265 | +//----------------------------------------------------------------------------- | |
| 266 | +CK_DLL_CTOR( type_ctor ); | |
| 267 | +CK_DLL_DTOR( type_dtor ); | |
| 268 | +CK_DLL_MFUN( type_equals ); | |
| 269 | +CK_DLL_MFUN( type_isa ); | |
| 270 | +CK_DLL_MFUN( type_isa_str ); | |
| 271 | +CK_DLL_MFUN( type_name ); | |
| 272 | +CK_DLL_MFUN( type_parent ); // return parent Type | |
| 273 | +CK_DLL_MFUN( type_children ); // return children Types | |
| 274 | +CK_DLL_MFUN( type_origin ); // built-in, chugin, defined in chuck | |
| 275 | +CK_DLL_MFUN( type_isPrimitive ); | |
| 276 | +CK_DLL_MFUN( type_isArray ); | |
| 277 | +CK_DLL_MFUN( type_arrayDims ); | |
| 278 | +CK_DLL_SFUN( type_findString ); | |
| 279 | +CK_DLL_SFUN( type_typeOf_obj ); // Type.typeOf( Object ) | |
| 280 | +CK_DLL_SFUN( type_typeOf_int ); // Type.typeOf( int ) | |
| 281 | +CK_DLL_SFUN( type_typeOf_float ); // Type.typeOf( float ) | |
| 282 | +CK_DLL_SFUN( type_typeOf_time ); // Type.typeOf( time ) | |
| 283 | +CK_DLL_SFUN( type_typeOf_dur ); // Type.typeOf( dur ) | |
| 284 | +CK_DLL_SFUN( type_typeOf_complex ); // Type.typeOf( complex ) | |
| 285 | +CK_DLL_SFUN( type_typeOf_polar ); // Type.typeOf( polar ) | |
| 286 | +CK_DLL_SFUN( type_typeOf_vec3 ); // Type.typeOf( vec3 ) | |
| 287 | +CK_DLL_SFUN( type_typeOf_vec4 ); // Type.typeOf( vec4 ) | |
| 288 | +CK_DLL_SFUN( type_getTypes ); | |
| 289 | +CK_DLL_SFUN( type_getTypesAll ); | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 259 | 294 | //----------------------------------------------------------------------------- |
| 260 | 295 | // name: Data_Exception |
| 261 | 296 | // desc: data for base Chuck Exception class |
| @@ -98,6 +98,8 @@ public: · 97 unmodified lines | ||
| 98 | 98 | virtual void release(); |
| 99 | 99 | // lock |
| 100 | 100 | virtual void lock(); |
| 101 | + // unlock | 1.5.0.0 (ge) added | |
| 102 | + virtual void unlock(); | |
| 101 | 103 | |
| 102 | 104 | // NOTE: be careful when overriding these, should always |
| 103 | 105 | // explicitly call up to ChucK_VM_Object (ge: 2013) |
| @@ -228,8 +230,14 @@ public: · 124 unmodified lines | ||
| 228 | 230 | virtual t_CKINT find( const std::string & key ) = 0; // find |
| 229 | 231 | virtual t_CKINT erase( const std::string & key ) = 0; // erase |
| 230 | 232 | virtual void clear( ) = 0; // clear |
| 233 | + virtual void zero( t_CKUINT start, t_CKUINT end ) = 0; // zero | |
| 234 | + virtual void zero() = 0; // zero (all) | |
| 231 | 235 | // get map keys | added (1.4.2.0) nshaheed |
| 232 | 236 | virtual void get_keys( std::vector<std::string> & keys ) = 0; |
| 237 | + // reverse array order | added (1.5.0.0) azaday | |
| 238 | + virtual void reverse() = 0; | |
| 239 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 240 | + virtual void shuffle() = 0; | |
| 233 | 241 | |
| 234 | 242 | Chuck_Type * m_array_type; |
| 235 | 243 | }; |
| @@ -259,6 +267,7 @@ public: · 23 unmodified lines | ||
| 259 | 267 | t_CKINT pop_out( t_CKINT pos ); |
| 260 | 268 | t_CKINT back( t_CKUINT * val ) const; |
| 261 | 269 | void zero( t_CKUINT start, t_CKUINT end ); |
| 270 | + void zero() { this->zero(0, m_vector.size()); } | |
| 262 | 271 | |
| 263 | 272 | virtual void clear( ); |
| 264 | 273 | virtual t_CKINT size( ) { return m_vector.size(); } |
| @@ -271,11 +280,18 @@ public: · 6 unmodified lines | ||
| 271 | 280 | virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY4_DATAKIND; } |
| 272 | 281 | // get map keys | added (1.4.2.0) nshaheed |
| 273 | 282 | virtual void get_keys( std::vector<std::string> & keys ); |
| 283 | + // reverse array order | added (1.5.0.0) azaday | |
| 284 | + virtual void reverse(); | |
| 285 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 286 | + virtual void shuffle(); | |
| 274 | 287 | |
| 275 | 288 | public: |
| 276 | 289 | std::vector<t_CKUINT> m_vector; |
| 277 | 290 | std::map<std::string, t_CKUINT> m_map; |
| 278 | 291 | t_CKBOOL m_is_obj; |
| 292 | + | |
| 293 | + // TODO: may need additional information here for set_size, if this is part of a multi-dim array | |
| 294 | + | |
| 279 | 295 | // t_CKINT m_size; |
| 280 | 296 | // t_CKINT m_capacity; |
| 281 | 297 | }; |
| @@ -305,6 +321,7 @@ public: · 23 unmodified lines | ||
| 305 | 321 | t_CKINT pop_out( t_CKINT pos ); |
| 306 | 322 | t_CKINT back( t_CKFLOAT * val ) const; |
| 307 | 323 | void zero( t_CKUINT start, t_CKUINT end ); |
| 324 | + void zero() { this->zero(0, m_vector.size()); } | |
| 308 | 325 | |
| 309 | 326 | virtual void clear( ); |
| 310 | 327 | virtual t_CKINT size( ) { return m_vector.size(); } |
| @@ -317,6 +334,10 @@ public: · 6 unmodified lines | ||
| 317 | 334 | virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY8_DATAKIND; } |
| 318 | 335 | // get map keys | added (1.4.2.0) nshaheed |
| 319 | 336 | virtual void get_keys( std::vector<std::string> & keys ); |
| 337 | + // reverse array order | added (1.5.0.0) azaday | |
| 338 | + virtual void reverse(); | |
| 339 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 340 | + virtual void shuffle(); | |
| 320 | 341 | |
| 321 | 342 | public: |
| 322 | 343 | std::vector<t_CKFLOAT> m_vector; |
| @@ -350,6 +371,7 @@ public: · 27 unmodified lines | ||
| 350 | 371 | t_CKINT pop_out( t_CKINT pos ); |
| 351 | 372 | t_CKINT back( t_CKCOMPLEX * val ) const; |
| 352 | 373 | void zero( t_CKUINT start, t_CKUINT end ); |
| 374 | + void zero() { this->zero(0, m_vector.size()); } | |
| 353 | 375 | |
| 354 | 376 | virtual void clear( ); |
| 355 | 377 | virtual t_CKINT size( ) { return m_vector.size(); } |
| @@ -362,6 +384,10 @@ public: · 6 unmodified lines | ||
| 362 | 384 | virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY16_DATAKIND; } |
| 363 | 385 | // get map keys | added (1.4.2.0) nshaheed |
| 364 | 386 | virtual void get_keys( std::vector<std::string> & keys ); |
| 387 | + // reverse array order | added (1.5.0.0) azaday | |
| 388 | + virtual void reverse(); | |
| 389 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 390 | + virtual void shuffle(); | |
| 365 | 391 | |
| 366 | 392 | public: |
| 367 | 393 | std::vector<t_CKCOMPLEX> m_vector; |
| @@ -395,6 +421,7 @@ public: · 27 unmodified lines | ||
| 395 | 421 | t_CKINT pop_out( t_CKUINT pos ); |
| 396 | 422 | t_CKINT back( t_CKVEC3 * val ) const; |
| 397 | 423 | void zero( t_CKUINT start, t_CKUINT end ); |
| 424 | + void zero() { this->zero(0, m_vector.size()); } | |
| 398 | 425 | |
| 399 | 426 | virtual void clear( ); |
| 400 | 427 | virtual t_CKINT size( ) { return m_vector.size(); } |
| @@ -407,6 +434,10 @@ public: · 6 unmodified lines | ||
| 407 | 434 | virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY24_DATAKIND; } |
| 408 | 435 | // get map keys | added (1.4.2.0) nshaheed |
| 409 | 436 | virtual void get_keys( std::vector<std::string> & keys ); |
| 437 | + // reverse array order | added (1.5.0.0) azaday | |
| 438 | + virtual void reverse(); | |
| 439 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 440 | + virtual void shuffle(); | |
| 410 | 441 | |
| 411 | 442 | public: |
| 412 | 443 | std::vector<t_CKVEC3> m_vector; |
| @@ -438,6 +469,7 @@ public: · 25 unmodified lines | ||
| 438 | 469 | t_CKINT pop_out( t_CKUINT pos ); |
| 439 | 470 | t_CKINT back( t_CKVEC4 * val ) const; |
| 440 | 471 | void zero( t_CKUINT start, t_CKUINT end ); |
| 472 | + void zero() { this->zero(0, m_vector.size()); } | |
| 441 | 473 | |
| 442 | 474 | virtual void clear( ); |
| 443 | 475 | virtual t_CKINT size( ) { return m_vector.size(); } |
| @@ -450,6 +482,10 @@ public: · 6 unmodified lines | ||
| 450 | 482 | virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY32_DATAKIND; } |
| 451 | 483 | // get map keys | added (1.4.1.2) nshaheed |
| 452 | 484 | virtual void get_keys( std::vector<std::string> & keys ); |
| 485 | + // reverse array order | added (1.5.0.0) azaday | |
| 486 | + virtual void reverse(); | |
| 487 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 488 | + virtual void shuffle(); | |
| 453 | 489 | |
| 454 | 490 | public: |
| 455 | 491 | std::vector<t_CKVEC4> m_vector; |
| @@ -589,15 +625,23 @@ public: · 133 unmodified lines | ||
| 589 | 625 | virtual void write( t_CKINT val, t_CKINT flags ) = 0; |
| 590 | 626 | virtual void write( t_CKFLOAT val ) = 0; |
| 591 | 627 | |
| 592 | − // constants | |
| 593 | 628 | public: |
| 629 | + // type | moved to IO in 1.5.0.0 (ge) | |
| 630 | + static const t_CKINT TYPE_ASCII; | |
| 631 | + static const t_CKINT TYPE_BINARY; | |
| 632 | + // datatype | |
| 594 | 633 | static const t_CKINT INT32; |
| 595 | 634 | static const t_CKINT INT16; |
| 596 | 635 | static const t_CKINT INT8; |
| 597 | − | |
| 636 | + // flags | moved to IO in 1.5.0.0 (ge) | |
| 637 | + static const t_CKINT FLAG_READ_WRITE; | |
| 638 | + static const t_CKINT FLAG_READONLY; | |
| 639 | + static const t_CKINT FLAG_WRITEONLY; | |
| 640 | + static const t_CKINT FLAG_APPEND; | |
| 598 | 641 | // asynchronous I/O members |
| 599 | 642 | static const t_CKINT MODE_SYNC; |
| 600 | 643 | static const t_CKINT MODE_ASYNC; |
| 644 | + | |
| 601 | 645 | Chuck_Event * m_asyncEvent; |
| 602 | 646 | #ifndef __DISABLE_THREADS__ |
| 603 | 647 | XThread * m_thread; |
| @@ -614,7 +658,7 @@ public: · 10 unmodified lines | ||
| 614 | 658 | |
| 615 | 659 | |
| 616 | 660 | |
| 617 | −#ifndef __DISABLE_FILEIO__ | |
| 661 | +// #ifndef __DISABLE_FILEIO__ | |
| 618 | 662 | //----------------------------------------------------------------------------- |
| 619 | 663 | // name: Chuck_IO_File |
| 620 | 664 | // desc: Chuck File IO class |
| @@ -673,15 +717,6 @@ public: · 52 unmodified lines | ||
| 673 | 717 | static THREAD_RETURN ( THREAD_TYPE writeFloat_thread ) ( void *data ); |
| 674 | 718 | #endif |
| 675 | 719 | |
| 676 | −public: | |
| 677 | − // constants | |
| 678 | − static const t_CKINT FLAG_READ_WRITE; | |
| 679 | − static const t_CKINT FLAG_READONLY; | |
| 680 | − static const t_CKINT FLAG_WRITEONLY; | |
| 681 | − static const t_CKINT FLAG_APPEND; | |
| 682 | − static const t_CKINT TYPE_ASCII; | |
| 683 | − static const t_CKINT TYPE_BINARY; | |
| 684 | − | |
| 685 | 720 | protected: |
| 686 | 721 | // open flags |
| 687 | 722 | t_CKINT m_flags; |
| @@ -698,7 +733,7 @@ protected: · 10 unmodified lines | ||
| 698 | 733 | // vm and shred |
| 699 | 734 | Chuck_VM * m_vmRef; |
| 700 | 735 | }; |
| 701 | −#endif // __DISABLE_FILEIO__ | |
| 736 | +// #endif // __DISABLE_FILEIO__ | |
| 702 | 737 | |
| 703 | 738 | |
| 704 | 739 | |
| @@ -63,6 +63,8 @@ t_CKBOOL chuck_parse( c_constr fname, FILE * fd = NULL, c_constr code = NULL ); · 62 unmodified lines | ||
| 63 | 63 | // reset the parser |
| 64 | 64 | void reset_parse( ); |
| 65 | 65 | |
| 66 | +// convert abstract syntax expression to string | |
| 67 | +std::string absyn2str( a_Exp exp ); | |
| 66 | 68 | |
| 67 | 69 | // syntax highlighting tools |
| 68 | 70 | #include <vector> |
| @@ -84,6 +84,22 @@ typedef enum { · 83 unmodified lines | ||
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | |
| 87 | +//----------------------------------------------------------------------------- | |
| 88 | +// name: enum te_Origin | 1.5.0.0 (ge) added | |
| 89 | +// desc: where something (e.g., a Type) originates | |
| 90 | +//----------------------------------------------------------------------------- | |
| 91 | +typedef enum { | |
| 92 | + te_originUnknown = 0, | |
| 93 | + te_originBuiltin, // in core | |
| 94 | + te_originChugin, // in imported chugin | |
| 95 | + te_originImport, // library CK code | |
| 96 | + te_originUserDefined, // in user chuck code | |
| 97 | + te_originGenerated // generated (e.g., array types like int[][][][]) | |
| 98 | +} te_Origin; | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 87 | 103 | //----------------------------------------------------------------------------- |
| 88 | 104 | // name: struct Chuck_Scope |
| 89 | 105 | // desc: scoping structure |
| @@ -199,8 +215,15 @@ public: · 109 unmodified lines | ||
| 199 | 215 | return (T)val; |
| 200 | 216 | } |
| 201 | 217 | |
| 218 | + // test if a name has been "mangled", e.g., "toString@0@Object" | |
| 219 | + static t_CKBOOL is_mangled( const std::string & name ) | |
| 220 | + { | |
| 221 | + // check for @ in the name, which would not be possible for names in language | |
| 222 | + return ( name.find("@") != std::string::npos ); | |
| 223 | + } | |
| 224 | + | |
| 202 | 225 | // get list of top level |
| 203 | − void get_toplevel( std::vector<Chuck_VM_Object *> & out ) | |
| 226 | + void get_toplevel( std::vector<Chuck_VM_Object *> & out, t_CKBOOL includeMangled = TRUE ) | |
| 204 | 227 | { |
| 205 | 228 | assert( scope.size() != 0 ); |
| 206 | 229 | std::map<S_Symbol, Chuck_VM_Object *>::iterator iter; |
| @@ -213,13 +236,16 @@ public: · 6 unmodified lines | ||
| 213 | 236 | // go through map |
| 214 | 237 | for( iter = m->begin(); iter != m->end(); iter++ ) |
| 215 | 238 | { |
| 239 | + // check mangled name | |
| 240 | + if( !includeMangled && is_mangled( std::string(S_name((*iter).first))) ) | |
| 241 | + continue; | |
| 216 | 242 | // add |
| 217 | 243 | out.push_back( (*iter).second ); |
| 218 | 244 | } |
| 219 | 245 | } |
| 220 | 246 | |
| 221 | 247 | // get list of top level |
| 222 | − void get_level( int level, std::vector<Chuck_VM_Object *> & out ) | |
| 248 | + void get_level( int level, std::vector<Chuck_VM_Object *> & out, t_CKBOOL includeMangled = TRUE ) | |
| 223 | 249 | { |
| 224 | 250 | assert( scope.size() >= level ); |
| 225 | 251 | std::map<S_Symbol, Chuck_VM_Object *>::iterator iter; |
| @@ -232,12 +258,15 @@ public: · 6 unmodified lines | ||
| 232 | 258 | // go through map |
| 233 | 259 | for( iter = m->begin(); iter != m->end(); iter++ ) |
| 234 | 260 | { |
| 261 | + // check mangled name | |
| 262 | + if( !includeMangled && is_mangled( std::string(S_name((*iter).first))) ) | |
| 263 | + continue; | |
| 264 | + | |
| 235 | 265 | // add |
| 236 | 266 | out.push_back( (*iter).second ); |
| 237 | 267 | } |
| 238 | 268 | } |
| 239 | 269 | |
| 240 | − | |
| 241 | 270 | protected: |
| 242 | 271 | std::vector<std::map<S_Symbol, Chuck_VM_Object *> *> scope; |
| 243 | 272 | std::map<S_Symbol, Chuck_VM_Object *> commit_map; |
| @@ -324,7 +353,7 @@ struct Chuck_Namespace : public Chuck_VM_Object · 80 unmodified lines | ||
| 324 | 353 | // get top level values |
| 325 | 354 | void get_values( std::vector<Chuck_Value *> & out ); |
| 326 | 355 | // get top level functions |
| 327 | − void get_funcs( std::vector<Chuck_Func *> & out ); | |
| 356 | + void get_funcs( std::vector<Chuck_Func *> & out, t_CKBOOL includeManged = TRUE ); | |
| 328 | 357 | }; |
| 329 | 358 | |
| 330 | 359 | |
| @@ -398,10 +427,15 @@ public: · 67 unmodified lines | ||
| 398 | 427 | // constructor |
| 399 | 428 | Chuck_Env(); |
| 400 | 429 | |
| 430 | +public: | |
| 431 | + // initialize | |
| 432 | + t_CKBOOL init(); | |
| 433 | + | |
| 401 | 434 | // REFACTOR-2017: carrier and accessors |
| 402 | 435 | public: |
| 403 | 436 | void set_carrier( Chuck_Carrier * carrier ) { m_carrier = carrier; } |
| 404 | − Chuck_VM * vm() { return m_carrier->vm; } | |
| 437 | + Chuck_VM * vm() { return m_carrier ? m_carrier->vm : NULL; } | |
| 438 | + Chuck_Compiler * compiler() { return m_carrier ? m_carrier->compiler : NULL; } | |
| 405 | 439 | |
| 406 | 440 | protected: |
| 407 | 441 | Chuck_Carrier * m_carrier; |
| @@ -533,12 +567,10 @@ public: · 125 unmodified lines | ||
| 533 | 567 | Chuck_Type * t_uanablob; |
| 534 | 568 | Chuck_Type * t_shred; |
| 535 | 569 | Chuck_Type * t_io; |
| 536 | − #ifndef __DISABLE_FILEIO__ | |
| 537 | 570 | Chuck_Type * t_fileio; |
| 538 | − #endif | |
| 539 | 571 | Chuck_Type * t_chout; |
| 540 | 572 | Chuck_Type * t_cherr; |
| 541 | − Chuck_Type * t_thread; | |
| 573 | + // Chuck_Type * t_thread; | |
| 542 | 574 | Chuck_Type * t_class; |
| 543 | 575 | Chuck_Type * t_dac; |
| 544 | 576 | Chuck_Type * t_adc; |
| @@ -583,8 +615,9 @@ struct Chuck_UGen_Info : public Chuck_VM_Object · 38 unmodified lines | ||
| 583 | 615 | //----------------------------------------------------------------------------- |
| 584 | 616 | // name: struct Chuck_Type |
| 585 | 617 | // desc: class containing information about a type |
| 586 | −//-----------------------------------------------------------------------------_id | |
| 587 | −struct Chuck_Type : public Chuck_VM_Object | |
| 618 | +// note: 1.5.0.0 (ge) Chuck_VM_Object -> Chuck_Object | |
| 619 | +//----------------------------------------------------------------------------- | |
| 620 | +struct Chuck_Type : public Chuck_Object | |
| 588 | 621 | { |
| 589 | 622 | // type id |
| 590 | 623 | te_Type xid; |
| @@ -620,6 +653,8 @@ struct Chuck_Type : public Chuck_VM_Object · 29 unmodified lines | ||
| 620 | 653 | t_CKBOOL has_destructor; |
| 621 | 654 | // custom allocator |
| 622 | 655 | f_alloc allocator; |
| 656 | + // origin hint | |
| 657 | + te_Origin originHint; | |
| 623 | 658 | |
| 624 | 659 | // documentation |
| 625 | 660 | std::string doc; |
| @@ -839,7 +874,10 @@ t_CKBOOL isfunc( Chuck_Env * env, Chuck_Type * type ); · 213 unmodified lines | ||
| 839 | 874 | t_CKBOOL iskindofint( Chuck_Env * env, Chuck_Type * type ); // added 1.3.1.0: this includes int + pointers |
| 840 | 875 | t_CKUINT getkindof( Chuck_Env * env, Chuck_Type * type ); // added 1.3.1.0: to get the kindof a type |
| 841 | 876 | |
| 877 | + | |
| 878 | +//----------------------------------------------------------------------------- | |
| 842 | 879 | // import |
| 880 | +//----------------------------------------------------------------------------- | |
| 843 | 881 | Chuck_Type * type_engine_import_class_begin( Chuck_Env * env, Chuck_Type * type, |
| 844 | 882 | Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor = NULL, |
| 845 | 883 | const char * doc = NULL ); |
| @@ -884,7 +922,10 @@ t_CKBOOL type_engine_import_class_end( Chuck_Env * env ); · 38 unmodified lines | ||
| 884 | 922 | t_CKBOOL type_engine_register_deprecate( Chuck_Env * env, |
| 885 | 923 | const std::string & former, const std::string & latter ); |
| 886 | 924 | |
| 887 | −// helpers | |
| 925 | + | |
| 926 | +//----------------------------------------------------------------------------- | |
| 927 | +// helper functions | |
| 928 | +//----------------------------------------------------------------------------- | |
| 888 | 929 | t_CKBOOL type_engine_check_reserved( Chuck_Env * env, const std::string & xid, int pos ); |
| 889 | 930 | t_CKBOOL type_engine_check_reserved( Chuck_Env * env, S_Symbol xid, int pos ); |
| 890 | 931 | // 1.4.1.0 (ge): abilty to toggle reserved words for special cases, such as Math.pi co-existing with pi (use with care!) |
| @@ -893,17 +934,21 @@ t_CKBOOL type_engine_check_primitive( Chuck_Env * env, Chuck_Type * type ); · 2 unmodified lines | ||
| 893 | 934 | t_CKBOOL type_engine_check_const( Chuck_Env * env, a_Exp e, int pos ); // TODO |
| 894 | 935 | t_CKBOOL type_engine_compat_func( a_Func_Def lhs, a_Func_Def rhs, int pos, std::string & err, t_CKBOOL print = TRUE ); |
| 895 | 936 | t_CKBOOL type_engine_get_deprecate( Chuck_Env * env, const std::string & from, std::string & to ); |
| 937 | +t_CKBOOL type_engine_is_base_static( Chuck_Env * env, Chuck_Type * baseType ); // 1.5.0.0 (ge) added | |
| 896 | 938 | Chuck_Type * type_engine_find_common_anc( Chuck_Type * lhs, Chuck_Type * rhs ); |
| 897 | 939 | Chuck_Type * type_engine_find_type( Chuck_Env * env, a_Id_List path ); |
| 940 | +Chuck_Type * type_engine_find_type( Chuck_Env * env, const std::string & name ); // 1.5.0.0 (ge) added | |
| 898 | 941 | Chuck_Value * type_engine_find_value( Chuck_Type * type, const std::string & xid ); |
| 899 | 942 | Chuck_Value * type_engine_find_value( Chuck_Type * type, S_Symbol xid ); |
| 900 | 943 | Chuck_Value * type_engine_find_value( Chuck_Env * env, const std::string & xid, t_CKBOOL climb, int linepos = 0 ); |
| 901 | 944 | Chuck_Namespace * type_engine_find_nspc( Chuck_Env * env, a_Id_List path ); |
| 902 | −/******************************************************************************* | |
| 903 | − * spencer: added this into function to provide the same logic path | |
| 904 | − * for type_engine_check_exp_decl() and ck_add_mvar() when they determine | |
| 905 | − * offsets for mvars -- added 1.3.0.0 | |
| 906 | − ******************************************************************************/ | |
| 945 | + | |
| 946 | + | |
| 947 | +//----------------------------------------------------------------------------- | |
| 948 | +// spencer: added this into function to provide the same logic path | |
| 949 | +// for type_engine_check_exp_decl() and ck_add_mvar() when they determine | |
| 950 | +// offsets for mvars -- added 1.3.0.0 | |
| 951 | +//----------------------------------------------------------------------------- | |
| 907 | 952 | t_CKUINT type_engine_next_offset( t_CKUINT current_offset, Chuck_Type * type ); |
| 908 | 953 | // array verify |
| 909 | 954 | t_CKBOOL verify_array( a_Array_Sub array ); |
| @@ -914,7 +959,11 @@ Chuck_Type * new_array_type( Chuck_Env * env, Chuck_Type * array_parent, · 4 unmodified lines | ||
| 914 | 959 | // make type | 1.4.1.1 (nshaheed) added |
| 915 | 960 | Chuck_Type * new_array_element_type( Chuck_Env * env, Chuck_Type * base_type, |
| 916 | 961 | t_CKUINT depth, Chuck_Namespace * owner_nspc); |
| 962 | + | |
| 963 | + | |
| 964 | +//----------------------------------------------------------------------------- | |
| 917 | 965 | // conversion |
| 966 | +//----------------------------------------------------------------------------- | |
| 918 | 967 | const char * type_path( a_Id_List path ); |
| 919 | 968 | a_Id_List str2list( const std::string & path ); |
| 920 | 969 | a_Id_List str2list( const std::string & path, t_CKBOOL & is_array ); |
| @@ -922,7 +971,19 @@ const char * howmuch2str( te_HowMuch how_much ); · 1 unmodified line | ||
| 922 | 971 | t_CKBOOL escape_str( char * str_lit, int linepos ); |
| 923 | 972 | t_CKINT str2char( const char * char_lit, int linepos ); |
| 924 | 973 | |
| 974 | + | |
| 975 | +//----------------------------------------------------------------------------- | |
| 976 | +// more helper functions for type scan and checking | 1.5.0.0 (ge) added | |
| 977 | +//----------------------------------------------------------------------------- | |
| 978 | +// compare two argument lists to see if they are the same (sequence of types) | |
| 979 | +t_CKBOOL same_arg_lists( a_Arg_List lhs, a_Arg_List rhs ); | |
| 980 | +// generate a string from an argument list (types only) | |
| 981 | +std::string arglist2string( a_Arg_List list ); | |
| 982 | + | |
| 983 | + | |
| 984 | +//----------------------------------------------------------------------------- | |
| 925 | 985 | // REFACTOR-2017: exile! these default types now stored in env |
| 986 | +//----------------------------------------------------------------------------- | |
| 926 | 987 | //extern Chuck_Type t_void; |
| 927 | 988 | //extern Chuck_Type t_int; |
| 928 | 989 | //extern Chuck_Type t_float; |
| @@ -95,7 +95,7 @@ t_CKBOOL stk_detach( Chuck_Carrier * carrier ); · 94 unmodified lines | ||
| 95 | 95 | // versions higher than 4.1.2 and replaced with the variable |
| 96 | 96 | // "StkFloat". |
| 97 | 97 | //typedef double StkFloat; |
| 98 | −//#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) | |
| 98 | +//#if defined(__PLATFORM_WIN32__) || | |
| 99 | 99 | // #pragma deprecated(MY_FLOAT) |
| 100 | 100 | //#else |
| 101 | 101 | // typedef StkFloat MY_FLOAT __attribute__ ((deprecated)); |
| @@ -250,7 +250,7 @@ typedef double FLOAT64; · 148 unmodified lines | ||
| 250 | 250 | #if defined(__WINDOWS_PTHREAD__) |
| 251 | 251 | #define __OS_WINDOWS_CYGWIN__ |
| 252 | 252 | #define __STK_REALTIME__ |
| 253 | −#elif defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) | |
| 253 | +#elif defined(__PLATFORM_WIN32__) | |
| 254 | 254 | #define __OS_WINDOWS__ |
| 255 | 255 | #define __STK_REALTIME__ |
| 256 | 256 | #elif defined(__PLATFORM_LINUX__) |
| @@ -497,10 +497,9 @@ class Instrmnt : public Stk · 240 unmodified lines | ||
| 497 | 497 | virtual void controlChange(int number, MY_FLOAT value); |
| 498 | 498 | |
| 499 | 499 | public: // SWAP formerly protected |
| 500 | + MY_FLOAT lastOutput; | |
| 500 | 501 | // chuck |
| 501 | 502 | t_CKFLOAT m_frequency; |
| 502 | − | |
| 503 | − MY_FLOAT lastOutput; | |
| 504 | 503 | }; |
| 505 | 504 | |
| 506 | 505 | |
| @@ -1587,7 +1586,6 @@ class FM : public Instrmnt · 1080 unmodified lines | ||
| 1587 | 1586 | MY_FLOAT __FM_gains[100]; |
| 1588 | 1587 | MY_FLOAT __FM_susLevels[16]; |
| 1589 | 1588 | MY_FLOAT __FM_attTimes[32]; |
| 1590 | − | |
| 1591 | 1589 | }; |
| 1592 | 1590 | |
| 1593 | 1591 | #endif |
| @@ -5195,7 +5193,7 @@ class Sitar : public Instrmnt · 3601 unmodified lines | ||
| 5195 | 5193 | The user is responsible for checking the values |
| 5196 | 5194 | returned by the read/write methods. Values |
| 5197 | 5195 | less than or equal to zero indicate a closed |
| 5198 | − or lost connection or the occurence of an error. | |
| 5196 | + or lost connection or the occurrence of an error. | |
| 5199 | 5197 | |
| 5200 | 5198 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5201 | 5199 | */ |
| @@ -24,17 +24,66 @@ · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | //----------------------------------------------------------------------------- |
| 26 | 26 | // file: ulib_ai.h |
| 27 | −// desc: class library for libAI -- part of ChAI (ChucK for AI) | |
| 27 | +// desc: Music and AI class library; part of ChAI (ChucK for AI) | |
| 28 | 28 | // |
| 29 | −// author: Ge Wang (ge@ccrma.stanford.edu) | |
| 30 | −// Yikai Li (yikaili@stanford.edu) | |
| 31 | −// date: Fall 2022 | |
| 29 | +// date: Fall 2022 -- present | |
| 30 | +// authors: Ge Wang (ge@ccrma.stanford.edu) | |
| 31 | +// Yikai Li (yikaili@stanford.edu) | |
| 32 | +// | |
| 33 | +// (HISTORICAL NOTE) | |
| 34 | +// Much of ChAI and its ways of thinking and doing can be foundationally | |
| 35 | +// attributed to the work of Dr. Rebecca Fiebrink, her landmark Ph.D. Thesis, | |
| 36 | +// /Real-time Human Interaction With Supervised Learning Algorithms for Music | |
| 37 | +// Composition and Performance/ (2011) [1], the Wekinator framework [2], her | |
| 38 | +// teaching at the intersections of AI, HCI, and Music [3], as well as earlier | |
| 39 | +// collaborations between Rebecca and Ge [4,5] including SMIRK [6] (Small Musical | |
| 40 | +// Information Retrieval toolKit; 2008; MARSYAS and the MIR work of Dr. George | |
| 41 | +// Tzanetakis; early efforts in on-the-fly learning), the unit analyzer | |
| 42 | +// framework [7] (2007; afford real-time audio feature extraction). All of | |
| 43 | +// these have directly or indirectly contributed the creation of ChAI. | |
| 44 | +// Additionally, ChAI benefitted from the teaching and design philosophy of | |
| 45 | +// Dr. Perry R. Cook (Ph.D. advisor to Rebecca, George, and Ge at Princeton, | |
| 46 | +// and ChucK co-author), who argued for real-time human interaction, parametric | |
| 47 | +// sound synthesis, and the importance of play in the design of musical tools. | |
| 48 | +// | |
| 49 | +// [1] Fiebrink, Rebecca. 2011. /Real-time Human Interaction With Supervised | |
| 50 | +// Learning Algorithms for Music Composition and Performance/ Ph.D. Thesis. | |
| 51 | +// Princeton University. https://www.cs.princeton.edu/techreports/2010/891.pdf | |
| 52 | +// | |
| 53 | +// [2] http://www.wekinator.org/ | |
| 54 | +// Wekinator | Software for real-time, interactive machine learning | |
| 55 | +// | |
| 56 | +// [3] Fiebrink, Rebecca. "Machine Learning for Musicians and Artists" MOOC | |
| 57 | +// https://www.kadenze.com/courses/machine-learning-for-musicians-and-artists/info | |
| 58 | +// | |
| 59 | +// [4] Fiebrink, R., G. Wang, P. R. Cook. 2008. "Foundations for On-the-fly | |
| 60 | +// Learning in the ChucK Programming Language." /International Computer Music | |
| 61 | +// Conference/. https://mcd.stanford.edu/publish/files/2008-icmc-learning.pdf | |
| 62 | +// | |
| 63 | +// [5] Fiebrink, R., G. Wang, P. R. Cook. 2008. "Support for Music Information | |
| 64 | +// Retrieval in the ChucK Programming Language." /International Conference | |
| 65 | +// on Music Information Retrieval/ (ISMIR). | |
| 66 | +// https://mcd.stanford.edu/publish/files/2008-ismir-proto.pdf | |
| 67 | +// | |
| 68 | +// [6] http://smirk.cs.princeton.edu/ | |
| 69 | +// sMIRk | Small Music Information Retrieval toolKit | |
| 70 | +// | |
| 71 | +// [7] Tzanetakis, G. and P. R. Cook. 2000 "MARSYAS: A Framework for Audio | |
| 72 | +// Analysis." Organised Sound. 4:(3) | |
| 73 | +// | |
| 74 | +// [8] Tzanetakis, G. and P. R. Cook. 2002 "Musical Genre Classification of | |
| 75 | +// Audio Signals." IEEE Transaction on Speech and Audio Processing. 10(5). | |
| 76 | +// | |
| 77 | +// [9] Wang, G., R. Fiebrink, P. R. Cook. 2007. "Combining Analysis and | |
| 78 | +// Synthesis in the ChucK Programming Language." /International Computer | |
| 79 | +// Music Conference/. https://mcd.stanford.edu/publish/files/2007-icmc-uana.pdf | |
| 32 | 80 | //----------------------------------------------------------------------------- |
| 33 | 81 | #ifndef __ULIB_AI_H__ |
| 34 | 82 | #define __ULIB_AI_H__ |
| 35 | 83 | |
| 36 | 84 | #include "chuck_dl.h" |
| 37 | 85 | #include "chuck_errmsg.h" |
| 86 | +#include "util_math.h" | |
| 38 | 87 | |
| 39 | 88 | |
| 40 | 89 | |
| @@ -86,7 +135,7 @@ public: · 45 unmodified lines | ||
| 86 | 135 | if( !m_matrix ) |
| 87 | 136 | { |
| 88 | 137 | // error |
| 89 | − CK_FPRINTF_STDERR( "[chuck]: ChaiMatrixFast allocation failure: %s, %d x %d...", | |
| 138 | + CK_FPRINTF_STDERR( "[chuck]: ChaiMatrixFast allocation failure: %s, %d x %d...\n", | |
| 90 | 139 | typeid( T ).name(), xDim, yDim ); |
| 91 | 140 | // bail |
| 92 | 141 | return FALSE; |
| @@ -106,18 +155,22 @@ public: · 13 unmodified lines | ||
| 106 | 155 | if( x < 0 || x >= m_xDim || y < 0 || y >= m_yDim ) |
| 107 | 156 | { |
| 108 | 157 | // error |
| 109 | − CK_FPRINTF_STDERR( "[chuck]: ChaiMatrixFast out of bound: %s[%d][%d]...", | |
| 158 | + CK_FPRINTF_STDERR( "[chuck]: ChaiMatrixFast out of bound: %s[%d][%d]...\n", | |
| 110 | 159 | typeid( T ).name(), x, y ); |
| 111 | 160 | // halt |
| 112 | 161 | // TODO: this should throw (a shred-level, probably) exception |
| 113 | 162 | assert( FALSE ); |
| 114 | 163 | } |
| 115 | 164 | |
| 116 | − // NOTE: this is NOT bound-checked!!! | |
| 117 | − // NOTE: yet, this is arguably no worse than using c 2d arrays | |
| 118 | 165 | return m_matrix[x * m_yDim + y]; |
| 119 | 166 | } |
| 120 | 167 | |
| 168 | + // overloaded operator | |
| 169 | + T & operator()( t_CKINT x, t_CKINT y ) | |
| 170 | + { | |
| 171 | + return v( x, y ); | |
| 172 | + } | |
| 173 | + | |
| 121 | 174 | // get dimensions |
| 122 | 175 | t_CKINT xDim() const |
| 123 | 176 | { return m_xDim; } |
| @@ -138,9 +191,6 @@ protected: · 14 unmodified lines | ||
| 138 | 191 | t_CKINT m_yDim; |
| 139 | 192 | }; |
| 140 | 193 | |
| 141 | − | |
| 142 | − | |
| 143 | − | |
| 144 | 194 | //----------------------------------------------------------------------------- |
| 145 | 195 | // name: class ChaiVectorFast | 1.4.2.0 (ge) added |
| 146 | 196 | // desc: a templated fast access but not bound-checked 1D array |
| @@ -185,7 +235,7 @@ public: · 38 unmodified lines | ||
| 185 | 235 | if( !m_vector ) |
| 186 | 236 | { |
| 187 | 237 | // error |
| 188 | − CK_FPRINTF_STDERR( "[chuck]: ChaiVectorFast allocation failure: %s[%d]...", | |
| 238 | + CK_FPRINTF_STDERR( "[chuck]: ChaiVectorFast allocation failure: %s[%d]...\n", | |
| 189 | 239 | typeid( T ).name(), length ); |
| 190 | 240 | // bail |
| 191 | 241 | return FALSE; |
| @@ -197,30 +247,69 @@ public: · 5 unmodified lines | ||
| 197 | 247 | return TRUE; |
| 198 | 248 | } |
| 199 | 249 | |
| 250 | + void shuffle() | |
| 251 | + { | |
| 252 | + T temp; | |
| 253 | + t_CKINT j; | |
| 254 | + for( t_CKINT i = m_length - 1; i > 0; i-- ) | |
| 255 | + { | |
| 256 | + j = ck_random() % ( i + 1 ); | |
| 257 | + temp = m_vector[i]; | |
| 258 | + m_vector[i] = m_vector[j]; | |
| 259 | + m_vector[j] = temp; | |
| 260 | + } | |
| 261 | + } | |
| 262 | + | |
| 200 | 263 | t_CKUINT length() |
| 201 | 264 | { return m_length; } |
| 202 | 265 | |
| 203 | 266 | t_CKINT size() |
| 204 | 267 | { return m_length; } |
| 205 | 268 | |
| 206 | − // get element value | |
| 207 | − T & v( t_CKINT i ) | |
| 269 | + T getMax() | |
| 270 | + { | |
| 271 | + T max = m_vector[0]; | |
| 272 | + for( t_CKINT i = 1; i < m_length; i++ ) | |
| 273 | + { | |
| 274 | + if( m_vector[i] > max ) | |
| 275 | + { | |
| 276 | + max = m_vector[i]; | |
| 277 | + } | |
| 278 | + } | |
| 279 | + return max; | |
| 280 | + } | |
| 281 | + | |
| 282 | + void setAll( T value ) | |
| 283 | + { | |
| 284 | + // iterate | |
| 285 | + for( t_CKINT i = 0; i < m_length; i++ ) | |
| 286 | + { | |
| 287 | + // set to value | |
| 288 | + m_vector[i] = value; | |
| 289 | + } | |
| 290 | + } | |
| 291 | + | |
| 292 | + T & operator[]( t_CKINT i ) | |
| 208 | 293 | { |
| 209 | 294 | // at least do a check |
| 210 | 295 | if( i < 0 || i >= m_length ) |
| 211 | 296 | { |
| 212 | 297 | // error |
| 213 | − CK_FPRINTF_STDERR( "[chuck]: ChaiVectorFast out of bound: %s[%d]...", | |
| 214 | − typeid( T ).name(), i ); | |
| 298 | + CK_FPRINTF_STDERR( "[chuck]: ChaiVectorFast out of bound: %s[%d] (capacity=%d)...\n", | |
| 299 | + typeid( T ).name(), i, m_length ); | |
| 215 | 300 | // TODO: this should throw (a shred-level, probably) exception |
| 216 | 301 | assert( FALSE ); |
| 217 | 302 | } |
| 218 | 303 | |
| 219 | − // NOTE: this is NOT bound-checked!!! | |
| 220 | − // NOTE: yet, this is arguably no worse than using c arrays | |
| 221 | 304 | return m_vector[i]; |
| 222 | 305 | } |
| 223 | 306 | |
| 307 | + // get element value | |
| 308 | + T & v( t_CKINT i ) | |
| 309 | + { | |
| 310 | + return ( *this )[i]; | |
| 311 | + } | |
| 312 | + | |
| 224 | 313 | void cleanup() |
| 225 | 314 | { |
| 226 | 315 | // reclaim array memory and zero the pointer |
| @@ -229,9 +318,60 @@ public: · 2 unmodified lines | ||
| 229 | 318 | m_length = 0; |
| 230 | 319 | } |
| 231 | 320 | |
| 232 | −protected: | |
| 321 | +public: | |
| 233 | 322 | T * m_vector; |
| 234 | 323 | t_CKINT m_length; |
| 235 | 324 | }; |
| 236 | 325 | |
| 237 | 326 | #endif |
| 327 | + | |
| 328 | +#ifndef _KD_TREE_H | |
| 329 | +#define _KD_TREE_H | |
| 330 | + | |
| 331 | +#include <float.h> | |
| 332 | +// #define DBL_EPSILON 2.2204460492503131e-16 | |
| 333 | + | |
| 334 | +#define KDTREE_MAX_LEVEL 64 | |
| 335 | +#define KDTREE_LEFT_INDEX 0 | |
| 336 | +#define KDTREE_RIGHT_INDEX 1 | |
| 337 | + | |
| 338 | +typedef struct knn_list | |
| 339 | +{ | |
| 340 | + struct kdnode * node; | |
| 341 | + double distance; | |
| 342 | + struct knn_list * prev; | |
| 343 | + struct knn_list * next; | |
| 344 | +} knn_list_t; | |
| 345 | + | |
| 346 | +typedef struct kdnode | |
| 347 | +{ | |
| 348 | + long coord_index; | |
| 349 | + double * coord; | |
| 350 | + struct kdnode * left; | |
| 351 | + struct kdnode * right; | |
| 352 | + t_CKINT r; | |
| 353 | +} kdnode_t; | |
| 354 | + | |
| 355 | +typedef struct kdtree | |
| 356 | +{ | |
| 357 | + struct kdnode * root; | |
| 358 | + size_t count; | |
| 359 | + size_t capacity; | |
| 360 | + double * coords; | |
| 361 | + double ** coord_table; | |
| 362 | + long * coord_indexes; | |
| 363 | + unsigned char * coord_deleted; | |
| 364 | + unsigned char * coord_passed; | |
| 365 | + struct knn_list knn_list_head; | |
| 366 | + t_CKINT dim; | |
| 367 | + t_CKINT knn_num; | |
| 368 | +} kdtree_t; | |
| 369 | + | |
| 370 | +struct kdtree * kdtree_init( t_CKINT dim ); | |
| 371 | +void kdtree_insert( struct kdtree * tree, double * coord ); | |
| 372 | +void kdtree_rebuild( struct kdtree * tree ); | |
| 373 | +void kdtree_knn_search( struct kdtree * tree, double * coord, t_CKINT k ); | |
| 374 | +void kdtree_destroy( struct kdtree * tree ); | |
| 375 | +void kdtree_dump( struct kdtree * tree ); | |
| 376 | + | |
| 377 | +#endif /* _KD_TREE_H */ | |
| @@ -42,24 +42,21 @@ struct Chuck_Compiler; · 41 unmodified lines | ||
| 42 | 42 | |
| 43 | 43 | // query |
| 44 | 44 | DLL_QUERY machine_query( Chuck_DL_Query * QUERY ); |
| 45 | + | |
| 46 | +#ifndef __DISABLE_OTF_SERVER__ | |
| 45 | 47 | typedef t_CKUINT (* proc_msg_func)( Chuck_VM *, Chuck_Compiler *, |
| 46 | 48 | Net_Msg *, t_CKBOOL, void * ); |
| 47 | 49 | t_CKBOOL machine_init( Chuck_Compiler * compiler, proc_msg_func func ); |
| 48 | 50 | // 1.4.0.1: TODO: refactor out of ulib machine; not all platforms have OTF |
| 51 | +#endif // __DISABLE_OTF_SERVER__ | |
| 52 | + | |
| 53 | +// machine exports | |
| 49 | 54 | t_CKUINT machine_intsize(); |
| 50 | 55 | |
| 51 | 56 | |
| 52 | −// exports | |
| 53 | −CK_DLL_SFUN( machine_crash_impl ); | |
| 54 | −CK_DLL_SFUN( machine_add_impl ); | |
| 55 | −CK_DLL_SFUN( machine_spork_impl ); | |
| 56 | −CK_DLL_SFUN( machine_remove_impl ); | |
| 57 | −CK_DLL_SFUN( machine_replace_impl ); | |
| 58 | −CK_DLL_SFUN( machine_status_impl ); | |
| 59 | −CK_DLL_SFUN( machine_intsize_impl ); | |
| 60 | −CK_DLL_SFUN( machine_shreds_impl ); | |
| 61 | −CK_DLL_SFUN( machine_realtime_impl ); | |
| 62 | −CK_DLL_SFUN( machine_silent_impl ); | |
| 57 | +// ckdoc query | |
| 58 | +DLL_QUERY ckdoc_query( Chuck_DL_Query * QUERY ); | |
| 59 | + | |
| 63 | 60 | |
| 64 | 61 | |
| 65 | 62 | #endif |
| @@ -90,6 +90,17 @@ CK_DLL_SFUN( srandom_impl ); · 89 unmodified lines | ||
| 90 | 90 | |
| 91 | 91 | CK_DLL_SFUN( gauss_impl ); |
| 92 | 92 | |
| 93 | +CK_DLL_SFUN( cossim_impl ); | |
| 94 | +CK_DLL_SFUN( cossim3d_impl ); | |
| 95 | +CK_DLL_SFUN( cossim4d_impl ); | |
| 96 | + | |
| 97 | +CK_DLL_SFUN( euclidean_impl ); | |
| 98 | +CK_DLL_SFUN( euclidean3d_impl ); | |
| 99 | +CK_DLL_SFUN( euclidean4d_impl ); | |
| 100 | + | |
| 101 | +CK_DLL_SFUN( map_impl ); | |
| 102 | +CK_DLL_SFUN( map2_impl ); | |
| 103 | + | |
| 93 | 104 | |
| 94 | 105 | |
| 95 | 106 | |
| @@ -32,6 +32,8 @@ · 31 unmodified lines | ||
| 32 | 32 | #ifndef __UTIL_HID_H__ |
| 33 | 33 | #define __UTIL_HID_H__ |
| 34 | 34 | |
| 35 | +#include "chuck_def.h" | |
| 36 | + | |
| 35 | 37 | |
| 36 | 38 | |
| 37 | 39 | |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #define __UTIL_MATH_H__ |
| 35 | 35 | |
| 36 | 36 | #include <math.h> |
| 37 | +#include "chuck_def.h" // 1.4.1.0 (ge) for t_CKINT | |
| 37 | 38 | |
| 38 | 39 | #if defined (__cplusplus) || defined(_cplusplus) |
| 39 | 40 | extern "C" { |
| @@ -52,7 +53,7 @@ double ck_remainder( double a, double b ); · 12 unmodified lines | ||
| 52 | 53 | |
| 53 | 54 | |
| 54 | 55 | // max for random functions |
| 55 | −#ifdef __WINDOWS_DS__ | |
| 56 | +#ifdef __PLATFORM_WIN32__ | |
| 56 | 57 | #define CK_RANDOM_MAX RAND_MAX |
| 57 | 58 | #else |
| 58 | 59 | #define CK_RANDOM_MAX 0x7fffffff |
| @@ -41,6 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #include <sys/socket.h> |
| 42 | 42 | #include <netinet/in.h> |
| 43 | 43 | #else |
| 44 | +#define _WINSOCKAPI_ | |
| 44 | 45 | #include <windows.h> |
| 45 | 46 | #endif |
| 46 | 47 | |
| @@ -41,6 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | // the included files were from the CNMAT OSC-Kit distrib. |
| 43 | 43 | #ifdef __PLATFORM_WIN32__ |
| 44 | +#define _WINSOCKAPI_ | |
| 44 | 45 | #include <windows.h> |
| 45 | 46 | #endif |
| 46 | 47 | |
| @@ -32,6 +32,8 @@ · 31 unmodified lines | ||
| 32 | 32 | #ifndef __UTIL_SERIAL_H__ |
| 33 | 33 | #define __UTIL_SERIAL_H__ |
| 34 | 34 | |
| 35 | +#include "chuck_def.h" | |
| 36 | + | |
| 35 | 37 | #include <vector> |
| 36 | 38 | #include <string> |
| 37 | 39 | |
| @@ -1748,7 +1748,13 @@ enum · 1747 unmodified lines | ||
| 1748 | 1748 | { |
| 1749 | 1749 | /* keep sorted for wav_w64_format_str() */ |
| 1750 | 1750 | WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Corporation */ |
| 1751 | − WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM format */ | |
| 1751 | + WAVE_FORMAT_MS_PCM = 0x0001, /* Microsoft PCM format */ | |
| 1752 | + /* ------------------------------------------------------------------------- | |
| 1753 | + creating and using WAVE_FORMAT_MS_PCM in this module, as WAVE_FORMAT_PCM may | |
| 1754 | + be defined by windows, e.g., in mmeapi.h -- which breaks the build...thanks | |
| 1755 | + important: WAVE_FORMAT_MS_PCM must be 1, as WAV format tag | 1.5.0.0 (ge) | |
| 1756 | + ------------------------------------------------------------------------- */ | |
| 1757 | + /* WAVE_FORMAT_PCM = 0x0001, */ /* Microsoft PCM format */ | |
| 1752 | 1758 | WAVE_FORMAT_MS_ADPCM = 0x0002, /* Microsoft ADPCM */ |
| 1753 | 1759 | WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* Micrososft 32 bit float format */ |
| 1754 | 1760 | WAVE_FORMAT_VSELP = 0x0004, /* Compaq Computer Corporation */ |
| @@ -1,21 +1,21 @@ | ||
| 1 | 1 | /*---------------------------------------------------------------------------- |
| 2 | 2 | ChucK Concurrent, On-the-fly Audio Programming Language |
| 3 | 3 | Compiler and Virtual Machine |
| 4 | − | |
| 4 | + | |
| 5 | 5 | Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved. |
| 6 | 6 | http://chuck.stanford.edu/ |
| 7 | 7 | http://chuck.cs.princeton.edu/ |
| 8 | − | |
| 8 | + | |
| 9 | 9 | This program is free software; you can redistribute it and/or modify |
| 10 | 10 | it under the terms of the GNU General Public License as published by |
| 11 | 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | 12 | (at your option) any later version. |
| 13 | − | |
| 13 | + | |
| 14 | 14 | This program is distributed in the hope that it will be useful, |
| 15 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | 17 | GNU General Public License for more details. |
| 18 | − | |
| 18 | + | |
| 19 | 19 | You should have received a copy of the GNU General Public License |
| 20 | 20 | along with this program; if not, write to the Free Software |
| 21 | 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| @@ -24,10 +24,10 @@ · 2 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | //----------------------------------------------------------------------------- |
| 26 | 26 | // file: chuck.h |
| 27 | −// desc: chuck engine header; VM + compiler + state; no audio I/O | |
| 27 | +// desc: chuck engine header; VM + compiler + state; independent of audio I/O | |
| 28 | 28 | // REFACTOR-2017 |
| 29 | 29 | // |
| 30 | −// author: Ge Wang (http://www.gewang.com/) | |
| 30 | +// author: Ge Wang (https://ccrma.stanford.edu/~ge/) | |
| 31 | 31 | // date: fall 2017 |
| 32 | 32 | // |
| 33 | 33 | // additional authors: |
| @@ -99,7 +99,7 @@ public: · 65 unmodified lines | ||
| 99 | 99 | ChucK(); |
| 100 | 100 | // desctructor |
| 101 | 101 | virtual ~ChucK(); |
| 102 | − | |
| 102 | + | |
| 103 | 103 | public: |
| 104 | 104 | // set parameter by name |
| 105 | 105 | // -- all params should have reasonable defaults |
| @@ -115,9 +115,9 @@ public: · 9 unmodified lines | ||
| 115 | 115 | |
| 116 | 116 | public: |
| 117 | 117 | // compile a file (can be called anytime) |
| 118 | − bool compileFile( const std::string & path, const std::string & argsTogether, int count = 1 ); | |
| 118 | + bool compileFile( const std::string & path, const std::string & argsTogether, t_CKINT count = 1 ); | |
| 119 | 119 | // compile code directly |
| 120 | − bool compileCode( const std::string & code, const std::string & argsTogether, int count = 1 ); | |
| 120 | + bool compileCode( const std::string & code, const std::string & argsTogether, t_CKINT count = 1 ); | |
| 121 | 121 | |
| 122 | 122 | public: |
| 123 | 123 | // initialize ChucK (using params) |
| @@ -127,12 +127,12 @@ public: · 3 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | public: |
| 129 | 129 | // run engine (call from callback) |
| 130 | − void run( SAMPLE * input, SAMPLE * output, int numFrames ); | |
| 130 | + void run( SAMPLE * input, SAMPLE * output, t_CKINT numFrames ); | |
| 131 | 131 | |
| 132 | 132 | public: |
| 133 | 133 | // is initialized |
| 134 | 134 | bool isInit() { return m_init; } |
| 135 | − | |
| 135 | + | |
| 136 | 136 | public: |
| 137 | 137 | // additional native chuck bindings/types (use with extra caution) |
| 138 | 138 | bool bind( f_ck_query queryFunc, const std::string & name ); |
| @@ -175,12 +175,10 @@ protected: · 36 unmodified lines | ||
| 175 | 175 | public: // static functions |
| 176 | 176 | // chuck version |
| 177 | 177 | static const char * version(); |
| 178 | − #ifndef __DISABLE_OTF_SERVER__ | |
| 179 | 178 | // chuck int size (in bits) |
| 180 | − // (this depends on machine, which depends on OTF, so | |
| 181 | − // disable it if we don't have OTF) | |
| 179 | + // (this depends on machine, which depends on OTF, so disable it if we don't have OTF) | |
| 180 | + // 1.5.0.0 (ge) | reinstated for non-OTF, along with parts of machine | |
| 182 | 181 | static t_CKUINT intSize(); |
| 183 | − #endif | |
| 184 | 182 | // number of ChucK's |
| 185 | 183 | static t_CKUINT numVMs() { return o_numVMs; }; |
| 186 | 184 | // --poop compatibilty |
| @@ -197,7 +195,7 @@ protected: · 10 unmodified lines | ||
| 197 | 195 | static const char VERSION[]; |
| 198 | 196 | // number of VMs -- managed from VM constructor/destructors |
| 199 | 197 | static t_CKUINT o_numVMs; |
| 200 | − | |
| 198 | + | |
| 201 | 199 | protected: |
| 202 | 200 | // initialize default params |
| 203 | 201 | void initDefaultParams(); |
| @@ -209,7 +207,7 @@ protected: · 5 unmodified lines | ||
| 209 | 207 | bool initChugins(); |
| 210 | 208 | // init OTF programming system |
| 211 | 209 | bool initOTF(); |
| 212 | − | |
| 210 | + | |
| 213 | 211 | protected: |
| 214 | 212 | // core elements: compiler, VM, etc. |
| 215 | 213 | Chuck_Carrier * m_carrier; |
| @@ -266,7 +266,7 @@ · 265 unmodified lines | ||
| 266 | 266 | |
| 267 | 267 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 268 | 268 | typedef union YYSTYPE |
| 269 | −#line 62 "chuck.y" | |
| 269 | +#line 65 "chuck.y" | |
| 270 | 270 | { |
| 271 | 271 | int pos; |
| 272 | 272 | int ival; |
| @@ -52,7 +52,7 @@ typedef enum { · 51 unmodified lines | ||
| 52 | 52 | ae_op_s_or_chuck, ae_op_s_xor_chuck, ae_op_shift_right_chuck, |
| 53 | 53 | ae_op_shift_left_chuck, ae_op_percent_chuck, ae_op_s_chuck, |
| 54 | 54 | ae_op_plusplus, ae_op_minusminus, ae_op_tilda, ae_op_exclamation, |
| 55 | − ae_op_at_chuck, ae_op_unchuck, ae_op_upchuck, ae_op_spork, | |
| 55 | + ae_op_at_chuck, ae_op_unchuck, ae_op_upchuck, ae_op_spork, | |
| 56 | 56 | ae_op_typeof, ae_op_sizeof, ae_op_new, ae_op_arrow_left, ae_op_arrow_right |
| 57 | 57 | } ae_Operator; |
| 58 | 58 | |
| @@ -118,7 +118,7 @@ typedef struct a_Vec_ * a_Vec; // ge: added 1.3.5.3 · 59 unmodified lines | ||
| 118 | 118 | |
| 119 | 119 | // forward reference for type |
| 120 | 120 | typedef struct Chuck_Type * t_CKTYPE; |
| 121 | −typedef struct Chuck_Value * t_CKVALUE; | |
| 121 | +typedef struct Chuck_Value * t_CKVALUE; | |
| 122 | 122 | typedef struct Chuck_Func * t_CKFUNC; |
| 123 | 123 | typedef struct Chuck_Namespace * t_CKNSPC; |
| 124 | 124 | typedef struct Chuck_VM_Code * t_CKVMCODE; |
| @@ -226,10 +226,11 @@ struct a_Exp_Decl_ { a_Type_Decl type; a_Var_Decl_List var_decl_list; int num_va · 101 unmodified lines | ||
| 226 | 226 | t_CKTYPE ck_type; int linepos; a_Exp self; }; |
| 227 | 227 | struct a_Exp_Hack_ { a_Exp exp; int linepos; a_Exp self; }; |
| 228 | 228 | struct a_Var_Decl_List_ { a_Var_Decl var_decl; a_Var_Decl_List next; int linepos; a_Exp self; }; |
| 229 | +// 1.4.2.0 (ge) added ck_type and ref, to handle multiple array decl (e.g., int x, y[], z[1];) | |
| 229 | 230 | struct a_Var_Decl_ { S_Symbol xid; a_Var_Decl var_decl; a_Array_Sub array; t_CKVALUE value; |
| 230 | − void * addr; int linepos; a_Exp self; }; | |
| 231 | + void * addr; t_CKTYPE ck_type; int ref; int linepos; a_Exp self; }; | |
| 231 | 232 | struct a_Type_Decl_ { a_Id_List xid; a_Array_Sub array; int ref; int linepos; /*a_Exp self;*/ }; |
| 232 | −struct a_Array_Sub_ { t_CKUINT depth; a_Exp exp_list; int linepos; a_Exp self; | |
| 233 | +struct a_Array_Sub_ { t_CKUINT depth; a_Exp exp_list; int linepos; a_Exp self; | |
| 233 | 234 | int err_num; int err_pos; }; |
| 234 | 235 | struct a_Arg_List_ { a_Type_Decl type_decl; a_Var_Decl var_decl; t_CKTYPE type; |
| 235 | 236 | a_Arg_List next; int linepos; a_Exp self; }; |
| @@ -238,7 +239,7 @@ struct a_Polar_ { a_Exp mod; a_Exp phase; int linepos; a_Exp self; }; · 2 unmodified lines | ||
| 238 | 239 | struct a_Vec_ { a_Exp args; int numdims; int linepos; a_Exp self; }; // ge: added 1.3.5.3 |
| 239 | 240 | |
| 240 | 241 | // enum primary exp type |
| 241 | −typedef enum { ae_primary_var, ae_primary_num, ae_primary_float, | |
| 242 | +typedef enum { ae_primary_var, ae_primary_num, ae_primary_float, | |
| 242 | 243 | ae_primary_str, ae_primary_array, ae_primary_exp, |
| 243 | 244 | ae_primary_hack, ae_primary_complex, ae_primary_polar, |
| 244 | 245 | ae_primary_vec, ae_primary_char, ae_primary_nil |
| @@ -248,7 +249,7 @@ struct a_Exp_Primary_ · 3 unmodified lines | ||
| 248 | 249 | { |
| 249 | 250 | ae_Exp_Primary_Type s_type; |
| 250 | 251 | t_CKVALUE value; |
| 251 | − | |
| 252 | + | |
| 252 | 253 | union |
| 253 | 254 | { |
| 254 | 255 | S_Symbol var; |
| @@ -286,7 +287,7 @@ struct a_Exp_ · 31 unmodified lines | ||
| 286 | 287 | t_CKUINT group_size; |
| 287 | 288 | t_CKTYPE cast_to; |
| 288 | 289 | t_CKUINT emit_var; // 1 = emit var, 2 = emit var and value |
| 289 | − | |
| 290 | + | |
| 290 | 291 | union |
| 291 | 292 | { |
| 292 | 293 | struct a_Exp_Binary_ binary; |
| @@ -320,15 +321,15 @@ struct a_Stmt_GotoLabel_ { S_Symbol name; int linepos; a_Stmt self; }; · 27 unmodified lines | ||
| 320 | 321 | |
| 321 | 322 | // enum values for stmt type |
| 322 | 323 | typedef enum { ae_stmt_exp, ae_stmt_while, ae_stmt_until, ae_stmt_for, ae_stmt_loop, |
| 323 | − ae_stmt_if, ae_stmt_code, ae_stmt_switch, ae_stmt_break, | |
| 324 | + ae_stmt_if, ae_stmt_code, ae_stmt_switch, ae_stmt_break, | |
| 324 | 325 | ae_stmt_continue, ae_stmt_return, ae_stmt_case, ae_stmt_gotolabel |
| 325 | 326 | } ae_Stmt_Type; |
| 326 | − | |
| 327 | + | |
| 327 | 328 | struct a_Stmt_ |
| 328 | 329 | { |
| 329 | 330 | ae_Stmt_Type s_type; |
| 330 | 331 | int skip; |
| 331 | − | |
| 332 | + | |
| 332 | 333 | union |
| 333 | 334 | { |
| 334 | 335 | a_Exp stmt_exp; |
| @@ -350,7 +351,7 @@ struct a_Stmt_ · 15 unmodified lines | ||
| 350 | 351 | }; |
| 351 | 352 | |
| 352 | 353 | struct a_Stmt_List_ { a_Stmt stmt; a_Stmt_List next; int linepos; }; |
| 353 | −struct a_Class_Def_ { ae_Keyword decl; a_Id_List name; a_Class_Ext ext; | |
| 354 | +struct a_Class_Def_ { ae_Keyword decl; a_Id_List name; a_Class_Ext ext; | |
| 354 | 355 | a_Class_Body body; t_CKTYPE type; int iface; t_CKNSPC home; |
| 355 | 356 | int linepos; }; |
| 356 | 357 | struct a_Class_Ext_ { a_Id_List extend_id; a_Id_List impl_list; int linepos; }; |
| @@ -363,10 +364,10 @@ typedef enum { ae_func_user, ae_func_builtin } ae_Func_Type; · 6 unmodified lines | ||
| 363 | 364 | // struct t_Func_BuiltIn_ { builtin_func_ptr func_ptr; int linepos; }; |
| 364 | 365 | struct a_Func_Def_ { |
| 365 | 366 | ae_Keyword func_decl; |
| 366 | − ae_Keyword static_decl; | |
| 367 | + ae_Keyword static_decl; | |
| 367 | 368 | a_Type_Decl type_decl; |
| 368 | 369 | t_CKTYPE ret_type; |
| 369 | − S_Symbol name; | |
| 370 | + S_Symbol name; | |
| 370 | 371 | a_Arg_List arg_list; |
| 371 | 372 | a_Stmt code; |
| 372 | 373 | t_CKFUNC ck_func; |
| @@ -384,7 +385,7 @@ typedef enum { ae_section_stmt, ae_section_func, ae_section_class · 11 unmodified lines | ||
| 384 | 385 | struct a_Section_ |
| 385 | 386 | { |
| 386 | 387 | ae_Section_Type s_type; |
| 387 | − | |
| 388 | + | |
| 388 | 389 | union |
| 389 | 390 | { |
| 390 | 391 | a_Stmt_List stmt_list; |
| @@ -1,21 +1,21 @@ | ||
| 1 | 1 | /*---------------------------------------------------------------------------- |
| 2 | 2 | ChucK Concurrent, On-the-fly Audio Programming Language |
| 3 | 3 | Compiler and Virtual Machine |
| 4 | − | |
| 4 | + | |
| 5 | 5 | Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved. |
| 6 | 6 | http://chuck.stanford.edu/ |
| 7 | 7 | http://chuck.cs.princeton.edu/ |
| 8 | − | |
| 8 | + | |
| 9 | 9 | This program is free software; you can redistribute it and/or modify |
| 10 | 10 | it under the terms of the GNU General Public License as published by |
| 11 | 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | 12 | (at your option) any later version. |
| 13 | − | |
| 13 | + | |
| 14 | 14 | This program is distributed in the hope that it will be useful, |
| 15 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | 17 | GNU General Public License for more details. |
| 18 | − | |
| 18 | + | |
| 19 | 19 | You should have received a copy of the GNU General Public License |
| 20 | 20 | along with this program; if not, write to the Free Software |
| 21 | 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| @@ -75,20 +75,20 @@ struct Chuck_Carrier · 53 unmodified lines | ||
| 75 | 75 | Chuck_VM * vm; |
| 76 | 76 | Chuck_IO_Chout * chout; |
| 77 | 77 | Chuck_IO_Cherr * cherr; |
| 78 | − | |
| 78 | + | |
| 79 | 79 | #ifndef __DISABLE_OTF_SERVER__ |
| 80 | 80 | // OTF programming things |
| 81 | 81 | ck_socket otf_socket; |
| 82 | 82 | t_CKINT otf_port; |
| 83 | 83 | CHUCK_THREAD otf_thread; |
| 84 | 84 | #endif |
| 85 | − | |
| 85 | + | |
| 86 | 86 | // STK-specific |
| 87 | 87 | #ifndef __DISABLE_WVOUT__ |
| 88 | 88 | XWriteThread * stk_writeThread; |
| 89 | 89 | std::map<WvOut *, WvOut *> stk_wvOutMap; |
| 90 | 90 | #endif |
| 91 | − | |
| 91 | + | |
| 92 | 92 | // constructor |
| 93 | 93 | Chuck_Carrier() : |
| 94 | 94 | chuck(NULL), |
| @@ -107,7 +107,7 @@ struct Chuck_Carrier · 12 unmodified lines | ||
| 107 | 107 | cherr( NULL ) |
| 108 | 108 | |
| 109 | 109 | { } |
| 110 | − | |
| 110 | + | |
| 111 | 111 | // get hint: is realtime audio? |
| 112 | 112 | t_CKBOOL hintIsRealtimeAudio(); |
| 113 | 113 | }; |
| @@ -56,7 +56,7 @@ struct Chuck_Compiler · 55 unmodified lines | ||
| 56 | 56 | protected: // data |
| 57 | 57 | // carrier |
| 58 | 58 | Chuck_Carrier * m_carrier; |
| 59 | − | |
| 59 | + | |
| 60 | 60 | public: // get protected data |
| 61 | 61 | // REFACTOR-2017: get associated, per-compiler environment |
| 62 | 62 | Chuck_Env * env() const { return m_carrier->env; } |
| @@ -67,7 +67,6 @@ public: // get protected data · 4 unmodified lines | ||
| 67 | 67 | // set carrier |
| 68 | 68 | t_CKBOOL setCarrier( Chuck_Carrier * c ) { m_carrier = c; return TRUE; } |
| 69 | 69 | |
| 70 | − | |
| 71 | 70 | public: // data |
| 72 | 71 | // emitter |
| 73 | 72 | Chuck_Emitter * emitter; |
| @@ -78,10 +77,16 @@ public: // data · 4 unmodified lines | ||
| 78 | 77 | t_CKBOOL m_auto_depend; |
| 79 | 78 | // recent map |
| 80 | 79 | std::map<std::string, Chuck_Context *> m_recent; |
| 81 | − | |
| 80 | + | |
| 81 | + // chugins | |
| 82 | 82 | std::list<Chuck_DLL *> m_dlls; |
| 83 | + // libraries (ck code) to import | |
| 83 | 84 | std::list<std::string> m_cklibs_to_preload; |
| 84 | − | |
| 85 | + | |
| 86 | + // origin hint; this flag is set to different te_Origin values | |
| 87 | + // to denote where new entities originate | 1.5.0.0 (ge) added | |
| 88 | + te_Origin m_originHint; | |
| 89 | + | |
| 85 | 90 | public: // to all |
| 86 | 91 | // contructor |
| 87 | 92 | Chuck_Compiler(); |
| @@ -89,8 +94,7 @@ public: // to all · 1 unmodified line | ||
| 89 | 94 | virtual ~Chuck_Compiler(); |
| 90 | 95 | |
| 91 | 96 | // initialize |
| 92 | − t_CKBOOL initialize( std::list<std::string> & chugin_search_paths, | |
| 93 | − std::list<std::string> & named_dls ); | |
| 97 | + t_CKBOOL initialize(); | |
| 94 | 98 | // shutdown |
| 95 | 99 | void shutdown(); |
| 96 | 100 | |
| @@ -103,22 +107,27 @@ public: // compile · 6 unmodified lines | ||
| 103 | 107 | // set auto depend |
| 104 | 108 | void set_auto_depend( t_CKBOOL v ); |
| 105 | 109 | // parse, type-check, and emit a program |
| 106 | − t_CKBOOL go( const std::string & filename, FILE * fd = NULL, | |
| 110 | + t_CKBOOL go( const std::string & filename, FILE * fd = NULL, | |
| 107 | 111 | const char * str_src = NULL, const std::string & full_path = "" ); |
| 108 | 112 | // resolve a type automatically, if auto_depend is on |
| 109 | 113 | t_CKBOOL resolve( const std::string & type ); |
| 110 | 114 | // get the code generated from the last go() |
| 111 | 115 | Chuck_VM_Code * output( ); |
| 112 | 116 | |
| 113 | −public: // replace-dac | added 1.4.1.0 (jack) | |
| 117 | +public: // replace-dac | added 1.4.1.0 (jack) | |
| 114 | 118 | // sets a "replacement dac": one global UGen is secretly used |
| 115 | 119 | // as a stand-in for "dac" for this compilation; |
| 116 | 120 | // for example, ChuckSubInstances in Chunity use a global Gain as a |
| 117 | 121 | // replacement dac, then use the global getUGenSamples() function to |
| 118 | − // get the samples of the gain. this enables the creation | |
| 122 | + // get the samples of the gain. this enables the creation | |
| 119 | 123 | // of a new sample sucker. |
| 120 | 124 | void setReplaceDac( t_CKBOOL shouldReplaceDac, const std::string & replacement ); |
| 121 | 125 | |
| 126 | +public: // chugin load | refactored 1.4.1.0 (ge) | |
| 127 | + t_CKBOOL load_external_modules( const char * extension, | |
| 128 | + std::list<std::string> & chugin_search_paths, | |
| 129 | + std::list<std::string> & named_dls ); | |
| 130 | + | |
| 122 | 131 | protected: // internal |
| 123 | 132 | // do entire file |
| 124 | 133 | t_CKBOOL do_entire_file( Chuck_Context * context ); |
| @@ -127,8 +136,11 @@ protected: // internal · 2 unmodified lines | ||
| 127 | 136 | // do all excect classes |
| 128 | 137 | t_CKBOOL do_all_except_classes( Chuck_Context * context ); |
| 129 | 138 | // do normal compile |
| 130 | − t_CKBOOL do_normal( const std::string & path, FILE * fd = NULL, | |
| 131 | − const char * str_src = NULL, const std::string & full_path = "" ); | |
| 139 | + t_CKBOOL do_normal_depend( const std::string & path, FILE * fd = NULL, | |
| 140 | + const char * str_src = NULL, const std::string & full_path = "" ); | |
| 141 | + // do auto-depend compile | |
| 142 | + t_CKBOOL do_auto_depend( const std::string & path, FILE * fd = NULL, | |
| 143 | + const char * str_src = NULL, const std::string & full_path = "" ); | |
| 132 | 144 | // look up in recent |
| 133 | 145 | Chuck_Context * find_recent_path( const std::string & path ); |
| 134 | 146 | // look up in recent |
| @@ -104,12 +104,12 @@ typedef struct { t_CKUINT N ; t_CKFLOAT * values ; } t_CKVECTOR; · 103 unmodified lines | ||
| 104 | 104 | |
| 105 | 105 | // kinds (added 1.3.1.0 to faciliate 64-bit support) |
| 106 | 106 | // to differentiate in case int and float have same size |
| 107 | −#define kindof_VOID 0 | |
| 108 | −#define kindof_INT 1 | |
| 109 | −#define kindof_FLOAT 2 | |
| 110 | −#define kindof_COMPLEX 3 | |
| 111 | −#define kindof_VEC3 4 | |
| 112 | −#define kindof_VEC4 5 | |
| 107 | +#define kindof_VOID 0 | |
| 108 | +#define kindof_INT 1 | |
| 109 | +#define kindof_FLOAT 2 | |
| 110 | +#define kindof_COMPLEX 3 | |
| 111 | +#define kindof_VEC3 4 | |
| 112 | +#define kindof_VEC4 5 | |
| 113 | 113 | |
| 114 | 114 | typedef char * c_str; |
| 115 | 115 | typedef const char * c_constr; |
| @@ -140,6 +140,9 @@ typedef struct { SAMPLE re ; SAMPLE im ; } t_CKCOMPLEX_SAMPLE; · 24 unmodified lines | ||
| 140 | 140 | #define FALSE 0 |
| 141 | 141 | #endif |
| 142 | 142 | |
| 143 | +// special non-zero value to denote "no value" | added 1.4.2.0 (ge) | |
| 144 | +#define CK_NO_VALUE 0xffffffff | |
| 145 | + | |
| 143 | 146 | // 3.1415926535897932384626433832795028841971693993751058209749445... |
| 144 | 147 | #define ONE_PI (3.14159265358979323846) |
| 145 | 148 | #define TWO_PI (2.0 * ONE_PI) |
| @@ -151,6 +154,8 @@ typedef struct { SAMPLE re ; SAMPLE im ; } t_CKCOMPLEX_SAMPLE; · 5 unmodified lines | ||
| 151 | 154 | #define SAFE_RELEASE(x) do { if(x){ x->release(); x = NULL; } } while(0) |
| 152 | 155 | #define SAFE_ADD_REF(x) do { if(x){ x->add_ref(); } } while(0) |
| 153 | 156 | #define SAFE_REF_ASSIGN(lhs,rhs) do { SAFE_RELEASE(lhs); (lhs) = (rhs); SAFE_ADD_REF(lhs); } while(0) |
| 157 | +#define SAFE_FREE(x) do { if(x){ free(x); x = NULL; } } while(0) | |
| 158 | +#define SAFE_UNLOCK_DELETE(x) do { if(x){ x->unlock(); delete x; x = NULL; } } while(0) | |
| 154 | 159 | #endif |
| 155 | 160 | |
| 156 | 161 | // max + min |
| @@ -188,7 +193,12 @@ typedef struct { SAMPLE re ; SAMPLE im ; } t_CKCOMPLEX_SAMPLE; · 31 unmodified lines | ||
| 188 | 193 | |
| 189 | 194 | #ifdef __PLATFORM_WIN32__ |
| 190 | 195 | #ifndef usleep |
| 191 | −#define usleep(x) Sleep( (x / 1000 <= 0 ? 1 : x / 1000) ) | |
| 196 | + #define usleep(x) Sleep( (x / 1000 <= 0 ? 1 : x / 1000) ) | |
| 197 | +#endif | |
| 198 | +// 1.4.2.0 (ge and spencer) | added for legacy windows, as part of switch to snprintf | |
| 199 | +// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 | |
| 200 | +#if defined(_MSC_VER) && _MSC_VER < 1900 | |
| 201 | + #define snprintf(buf,len, format,...) _snprintf_s(buf, len,len, format, __VA_ARGS__) | |
| 192 | 202 | #endif |
| 193 | 203 | #pragma warning (disable : 4996) // stdio deprecation |
| 194 | 204 | #pragma warning (disable : 4786) // stl debug info |
| @@ -154,14 +154,14 @@ namespace Chuck_DL_Api { struct Api; } · 153 unmodified lines | ||
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | // chuck dll export linkage and calling convention |
| 157 | −#if defined (__PLATFORM_WIN32__) | |
| 157 | +#if defined (__PLATFORM_WIN32__) | |
| 158 | 158 | #define CK_DLL_LINKAGE extern "C" __declspec( dllexport ) |
| 159 | 159 | #else |
| 160 | − #define CK_DLL_LINKAGE extern "C" | |
| 161 | −#endif | |
| 160 | + #define CK_DLL_LINKAGE extern "C" | |
| 161 | +#endif | |
| 162 | 162 | |
| 163 | 163 | // calling convention of functions provided by chuck to the dll |
| 164 | −#if defined(__WINDOWS_DS__) | |
| 164 | +#if defined(__PLATFORM_WIN32__) | |
| 165 | 165 | #define CK_DLL_CALL _cdecl |
| 166 | 166 | #else |
| 167 | 167 | #define CK_DLL_CALL |
| @@ -183,7 +183,7 @@ typedef const Chuck_DL_Api::Api *CK_DL_API; · 15 unmodified lines | ||
| 183 | 183 | // example: CK_DLL_QUERY |
| 184 | 184 | #ifndef __CK_DLL_STATIC__ |
| 185 | 185 | #define CK_DLL_QUERY(name) CK_DLL_DECLVERSION CK_DLL_EXPORT(t_CKBOOL) ck_query( Chuck_DL_Query * QUERY ) |
| 186 | −#else | |
| 186 | +#else | |
| 187 | 187 | #define CK_DLL_QUERY(name) CK_DLL_QUERY_STATIC(name) |
| 188 | 188 | #endif // __CK_DLL_STATIC__ |
| 189 | 189 | // macro for defining ChucK DLL export allocator |
| @@ -382,13 +382,13 @@ public: · 192 unmodified lines | ||
| 382 | 382 | |
| 383 | 383 | // re-added 1.4.0.1 |
| 384 | 384 | f_create_main_thread_hook create_main_thread_hook; |
| 385 | − | |
| 385 | + | |
| 386 | 386 | // NOTE: everything below std::anything cannot be reliably accessed |
| 387 | 387 | // by offset between dynamic modules, since std::anything could be variable |
| 388 | 388 | // size -- put everything need to be accessed across modules above here! |
| 389 | 389 | // discovered by the vigilant and forever traumatized Jack Atherton, |
| 390 | 390 | // fixed during REFACTOR-2017; warning by the guilt-ridden Ge Wang |
| 391 | − | |
| 391 | + | |
| 392 | 392 | // dll |
| 393 | 393 | Chuck_DLL * dll_ref; |
| 394 | 394 | // reserved |
| @@ -410,7 +410,7 @@ public: · 15 unmodified lines | ||
| 410 | 410 | std::vector<Chuck_DL_Class *> classes; |
| 411 | 411 | // stack |
| 412 | 412 | std::vector<Chuck_DL_Class * >stack; |
| 413 | − | |
| 413 | + | |
| 414 | 414 | // constructor |
| 415 | 415 | Chuck_DL_Query( Chuck_Carrier * carrier ); |
| 416 | 416 | // desctructor |
| @@ -458,12 +458,12 @@ struct Chuck_DL_Class · 41 unmodified lines | ||
| 458 | 458 | std::vector<Chuck_DL_Class *> classes; |
| 459 | 459 | // current mvar offset |
| 460 | 460 | t_CKUINT current_mvar_offset; |
| 461 | − | |
| 461 | + | |
| 462 | 462 | t_CKUINT ugen_num_in, ugen_num_out; |
| 463 | − | |
| 463 | + | |
| 464 | 464 | std::string doc; |
| 465 | 465 | std::vector<std::string> examples; |
| 466 | − | |
| 466 | + | |
| 467 | 467 | // constructor |
| 468 | 468 | Chuck_DL_Class() { dtor = NULL; ugen_tick = NULL; ugen_tickf = NULL; ugen_pmsg = NULL; uana_tock = NULL; ugen_pmsg = NULL; current_mvar_offset = 0; ugen_num_in = ugen_num_out = 0; } |
| 469 | 469 | // destructor |
| @@ -515,7 +515,7 @@ struct Chuck_DL_Func · 45 unmodified lines | ||
| 515 | 515 | std::vector<Chuck_DL_Value *> args; |
| 516 | 516 | // description |
| 517 | 517 | std::string doc; |
| 518 | − | |
| 518 | + | |
| 519 | 519 | // constructor |
| 520 | 520 | Chuck_DL_Func() { ctor = NULL; } |
| 521 | 521 | Chuck_DL_Func( const char * t, const char * n, t_CKUINT a ) |
| @@ -580,7 +580,7 @@ union Chuck_DL_Return · 58 unmodified lines | ||
| 580 | 580 | t_CKVEC4 v_vec4; // ge: added 1.3.5.3 |
| 581 | 581 | Chuck_Object * v_object; |
| 582 | 582 | Chuck_String * v_string; |
| 583 | − | |
| 583 | + | |
| 584 | 584 | Chuck_DL_Return() { v_vec4.x = v_vec4.y = v_vec4.z = v_vec4.w = 0; } |
| 585 | 585 | }; |
| 586 | 586 | |
| @@ -595,7 +595,7 @@ struct Chuck_DLL : public Chuck_VM_Object · 8 unmodified lines | ||
| 595 | 595 | { |
| 596 | 596 | public: |
| 597 | 597 | // load dynamic ckx/dll from filename |
| 598 | − t_CKBOOL load( const char * filename, | |
| 598 | + t_CKBOOL load( const char * filename, | |
| 599 | 599 | const char * func = CK_QUERY_FUNC, |
| 600 | 600 | t_CKBOOL lazy = FALSE ); |
| 601 | 601 | t_CKBOOL load( f_ck_query query_func, t_CKBOOL lazy = FALSE ); |
| @@ -611,7 +611,7 @@ public: · 9 unmodified lines | ||
| 611 | 611 | t_CKBOOL good() const; |
| 612 | 612 | // name |
| 613 | 613 | const char * name() const; |
| 614 | − | |
| 614 | + | |
| 615 | 615 | public: |
| 616 | 616 | // constructor |
| 617 | 617 | Chuck_DLL( Chuck_Carrier * carrier, const char * xid = NULL ) |
| @@ -644,7 +644,7 @@ public: · 26 unmodified lines | ||
| 644 | 644 | void * bindle, Chuck_Carrier * carrier); |
| 645 | 645 | t_CKBOOL (* const activate)(Chuck_DL_MainThreadHook *); |
| 646 | 646 | t_CKBOOL (* const deactivate)(Chuck_DL_MainThreadHook *); |
| 647 | − | |
| 647 | + | |
| 648 | 648 | Chuck_Carrier * const m_carrier; |
| 649 | 649 | f_mainthreadhook const m_hook; |
| 650 | 650 | f_mainthreadquit const m_quit; |
| @@ -665,45 +665,49 @@ struct Api · 14 unmodified lines | ||
| 665 | 665 | public: |
| 666 | 666 | static Api g_api; |
| 667 | 667 | static inline const Api * instance() { return &g_api; } |
| 668 | − | |
| 668 | + | |
| 669 | 669 | struct VMApi |
| 670 | 670 | { |
| 671 | 671 | VMApi(); |
| 672 | 672 | t_CKUINT (* const get_srate)( CK_DL_API, Chuck_VM_Shred * ); |
| 673 | 673 | } * const vm; |
| 674 | − | |
| 674 | + | |
| 675 | 675 | struct ObjectApi |
| 676 | 676 | { |
| 677 | 677 | ObjectApi(); |
| 678 | − private: | |
| 678 | + | |
| 679 | + // 1.5.0.0 (nshaheed and ge and anonymous pr-lab member) | changed from private to public | |
| 680 | + // also changed all std::string & in this section to const char * | |
| 681 | + // intent: this allows for chugins to access member variables and create chuck strings | |
| 682 | + public: | |
| 679 | 683 | // function pointer get_type() |
| 680 | − Type (* const get_type)( CK_DL_API, Chuck_VM_Shred *, std::string &name ); | |
| 684 | + Type (* const get_type)( CK_DL_API, Chuck_VM_Shred *, const char * name ); | |
| 681 | 685 | // function pointer create() |
| 682 | 686 | Object (* const create)( CK_DL_API, Chuck_VM_Shred *, Type type ); |
| 683 | 687 | // function pointer create_string() |
| 684 | − String (* const create_string)( CK_DL_API, Chuck_VM_Shred *, std::string &value ); | |
| 688 | + String (* const create_string)( CK_DL_API, Chuck_VM_Shred *, const char * value ); | |
| 685 | 689 | // function pointers for get_mvar_*() |
| 686 | − t_CKBOOL (* const get_mvar_int)( CK_DL_API, Object object, std::string &name, t_CKINT &value ); | |
| 687 | − t_CKBOOL (* const get_mvar_float)( CK_DL_API, Object object, std::string &name, t_CKFLOAT &value ); | |
| 688 | − t_CKBOOL (* const get_mvar_dur)( CK_DL_API, Object object, std::string &name, t_CKDUR &value ); | |
| 689 | − t_CKBOOL (* const get_mvar_time)( CK_DL_API, Object object, std::string &name, t_CKTIME &value ); | |
| 690 | − t_CKBOOL (* const get_mvar_string)( CK_DL_API, Object object, std::string &name, String &value ); | |
| 691 | − t_CKBOOL (* const get_mvar_object)( CK_DL_API, Object object, std::string &name, Object &value ); | |
| 690 | + t_CKBOOL (* const get_mvar_int)( CK_DL_API, Object object, const char * name, t_CKINT & value ); | |
| 691 | + t_CKBOOL (* const get_mvar_float)( CK_DL_API, Object object, const char * name, t_CKFLOAT & value ); | |
| 692 | + t_CKBOOL (* const get_mvar_dur)( CK_DL_API, Object object, const char * name, t_CKDUR & value ); | |
| 693 | + t_CKBOOL (* const get_mvar_time)( CK_DL_API, Object object, const char * name, t_CKTIME & value ); | |
| 694 | + t_CKBOOL (* const get_mvar_string)( CK_DL_API, Object object, const char * name, String & value ); | |
| 695 | + t_CKBOOL (* const get_mvar_object)( CK_DL_API, Object object, const char * name, Object & value ); | |
| 692 | 696 | // function pointer for set_string() |
| 693 | − t_CKBOOL (* const set_string)( CK_DL_API, String string, std::string &value ); | |
| 697 | + t_CKBOOL (* const set_string)( CK_DL_API, String string, const char * value ); | |
| 694 | 698 | } * const object; |
| 695 | − | |
| 699 | + | |
| 696 | 700 | Api() : |
| 697 | 701 | vm(new VMApi), |
| 698 | 702 | object(new ObjectApi) |
| 699 | 703 | { } |
| 700 | − | |
| 704 | + | |
| 701 | 705 | private: |
| 702 | 706 | Api( Api & a ) : |
| 703 | 707 | vm(a.vm), |
| 704 | 708 | object(a.object) |
| 705 | 709 | { assert(0); }; |
| 706 | − | |
| 710 | + | |
| 707 | 711 | Api & operator=( Api & a ) { assert(0); return a; } |
| 708 | 712 | }; |
| 709 | 713 | } |
| @@ -720,31 +724,33 @@ private: · 10 unmodified lines | ||
| 720 | 724 | |
| 721 | 725 | #error ChucK not support on Mac OS X 10.3 or lower |
| 722 | 726 | |
| 723 | −#elif defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) | |
| 724 | − | |
| 725 | − #ifdef __cplusplus | |
| 726 | − extern "C" { | |
| 727 | − #endif | |
| 728 | − | |
| 729 | − #define RTLD_LAZY 0x1 | |
| 730 | − #define RTLD_NOW 0x2 | |
| 731 | − #define RTLD_LOCAL 0x4 | |
| 732 | − #define RTLD_GLOBAL 0x8 | |
| 733 | − #define RTLD_NOLOAD 0x10 | |
| 734 | − #define RTLD_SHARED 0x20 /* not used, the default */ | |
| 735 | − #define RTLD_UNSHARED 0x40 | |
| 736 | − #define RTLD_NODELETE 0x80 | |
| 737 | − #define RTLD_LAZY_UNDEF 0x100 | |
| 738 | − | |
| 739 | − void * dlopen( const char * path, int mode ); | |
| 740 | − void * dlsym( void * handle, const char * symbol ); | |
| 741 | − const char * dlerror( void ); | |
| 742 | − int dlclose( void * handle ); | |
| 743 | − static char dlerror_buffer[128]; | |
| 744 | − | |
| 745 | − #ifdef __cplusplus | |
| 746 | − } | |
| 747 | − #endif | |
| 727 | +#elif defined(__PLATFORM_WIN32__) | |
| 728 | + | |
| 729 | + #ifdef __cplusplus | |
| 730 | + extern "C" { | |
| 731 | + #endif | |
| 732 | + | |
| 733 | + #define RTLD_LAZY 0x1 | |
| 734 | + #define RTLD_NOW 0x2 | |
| 735 | + #define RTLD_LOCAL 0x4 | |
| 736 | + #define RTLD_GLOBAL 0x8 | |
| 737 | + #define RTLD_NOLOAD 0x10 | |
| 738 | + #define RTLD_SHARED 0x20 /* not used, the default */ | |
| 739 | + #define RTLD_UNSHARED 0x40 | |
| 740 | + #define RTLD_NODELETE 0x80 | |
| 741 | + #define RTLD_LAZY_UNDEF 0x100 | |
| 742 | + | |
| 743 | + void * dlopen( const char * path, int mode ); | |
| 744 | + void * dlsym( void * handle, const char * symbol ); | |
| 745 | + const char * dlerror( void ); | |
| 746 | + int dlclose( void * handle ); | |
| 747 | + // 1.4.2.0 (ge) | added DLERROR_BUFFER_LENGTH | |
| 748 | + #define DLERROR_BUFFER_LENGTH 128 | |
| 749 | + static char dlerror_buffer[DLERROR_BUFFER_LENGTH]; | |
| 750 | + | |
| 751 | + #ifdef __cplusplus | |
| 752 | + } | |
| 753 | + #endif | |
| 748 | 754 | |
| 749 | 755 | #else |
| 750 | 756 | #include "dlfcn.h" |
| @@ -74,10 +74,10 @@ public: · 73 unmodified lines | ||
| 74 | 74 | std::vector<Chuck_Instr_Goto *> stack_break; |
| 75 | 75 | // return stack |
| 76 | 76 | std::vector<Chuck_Instr_Goto *> stack_return; |
| 77 | − | |
| 77 | + | |
| 78 | 78 | // filename this code came from (added 1.3.0.0) |
| 79 | 79 | std::string filename; |
| 80 | − | |
| 80 | + | |
| 81 | 81 | // constructor |
| 82 | 82 | Chuck_Code( ) |
| 83 | 83 | { |
| @@ -122,7 +122,7 @@ struct Chuck_Emitter : public Chuck_VM_Object · 38 unmodified lines | ||
| 122 | 122 | |
| 123 | 123 | // constructor |
| 124 | 124 | Chuck_Emitter() |
| 125 | − { env = NULL; code = NULL; context = NULL; | |
| 125 | + { env = NULL; code = NULL; context = NULL; | |
| 126 | 126 | nspc = NULL; func = NULL; dump = FALSE; |
| 127 | 127 | should_replace_dac = FALSE; } |
| 128 | 128 | |
| @@ -148,11 +148,13 @@ struct Chuck_Emitter : public Chuck_VM_Object · 19 unmodified lines | ||
| 148 | 148 | // add references to locals on current scope (added 1.3.0.0) |
| 149 | 149 | void addref_on_scope(); |
| 150 | 150 | // pop scope |
| 151 | − void pop_scope( ); | |
| 151 | + void pop_scope(); | |
| 152 | + // traverse scope on jumps such as 'return' 'break' 'continue' | 1.5.0.0 (ge) | |
| 153 | + void traverse_scope_on_jump(); | |
| 152 | 154 | |
| 153 | 155 | // default durations |
| 154 | 156 | t_CKBOOL find_dur( const std::string & name, t_CKDUR * out ); |
| 155 | − | |
| 157 | + | |
| 156 | 158 | // post REFACTOR-2017: replace-dac |
| 157 | 159 | std::string dac_replacement; |
| 158 | 160 | t_CKBOOL should_replace_dac; |
| @@ -43,17 +43,17 @@ extern "C" { · 42 unmodified lines | ||
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | extern t_CKBOOL EM_anyErrors; |
| 46 | −extern int EM_tokPos; | |
| 47 | −extern int EM_lineNum; | |
| 46 | +extern t_CKINT EM_tokPos; | |
| 47 | +extern t_CKINT EM_lineNum; | |
| 48 | 48 | |
| 49 | −// EM_extLineNum is synced with EM_lineNum in lexer/parser phase, then synced | |
| 49 | +// EM_extLineNum is synced with EM_lineNum in lexer/parser phase, then synced | |
| 50 | 50 | // with scanner/typechecker (EM_lineNum is not synced with scanner/typechecker) |
| 51 | −extern int EM_extLineNum; | |
| 51 | +extern t_CKINT EM_extLineNum; | |
| 52 | 52 | |
| 53 | 53 | void EM_newline( ); |
| 54 | 54 | |
| 55 | 55 | // levels |
| 56 | −#define CK_LOG_CRAZY 10 // set this to log everything | |
| 56 | +#define CK_LOG_ALL 10 // set this to log everything | |
| 57 | 57 | #define CK_LOG_FINEST 9 |
| 58 | 58 | #define CK_LOG_FINER 8 |
| 59 | 59 | #define CK_LOG_FINE 7 |
| @@ -155,9 +155,9 @@ extern t_CKINT g_loglevel; · 95 unmodified lines | ||
| 155 | 155 | // macro to compare |
| 156 | 156 | #define DO_LOG(x) ( x <= g_loglevel ) |
| 157 | 157 | |
| 158 | −void EM_error( int, c_constr, ... ); | |
| 159 | −void EM_error2( int, c_constr, ... ); | |
| 160 | −void EM_error2b( int, c_constr, ... ); | |
| 158 | +void EM_error( t_CKINT, c_constr, ... ); | |
| 159 | +void EM_error2( t_CKINT, c_constr, ... ); | |
| 160 | +void EM_error2b( t_CKINT, c_constr, ... ); | |
| 161 | 161 | void EM_error3( c_constr, ... ); |
| 162 | 162 | void EM_impossible( c_constr, ... ); |
| 163 | 163 | t_CKBOOL EM_reset( c_constr filename, FILE * fd ); |
| @@ -190,7 +190,7 @@ public: · 26 unmodified lines | ||
| 190 | 190 | { |
| 191 | 191 | EM_pushlog(); |
| 192 | 192 | } |
| 193 | − | |
| 193 | + | |
| 194 | 194 | ~SmartPushLog() |
| 195 | 195 | { |
| 196 | 196 | EM_poplog(); |
| @@ -92,7 +92,7 @@ public: · 91 unmodified lines | ||
| 92 | 92 | Chuck_Local * alloc_local( t_CKUINT size, const std::string & name, |
| 93 | 93 | t_CKBOOL is_ref, t_CKBOOL is_obj, t_CKBOOL is_global ); |
| 94 | 94 | // get the current scope (added 1.3.0.0) |
| 95 | − void get_scope( std::vector<Chuck_Local *> & out ) const; | |
| 95 | + void get_scope( std::vector<Chuck_Local *> & out, bool localOnly = true ) const; | |
| 96 | 96 | // pop scope |
| 97 | 97 | void pop_scope( std::vector<Chuck_Local *> & out ); |
| 98 | 98 | }; |
| @@ -164,7 +164,7 @@ struct Chuck_Global_Request · 163 unmodified lines | ||
| 164 | 164 | // chuck_msg |
| 165 | 165 | Chuck_Execute_Chuck_Msg_Request* executeChuckMsgRequest; |
| 166 | 166 | }; |
| 167 | − | |
| 167 | + | |
| 168 | 168 | Chuck_Global_Request() |
| 169 | 169 | { |
| 170 | 170 | retries = 0; |
| @@ -183,7 +183,7 @@ struct Chuck_Globals_Manager · 12 unmodified lines | ||
| 183 | 183 | public: |
| 184 | 184 | Chuck_Globals_Manager( Chuck_VM * vm ); |
| 185 | 185 | ~Chuck_Globals_Manager(); |
| 186 | − | |
| 186 | + | |
| 187 | 187 | public: |
| 188 | 188 | // REFACTOR-2017: externally accessible + global variables. |
| 189 | 189 | // use these getters and setters from outside the audio thread |
| @@ -191,17 +191,17 @@ public: · 1 unmodified line | ||
| 191 | 191 | t_CKBOOL getGlobalInt( const char * name, void (*callback)(const char*, t_CKINT) ); |
| 192 | 192 | t_CKBOOL getGlobalInt( const char * name, t_CKINT callbackID, void (*callback)(t_CKINT, t_CKINT) ); |
| 193 | 193 | t_CKBOOL setGlobalInt( const char * name, t_CKINT val ); |
| 194 | − | |
| 194 | + | |
| 195 | 195 | t_CKBOOL getGlobalFloat( const char * name, void (*callback)(t_CKFLOAT) ); |
| 196 | 196 | t_CKBOOL getGlobalFloat( const char * name, void (*callback)(const char*, t_CKFLOAT) ); |
| 197 | 197 | t_CKBOOL getGlobalFloat( const char * name, t_CKINT callbackID, void (*callback)(t_CKINT, t_CKFLOAT) ); |
| 198 | 198 | t_CKBOOL setGlobalFloat( const char * name, t_CKFLOAT val ); |
| 199 | − | |
| 199 | + | |
| 200 | 200 | t_CKBOOL getGlobalString( const char * name, void (*callback)(const char*) ); |
| 201 | 201 | t_CKBOOL getGlobalString( const char * name, void (*callback)(const char*, const char*) ); |
| 202 | 202 | t_CKBOOL getGlobalString( const char * name, t_CKINT callbackID, void (*callback)(t_CKINT, const char*) ); |
| 203 | 203 | t_CKBOOL setGlobalString( const char * name, const char * val ); |
| 204 | − | |
| 204 | + | |
| 205 | 205 | t_CKBOOL signalGlobalEvent( const char * name ); |
| 206 | 206 | t_CKBOOL broadcastGlobalEvent( const char * name ); |
| 207 | 207 | t_CKBOOL listenForGlobalEvent( const char * name, void (*callback)(void), t_CKBOOL listen_forever ); |
| @@ -210,9 +210,9 @@ public: · 2 unmodified lines | ||
| 210 | 210 | t_CKBOOL stopListeningForGlobalEvent( const char * name, void (*callback)(void) ); |
| 211 | 211 | t_CKBOOL stopListeningForGlobalEvent( const char * name, void (*callback)(const char*) ); |
| 212 | 212 | t_CKBOOL stopListeningForGlobalEvent( const char * name, t_CKINT callbackID, void (*callback)(t_CKINT) ); |
| 213 | − | |
| 213 | + | |
| 214 | 214 | t_CKBOOL getGlobalUGenSamples( const char * name, SAMPLE* buffer, int numFrames ); |
| 215 | − | |
| 215 | + | |
| 216 | 216 | t_CKBOOL setGlobalIntArray( const char * name, t_CKINT arrayValues[], t_CKUINT numValues ); |
| 217 | 217 | t_CKBOOL getGlobalIntArray( const char * name, void (*callback)(t_CKINT[], t_CKUINT) ); |
| 218 | 218 | t_CKBOOL getGlobalIntArray( const char * name, void (*callback)(const char*, t_CKINT[], t_CKUINT) ); |
| @@ -225,7 +225,7 @@ public: · 6 unmodified lines | ||
| 225 | 225 | t_CKBOOL getGlobalAssociativeIntArrayValue( const char * name, const char * key, void (*callback)(t_CKINT) ); |
| 226 | 226 | t_CKBOOL getGlobalAssociativeIntArrayValue( const char * name, const char * key, void (*callback)(const char*, t_CKINT) ); |
| 227 | 227 | t_CKBOOL getGlobalAssociativeIntArrayValue( const char * name, t_CKINT callbackID, const char * key, void (*callback)(t_CKINT, t_CKINT) ); |
| 228 | − | |
| 228 | + | |
| 229 | 229 | t_CKBOOL setGlobalFloatArray( const char * name, t_CKFLOAT arrayValues[], t_CKUINT numValues ); |
| 230 | 230 | t_CKBOOL getGlobalFloatArray( const char * name, void (*callback)(t_CKFLOAT[], t_CKUINT) ); |
| 231 | 231 | t_CKBOOL getGlobalFloatArray( const char * name, void (*callback)(const char*, t_CKFLOAT[], t_CKUINT) ); |
| @@ -238,11 +238,11 @@ public: · 6 unmodified lines | ||
| 238 | 238 | t_CKBOOL getGlobalAssociativeFloatArrayValue( const char * name, const char * key, void (*callback)(t_CKFLOAT) ); |
| 239 | 239 | t_CKBOOL getGlobalAssociativeFloatArrayValue( const char * name, const char * key, void (*callback)(const char*, t_CKFLOAT) ); |
| 240 | 240 | t_CKBOOL getGlobalAssociativeFloatArrayValue( const char * name, t_CKINT callbackID, const char * key, void (*callback)(t_CKINT, t_CKFLOAT) ); |
| 241 | − | |
| 241 | + | |
| 242 | 242 | public: |
| 243 | 243 | // run Chuck_Msg in the globals order |
| 244 | 244 | t_CKBOOL execute_chuck_msg_with_globals( Chuck_Msg* msg ); |
| 245 | − | |
| 245 | + | |
| 246 | 246 | public: |
| 247 | 247 | // REFACTOR-2017: externally accessible + global variables. |
| 248 | 248 | // WARNING: these internal functions are to be used only by other |
| @@ -250,25 +250,25 @@ public: · 1 unmodified line | ||
| 250 | 250 | t_CKBOOL init_global_int( const std::string & name ); |
| 251 | 251 | t_CKINT get_global_int_value( const std::string & name ); |
| 252 | 252 | t_CKINT* get_ptr_to_global_int( const std::string & name ); |
| 253 | − | |
| 253 | + | |
| 254 | 254 | t_CKBOOL init_global_float( const std::string & name ); |
| 255 | 255 | t_CKFLOAT get_global_float_value( const std::string & name ); |
| 256 | 256 | t_CKFLOAT* get_ptr_to_global_float( const std::string & name ); |
| 257 | − | |
| 257 | + | |
| 258 | 258 | t_CKBOOL init_global_string( const std::string & name ); |
| 259 | 259 | Chuck_String* get_global_string( const std::string & name ); |
| 260 | 260 | Chuck_String** get_ptr_to_global_string( const std::string & name ); |
| 261 | − | |
| 261 | + | |
| 262 | 262 | t_CKBOOL init_global_event( const std::string & name, Chuck_Type* type ); |
| 263 | 263 | Chuck_Event* get_global_event( const std::string & name ); |
| 264 | 264 | Chuck_Event** get_ptr_to_global_event( const std::string & name ); |
| 265 | − | |
| 265 | + | |
| 266 | 266 | t_CKBOOL init_global_ugen( const std::string & name, Chuck_Type* type ); |
| 267 | 267 | t_CKBOOL is_global_ugen_init( const std::string & name ); |
| 268 | 268 | t_CKBOOL is_global_ugen_valid( const std::string & name ); |
| 269 | 269 | Chuck_UGen* get_global_ugen( const std::string & name ); |
| 270 | 270 | Chuck_UGen** get_ptr_to_global_ugen( const std::string & name ); |
| 271 | − | |
| 271 | + | |
| 272 | 272 | t_CKBOOL init_global_array( const std::string & name, Chuck_Type* type, te_GlobalType arr_type ); |
| 273 | 273 | Chuck_Object* get_global_array( const std::string & name ); |
| 274 | 274 | Chuck_Object** get_ptr_to_global_array( const std::string & name ); |
| @@ -282,24 +282,24 @@ public: · 7 unmodified lines | ||
| 282 | 282 | t_CKBOOL is_global_object_valid( const std::string & name ); |
| 283 | 283 | Chuck_Object* get_global_object( const std::string & name ); |
| 284 | 284 | Chuck_Object** get_ptr_to_global_object( const std::string & name ); |
| 285 | − | |
| 285 | + | |
| 286 | 286 | t_CKBOOL should_call_global_ctor( const std::string & name, te_GlobalType type ); |
| 287 | 287 | void global_ctor_was_called( const std::string & name, te_GlobalType type ); |
| 288 | − | |
| 288 | + | |
| 289 | 289 | // global variables -- clean up |
| 290 | 290 | void cleanup_global_variables(); |
| 291 | − | |
| 291 | + | |
| 292 | 292 | public: // these should ever ONLY be called from within the VM |
| 293 | 293 | // request queue: add, query for size |
| 294 | 294 | t_CKBOOL add_request( Chuck_Global_Request request ); |
| 295 | 295 | t_CKBOOL more_requests(); |
| 296 | 296 | // REFACTOR-2017: execute the messages from the global queue |
| 297 | 297 | void handle_global_queue_messages(); |
| 298 | − | |
| 298 | + | |
| 299 | 299 | private: |
| 300 | 300 | // ptr to my vm |
| 301 | 301 | Chuck_VM * m_vm; |
| 302 | − | |
| 302 | + | |
| 303 | 303 | // global variables -- storage |
| 304 | 304 | std::map< std::string, Chuck_Global_Int_Container* > m_global_ints; |
| 305 | 305 | std::map< std::string, Chuck_Global_Float_Container* > m_global_floats; |
| @@ -311,7 +311,7 @@ private: · 5 unmodified lines | ||
| 311 | 311 | |
| 312 | 312 | // global variables -- messages for set, get, etc. |
| 313 | 313 | XCircleBuffer< Chuck_Global_Request > m_global_request_queue; |
| 314 | − | |
| 314 | + | |
| 315 | 315 | // retry queue: sometimes a request comes through exactly 1 sample |
| 316 | 316 | // before the relevant global variable is constructed |
| 317 | 317 | // (e.g. signalEvent before the compileCode that would construct the event) |
| @@ -44,6 +44,9 @@ struct Chuck_VM_Shred; · 43 unmodified lines | ||
| 44 | 44 | struct Chuck_Type; |
| 45 | 45 | struct Chuck_Func; |
| 46 | 46 | |
| 47 | +// 1.4.2.0 (ge) | added for switching from snprintf() | |
| 48 | +#define CK_PRINT_BUF_LENGTH 256 | |
| 49 | + | |
| 47 | 50 | |
| 48 | 51 | |
| 49 | 52 | |
| @@ -55,19 +58,25 @@ struct Chuck_Instr · 5 unmodified lines | ||
| 55 | 58 | { |
| 56 | 59 | public: |
| 57 | 60 | Chuck_Instr(); |
| 58 | − virtual ~Chuck_Instr() { } | |
| 61 | + virtual ~Chuck_Instr() { SAFE_DELETE(m_codestr); } | |
| 59 | 62 | |
| 60 | 63 | public: |
| 61 | 64 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) = 0; |
| 62 | 65 | |
| 63 | 66 | public: |
| 64 | 67 | virtual const char * name() const; |
| 65 | − virtual const char * params() const | |
| 68 | + virtual const char * params() const | |
| 66 | 69 | { return ""; } |
| 67 | 70 | |
| 68 | 71 | public: |
| 72 | + // store line position for error messages | |
| 69 | 73 | void set_linepos( t_CKUINT linepos ); |
| 70 | 74 | t_CKUINT m_linepos; |
| 75 | + | |
| 76 | + // set codestr associated with this instruction | |
| 77 | + void set_codestr( const std::string & str ); | |
| 78 | + // (used in instruction dump) | 1.5.0.0 (ge) added | |
| 79 | + std::string * m_codestr; | |
| 71 | 80 | }; |
| 72 | 81 | |
| 73 | 82 | |
| @@ -84,7 +93,7 @@ public: · 10 unmodified lines | ||
| 84 | 93 | |
| 85 | 94 | public: |
| 86 | 95 | virtual const char * params() const |
| 87 | − { static char buffer[256]; sprintf( buffer, "%ld", m_jmp ); return buffer; } | |
| 96 | + { static char buffer[CK_PRINT_BUF_LENGTH]; snprintf( buffer, CK_PRINT_BUF_LENGTH, "%ld", (long)m_jmp ); return buffer; } | |
| 88 | 97 | |
| 89 | 98 | protected: |
| 90 | 99 | t_CKUINT m_jmp; |
| @@ -105,7 +114,7 @@ public: · 14 unmodified lines | ||
| 105 | 114 | |
| 106 | 115 | public: |
| 107 | 116 | virtual const char * params() const |
| 108 | − { static char buffer[256]; sprintf( buffer, "%ld", m_val ); return buffer; } | |
| 117 | + { static char buffer[CK_PRINT_BUF_LENGTH]; snprintf( buffer, CK_PRINT_BUF_LENGTH, "%ld", (long)m_val ); return buffer; } | |
| 109 | 118 | |
| 110 | 119 | protected: |
| 111 | 120 | t_CKUINT m_val; |
| @@ -126,7 +135,7 @@ public: · 14 unmodified lines | ||
| 126 | 135 | |
| 127 | 136 | public: |
| 128 | 137 | virtual const char * params() const |
| 129 | − { static char buffer[256]; sprintf( buffer, "%.6f", m_val ); return buffer; } | |
| 138 | + { static char buffer[CK_PRINT_BUF_LENGTH]; snprintf( buffer, CK_PRINT_BUF_LENGTH, "%.6f", m_val ); return buffer; } | |
| 130 | 139 | |
| 131 | 140 | protected: |
| 132 | 141 | t_CKFLOAT m_val; |
| @@ -2014,6 +2023,23 @@ protected: · 1881 unmodified lines | ||
| 2014 | 2023 | |
| 2015 | 2024 | |
| 2016 | 2025 | |
| 2026 | +//----------------------------------------------------------------------------- | |
| 2027 | +// name: struct Chuck_Instr_Reg_Push_Zero | |
| 2028 | +// desc: push immediate value 0 to reg stack with specific width | |
| 2029 | +//----------------------------------------------------------------------------- | |
| 2030 | +struct Chuck_Instr_Reg_Push_Zero : public Chuck_Instr_Unary_Op | |
| 2031 | +{ | |
| 2032 | +public: | |
| 2033 | + Chuck_Instr_Reg_Push_Zero( t_CKUINT sizeInBytes ) | |
| 2034 | + { this->set( sizeInBytes ); } | |
| 2035 | + | |
| 2036 | +public: | |
| 2037 | + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); | |
| 2038 | +}; | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2017 | 2043 | //----------------------------------------------------------------------------- |
| 2018 | 2044 | // name: struct Chuck_Instr_Reg_Dup_Last |
| 2019 | 2045 | // desc: duplicate last value on reg stack |
| @@ -2133,8 +2159,8 @@ public: · 113 unmodified lines | ||
| 2133 | 2159 | public: |
| 2134 | 2160 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2135 | 2161 | virtual const char * params() const |
| 2136 | − { static char buffer[256]; | |
| 2137 | − sprintf( buffer, "src=%ld, base=%ld", m_val, base ); | |
| 2162 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2163 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "src=%ld, base=%ld", (long)m_val, (long)base ); | |
| 2138 | 2164 | return buffer; } |
| 2139 | 2165 | |
| 2140 | 2166 | protected: |
| @@ -2158,8 +2184,8 @@ public: · 17 unmodified lines | ||
| 2158 | 2184 | public: |
| 2159 | 2185 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2160 | 2186 | virtual const char * params() const |
| 2161 | − { static char buffer[256]; | |
| 2162 | − sprintf( buffer, "src=%ld, base=%ld", m_val, base ); | |
| 2187 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2188 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "src=%ld, base=%ld", (long)m_val, (long)base ); | |
| 2163 | 2189 | return buffer; } |
| 2164 | 2190 | |
| 2165 | 2191 | protected: |
| @@ -2183,8 +2209,8 @@ public: · 17 unmodified lines | ||
| 2183 | 2209 | public: |
| 2184 | 2210 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2185 | 2211 | virtual const char * params() const |
| 2186 | − { static char buffer[256]; | |
| 2187 | − sprintf( buffer, "src=%ld, base=%ld", m_val, base ); | |
| 2212 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2213 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "src=%ld, base=%ld", (long)m_val, (long)base ); | |
| 2188 | 2214 | return buffer; } |
| 2189 | 2215 | |
| 2190 | 2216 | protected: |
| @@ -2204,14 +2230,14 @@ struct Chuck_Instr_Reg_Push_Mem_Vec3 : public Chuck_Instr_Unary_Op · 13 unmodified lines | ||
| 2204 | 2230 | public: |
| 2205 | 2231 | Chuck_Instr_Reg_Push_Mem_Vec3( t_CKUINT src, t_CKBOOL use_base = FALSE ) |
| 2206 | 2232 | { this->set( src ); base = use_base; } |
| 2207 | − | |
| 2233 | + | |
| 2208 | 2234 | public: |
| 2209 | 2235 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2210 | 2236 | virtual const char * params() const |
| 2211 | − { static char buffer[256]; | |
| 2212 | − sprintf( buffer, "src=%ld, base=%ld", m_val, base ); | |
| 2237 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2238 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "src=%ld, base=%ld", (long)m_val, (long)base ); | |
| 2213 | 2239 | return buffer; } |
| 2214 | − | |
| 2240 | + | |
| 2215 | 2241 | protected: |
| 2216 | 2242 | // use global stack base |
| 2217 | 2243 | t_CKBOOL base; |
| @@ -2229,14 +2255,14 @@ struct Chuck_Instr_Reg_Push_Mem_Vec4 : public Chuck_Instr_Unary_Op · 11 unmodified lines | ||
| 2229 | 2255 | public: |
| 2230 | 2256 | Chuck_Instr_Reg_Push_Mem_Vec4( t_CKUINT src, t_CKBOOL use_base = FALSE ) |
| 2231 | 2257 | { this->set( src ); base = use_base; } |
| 2232 | − | |
| 2258 | + | |
| 2233 | 2259 | public: |
| 2234 | 2260 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2235 | 2261 | virtual const char * params() const |
| 2236 | − { static char buffer[256]; | |
| 2237 | − sprintf( buffer, "src=%ld, base=%ld", m_val, base ); | |
| 2262 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2263 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "src=%ld, base=%ld", (long)m_val, (long)base ); | |
| 2238 | 2264 | return buffer; } |
| 2239 | − | |
| 2265 | + | |
| 2240 | 2266 | protected: |
| 2241 | 2267 | // use global stack base |
| 2242 | 2268 | t_CKBOOL base; |
| @@ -2258,8 +2284,8 @@ public: · 15 unmodified lines | ||
| 2258 | 2284 | public: |
| 2259 | 2285 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2260 | 2286 | virtual const char * params() const |
| 2261 | − { static char buffer[256]; | |
| 2262 | − sprintf( buffer, "name='%s'", m_name.c_str() ); | |
| 2287 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2288 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "name='%s'", m_name.c_str() ); | |
| 2263 | 2289 | return buffer; } |
| 2264 | 2290 | |
| 2265 | 2291 | public: |
| @@ -2283,8 +2309,8 @@ public: · 17 unmodified lines | ||
| 2283 | 2309 | public: |
| 2284 | 2310 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2285 | 2311 | virtual const char * params() const |
| 2286 | − { static char buffer[256]; | |
| 2287 | − sprintf( buffer, "src=%ld, base=%ld", m_val, base ); | |
| 2312 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2313 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "src=%ld, base=%ld", (long)m_val, (long)base ); | |
| 2288 | 2314 | return buffer; } |
| 2289 | 2315 | |
| 2290 | 2316 | protected: |
| @@ -2308,8 +2334,8 @@ public: · 17 unmodified lines | ||
| 2308 | 2334 | public: |
| 2309 | 2335 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2310 | 2336 | virtual const char * params() const |
| 2311 | − { static char buffer[256]; | |
| 2312 | − sprintf( buffer, "name='%s'", m_name.c_str() ); | |
| 2337 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2338 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "name='%s'", m_name.c_str() ); | |
| 2313 | 2339 | return buffer; } |
| 2314 | 2340 | |
| 2315 | 2341 | protected: |
| @@ -2364,12 +2390,12 @@ struct Chuck_Instr_Mem_Set_Imm : public Chuck_Instr · 48 unmodified lines | ||
| 2364 | 2390 | public: |
| 2365 | 2391 | Chuck_Instr_Mem_Set_Imm( t_CKUINT offset, t_CKUINT val ) |
| 2366 | 2392 | { m_offset = offset; m_val = val; } |
| 2367 | − | |
| 2393 | + | |
| 2368 | 2394 | public: |
| 2369 | 2395 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2370 | 2396 | virtual const char * params() const |
| 2371 | − { static char buffer[256]; | |
| 2372 | − sprintf( buffer, "offset=%ld, value=%ld", m_offset, m_val ); | |
| 2397 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2398 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "offset=%ld, value=%ld", (long)m_offset, (long)m_val ); | |
| 2373 | 2399 | return buffer; } |
| 2374 | 2400 | |
| 2375 | 2401 | protected: |
| @@ -2389,12 +2415,12 @@ struct Chuck_Instr_Mem_Set_Imm2 : public Chuck_Instr_Unary_Op · 13 unmodified lines | ||
| 2389 | 2415 | public: |
| 2390 | 2416 | Chuck_Instr_Mem_Set_Imm2( t_CKUINT offset, t_CKFLOAT val ) |
| 2391 | 2417 | { m_offset = offset; m_val = val; } |
| 2392 | − | |
| 2418 | + | |
| 2393 | 2419 | public: |
| 2394 | 2420 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2395 | 2421 | virtual const char * params() const |
| 2396 | − { static char buffer[256]; | |
| 2397 | − sprintf( buffer, "offset=%ld, value=%f", m_offset, m_val ); | |
| 2422 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2423 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "offset=%ld, value=%f", (long)m_offset, m_val ); | |
| 2398 | 2424 | return buffer; } |
| 2399 | 2425 | |
| 2400 | 2426 | protected: |
| @@ -2414,7 +2440,7 @@ struct Chuck_Instr_Mem_Push_Imm : public Chuck_Instr_Unary_Op · 13 unmodified lines | ||
| 2414 | 2440 | public: |
| 2415 | 2441 | Chuck_Instr_Mem_Push_Imm( t_CKUINT src ) |
| 2416 | 2442 | { this->set( src ); } |
| 2417 | − | |
| 2443 | + | |
| 2418 | 2444 | public: |
| 2419 | 2445 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2420 | 2446 | }; |
| @@ -2430,7 +2456,7 @@ struct Chuck_Instr_Mem_Push_Imm2 : public Chuck_Instr_Unary_Op2 · 9 unmodified lines | ||
| 2430 | 2456 | public: |
| 2431 | 2457 | Chuck_Instr_Mem_Push_Imm2( t_CKFLOAT src ) |
| 2432 | 2458 | { this->set( src ); } |
| 2433 | − | |
| 2459 | + | |
| 2434 | 2460 | public: |
| 2435 | 2461 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2436 | 2462 | }; |
| @@ -2513,10 +2539,10 @@ public: · 76 unmodified lines | ||
| 2513 | 2539 | // (added 1.3.0.0 -- is_object) |
| 2514 | 2540 | Chuck_Instr_Alloc_Word( t_CKUINT offset, t_CKBOOL is_object ) |
| 2515 | 2541 | { this->set( offset ); m_is_object = is_object; } |
| 2516 | − | |
| 2542 | + | |
| 2517 | 2543 | // was this object reference? (added 1.3.0.0) |
| 2518 | 2544 | t_CKBOOL m_is_object; |
| 2519 | − | |
| 2545 | + | |
| 2520 | 2546 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2521 | 2547 | }; |
| 2522 | 2548 | |
| @@ -2532,7 +2558,7 @@ struct Chuck_Instr_Alloc_Word2 : public Chuck_Instr_Unary_Op · 9 unmodified lines | ||
| 2532 | 2558 | public: |
| 2533 | 2559 | Chuck_Instr_Alloc_Word2( t_CKUINT offset ) |
| 2534 | 2560 | { this->set( offset ); } |
| 2535 | − | |
| 2561 | + | |
| 2536 | 2562 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2537 | 2563 | }; |
| 2538 | 2564 | |
| @@ -2564,7 +2590,7 @@ struct Chuck_Instr_Alloc_Vec3 : public Chuck_Instr_Unary_Op · 25 unmodified lines | ||
| 2564 | 2590 | public: |
| 2565 | 2591 | Chuck_Instr_Alloc_Vec3( t_CKUINT offset ) |
| 2566 | 2592 | { this->set( offset ); } |
| 2567 | − | |
| 2593 | + | |
| 2568 | 2594 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2569 | 2595 | }; |
| 2570 | 2596 | |
| @@ -2580,7 +2606,7 @@ struct Chuck_Instr_Alloc_Vec4 : public Chuck_Instr_Unary_Op · 9 unmodified lines | ||
| 2580 | 2606 | public: |
| 2581 | 2607 | Chuck_Instr_Alloc_Vec4( t_CKUINT offset ) |
| 2582 | 2608 | { this->set( offset ); } |
| 2583 | − | |
| 2609 | + | |
| 2584 | 2610 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2585 | 2611 | }; |
| 2586 | 2612 | |
| @@ -2644,7 +2670,7 @@ struct Chuck_Instr_Alloc_Member_Vec3 : public Chuck_Instr_Unary_Op · 57 unmodified lines | ||
| 2644 | 2670 | public: |
| 2645 | 2671 | Chuck_Instr_Alloc_Member_Vec3( t_CKUINT offset ) |
| 2646 | 2672 | { this->set( offset ); } |
| 2647 | − | |
| 2673 | + | |
| 2648 | 2674 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2649 | 2675 | }; |
| 2650 | 2676 | |
| @@ -2660,7 +2686,7 @@ struct Chuck_Instr_Alloc_Member_Vec4 : public Chuck_Instr_Unary_Op · 9 unmodified lines | ||
| 2660 | 2686 | public: |
| 2661 | 2687 | Chuck_Instr_Alloc_Member_Vec4( t_CKUINT offset ) |
| 2662 | 2688 | { this->set( offset ); } |
| 2663 | − | |
| 2689 | + | |
| 2664 | 2690 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2665 | 2691 | }; |
| 2666 | 2692 | |
| @@ -2678,22 +2704,22 @@ public: · 11 unmodified lines | ||
| 2678 | 2704 | Chuck_Instr_Alloc_Word_Global() |
| 2679 | 2705 | { this->set( 0 ); m_stack_offset = 0; m_chuck_type = NULL; |
| 2680 | 2706 | m_should_execute_ctors = FALSE; m_is_array = FALSE; } |
| 2681 | − | |
| 2707 | + | |
| 2682 | 2708 | virtual const char * params() const |
| 2683 | − { static char buffer[256]; | |
| 2684 | − sprintf( buffer, "name='%s'", m_name.c_str() ); | |
| 2709 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 2710 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "name='%s'", m_name.c_str() ); | |
| 2685 | 2711 | return buffer; } |
| 2686 | − | |
| 2712 | + | |
| 2687 | 2713 | // global name and type |
| 2688 | 2714 | std::string m_name; |
| 2689 | 2715 | te_GlobalType m_type; |
| 2690 | 2716 | t_CKBOOL m_is_array; |
| 2691 | − | |
| 2717 | + | |
| 2692 | 2718 | // for objects |
| 2693 | 2719 | t_CKBOOL m_should_execute_ctors; |
| 2694 | 2720 | t_CKUINT m_stack_offset; |
| 2695 | 2721 | Chuck_Type * m_chuck_type; |
| 2696 | − | |
| 2722 | + | |
| 2697 | 2723 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2698 | 2724 | }; |
| 2699 | 2725 | |
| @@ -2946,7 +2972,7 @@ struct Chuck_Instr_AddRef_Object2 : public Chuck_Instr_Unary_Op · 246 unmodified lines | ||
| 2946 | 2972 | public: |
| 2947 | 2973 | Chuck_Instr_AddRef_Object2( t_CKUINT offset ) |
| 2948 | 2974 | { this->set( offset ); } |
| 2949 | − | |
| 2975 | + | |
| 2950 | 2976 | public: |
| 2951 | 2977 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 2952 | 2978 | }; |
| @@ -2957,6 +2983,7 @@ public: · 4 unmodified lines | ||
| 2957 | 2983 | //----------------------------------------------------------------------------- |
| 2958 | 2984 | // name: struct Chuck_Instr_Reg_AddRef_Object3 |
| 2959 | 2985 | // desc: added 1.3.0.0 -- does the ref add in-place |
| 2986 | +// operates on top of the register stack | |
| 2960 | 2987 | //----------------------------------------------------------------------------- |
| 2961 | 2988 | struct Chuck_Instr_Reg_AddRef_Object3 : public Chuck_Instr |
| 2962 | 2989 | { |
| @@ -2969,7 +2996,7 @@ public: · 6 unmodified lines | ||
| 2969 | 2996 | |
| 2970 | 2997 | //----------------------------------------------------------------------------- |
| 2971 | 2998 | // name: struct Chuck_Instr_Release_Object |
| 2972 | −// desc: ... | |
| 2999 | +// desc: release object on stack by its offset | |
| 2973 | 3000 | //----------------------------------------------------------------------------- |
| 2974 | 3001 | struct Chuck_Instr_Release_Object : public Chuck_Instr |
| 2975 | 3002 | { |
| @@ -2998,6 +3025,38 @@ public: · 22 unmodified lines | ||
| 2998 | 3025 | |
| 2999 | 3026 | |
| 3000 | 3027 | |
| 3028 | +//----------------------------------------------------------------------------- | |
| 3029 | +// name: struct Chuck_Instr_Release_Object3_Pop_Word | |
| 3030 | +// desc: release object reference + pop from reg stack | 1.5.0.0 (ge) added | |
| 3031 | +// the variant assumes object pointer directly on stack (not offset) | |
| 3032 | +//----------------------------------------------------------------------------- | |
| 3033 | +struct Chuck_Instr_Release_Object3_Pop_Word : public Chuck_Instr | |
| 3034 | +{ | |
| 3035 | +public: | |
| 3036 | + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); | |
| 3037 | +}; | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | +//----------------------------------------------------------------------------- | |
| 3043 | +// name: struct Chuck_Instr_Release_Object4 | |
| 3044 | +// desc: release object reference from reg stack (no pop) | 1.5.0.0 (ge) added | |
| 3045 | +// the variant assumes object pointer directly on stack (not offset) | |
| 3046 | +//----------------------------------------------------------------------------- | |
| 3047 | +struct Chuck_Instr_Release_Object4 : public Chuck_Instr_Unary_Op | |
| 3048 | +{ | |
| 3049 | +public: | |
| 3050 | + Chuck_Instr_Release_Object4( t_CKUINT offset ) | |
| 3051 | + { this->set( offset ); } | |
| 3052 | + | |
| 3053 | +public: | |
| 3054 | + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); | |
| 3055 | +}; | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3001 | 3060 | //----------------------------------------------------------------------------- |
| 3002 | 3061 | // name: struct Chuck_Instr_Func_To_Code |
| 3003 | 3062 | // desc: Chuck_Func * to Chuck_VM_Code * |
| @@ -3031,11 +3090,14 @@ public: · 27 unmodified lines | ||
| 3031 | 3090 | struct Chuck_Instr_Func_Call_Member : public Chuck_Instr_Unary_Op |
| 3032 | 3091 | { |
| 3033 | 3092 | public: |
| 3034 | − Chuck_Instr_Func_Call_Member( t_CKUINT ret_size ) | |
| 3035 | − { this->set( ret_size ); } | |
| 3093 | + Chuck_Instr_Func_Call_Member( t_CKUINT ret_size, Chuck_Func * func_ref ) | |
| 3094 | + { this->set( ret_size ); m_func_ref = func_ref; } | |
| 3036 | 3095 | |
| 3037 | 3096 | public: |
| 3038 | 3097 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3098 | + | |
| 3099 | +public: | |
| 3100 | + Chuck_Func * m_func_ref; // 1.5.0.0 (ge) | added for arg list cleanup | |
| 3039 | 3101 | }; |
| 3040 | 3102 | |
| 3041 | 3103 | |
| @@ -3048,11 +3110,14 @@ public: · 6 unmodified lines | ||
| 3048 | 3110 | struct Chuck_Instr_Func_Call_Static : public Chuck_Instr_Unary_Op |
| 3049 | 3111 | { |
| 3050 | 3112 | public: |
| 3051 | − Chuck_Instr_Func_Call_Static( t_CKUINT ret_size ) | |
| 3052 | − { this->set( ret_size ); } | |
| 3113 | + Chuck_Instr_Func_Call_Static( t_CKUINT ret_size, Chuck_Func * func_ref ) | |
| 3114 | + { this->set( ret_size ); m_func_ref = func_ref; } | |
| 3053 | 3115 | |
| 3054 | 3116 | public: |
| 3055 | 3117 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3118 | + | |
| 3119 | +public: | |
| 3120 | + Chuck_Func * m_func_ref; // 1.5.0.0 (ge) | added for arg list cleanup | |
| 3056 | 3121 | }; |
| 3057 | 3122 | |
| 3058 | 3123 | |
| @@ -3145,6 +3210,7 @@ protected: · 86 unmodified lines | ||
| 3145 | 3210 | Chuck_Type * m_type_ref; |
| 3146 | 3211 | t_CKINT m_length; |
| 3147 | 3212 | t_CKBOOL m_is_obj; |
| 3213 | + t_CKBOOL m_is_float; | |
| 3148 | 3214 | char * m_param_str; |
| 3149 | 3215 | }; |
| 3150 | 3216 | |
| @@ -3158,8 +3224,9 @@ protected: · 7 unmodified lines | ||
| 3158 | 3224 | struct Chuck_Instr_Array_Alloc : public Chuck_Instr |
| 3159 | 3225 | { |
| 3160 | 3226 | public: // REFACTOR-2017: added env |
| 3161 | − Chuck_Instr_Array_Alloc( Chuck_Env * env, t_CKUINT depth, Chuck_Type * the_type, | |
| 3162 | − t_CKUINT offset, t_CKBOOL ref ); | |
| 3227 | + Chuck_Instr_Array_Alloc( Chuck_Env * env, t_CKUINT depth, | |
| 3228 | + Chuck_Type * contentType, t_CKUINT offset, t_CKBOOL ref, | |
| 3229 | + Chuck_Type * arrayType ); | |
| 3163 | 3230 | virtual ~Chuck_Instr_Array_Alloc(); |
| 3164 | 3231 | |
| 3165 | 3232 | public: |
| @@ -3168,7 +3235,8 @@ public: · 2 unmodified lines | ||
| 3168 | 3235 | |
| 3169 | 3236 | protected: |
| 3170 | 3237 | t_CKUINT m_depth; |
| 3171 | − Chuck_Type * m_type_ref; | |
| 3238 | + Chuck_Type * m_type_ref_content; | |
| 3239 | + Chuck_Type * m_type_ref_array; // 1.5.0.0 (ge) added | |
| 3172 | 3240 | t_CKBOOL m_is_obj; |
| 3173 | 3241 | char * m_param_str; |
| 3174 | 3242 | t_CKUINT m_stack_offset; |
| @@ -3185,16 +3253,16 @@ protected: · 10 unmodified lines | ||
| 3185 | 3253 | struct Chuck_Instr_Array_Access : public Chuck_Instr |
| 3186 | 3254 | { |
| 3187 | 3255 | public: |
| 3188 | − Chuck_Instr_Array_Access( t_CKUINT kind, t_CKUINT emit_addr, | |
| 3256 | + Chuck_Instr_Array_Access( t_CKUINT kind, t_CKUINT emit_addr, | |
| 3189 | 3257 | t_CKUINT istr = FALSE ) |
| 3190 | 3258 | { m_kind = kind; m_emit_addr = emit_addr; m_istr = istr; } |
| 3191 | 3259 | |
| 3192 | 3260 | public: |
| 3193 | 3261 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3194 | 3262 | virtual const char * params() const |
| 3195 | − { static char buffer[256]; | |
| 3196 | − sprintf( buffer, "kind=%ld, emit_addr=%ld istr=%ld", | |
| 3197 | − m_kind, m_emit_addr, m_istr ); | |
| 3263 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3264 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "kind=%ld, emit_addr=%p istr=%ld", | |
| 3265 | + (long)m_kind, (void *)m_emit_addr, (long)m_istr ); | |
| 3198 | 3266 | return buffer; } |
| 3199 | 3267 | |
| 3200 | 3268 | protected: |
| @@ -3219,8 +3287,8 @@ public: · 18 unmodified lines | ||
| 3219 | 3287 | public: |
| 3220 | 3288 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3221 | 3289 | virtual const char * params() const |
| 3222 | − { static char buffer[256]; | |
| 3223 | − sprintf( buffer, "kind=%ld, emit_addr=%ld", m_kind, m_emit_addr ); | |
| 3290 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3291 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "kind=%ld, emit_addr=%p", (long)m_kind, (void *)m_emit_addr ); | |
| 3224 | 3292 | return buffer; } |
| 3225 | 3293 | |
| 3226 | 3294 | protected: |
| @@ -3246,15 +3314,15 @@ public: · 19 unmodified lines | ||
| 3246 | 3314 | public: |
| 3247 | 3315 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3248 | 3316 | virtual const char * params() const |
| 3249 | − { static char buffer[256]; | |
| 3250 | − sprintf( buffer, "depth=%ld, kind=%ld, emit_addr=%ld", m_depth, m_kind, m_emit_addr ); | |
| 3317 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3318 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "depth=%ld, kind=%ld, emit_addr=%p", (long)m_depth, (long)m_kind, (void *)m_emit_addr ); | |
| 3251 | 3319 | return buffer; } |
| 3252 | 3320 | |
| 3253 | 3321 | protected: |
| 3254 | 3322 | t_CKUINT m_depth; |
| 3255 | 3323 | t_CKUINT m_kind; |
| 3256 | 3324 | t_CKUINT m_emit_addr; |
| 3257 | − | |
| 3325 | + | |
| 3258 | 3326 | // 1.3.1.0 list of types of indices |
| 3259 | 3327 | std::vector<t_CKBOOL> m_indexIsAssociative; |
| 3260 | 3328 | }; |
| @@ -3275,8 +3343,8 @@ public: · 14 unmodified lines | ||
| 3275 | 3343 | public: |
| 3276 | 3344 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3277 | 3345 | virtual const char * params() const |
| 3278 | − { static char buffer[256]; | |
| 3279 | − sprintf( buffer, "offset=%ld, kind=%ld, emit_addr=%ld", m_offset, m_kind, m_emit_addr ); | |
| 3346 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3347 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "offset=%ld, kind=%ld, emit_addr=%p", (long)m_offset, (long)m_kind, (void *)m_emit_addr ); | |
| 3280 | 3348 | return buffer; } |
| 3281 | 3349 | |
| 3282 | 3350 | protected: |
| @@ -3301,8 +3369,8 @@ public: · 18 unmodified lines | ||
| 3301 | 3369 | public: |
| 3302 | 3370 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3303 | 3371 | virtual const char * params() const |
| 3304 | − { static char buffer[256]; | |
| 3305 | − sprintf( buffer, "offset=%ld", m_offset ); | |
| 3372 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3373 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "offset=%ld", (long)m_offset ); | |
| 3306 | 3374 | return buffer; } |
| 3307 | 3375 | |
| 3308 | 3376 | protected: |
| @@ -3321,14 +3389,14 @@ struct Chuck_Instr_Dot_Primitive_Func : public Chuck_Instr · 12 unmodified lines | ||
| 3321 | 3389 | public: |
| 3322 | 3390 | Chuck_Instr_Dot_Primitive_Func( t_CKUINT native_func ) |
| 3323 | 3391 | { m_native_func = native_func; } |
| 3324 | − | |
| 3392 | + | |
| 3325 | 3393 | public: |
| 3326 | 3394 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3327 | 3395 | virtual const char * params() const |
| 3328 | − { static char buffer[256]; | |
| 3329 | − sprintf( buffer, "native_func=%ld", m_native_func ); | |
| 3396 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3397 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "native_func=%p", (void *)m_native_func ); | |
| 3330 | 3398 | return buffer; } |
| 3331 | − | |
| 3399 | + | |
| 3332 | 3400 | protected: |
| 3333 | 3401 | t_CKUINT m_native_func; |
| 3334 | 3402 | }; |
| @@ -3349,8 +3417,9 @@ public: · 14 unmodified lines | ||
| 3349 | 3417 | public: |
| 3350 | 3418 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3351 | 3419 | virtual const char * params() const |
| 3352 | − { static char buffer[256]; | |
| 3353 | − sprintf( buffer, "offset=%ld, size=%ld, kind=%ld, emit_addr=%ld", m_offset, m_size, m_kind, m_emit_addr ); | |
| 3420 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3421 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "offset=%ld, size=%ld, kind=%ld, emit_addr=%p", | |
| 3422 | + (long)m_offset, (long)m_size, (long)m_kind, (void *)m_emit_addr ); | |
| 3354 | 3423 | return buffer; } |
| 3355 | 3424 | |
| 3356 | 3425 | protected: |
| @@ -3376,8 +3445,9 @@ public: · 19 unmodified lines | ||
| 3376 | 3445 | public: |
| 3377 | 3446 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3378 | 3447 | virtual const char * params() const |
| 3379 | − { static char buffer[256]; | |
| 3380 | − sprintf( buffer, "addr=%ld, kind=%ld, emit_addr=%ld", (t_CKUINT)m_addr, m_kind, m_emit_addr ); | |
| 3448 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3449 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "addr=%p, kind=%ld, emit_addr=%p", | |
| 3450 | + (void *)m_addr, (long)m_kind, (void *)m_emit_addr ); | |
| 3381 | 3451 | return buffer; } |
| 3382 | 3452 | |
| 3383 | 3453 | protected: |
| @@ -3402,8 +3472,8 @@ public: · 18 unmodified lines | ||
| 3402 | 3472 | public: |
| 3403 | 3473 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3404 | 3474 | virtual const char * params() const |
| 3405 | − { static char buffer[256]; | |
| 3406 | − sprintf( buffer, "func=%ld", (t_CKUINT)m_func ); | |
| 3475 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3476 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "func=%p", (void *)m_func ); | |
| 3407 | 3477 | return buffer; } |
| 3408 | 3478 | |
| 3409 | 3479 | protected: |
| @@ -3426,8 +3496,8 @@ public: · 16 unmodified lines | ||
| 3426 | 3496 | public: |
| 3427 | 3497 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3428 | 3498 | virtual const char * params() const |
| 3429 | − { static char buffer[256]; | |
| 3430 | − sprintf( buffer, "is_mem=%ld, emit_addr=%ld", m_is_mem, m_emit_addr ); | |
| 3499 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3500 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "is_mem=%ld, emit_addr=%p", (long)m_is_mem, (void *)m_emit_addr ); | |
| 3431 | 3501 | return buffer; } |
| 3432 | 3502 | |
| 3433 | 3503 | protected: |
| @@ -3451,8 +3521,8 @@ public: · 17 unmodified lines | ||
| 3451 | 3521 | public: |
| 3452 | 3522 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3453 | 3523 | virtual const char * params() const |
| 3454 | − { static char buffer[256]; | |
| 3455 | − sprintf( buffer, "is_mem=%ld, emit_addr=%ld", m_is_mem, m_emit_addr ); | |
| 3524 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3525 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "is_mem=%ld, emit_addr=%p", (long)m_is_mem, (void *)m_emit_addr ); | |
| 3456 | 3526 | return buffer; } |
| 3457 | 3527 | |
| 3458 | 3528 | protected: |
| @@ -3472,14 +3542,14 @@ struct Chuck_Instr_Dot_Cmp_Third : public Chuck_Instr · 13 unmodified lines | ||
| 3472 | 3542 | public: |
| 3473 | 3543 | Chuck_Instr_Dot_Cmp_Third( t_CKUINT is_mem, t_CKUINT emit_addr ) |
| 3474 | 3544 | { m_is_mem = is_mem; m_emit_addr = emit_addr; } |
| 3475 | − | |
| 3545 | + | |
| 3476 | 3546 | public: |
| 3477 | 3547 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3478 | 3548 | virtual const char * params() const |
| 3479 | − { static char buffer[256]; | |
| 3480 | − sprintf( buffer, "is_mem=%ld, emit_addr=%ld", m_is_mem, m_emit_addr ); | |
| 3549 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3550 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "is_mem=%ld, emit_addr=%p", (long)m_is_mem, (void *)m_emit_addr ); | |
| 3481 | 3551 | return buffer; } |
| 3482 | − | |
| 3552 | + | |
| 3483 | 3553 | protected: |
| 3484 | 3554 | t_CKUINT m_is_mem; |
| 3485 | 3555 | t_CKUINT m_emit_addr; |
| @@ -3497,14 +3567,14 @@ struct Chuck_Instr_Dot_Cmp_Fourth : public Chuck_Instr · 11 unmodified lines | ||
| 3497 | 3567 | public: |
| 3498 | 3568 | Chuck_Instr_Dot_Cmp_Fourth( t_CKUINT is_mem, t_CKUINT emit_addr ) |
| 3499 | 3569 | { m_is_mem = is_mem; m_emit_addr = emit_addr; } |
| 3500 | − | |
| 3570 | + | |
| 3501 | 3571 | public: |
| 3502 | 3572 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3503 | 3573 | virtual const char * params() const |
| 3504 | − { static char buffer[256]; | |
| 3505 | − sprintf( buffer, "is_mem=%ld, emit_addr=%ld", m_is_mem, m_emit_addr ); | |
| 3574 | + { static char buffer[CK_PRINT_BUF_LENGTH]; | |
| 3575 | + snprintf( buffer, CK_PRINT_BUF_LENGTH, "is_mem=%ld, emit_addr=%p", (long)m_is_mem, (void *)m_emit_addr ); | |
| 3506 | 3576 | return buffer; } |
| 3507 | − | |
| 3577 | + | |
| 3508 | 3578 | protected: |
| 3509 | 3579 | t_CKUINT m_is_mem; |
| 3510 | 3580 | t_CKUINT m_emit_addr; |
| @@ -3586,10 +3656,10 @@ struct Chuck_Instr_UGen_Link : public Chuck_Instr · 75 unmodified lines | ||
| 3586 | 3656 | { |
| 3587 | 3657 | public: |
| 3588 | 3658 | Chuck_Instr_UGen_Link( t_CKBOOL isUpChuck = FALSE ); |
| 3589 | − | |
| 3659 | + | |
| 3590 | 3660 | public: |
| 3591 | 3661 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3592 | − | |
| 3662 | + | |
| 3593 | 3663 | protected: |
| 3594 | 3664 | t_CKBOOL m_isUpChuck; |
| 3595 | 3665 | }; |
| @@ -3609,7 +3679,7 @@ public: · 13 unmodified lines | ||
| 3609 | 3679 | { } |
| 3610 | 3680 | |
| 3611 | 3681 | virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); |
| 3612 | − | |
| 3682 | + | |
| 3613 | 3683 | protected: |
| 3614 | 3684 | t_CKBOOL m_srcIsArray, m_dstIsArray; |
| 3615 | 3685 | }; |
| @@ -53,9 +53,9 @@ t_CKBOOL init_class_MidiRW( Chuck_Env * env ); · 52 unmodified lines | ||
| 53 | 53 | t_CKBOOL init_class_HID( Chuck_Env * env ); |
| 54 | 54 | #endif |
| 55 | 55 | t_CKBOOL init_class_io( Chuck_Env * env, Chuck_Type * type ); |
| 56 | −#ifndef __DISABLE_FILEIO__ | |
| 56 | +// #ifndef __DISABLE_FILEIO__ | |
| 57 | 57 | t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type ); |
| 58 | −#endif | |
| 58 | +// #endif | |
| 59 | 59 | // added 1.3.0.0 -- moved to be full-fledged class |
| 60 | 60 | t_CKBOOL init_class_chout( Chuck_Env * env, Chuck_Type * type ); |
| 61 | 61 | // added 1.3.0.0 -- moved to be full-fledged class |
| @@ -77,7 +77,7 @@ CK_DLL_SFUN( io_newline ); · 15 unmodified lines | ||
| 77 | 77 | CK_DLL_SFUN( io_openfile ); |
| 78 | 78 | |
| 79 | 79 | |
| 80 | −#ifndef __DISABLE_FILEIO__ | |
| 80 | +// #ifndef __DISABLE_FILEIO__ | |
| 81 | 81 | //----------------------------------------------------------------------------- |
| 82 | 82 | // fileio API |
| 83 | 83 | //----------------------------------------------------------------------------- |
| @@ -99,6 +99,9 @@ CK_DLL_MFUN( fileio_read ); · 15 unmodified lines | ||
| 99 | 99 | CK_DLL_MFUN( fileio_readline ); |
| 100 | 100 | CK_DLL_MFUN( fileio_readint ); |
| 101 | 101 | CK_DLL_MFUN( fileio_readintflags ); |
| 102 | +CK_DLL_MFUN( fileio_readint8 ); | |
| 103 | +CK_DLL_MFUN( fileio_readint16 ); | |
| 104 | +CK_DLL_MFUN( fileio_readint32 ); | |
| 102 | 105 | CK_DLL_MFUN( fileio_readfloat ); |
| 103 | 106 | CK_DLL_MFUN( fileio_eof ); |
| 104 | 107 | CK_DLL_MFUN( fileio_more ); |
| @@ -106,7 +109,7 @@ CK_DLL_MFUN( fileio_writestring ); · 1 unmodified line | ||
| 106 | 109 | CK_DLL_MFUN( fileio_writeint ); |
| 107 | 110 | CK_DLL_MFUN( fileio_writeintflags ); |
| 108 | 111 | CK_DLL_MFUN( fileio_writefloat ); |
| 109 | −#endif | |
| 112 | +// #endif // __DISABLE_FILEIO__ | |
| 110 | 113 | |
| 111 | 114 | |
| 112 | 115 | //----------------------------------------------------------------------------- |
| @@ -289,29 +292,29 @@ struct Chuck_IO_Serial : public Chuck_IO · 176 unmodified lines | ||
| 289 | 292 | public: |
| 290 | 293 | Chuck_IO_Serial( Chuck_VM * vm ); |
| 291 | 294 | virtual ~Chuck_IO_Serial(); |
| 292 | − | |
| 295 | + | |
| 293 | 296 | static void shutdown(); |
| 294 | 297 | |
| 295 | 298 | public: |
| 296 | 299 | // meta |
| 297 | 300 | virtual t_CKBOOL open( const t_CKUINT i, t_CKINT flags, t_CKUINT baud = CK_BAUD_9600 ); |
| 298 | 301 | virtual t_CKBOOL open( const std::string & path, t_CKINT flags, t_CKUINT baud = CK_BAUD_9600 ); |
| 299 | − | |
| 302 | + | |
| 300 | 303 | virtual t_CKBOOL can_wait(); |
| 301 | − | |
| 304 | + | |
| 302 | 305 | virtual t_CKBOOL good(); |
| 303 | 306 | virtual void close(); |
| 304 | 307 | virtual void flush(); |
| 305 | 308 | virtual t_CKINT mode(); |
| 306 | 309 | virtual void mode( t_CKINT flag ); |
| 307 | − | |
| 310 | + | |
| 308 | 311 | // reading |
| 309 | 312 | virtual Chuck_String * readLine(); |
| 310 | 313 | virtual t_CKINT readInt( t_CKINT flags ); |
| 311 | 314 | virtual t_CKFLOAT readFloat(); |
| 312 | 315 | virtual t_CKBOOL readString( std::string & str ); |
| 313 | 316 | virtual t_CKBOOL eof(); |
| 314 | − | |
| 317 | + | |
| 315 | 318 | // writing |
| 316 | 319 | virtual void write( const std::string & val ); |
| 317 | 320 | virtual void write( t_CKINT val ); |
| @@ -322,7 +325,7 @@ public: · 4 unmodified lines | ||
| 322 | 325 | // serial stuff |
| 323 | 326 | virtual t_CKBOOL setBaudRate( t_CKUINT rate ); |
| 324 | 327 | virtual t_CKUINT getBaudRate(); |
| 325 | − | |
| 328 | + | |
| 326 | 329 | // async reading |
| 327 | 330 | virtual t_CKBOOL readAsync( t_CKUINT type, t_CKUINT num ); |
| 328 | 331 | virtual Chuck_String * getLine(); |
| @@ -331,8 +334,8 @@ public: · 2 unmodified lines | ||
| 331 | 334 | virtual Chuck_Array * getInts(); |
| 332 | 335 | virtual Chuck_Array * getFloats(); |
| 333 | 336 | virtual Chuck_String * getString(); |
| 334 | − | |
| 335 | − static const t_CKUINT TYPE_NONE; | |
| 337 | + | |
| 338 | + static const t_CKUINT TYPE_NONE; | |
| 336 | 339 | static const t_CKUINT TYPE_BYTE; |
| 337 | 340 | static const t_CKUINT TYPE_WORD; |
| 338 | 341 | static const t_CKUINT TYPE_INT; |
| @@ -340,14 +343,14 @@ public: · 1 unmodified line | ||
| 340 | 343 | static const t_CKUINT TYPE_STRING; |
| 341 | 344 | static const t_CKUINT TYPE_LINE; |
| 342 | 345 | static const t_CKUINT TYPE_WRITE; |
| 343 | − | |
| 346 | + | |
| 344 | 347 | struct Request |
| 345 | 348 | { |
| 346 | 349 | t_CKUINT m_type; // type |
| 347 | 350 | t_CKUINT m_num; // how many |
| 348 | 351 | t_CKUINT m_status; |
| 349 | 352 | t_CKUINT m_val; // ISSUE: 64-bit |
| 350 | − | |
| 353 | + | |
| 351 | 354 | enum Status |
| 352 | 355 | { |
| 353 | 356 | RQ_STATUS_PENDING, |
| @@ -357,9 +360,9 @@ public: · 3 unmodified lines | ||
| 357 | 360 | RQ_STATUS_EOF, |
| 358 | 361 | }; |
| 359 | 362 | }; |
| 360 | − | |
| 363 | + | |
| 361 | 364 | virtual t_CKBOOL ready(); |
| 362 | − | |
| 365 | + | |
| 363 | 366 | // available baud rates |
| 364 | 367 | static const t_CKUINT CK_BAUD_2400; |
| 365 | 368 | static const t_CKUINT CK_BAUD_4800; |
| @@ -375,7 +378,7 @@ public: · 9 unmodified lines | ||
| 375 | 378 | static const t_CKUINT CK_BAUD_230400; |
| 376 | 379 | |
| 377 | 380 | protected: |
| 378 | − | |
| 381 | + | |
| 379 | 382 | void start_read_thread(); |
| 380 | 383 | XThread * m_read_thread; |
| 381 | 384 | static void *shell_read_cb(void *); |
| @@ -384,14 +387,14 @@ protected: · 2 unmodified lines | ||
| 384 | 387 | XThread * m_write_thread; |
| 385 | 388 | static void *shell_write_cb(void *); |
| 386 | 389 | void write_cb(); |
| 387 | − | |
| 390 | + | |
| 388 | 391 | void close_int(); |
| 389 | 392 | |
| 390 | 393 | t_CKBOOL get_buffer(t_CKINT timeout_ms = 1); |
| 391 | 394 | t_CKINT peek_buffer(); |
| 392 | 395 | t_CKINT pull_buffer(); |
| 393 | 396 | t_CKINT buffer_bytes_to_tmp(t_CKINT num_bytes); |
| 394 | − | |
| 397 | + | |
| 395 | 398 | t_CKBOOL handle_line(Request &); |
| 396 | 399 | t_CKBOOL handle_string(Request &); |
| 397 | 400 | t_CKBOOL handle_float_ascii(Request &); |
| @@ -399,38 +402,38 @@ protected: · 1 unmodified line | ||
| 399 | 402 | t_CKBOOL handle_byte(Request &); |
| 400 | 403 | t_CKBOOL handle_float_binary(Request &); |
| 401 | 404 | t_CKBOOL handle_int_binary(Request &); |
| 402 | − | |
| 405 | + | |
| 403 | 406 | bool m_do_read_thread; |
| 404 | 407 | bool m_do_write_thread; |
| 405 | − | |
| 408 | + | |
| 406 | 409 | CircularBuffer<Request> m_asyncRequests; |
| 407 | 410 | CircularBuffer<Request> m_asyncResponses; |
| 408 | 411 | CBufferSimple * m_event_buffer; |
| 409 | 412 | |
| 410 | 413 | int m_fd; |
| 411 | 414 | FILE * m_cfd; |
| 412 | − | |
| 415 | + | |
| 413 | 416 | std::string m_path; |
| 414 | − | |
| 417 | + | |
| 415 | 418 | unsigned char * m_io_buf; |
| 416 | 419 | t_CKUINT m_io_buf_max; |
| 417 | 420 | t_CKUINT m_io_buf_available; |
| 418 | 421 | t_CKUINT m_io_buf_pos; |
| 419 | − | |
| 422 | + | |
| 420 | 423 | unsigned char * m_tmp_buf; |
| 421 | 424 | t_CKUINT m_tmp_buf_max; |
| 422 | − | |
| 425 | + | |
| 423 | 426 | CircularBuffer<Request> m_asyncWriteRequests; |
| 424 | 427 | CircularBuffer<char> m_writeBuffer; |
| 425 | − | |
| 428 | + | |
| 426 | 429 | t_CKINT m_flags; |
| 427 | 430 | t_CKINT m_iomode; // SYNC or ASYNC |
| 428 | 431 | t_CKBOOL m_eof; |
| 429 | − | |
| 432 | + | |
| 430 | 433 | t_CKBOOL m_do_exit; |
| 431 | − | |
| 434 | + | |
| 432 | 435 | static std::list<Chuck_IO_Serial *> s_serials; |
| 433 | − | |
| 436 | + | |
| 434 | 437 | Chuck_VM * m_vmRef; |
| 435 | 438 | }; |
| 436 | 439 | #endif // __DISABLE_SERIAL__ |
| @@ -58,7 +58,8 @@ t_CKBOOL init_class_string( Chuck_Env * env, Chuck_Type * type ); · 57 unmodified lines | ||
| 58 | 58 | t_CKBOOL init_class_array( Chuck_Env * env, Chuck_Type * type ); |
| 59 | 59 | t_CKBOOL init_class_vec3( Chuck_Env * env, Chuck_Type * type ); // 1.3.5.3 |
| 60 | 60 | t_CKBOOL init_class_vec4( Chuck_Env * env, Chuck_Type * type ); // 1.3.5.3 |
| 61 | − | |
| 61 | +t_CKBOOL init_class_type( Chuck_Env * env, Chuck_Type * type ); // 1.5.0.0 | |
| 62 | +t_CKBOOL init_primitive_types( Chuck_Env * env ); // 1.5.0.0 | |
| 62 | 63 | |
| 63 | 64 | |
| 64 | 65 | |
| @@ -69,11 +70,11 @@ t_CKBOOL init_class_vec4( Chuck_Env * env, Chuck_Type * type ); // 1.3.5.3 · 4 unmodified lines | ||
| 69 | 70 | CK_DLL_CTOR( object_ctor ); |
| 70 | 71 | CK_DLL_DTOR( object_dtor ); |
| 71 | 72 | CK_DLL_MFUN( object_equals ); |
| 72 | −CK_DLL_MFUN( object_getType ); | |
| 73 | 73 | CK_DLL_MFUN( object_hashCode ); |
| 74 | 74 | CK_DLL_MFUN( object_toString ); |
| 75 | 75 | CK_DLL_MFUN( object_dump ); |
| 76 | −CK_DLL_SFUN( object_apropos ); | |
| 76 | +CK_DLL_SFUN( object_help ); | |
| 77 | +CK_DLL_SFUN( object_typeInfo ); | |
| 77 | 78 | |
| 78 | 79 | |
| 79 | 80 | //----------------------------------------------------------------------------- |
| @@ -180,12 +181,17 @@ CK_DLL_MFUN( array_set_size ); · 100 unmodified lines | ||
| 180 | 181 | CK_DLL_MFUN( array_get_size ); |
| 181 | 182 | CK_DLL_MFUN( array_push_back ); |
| 182 | 183 | CK_DLL_MFUN( array_pop_back ); |
| 184 | +CK_DLL_MFUN( array_pop_out ); | |
| 183 | 185 | CK_DLL_MFUN( array_push_front ); |
| 184 | 186 | CK_DLL_MFUN( array_pop_front ); |
| 185 | 187 | CK_DLL_MFUN( array_find ); |
| 186 | 188 | CK_DLL_MFUN( array_erase ); |
| 187 | 189 | CK_DLL_MFUN( array_clear ); |
| 188 | 190 | CK_DLL_MFUN( array_reset ); |
| 191 | +CK_DLL_MFUN( array_zero ); | |
| 192 | +CK_DLL_MFUN( array_get_keys ); | |
| 193 | +CK_DLL_MFUN( array_reverse ); | |
| 194 | +CK_DLL_MFUN( array_shuffle ); | |
| 189 | 195 | |
| 190 | 196 | |
| 191 | 197 | //----------------------------------------------------------------------------- |
| @@ -254,6 +260,37 @@ CK_DLL_MFUN( vec4_magnitude ); · 62 unmodified lines | ||
| 254 | 260 | CK_DLL_MFUN( vec4_normalize ); |
| 255 | 261 | |
| 256 | 262 | |
| 263 | +//----------------------------------------------------------------------------- | |
| 264 | +// type API | 1.5.0.0 (ge) added | |
| 265 | +//----------------------------------------------------------------------------- | |
| 266 | +CK_DLL_CTOR( type_ctor ); | |
| 267 | +CK_DLL_DTOR( type_dtor ); | |
| 268 | +CK_DLL_MFUN( type_equals ); | |
| 269 | +CK_DLL_MFUN( type_isa ); | |
| 270 | +CK_DLL_MFUN( type_isa_str ); | |
| 271 | +CK_DLL_MFUN( type_name ); | |
| 272 | +CK_DLL_MFUN( type_parent ); // return parent Type | |
| 273 | +CK_DLL_MFUN( type_children ); // return children Types | |
| 274 | +CK_DLL_MFUN( type_origin ); // built-in, chugin, defined in chuck | |
| 275 | +CK_DLL_MFUN( type_isPrimitive ); | |
| 276 | +CK_DLL_MFUN( type_isArray ); | |
| 277 | +CK_DLL_MFUN( type_arrayDims ); | |
| 278 | +CK_DLL_SFUN( type_findString ); | |
| 279 | +CK_DLL_SFUN( type_typeOf_obj ); // Type.typeOf( Object ) | |
| 280 | +CK_DLL_SFUN( type_typeOf_int ); // Type.typeOf( int ) | |
| 281 | +CK_DLL_SFUN( type_typeOf_float ); // Type.typeOf( float ) | |
| 282 | +CK_DLL_SFUN( type_typeOf_time ); // Type.typeOf( time ) | |
| 283 | +CK_DLL_SFUN( type_typeOf_dur ); // Type.typeOf( dur ) | |
| 284 | +CK_DLL_SFUN( type_typeOf_complex ); // Type.typeOf( complex ) | |
| 285 | +CK_DLL_SFUN( type_typeOf_polar ); // Type.typeOf( polar ) | |
| 286 | +CK_DLL_SFUN( type_typeOf_vec3 ); // Type.typeOf( vec3 ) | |
| 287 | +CK_DLL_SFUN( type_typeOf_vec4 ); // Type.typeOf( vec4 ) | |
| 288 | +CK_DLL_SFUN( type_getTypes ); | |
| 289 | +CK_DLL_SFUN( type_getTypesAll ); | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 257 | 294 | //----------------------------------------------------------------------------- |
| 258 | 295 | // name: Data_Exception |
| 259 | 296 | // desc: data for base Chuck Exception class |
| @@ -98,7 +98,9 @@ public: · 97 unmodified lines | ||
| 98 | 98 | virtual void release(); |
| 99 | 99 | // lock |
| 100 | 100 | virtual void lock(); |
| 101 | − | |
| 101 | + // unlock | 1.5.0.0 (ge) added | |
| 102 | + virtual void unlock(); | |
| 103 | + | |
| 102 | 104 | // NOTE: be careful when overriding these, should always |
| 103 | 105 | // explicitly call up to ChucK_VM_Object (ge: 2013) |
| 104 | 106 | |
| @@ -132,7 +134,7 @@ private: · 27 unmodified lines | ||
| 132 | 134 | //{ |
| 133 | 135 | //public: |
| 134 | 136 | // static Chuck_VM_Alloc * instance(); |
| 135 | −// | |
| 137 | +// | |
| 136 | 138 | //public: |
| 137 | 139 | // void add_object( Chuck_VM_Object * obj ); |
| 138 | 140 | // void free_object( Chuck_VM_Object * obj ); |
| @@ -180,8 +182,8 @@ public: · 41 unmodified lines | ||
| 180 | 182 | |
| 181 | 183 | public: |
| 182 | 184 | // output type info (can be overriden; but probably shouldn't be) |
| 183 | − virtual void apropos(); | |
| 184 | − | |
| 185 | + virtual void help(); | |
| 186 | + | |
| 185 | 187 | public: |
| 186 | 188 | // virtual table |
| 187 | 189 | Chuck_VTable * vtable; |
| @@ -228,7 +230,15 @@ public: · 40 unmodified lines | ||
| 228 | 230 | virtual t_CKINT find( const std::string & key ) = 0; // find |
| 229 | 231 | virtual t_CKINT erase( const std::string & key ) = 0; // erase |
| 230 | 232 | virtual void clear( ) = 0; // clear |
| 231 | − | |
| 233 | + virtual void zero( t_CKUINT start, t_CKUINT end ) = 0; // zero | |
| 234 | + virtual void zero() = 0; // zero (all) | |
| 235 | + // get map keys | added (1.4.2.0) nshaheed | |
| 236 | + virtual void get_keys( std::vector<std::string> & keys ) = 0; | |
| 237 | + // reverse array order | added (1.5.0.0) azaday | |
| 238 | + virtual void reverse() = 0; | |
| 239 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 240 | + virtual void shuffle() = 0; | |
| 241 | + | |
| 232 | 242 | Chuck_Type * m_array_type; |
| 233 | 243 | }; |
| 234 | 244 | |
| @@ -254,8 +264,10 @@ public: · 19 unmodified lines | ||
| 254 | 264 | t_CKINT set( const std::string & key, t_CKUINT val ); |
| 255 | 265 | t_CKINT push_back( t_CKUINT val ); |
| 256 | 266 | t_CKINT pop_back( ); |
| 267 | + t_CKINT pop_out( t_CKINT pos ); | |
| 257 | 268 | t_CKINT back( t_CKUINT * val ) const; |
| 258 | 269 | void zero( t_CKUINT start, t_CKUINT end ); |
| 270 | + void zero() { this->zero(0, m_vector.size()); } | |
| 259 | 271 | |
| 260 | 272 | virtual void clear( ); |
| 261 | 273 | virtual t_CKINT size( ) { return m_vector.size(); } |
| @@ -264,13 +276,22 @@ public: · 2 unmodified lines | ||
| 264 | 276 | virtual t_CKINT set_capacity( t_CKINT capacity ); |
| 265 | 277 | virtual t_CKINT find( const std::string & key ); |
| 266 | 278 | virtual t_CKINT erase( const std::string & key ); |
| 267 | − virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY4_DATASIZE; } | |
| 268 | − virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY4_DATAKIND; } | |
| 279 | + virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY4_DATASIZE; } | |
| 280 | + virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY4_DATAKIND; } | |
| 281 | + // get map keys | added (1.4.2.0) nshaheed | |
| 282 | + virtual void get_keys( std::vector<std::string> & keys ); | |
| 283 | + // reverse array order | added (1.5.0.0) azaday | |
| 284 | + virtual void reverse(); | |
| 285 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 286 | + virtual void shuffle(); | |
| 269 | 287 | |
| 270 | 288 | public: |
| 271 | 289 | std::vector<t_CKUINT> m_vector; |
| 272 | 290 | std::map<std::string, t_CKUINT> m_map; |
| 273 | 291 | t_CKBOOL m_is_obj; |
| 292 | + | |
| 293 | + // TODO: may need additional information here for set_size, if this is part of a multi-dim array | |
| 294 | + | |
| 274 | 295 | // t_CKINT m_size; |
| 275 | 296 | // t_CKINT m_capacity; |
| 276 | 297 | }; |
| @@ -297,8 +318,10 @@ public: · 20 unmodified lines | ||
| 297 | 318 | t_CKINT set( const std::string & key, t_CKFLOAT val ); |
| 298 | 319 | t_CKINT push_back( t_CKFLOAT val ); |
| 299 | 320 | t_CKINT pop_back( ); |
| 321 | + t_CKINT pop_out( t_CKINT pos ); | |
| 300 | 322 | t_CKINT back( t_CKFLOAT * val ) const; |
| 301 | 323 | void zero( t_CKUINT start, t_CKUINT end ); |
| 324 | + void zero() { this->zero(0, m_vector.size()); } | |
| 302 | 325 | |
| 303 | 326 | virtual void clear( ); |
| 304 | 327 | virtual t_CKINT size( ) { return m_vector.size(); } |
| @@ -308,7 +331,13 @@ public: · 3 unmodified lines | ||
| 308 | 331 | virtual t_CKINT find( const std::string & key ); |
| 309 | 332 | virtual t_CKINT erase( const std::string & key ); |
| 310 | 333 | virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY8_DATASIZE; } |
| 311 | − virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY8_DATAKIND; } | |
| 334 | + virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY8_DATAKIND; } | |
| 335 | + // get map keys | added (1.4.2.0) nshaheed | |
| 336 | + virtual void get_keys( std::vector<std::string> & keys ); | |
| 337 | + // reverse array order | added (1.5.0.0) azaday | |
| 338 | + virtual void reverse(); | |
| 339 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 340 | + virtual void shuffle(); | |
| 312 | 341 | |
| 313 | 342 | public: |
| 314 | 343 | std::vector<t_CKFLOAT> m_vector; |
| @@ -339,8 +368,10 @@ public: · 24 unmodified lines | ||
| 339 | 368 | t_CKINT set( const std::string & key, const t_CKCOMPLEX & val ); |
| 340 | 369 | t_CKINT push_back( const t_CKCOMPLEX & val ); |
| 341 | 370 | t_CKINT pop_back( ); |
| 371 | + t_CKINT pop_out( t_CKINT pos ); | |
| 342 | 372 | t_CKINT back( t_CKCOMPLEX * val ) const; |
| 343 | 373 | void zero( t_CKUINT start, t_CKUINT end ); |
| 374 | + void zero() { this->zero(0, m_vector.size()); } | |
| 344 | 375 | |
| 345 | 376 | virtual void clear( ); |
| 346 | 377 | virtual t_CKINT size( ) { return m_vector.size(); } |
| @@ -350,7 +381,13 @@ public: · 3 unmodified lines | ||
| 350 | 381 | virtual t_CKINT find( const std::string & key ); |
| 351 | 382 | virtual t_CKINT erase( const std::string & key ); |
| 352 | 383 | virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY16_DATASIZE; } |
| 353 | − virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY16_DATAKIND; } | |
| 384 | + virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY16_DATAKIND; } | |
| 385 | + // get map keys | added (1.4.2.0) nshaheed | |
| 386 | + virtual void get_keys( std::vector<std::string> & keys ); | |
| 387 | + // reverse array order | added (1.5.0.0) azaday | |
| 388 | + virtual void reverse(); | |
| 389 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 390 | + virtual void shuffle(); | |
| 354 | 391 | |
| 355 | 392 | public: |
| 356 | 393 | std::vector<t_CKCOMPLEX> m_vector; |
| @@ -371,7 +408,7 @@ struct Chuck_Array24 : Chuck_Array · 14 unmodified lines | ||
| 371 | 408 | public: |
| 372 | 409 | Chuck_Array24( t_CKINT capacity = 8 ); |
| 373 | 410 | virtual ~Chuck_Array24(); |
| 374 | − | |
| 411 | + | |
| 375 | 412 | public: |
| 376 | 413 | t_CKUINT addr( t_CKINT i ); |
| 377 | 414 | t_CKUINT addr( const std::string & key ); |
| @@ -381,9 +418,11 @@ public: · 3 unmodified lines | ||
| 381 | 418 | t_CKINT set( const std::string & key, const t_CKVEC3 & val ); |
| 382 | 419 | t_CKINT push_back( const t_CKVEC3 & val ); |
| 383 | 420 | t_CKINT pop_back( ); |
| 421 | + t_CKINT pop_out( t_CKUINT pos ); | |
| 384 | 422 | t_CKINT back( t_CKVEC3 * val ) const; |
| 385 | 423 | void zero( t_CKUINT start, t_CKUINT end ); |
| 386 | − | |
| 424 | + void zero() { this->zero(0, m_vector.size()); } | |
| 425 | + | |
| 387 | 426 | virtual void clear( ); |
| 388 | 427 | virtual t_CKINT size( ) { return m_vector.size(); } |
| 389 | 428 | virtual t_CKINT capacity( ) { return m_vector.capacity(); } |
| @@ -393,7 +432,13 @@ public: · 3 unmodified lines | ||
| 393 | 432 | virtual t_CKINT erase( const std::string & key ); |
| 394 | 433 | virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY24_DATASIZE; } |
| 395 | 434 | virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY24_DATAKIND; } |
| 396 | − | |
| 435 | + // get map keys | added (1.4.2.0) nshaheed | |
| 436 | + virtual void get_keys( std::vector<std::string> & keys ); | |
| 437 | + // reverse array order | added (1.5.0.0) azaday | |
| 438 | + virtual void reverse(); | |
| 439 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 440 | + virtual void shuffle(); | |
| 441 | + | |
| 397 | 442 | public: |
| 398 | 443 | std::vector<t_CKVEC3> m_vector; |
| 399 | 444 | std::map<std::string, t_CKVEC3> m_map; |
| @@ -411,7 +456,7 @@ struct Chuck_Array32 : Chuck_Array · 11 unmodified lines | ||
| 411 | 456 | public: |
| 412 | 457 | Chuck_Array32( t_CKINT capacity = 8 ); |
| 413 | 458 | virtual ~Chuck_Array32(); |
| 414 | − | |
| 459 | + | |
| 415 | 460 | public: |
| 416 | 461 | t_CKUINT addr( t_CKINT i ); |
| 417 | 462 | t_CKUINT addr( const std::string & key ); |
| @@ -421,9 +466,11 @@ public: · 3 unmodified lines | ||
| 421 | 466 | t_CKINT set( const std::string & key, const t_CKVEC4 & val ); |
| 422 | 467 | t_CKINT push_back( const t_CKVEC4 & val ); |
| 423 | 468 | t_CKINT pop_back( ); |
| 469 | + t_CKINT pop_out( t_CKUINT pos ); | |
| 424 | 470 | t_CKINT back( t_CKVEC4 * val ) const; |
| 425 | 471 | void zero( t_CKUINT start, t_CKUINT end ); |
| 426 | − | |
| 472 | + void zero() { this->zero(0, m_vector.size()); } | |
| 473 | + | |
| 427 | 474 | virtual void clear( ); |
| 428 | 475 | virtual t_CKINT size( ) { return m_vector.size(); } |
| 429 | 476 | virtual t_CKINT capacity( ) { return m_vector.capacity(); } |
| @@ -433,7 +480,13 @@ public: · 3 unmodified lines | ||
| 433 | 480 | virtual t_CKINT erase( const std::string & key ); |
| 434 | 481 | virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY32_DATASIZE; } |
| 435 | 482 | virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY32_DATAKIND; } |
| 436 | − | |
| 483 | + // get map keys | added (1.4.1.2) nshaheed | |
| 484 | + virtual void get_keys( std::vector<std::string> & keys ); | |
| 485 | + // reverse array order | added (1.5.0.0) azaday | |
| 486 | + virtual void reverse(); | |
| 487 | + // reverse array order | added (1.5.0.0) kunwoo, nshaheed, azaday, ge | |
| 488 | + virtual void shuffle(); | |
| 489 | + | |
| 437 | 490 | public: |
| 438 | 491 | std::vector<t_CKVEC4> m_vector; |
| 439 | 492 | std::map<std::string, t_CKVEC4> m_map; |
| @@ -457,7 +510,7 @@ struct Chuck_Global_Event_Listener · 17 unmodified lines | ||
| 457 | 510 | Chuck_Global_Get_Callback_Type callback_type; |
| 458 | 511 | std::string name; |
| 459 | 512 | t_CKINT id; |
| 460 | − Chuck_Global_Event_Listener() : void_callback(NULL), listen_forever(FALSE), | |
| 513 | + Chuck_Global_Event_Listener() : void_callback(NULL), listen_forever(FALSE), | |
| 461 | 514 | callback_type(ck_get_plain), name(""), id(0) {}; |
| 462 | 515 | }; |
| 463 | 516 | |
| @@ -550,7 +603,7 @@ struct Chuck_IO : Chuck_Event · 86 unmodified lines | ||
| 550 | 603 | public: |
| 551 | 604 | Chuck_IO(); |
| 552 | 605 | virtual ~Chuck_IO(); |
| 553 | − | |
| 606 | + | |
| 554 | 607 | public: |
| 555 | 608 | // meta |
| 556 | 609 | virtual t_CKBOOL good() = 0; |
| @@ -558,29 +611,37 @@ public: · 1 unmodified line | ||
| 558 | 611 | virtual void flush() = 0; |
| 559 | 612 | virtual t_CKINT mode() = 0; |
| 560 | 613 | virtual void mode( t_CKINT flag ) = 0; |
| 561 | − | |
| 614 | + | |
| 562 | 615 | // reading |
| 563 | 616 | virtual Chuck_String * readLine() = 0; |
| 564 | 617 | virtual t_CKINT readInt( t_CKINT flags ) = 0; |
| 565 | 618 | virtual t_CKFLOAT readFloat() = 0; |
| 566 | 619 | virtual t_CKBOOL readString( std::string & str ) = 0; |
| 567 | 620 | virtual t_CKBOOL eof() = 0; |
| 568 | − | |
| 621 | + | |
| 569 | 622 | // writing |
| 570 | 623 | virtual void write( const std::string & val ) = 0; |
| 571 | 624 | virtual void write( t_CKINT val ) = 0; |
| 572 | 625 | virtual void write( t_CKINT val, t_CKINT flags ) = 0; |
| 573 | 626 | virtual void write( t_CKFLOAT val ) = 0; |
| 574 | − | |
| 575 | − // constants | |
| 627 | + | |
| 576 | 628 | public: |
| 629 | + // type | moved to IO in 1.5.0.0 (ge) | |
| 630 | + static const t_CKINT TYPE_ASCII; | |
| 631 | + static const t_CKINT TYPE_BINARY; | |
| 632 | + // datatype | |
| 577 | 633 | static const t_CKINT INT32; |
| 578 | 634 | static const t_CKINT INT16; |
| 579 | 635 | static const t_CKINT INT8; |
| 580 | − | |
| 636 | + // flags | moved to IO in 1.5.0.0 (ge) | |
| 637 | + static const t_CKINT FLAG_READ_WRITE; | |
| 638 | + static const t_CKINT FLAG_READONLY; | |
| 639 | + static const t_CKINT FLAG_WRITEONLY; | |
| 640 | + static const t_CKINT FLAG_APPEND; | |
| 581 | 641 | // asynchronous I/O members |
| 582 | 642 | static const t_CKINT MODE_SYNC; |
| 583 | 643 | static const t_CKINT MODE_ASYNC; |
| 644 | + | |
| 584 | 645 | Chuck_Event * m_asyncEvent; |
| 585 | 646 | #ifndef __DISABLE_THREADS__ |
| 586 | 647 | XThread * m_thread; |
| @@ -597,7 +658,7 @@ public: · 10 unmodified lines | ||
| 597 | 658 | |
| 598 | 659 | |
| 599 | 660 | |
| 600 | −#ifndef __DISABLE_FILEIO__ | |
| 661 | +// #ifndef __DISABLE_FILEIO__ | |
| 601 | 662 | //----------------------------------------------------------------------------- |
| 602 | 663 | // name: Chuck_IO_File |
| 603 | 664 | // desc: Chuck File IO class |
| @@ -608,7 +669,7 @@ public: · 4 unmodified lines | ||
| 608 | 669 | // REFACTOR-2017 |
| 609 | 670 | Chuck_IO_File( Chuck_VM * vm ); |
| 610 | 671 | virtual ~Chuck_IO_File(); |
| 611 | − | |
| 672 | + | |
| 612 | 673 | public: |
| 613 | 674 | // meta |
| 614 | 675 | virtual t_CKBOOL open( const std::string & path, t_CKINT flags ); |
| @@ -618,15 +679,15 @@ public: · 3 unmodified lines | ||
| 618 | 679 | virtual t_CKINT mode(); |
| 619 | 680 | virtual void mode( t_CKINT flag ); |
| 620 | 681 | virtual t_CKINT size(); |
| 621 | − | |
| 682 | + | |
| 622 | 683 | // seeking |
| 623 | 684 | virtual void seek( t_CKINT pos ); |
| 624 | 685 | virtual t_CKINT tell(); |
| 625 | − | |
| 686 | + | |
| 626 | 687 | // directories |
| 627 | 688 | virtual t_CKINT isDir(); |
| 628 | 689 | virtual Chuck_Array4 * dirList(); |
| 629 | − | |
| 690 | + | |
| 630 | 691 | // reading |
| 631 | 692 | // virtual Chuck_String * read( t_CKINT length ); |
| 632 | 693 | virtual Chuck_String * readLine(); |
| @@ -634,7 +695,7 @@ public: · 1 unmodified line | ||
| 634 | 695 | virtual t_CKFLOAT readFloat(); |
| 635 | 696 | virtual t_CKBOOL readString( std::string & str ); |
| 636 | 697 | virtual t_CKBOOL eof(); |
| 637 | − | |
| 698 | + | |
| 638 | 699 | // reading -- async |
| 639 | 700 | /* TODO: doesn't look like asynchronous reads will work |
| 640 | 701 | static THREAD_RETURN ( THREAD_TYPE read_thread ) ( void *data ); |
| @@ -642,29 +703,20 @@ public: · 1 unmodified line | ||
| 642 | 703 | static THREAD_RETURN ( THREAD_TYPE readInt_thread ) ( void *data ); |
| 643 | 704 | static THREAD_RETURN ( THREAD_TYPE readFloat_thread ) ( void *data ); |
| 644 | 705 | */ |
| 645 | − | |
| 706 | + | |
| 646 | 707 | // writing |
| 647 | 708 | virtual void write( const std::string & val ); |
| 648 | 709 | virtual void write( t_CKINT val ); |
| 649 | 710 | virtual void write( t_CKINT val, t_CKINT flags ); |
| 650 | 711 | virtual void write( t_CKFLOAT val ); |
| 651 | − | |
| 712 | + | |
| 652 | 713 | #ifndef __DISABLE_THREADS__ |
| 653 | 714 | // writing -- async |
| 654 | 715 | static THREAD_RETURN ( THREAD_TYPE writeStr_thread ) ( void *data ); |
| 655 | 716 | static THREAD_RETURN ( THREAD_TYPE writeInt_thread ) ( void *data ); |
| 656 | 717 | static THREAD_RETURN ( THREAD_TYPE writeFloat_thread ) ( void *data ); |
| 657 | 718 | #endif |
| 658 | − | |
| 659 | −public: | |
| 660 | − // constants | |
| 661 | − static const t_CKINT FLAG_READ_WRITE; | |
| 662 | − static const t_CKINT FLAG_READONLY; | |
| 663 | − static const t_CKINT FLAG_WRITEONLY; | |
| 664 | − static const t_CKINT FLAG_APPEND; | |
| 665 | − static const t_CKINT TYPE_ASCII; | |
| 666 | − static const t_CKINT TYPE_BINARY; | |
| 667 | − | |
| 719 | + | |
| 668 | 720 | protected: |
| 669 | 721 | // open flags |
| 670 | 722 | t_CKINT m_flags; |
| @@ -681,7 +733,7 @@ protected: · 10 unmodified lines | ||
| 681 | 733 | // vm and shred |
| 682 | 734 | Chuck_VM * m_vmRef; |
| 683 | 735 | }; |
| 684 | −#endif // __DISABLE_FILEIO__ | |
| 736 | +// #endif // __DISABLE_FILEIO__ | |
| 685 | 737 | |
| 686 | 738 | |
| 687 | 739 | |
| @@ -74,15 +74,15 @@ void otf_hton( Net_Msg * msg ); · 73 unmodified lines | ||
| 74 | 74 | void otf_ntoh( Net_Msg * msg ); |
| 75 | 75 | |
| 76 | 76 | // process incoming message |
| 77 | −t_CKUINT otf_process_msg( Chuck_VM * vm, Chuck_Compiler * compiler, | |
| 77 | +t_CKUINT otf_process_msg( Chuck_VM * vm, Chuck_Compiler * compiler, | |
| 78 | 78 | Net_Msg * msg, t_CKBOOL immediate, void * data ); |
| 79 | 79 | |
| 80 | 80 | // send command |
| 81 | −int otf_send_cmd( int argc, const char ** argv, t_CKINT & i, const char * host, int port, int * is_otf = NULL ); | |
| 81 | +t_CKINT otf_send_cmd( t_CKINT argc, const char ** argv, t_CKINT & i, const char * host, t_CKINT port, t_CKINT * is_otf = NULL ); | |
| 82 | 82 | // send file to remote host |
| 83 | −int otf_send_file( const char * filename, Net_Msg & msg, const char * op, ck_socket sock ); | |
| 83 | +t_CKINT otf_send_file( const char * filename, Net_Msg & msg, const char * op, ck_socket sock ); | |
| 84 | 84 | // connect |
| 85 | −ck_socket otf_send_connect( const char * host, int port ); | |
| 85 | +ck_socket otf_send_connect( const char * host, t_CKINT port ); | |
| 86 | 86 | |
| 87 | 87 | // callback |
| 88 | 88 | void * otf_cb( void * p ); |
| @@ -63,6 +63,8 @@ t_CKBOOL chuck_parse( c_constr fname, FILE * fd = NULL, c_constr code = NULL ); · 62 unmodified lines | ||
| 63 | 63 | // reset the parser |
| 64 | 64 | void reset_parse( ); |
| 65 | 65 | |
| 66 | +// convert abstract syntax expression to string | |
| 67 | +std::string absyn2str( a_Exp exp ); | |
| 66 | 68 | |
| 67 | 69 | // syntax highlighting tools |
| 68 | 70 | #include <vector> |
| @@ -103,7 +105,7 @@ struct SyntaxToken · 34 unmodified lines | ||
| 103 | 105 | std::string::size_type begin; |
| 104 | 106 | // from the beginning of line |
| 105 | 107 | std::string::size_type end; |
| 106 | − | |
| 108 | + | |
| 107 | 109 | // constructor |
| 108 | 110 | SyntaxToken() : type(0) { } |
| 109 | 111 | // copy constructor |
| @@ -121,7 +123,7 @@ struct SyntaxToken · 11 unmodified lines | ||
| 121 | 123 | struct SyntaxTokenList |
| 122 | 124 | { |
| 123 | 125 | std::vector<SyntaxToken> list; |
| 124 | − std::vector<SyntaxToken>::size_type howmany; | |
| 126 | + std::vector<SyntaxToken>::size_type howmany; | |
| 125 | 127 | // copy constructor |
| 126 | 128 | SyntaxTokenList( const SyntaxTokenList & rhs ) |
| 127 | 129 | { |
| @@ -133,9 +135,9 @@ struct SyntaxTokenList · 5 unmodified lines | ||
| 133 | 135 | for( std::vector<SyntaxToken>::size_type i = 0; i < howmany; i++ ) |
| 134 | 136 | list[i] = rhs.list[i]; |
| 135 | 137 | } |
| 136 | − SyntaxTokenList() { | |
| 137 | − howmany = 0; | |
| 138 | − } | |
| 138 | + SyntaxTokenList() { | |
| 139 | + howmany = 0; | |
| 140 | + } | |
| 139 | 141 | }; |
| 140 | 142 | |
| 141 | 143 | |
| @@ -38,13 +38,13 @@ · 37 unmodified lines | ||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | // scan a program into the env - type discovery scan |
| 41 | −t_CKBOOL type_engine_scan0_prog( Chuck_Env * env, a_Program prog, | |
| 41 | +t_CKBOOL type_engine_scan0_prog( Chuck_Env * env, a_Program prog, | |
| 42 | 42 | te_HowMuch val = te_do_all ); |
| 43 | 43 | // scan a class definition (used by type_engine_add_dll()) |
| 44 | 44 | t_CKBOOL type_engine_scan0_class_def( Chuck_Env * env, a_Class_Def def ); |
| 45 | 45 | |
| 46 | 46 | // scan a program into the env - type resolution scan |
| 47 | −t_CKBOOL type_engine_scan1_prog( Chuck_Env * env, a_Program prog, | |
| 47 | +t_CKBOOL type_engine_scan1_prog( Chuck_Env * env, a_Program prog, | |
| 48 | 48 | te_HowMuch val = te_do_all ); |
| 49 | 49 | // scan a class definition (used by type_engine_add_dll()) |
| 50 | 50 | t_CKBOOL type_engine_scan1_class_def( Chuck_Env * env, a_Class_Def def ); |
| @@ -51,7 +51,7 @@ typedef string Chuck_Shell_Response; · 50 unmodified lines | ||
| 51 | 51 | |
| 52 | 52 | //----------------------------------------------------------------------------- |
| 53 | 53 | // name: class Chuck_Shell |
| 54 | −// desc: controller class for facilitating interaction between a shell UI and a | |
| 54 | +// desc: controller class for facilitating interaction between a shell UI and a | |
| 55 | 55 | // shell mode. |
| 56 | 56 | //----------------------------------------------------------------------------- |
| 57 | 57 | class Chuck_Shell |
| @@ -59,7 +59,7 @@ class Chuck_Shell · 1 unmodified line | ||
| 59 | 59 | public: |
| 60 | 60 | Chuck_Shell(); |
| 61 | 61 | virtual ~Chuck_Shell(); |
| 62 | − | |
| 62 | + | |
| 63 | 63 | t_CKBOOL init( Chuck_VM * process_vm, Chuck_Shell_UI * ); |
| 64 | 64 | void run(); |
| 65 | 65 | t_CKBOOL execute( string &, string & ); |
| @@ -79,35 +79,35 @@ public: // HACK-GE: these were moved from protected for win32 · 13 unmodified lines | ||
| 79 | 79 | map < string, string > variables; |
| 80 | 80 | map < string, Command * > commands; |
| 81 | 81 | vector < Command * > allocated_commands; |
| 82 | − | |
| 83 | − map < string, string > saved_code; | |
| 82 | + | |
| 83 | + map < string, string > saved_code; | |
| 84 | 84 | |
| 85 | 85 | string code; |
| 86 | 86 | |
| 87 | − // helper functions | |
| 88 | − t_CKBOOL do_glob( const string &, string &, vector < string > & ); | |
| 87 | + // helper functions | |
| 88 | + t_CKBOOL do_glob( const string &, string &, vector < string > & ); | |
| 89 | 89 | void do_code( string &, string &, string command = "+ " ); |
| 90 | 90 | void do_code_context( string & ); |
| 91 | 91 | |
| 92 | 92 | protected: |
| 93 | − // helper functions | |
| 94 | − void do_aliases(); | |
| 95 | − void do_variables(); | |
| 96 | − | |
| 97 | − // code helper functions | |
| 98 | − void start_code(); | |
| 93 | + // helper functions | |
| 94 | + void do_aliases(); | |
| 95 | + void do_variables(); | |
| 96 | + | |
| 97 | + // code helper functions | |
| 98 | + void start_code(); | |
| 99 | 99 | void continue_code( string & ); |
| 100 | 100 | void string_hash( string &, string & ); |
| 101 | − | |
| 101 | + | |
| 102 | 102 | Chuck_Shell_UI * ui; |
| 103 | − | |
| 103 | + | |
| 104 | 104 | t_CKBOOL initialized; |
| 105 | 105 | t_CKBOOL stop; |
| 106 | − | |
| 106 | + | |
| 107 | 107 | string prompt; |
| 108 | − | |
| 108 | + | |
| 109 | 109 | string in; |
| 110 | − | |
| 110 | + | |
| 111 | 111 | // code entry variables |
| 112 | 112 | t_CKBOOL code_entry_active; |
| 113 | 113 | t_CKUINT scope; |
| @@ -127,13 +127,13 @@ public: // HACK-GE: moved from protected for win32 · 13 unmodified lines | ||
| 127 | 127 | public: |
| 128 | 128 | virtual t_CKBOOL init( Chuck_Shell * ); |
| 129 | 129 | virtual t_CKINT execute( vector< string > &, string & ) = 0; |
| 130 | − virtual string usage(); | |
| 131 | − virtual string long_usage(); | |
| 132 | − | |
| 130 | + virtual string usage(); | |
| 131 | + virtual string long_usage(); | |
| 132 | + | |
| 133 | 133 | protected: |
| 134 | 134 | Chuck_Shell * caller; |
| 135 | 135 | }; |
| 136 | − | |
| 136 | + | |
| 137 | 137 | //----------------------------------------------------------------------------- |
| 138 | 138 | // name: class Chuck_Shell::Command_VM |
| 139 | 139 | // desc: ... |
| @@ -144,8 +144,8 @@ public: // HACK-GE: moved from protected for win32 · 4 unmodified lines | ||
| 144 | 144 | ~Command_VM(); |
| 145 | 145 | t_CKBOOL init( Chuck_Shell * ); |
| 146 | 146 | t_CKINT execute( vector< string > &, string & ); |
| 147 | − string usage(); | |
| 148 | − | |
| 147 | + string usage(); | |
| 148 | + | |
| 149 | 149 | protected: |
| 150 | 150 | map < string, Command * > commands; |
| 151 | 151 | vector < Command * > allocated_commands; |
| @@ -160,7 +160,7 @@ public: // HACK-GE: moved from protected for win32 · 8 unmodified lines | ||
| 160 | 160 | public: |
| 161 | 161 | t_CKINT execute( vector< string > &, string & ); |
| 162 | 162 | }; |
| 163 | − | |
| 163 | + | |
| 164 | 164 | //----------------------------------------------------------------------------- |
| 165 | 165 | // name: class Chuck_Shell::Command_VM_Remove |
| 166 | 166 | // desc: ... |
| @@ -180,7 +180,7 @@ public: // HACK-GE: moved from protected for win32 · 13 unmodified lines | ||
| 180 | 180 | public: |
| 181 | 181 | t_CKINT execute( vector< string > &, string & ); |
| 182 | 182 | }; |
| 183 | − | |
| 183 | + | |
| 184 | 184 | //----------------------------------------------------------------------------- |
| 185 | 185 | // name: class Chuck_Shell::Command_VM_List |
| 186 | 186 | // desc: ... |
| @@ -190,7 +190,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 190 | 190 | public: |
| 191 | 191 | t_CKINT execute( vector< string > &, string & ); |
| 192 | 192 | }; |
| 193 | − | |
| 193 | + | |
| 194 | 194 | //----------------------------------------------------------------------------- |
| 195 | 195 | // name: class Chuck_Shell::Command_VM_Swap |
| 196 | 196 | // desc: ... |
| @@ -200,7 +200,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 200 | 200 | public: |
| 201 | 201 | t_CKINT execute( vector< string > &, string & ); |
| 202 | 202 | }; |
| 203 | − | |
| 203 | + | |
| 204 | 204 | //----------------------------------------------------------------------------- |
| 205 | 205 | // name: class Chuck_Shell::Command_VM_AttachAdd |
| 206 | 206 | // desc: ... |
| @@ -210,7 +210,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 210 | 210 | public: |
| 211 | 211 | t_CKINT execute( vector< string > &, string & ); |
| 212 | 212 | }; |
| 213 | − | |
| 213 | + | |
| 214 | 214 | //----------------------------------------------------------------------------- |
| 215 | 215 | // name: class Chuck_Shell::Command_Add |
| 216 | 216 | // desc: ... |
| @@ -219,9 +219,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 219 | 219 | { |
| 220 | 220 | public: |
| 221 | 221 | t_CKINT execute( vector < string > &, string & ); |
| 222 | − string usage(); | |
| 222 | + string usage(); | |
| 223 | 223 | }; |
| 224 | − | |
| 224 | + | |
| 225 | 225 | //----------------------------------------------------------------------------- |
| 226 | 226 | // name: class Chuck_Shell::Command_Remove |
| 227 | 227 | // desc: ... |
| @@ -230,9 +230,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 230 | 230 | { |
| 231 | 231 | public: |
| 232 | 232 | t_CKINT execute( vector < string > &, string & ); |
| 233 | − string usage(); | |
| 233 | + string usage(); | |
| 234 | 234 | }; |
| 235 | − | |
| 235 | + | |
| 236 | 236 | //----------------------------------------------------------------------------- |
| 237 | 237 | // name: class Chuck_Shell::Command_Status |
| 238 | 238 | // desc: ... |
| @@ -241,10 +241,10 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 241 | 241 | { |
| 242 | 242 | public: |
| 243 | 243 | t_CKINT execute( vector < string > &, string & ); |
| 244 | − string usage(); | |
| 244 | + string usage(); | |
| 245 | 245 | }; |
| 246 | − | |
| 247 | − //----------------------------------------------------------------------------- | |
| 246 | + | |
| 247 | + //----------------------------------------------------------------------------- | |
| 248 | 248 | // name: class Chuck_Shell::Command_Removeall |
| 249 | 249 | // desc: ... |
| 250 | 250 | //----------------------------------------------------------------------------- |
| @@ -252,9 +252,9 @@ public: // HACK-GE: moved from protected for win32 · 1 unmodified line | ||
| 252 | 252 | { |
| 253 | 253 | public: |
| 254 | 254 | t_CKINT execute( vector< string > &, string & ); |
| 255 | − string usage(); | |
| 255 | + string usage(); | |
| 256 | 256 | }; |
| 257 | − | |
| 257 | + | |
| 258 | 258 | //----------------------------------------------------------------------------- |
| 259 | 259 | // name: class Chuck_Shell::Command_Removelast |
| 260 | 260 | // desc: ... |
| @@ -263,9 +263,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 263 | 263 | { |
| 264 | 264 | public: |
| 265 | 265 | t_CKINT execute( vector< string > &, string & ); |
| 266 | − string usage(); | |
| 266 | + string usage(); | |
| 267 | 267 | }; |
| 268 | − | |
| 268 | + | |
| 269 | 269 | //----------------------------------------------------------------------------- |
| 270 | 270 | // name: class Chuck_Shell::Command_Replace |
| 271 | 271 | // desc: ... |
| @@ -274,9 +274,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 274 | 274 | { |
| 275 | 275 | public: |
| 276 | 276 | t_CKINT execute( vector< string > &, string & ); |
| 277 | − string usage(); | |
| 277 | + string usage(); | |
| 278 | 278 | }; |
| 279 | − | |
| 279 | + | |
| 280 | 280 | //----------------------------------------------------------------------------- |
| 281 | 281 | // name: class Chuck_Shell::Command_Kill |
| 282 | 282 | // desc: ... |
| @@ -285,9 +285,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 285 | 285 | { |
| 286 | 286 | public: |
| 287 | 287 | t_CKINT execute( vector< string > &, string & ); |
| 288 | − //string usage(); | |
| 288 | + //string usage(); | |
| 289 | 289 | }; |
| 290 | − | |
| 290 | + | |
| 291 | 291 | //----------------------------------------------------------------------------- |
| 292 | 292 | // name: class Chuck_Shell::Command_Close |
| 293 | 293 | // desc: ... |
| @@ -296,9 +296,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 296 | 296 | { |
| 297 | 297 | public: |
| 298 | 298 | t_CKINT execute( vector< string > &, string & ); |
| 299 | − //string usage(); | |
| 299 | + //string usage(); | |
| 300 | 300 | }; |
| 301 | − | |
| 301 | + | |
| 302 | 302 | //----------------------------------------------------------------------------- |
| 303 | 303 | // name: class Chuck_Shell::Command_Exit |
| 304 | 304 | // desc: ... |
| @@ -307,9 +307,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 307 | 307 | { |
| 308 | 308 | public: |
| 309 | 309 | t_CKINT execute( vector< string > &, string & ); |
| 310 | − //string usage(); | |
| 310 | + //string usage(); | |
| 311 | 311 | }; |
| 312 | − | |
| 312 | + | |
| 313 | 313 | //----------------------------------------------------------------------------- |
| 314 | 314 | // name: class Chuck_Shell::Command_Ls |
| 315 | 315 | // desc: ... |
| @@ -318,9 +318,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 318 | 318 | { |
| 319 | 319 | public: |
| 320 | 320 | t_CKINT execute( vector< string > &, string & ); |
| 321 | − //string usage(); | |
| 321 | + //string usage(); | |
| 322 | 322 | }; |
| 323 | − | |
| 323 | + | |
| 324 | 324 | //----------------------------------------------------------------------------- |
| 325 | 325 | // name: class Chuck_Shell::Command_Cd |
| 326 | 326 | // desc: ... |
| @@ -329,9 +329,9 @@ public: // HACK-GE: moved from protected for win32 · 2 unmodified lines | ||
| 329 | 329 | { |
| 330 | 330 | public: |
| 331 | 331 | t_CKINT execute( vector< string > &, string & ); |
| 332 | − //string usage(); | |
| 332 | + //string usage(); | |
| 333 | 333 | }; |
| 334 | − | |
| 334 | + | |
| 335 | 335 | //----------------------------------------------------------------------------- |
| 336 | 336 | // name: class Chuck_Shell::Command_Pwd |
| 337 | 337 | // desc: ... |
| @@ -341,7 +341,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 341 | 341 | public: |
| 342 | 342 | t_CKINT execute( vector< string > &, string & ); |
| 343 | 343 | }; |
| 344 | − | |
| 344 | + | |
| 345 | 345 | //----------------------------------------------------------------------------- |
| 346 | 346 | // name: class Chuck_Shell::Command_Alias |
| 347 | 347 | // desc: ... |
| @@ -351,7 +351,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 351 | 351 | public: |
| 352 | 352 | t_CKINT execute( vector< string > &, string & ); |
| 353 | 353 | }; |
| 354 | − | |
| 354 | + | |
| 355 | 355 | //----------------------------------------------------------------------------- |
| 356 | 356 | // name: class Chuck_Shell::Command_Unalias |
| 357 | 357 | // desc: ... |
| @@ -361,7 +361,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 361 | 361 | public: |
| 362 | 362 | t_CKINT execute( vector< string > &, string & ); |
| 363 | 363 | }; |
| 364 | − | |
| 364 | + | |
| 365 | 365 | //----------------------------------------------------------------------------- |
| 366 | 366 | // name: class Chuck_Shell::Command_Source |
| 367 | 367 | // desc: ... |
| @@ -371,7 +371,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 371 | 371 | public: |
| 372 | 372 | t_CKINT execute( vector< string > &, string & ); |
| 373 | 373 | }; |
| 374 | − | |
| 374 | + | |
| 375 | 375 | //----------------------------------------------------------------------------- |
| 376 | 376 | // name: class Chuck_Shell::Command_Code |
| 377 | 377 | // desc: ... |
| @@ -382,13 +382,13 @@ public: // HACK-GE: moved from protected for win32 · 4 unmodified lines | ||
| 382 | 382 | ~Command_Code(); |
| 383 | 383 | t_CKBOOL init( Chuck_Shell * ); |
| 384 | 384 | t_CKINT execute( vector< string > &, string & ); |
| 385 | − string usage(); | |
| 386 | − | |
| 385 | + string usage(); | |
| 386 | + | |
| 387 | 387 | private: |
| 388 | 388 | map < string, Command * > commands; |
| 389 | 389 | vector < Command * > allocated_commands; |
| 390 | 390 | }; |
| 391 | − | |
| 391 | + | |
| 392 | 392 | //----------------------------------------------------------------------------- |
| 393 | 393 | // name: class Chuck_Shell::Command_CodeContext |
| 394 | 394 | // desc: ... |
| @@ -398,7 +398,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 398 | 398 | public: |
| 399 | 399 | t_CKINT execute( vector< string > &, string & ); |
| 400 | 400 | }; |
| 401 | − | |
| 401 | + | |
| 402 | 402 | //----------------------------------------------------------------------------- |
| 403 | 403 | // name: class Chuck_Shell::Command_CodeSave |
| 404 | 404 | // desc: ... |
| @@ -413,22 +413,22 @@ public: // HACK-GE: moved from protected for win32 · 8 unmodified lines | ||
| 413 | 413 | // name: class Chuck_Shell::Command_CodeDelete |
| 414 | 414 | // desc: ... |
| 415 | 415 | //----------------------------------------------------------------------------- |
| 416 | − class Command_CodeDelete : public Command | |
| 416 | + class Command_CodeDelete : public Command | |
| 417 | 417 | { |
| 418 | 418 | public: |
| 419 | 419 | t_CKINT execute( vector< string > &, string & ); |
| 420 | 420 | }; |
| 421 | − | |
| 421 | + | |
| 422 | 422 | //----------------------------------------------------------------------------- |
| 423 | 423 | // name: class Chuck_Shell::Command_CodeAdd |
| 424 | 424 | // desc: ... |
| 425 | 425 | //----------------------------------------------------------------------------- |
| 426 | 426 | class Command_CodeAdd : public Command |
| 427 | 427 | { |
| 428 | − public: | |
| 428 | + public: | |
| 429 | 429 | t_CKINT execute( vector< string > &, string & ); |
| 430 | 430 | }; |
| 431 | − | |
| 431 | + | |
| 432 | 432 | //----------------------------------------------------------------------------- |
| 433 | 433 | // name: class Chuck_Shell::Command_CodeList |
| 434 | 434 | // desc: ... |
| @@ -448,7 +448,7 @@ public: // HACK-GE: moved from protected for win32 · 13 unmodified lines | ||
| 448 | 448 | public: |
| 449 | 449 | t_CKINT execute( vector< string > &, string & ); |
| 450 | 450 | }; |
| 451 | − | |
| 451 | + | |
| 452 | 452 | //----------------------------------------------------------------------------- |
| 453 | 453 | // name: class Chuck_Shell::Command_CodeWrite |
| 454 | 454 | // desc: ... |
| @@ -468,7 +468,7 @@ public: // HACK-GE: moved from protected for win32 · 13 unmodified lines | ||
| 468 | 468 | public: |
| 469 | 469 | t_CKINT execute( vector< string > &, string & ); |
| 470 | 470 | }; |
| 471 | − | |
| 471 | + | |
| 472 | 472 | //----------------------------------------------------------------------------- |
| 473 | 473 | // name: class Chuck_Shell::Command_Help |
| 474 | 474 | // desc: ... |
| @@ -478,7 +478,7 @@ public: // HACK-GE: moved from protected for win32 · 3 unmodified lines | ||
| 478 | 478 | public: |
| 479 | 479 | t_CKINT execute( vector< string > &, string & ); |
| 480 | 480 | }; |
| 481 | − | |
| 481 | + | |
| 482 | 482 | }; |
| 483 | 483 | |
| 484 | 484 | |
| @@ -492,7 +492,7 @@ public: · 7 unmodified lines | ||
| 492 | 492 | virtual ~Chuck_Shell_VM() {} |
| 493 | 493 | |
| 494 | 494 | public: |
| 495 | − virtual Chuck_Shell_VM * copy()=0; | |
| 495 | + virtual Chuck_Shell_VM * copy()=0; | |
| 496 | 496 | virtual t_CKBOOL add_shred( const vector< string > &, string & )=0; |
| 497 | 497 | virtual t_CKBOOL remove_shred( const vector< string > &, string & )=0; |
| 498 | 498 | virtual t_CKBOOL remove_all( string & )=0; |
| @@ -511,9 +511,9 @@ class Chuck_Shell_Network_VM : public Chuck_Shell_VM · 12 unmodified lines | ||
| 511 | 511 | { |
| 512 | 512 | public: |
| 513 | 513 | virtual ~Chuck_Shell_Network_VM() {} |
| 514 | − | |
| 514 | + | |
| 515 | 515 | public: |
| 516 | − Chuck_Shell_VM * copy(); | |
| 516 | + Chuck_Shell_VM * copy(); | |
| 517 | 517 | t_CKBOOL init( const string &, t_CKINT ); |
| 518 | 518 | t_CKBOOL add_shred( const vector< string > &, string & ); |
| 519 | 519 | t_CKBOOL remove_shred( const vector< string > &, string & ); |
| @@ -523,9 +523,9 @@ public: · 3 unmodified lines | ||
| 523 | 523 | t_CKBOOL status( string & ); |
| 524 | 524 | t_CKBOOL kill( string & ); |
| 525 | 525 | string fullname(); |
| 526 | − | |
| 527 | −private: | |
| 528 | − string hostname; | |
| 526 | + | |
| 527 | +private: | |
| 528 | + string hostname; | |
| 529 | 529 | t_CKINT port; |
| 530 | 530 | }; |
| 531 | 531 | /* |
| @@ -537,9 +537,9 @@ class Chuck_Shell_Process_VM : public Chuck_Shell_VM · 5 unmodified lines | ||
| 537 | 537 | { |
| 538 | 538 | public: |
| 539 | 539 | virtual ~Chuck_Shell_Process_VM() {} |
| 540 | − | |
| 540 | + | |
| 541 | 541 | public: |
| 542 | − Chuck_Shell_VM * copy(); | |
| 542 | + Chuck_Shell_VM * copy(); | |
| 543 | 543 | t_CKBOOL init( const string &, t_CKINT ); |
| 544 | 544 | t_CKBOOL add_shred( const vector< string > &, string & ); |
| 545 | 545 | t_CKBOOL remove_shred( const vector< string > &, string & ); |
| @@ -549,12 +549,12 @@ public: · 3 unmodified lines | ||
| 549 | 549 | t_CKBOOL status( string & ); |
| 550 | 550 | t_CKBOOL kill( string & ); |
| 551 | 551 | string fullname(); |
| 552 | − | |
| 553 | − t_CKUINT last_shred_id(); | |
| 554 | − | |
| 555 | −private: | |
| 556 | − Chuck_VM * vm; | |
| 557 | − Chuck_Compiler * compiler; | |
| 552 | + | |
| 553 | + t_CKUINT last_shred_id(); | |
| 554 | + | |
| 555 | +private: | |
| 556 | + Chuck_VM * vm; | |
| 557 | + Chuck_Compiler * compiler; | |
| 558 | 558 | }; |
| 559 | 559 | */ |
| 560 | 560 | //----------------------------------------------------------------------------- |
| @@ -64,7 +64,7 @@ struct Shred_Activation · 63 unmodified lines | ||
| 64 | 64 | { |
| 65 | 65 | t_CKTIME when; |
| 66 | 66 | t_CKUINT cycles; |
| 67 | − | |
| 67 | + | |
| 68 | 68 | Shred_Activation( t_CKTIME a, t_CKUINT b ) { when = a; cycles = b; } |
| 69 | 69 | }; |
| 70 | 70 | |
| @@ -108,31 +108,31 @@ public: · 37 unmodified lines | ||
| 108 | 108 | std::string owner; |
| 109 | 109 | // source |
| 110 | 110 | std::string source; |
| 111 | − | |
| 111 | + | |
| 112 | 112 | // ctrl rate calculation |
| 113 | 113 | std::queue<t_CKDUR> diffs; |
| 114 | 114 | // number of diffs |
| 115 | 115 | t_CKUINT num_diffs; |
| 116 | 116 | // total diffs |
| 117 | 117 | t_CKDUR diff_total; |
| 118 | − | |
| 118 | + | |
| 119 | 119 | // exe per activation |
| 120 | 120 | std::queue<t_CKUINT> act_cycles; |
| 121 | 121 | // total |
| 122 | 122 | t_CKUINT act_cycles_total; |
| 123 | 123 | // last |
| 124 | 124 | t_CKUINT last_cycles; |
| 125 | − | |
| 125 | + | |
| 126 | 126 | // children |
| 127 | 127 | std::vector<Shred_Stat *> children; |
| 128 | 128 | void get_sporked( std::vector<Shred_Stat *> & out ); |
| 129 | 129 | |
| 130 | 130 | std::vector<Shred_Activation> activationss; |
| 131 | 131 | void get_activations( std::vector<Shred_Activation> & out ); |
| 132 | − | |
| 132 | + | |
| 133 | 133 | // mutex |
| 134 | 134 | XMutex mutex; |
| 135 | − | |
| 135 | + | |
| 136 | 136 | // audicle info |
| 137 | 137 | Shred_Data * data; |
| 138 | 138 | Shred_Time * time; |
| @@ -161,7 +161,7 @@ public: · 22 unmodified lines | ||
| 161 | 161 | static Chuck_Stats * instance(); |
| 162 | 162 | |
| 163 | 163 | public: |
| 164 | − void set_vm_ref( Chuck_VM * _vm ) { vm = _vm; } | |
| 164 | + void set_vm_ref( Chuck_VM * _vm ) { vm = _vm; } | |
| 165 | 165 | |
| 166 | 166 | public: |
| 167 | 167 | void add_shred( Chuck_VM_Shred * shred ); |
| @@ -173,16 +173,16 @@ public: · 5 unmodified lines | ||
| 173 | 173 | public: |
| 174 | 174 | Shred_Stat * get_shred( t_CKUINT xid ) |
| 175 | 175 | { mutex.acquire(); Shred_Stat * s = shreds[xid]; mutex.release(); return s; } |
| 176 | − void get_shreds( std::vector<Shred_Stat *> & out, | |
| 176 | + void get_shreds( std::vector<Shred_Stat *> & out, | |
| 177 | 177 | std::map<Shred_Stat *, Shred_Stat *> & d ); |
| 178 | 178 | static t_CKBOOL activations_yes; |
| 179 | 179 | |
| 180 | 180 | protected: |
| 181 | 181 | Chuck_Stats(); |
| 182 | 182 | ~Chuck_Stats(); |
| 183 | − | |
| 183 | + | |
| 184 | 184 | static Chuck_Stats * our_instance; |
| 185 | − | |
| 185 | + | |
| 186 | 186 | protected: |
| 187 | 187 | Chuck_VM * vm; |
| 188 | 188 | std::map<t_CKUINT, Shred_Stat *> shreds; |
| @@ -43,7 +43,7 @@ extern "C" { · 42 unmodified lines | ||
| 43 | 43 | |
| 44 | 44 | typedef struct S_Symbol_ * S_Symbol; |
| 45 | 45 | |
| 46 | −/* Make a unique symbol from a given c_str. | |
| 46 | +/* Make a unique symbol from a given c_str. | |
| 47 | 47 | * Different calls to make_symbol("foo") will yield the same S_Symbol |
| 48 | 48 | * value, even if the "foo" c_str are at different locations. */ |
| 49 | 49 | S_Symbol insert_symbol( c_constr ); |
| @@ -51,7 +51,7 @@ TAB_table TAB_empty2(unsigned long size); · 50 unmodified lines | ||
| 51 | 51 | TAB_table TAB_empty3( TAB_eq_func eq, TAB_hash_func hash, unsigned int size ); |
| 52 | 52 | void TAB_delete( TAB_table t ); |
| 53 | 53 | |
| 54 | −/* Enter the mapping "key"->"value" into table "t", | |
| 54 | +/* Enter the mapping "key"->"value" into table "t", | |
| 55 | 55 | * shadowing but not destroying any previous binding for "key". */ |
| 56 | 56 | void TAB_enter(TAB_table t, void *key, void *value); |
| 57 | 57 | |
| @@ -65,7 +65,7 @@ void *TAB_topv(TAB_table t); · 7 unmodified lines | ||
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | /* Call "show" on every "key"->"value" pair in the table, |
| 68 | − * including shadowed bindings, in order from the most | |
| 68 | + * including shadowed bindings, in order from the most | |
| 69 | 69 | * recent binding of any key to the oldest binding in the table */ |
| 70 | 70 | void TAB_dump(TAB_table t, void (*show)(void *key, void *value)); |
| 71 | 71 | |
| @@ -49,8 +49,8 @@ typedef enum { · 48 unmodified lines | ||
| 49 | 49 | // general types |
| 50 | 50 | te_none = 0, te_int, te_uint, te_single, te_float, te_double, te_time, te_dur, |
| 51 | 51 | te_complex, te_polar, te_string, te_thread, te_shred, te_class, |
| 52 | − te_function, te_object, te_user, te_array, te_null, te_ugen, te_uana, | |
| 53 | − te_event, te_void, te_stdout, te_stderr, te_adc, te_dac, te_bunghole, | |
| 52 | + te_function, te_object, te_user, te_array, te_null, te_ugen, te_uana, | |
| 53 | + te_event, te_void, te_stdout, te_stderr, te_adc, te_dac, te_bunghole, | |
| 54 | 54 | te_uanablob, te_io, te_fileio, te_chout, te_cherr, te_multi, |
| 55 | 55 | te_vec3, te_vec4, te_vector // ge: added 1.3.5.3 |
| 56 | 56 | } te_Type; |
| @@ -77,13 +77,29 @@ typedef enum { · 20 unmodified lines | ||
| 77 | 77 | // name: enum te_HowMuch |
| 78 | 78 | // desc: how much to scan/type check |
| 79 | 79 | //----------------------------------------------------------------------------- |
| 80 | −typedef enum { | |
| 80 | +typedef enum { | |
| 81 | 81 | te_do_all = 0, te_do_classes_only, te_do_no_classes |
| 82 | 82 | } te_HowMuch; |
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | |
| 87 | +//----------------------------------------------------------------------------- | |
| 88 | +// name: enum te_Origin | 1.5.0.0 (ge) added | |
| 89 | +// desc: where something (e.g., a Type) originates | |
| 90 | +//----------------------------------------------------------------------------- | |
| 91 | +typedef enum { | |
| 92 | + te_originUnknown = 0, | |
| 93 | + te_originBuiltin, // in core | |
| 94 | + te_originChugin, // in imported chugin | |
| 95 | + te_originImport, // library CK code | |
| 96 | + te_originUserDefined, // in user chuck code | |
| 97 | + te_originGenerated // generated (e.g., array types like int[][][][]) | |
| 98 | +} te_Origin; | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 87 | 103 | //----------------------------------------------------------------------------- |
| 88 | 104 | // name: struct Chuck_Scope |
| 89 | 105 | // desc: scoping structure |
| @@ -111,14 +127,14 @@ public: · 21 unmodified lines | ||
| 111 | 127 | // reset the scope |
| 112 | 128 | void reset() |
| 113 | 129 | { scope.clear(); this->push(); } |
| 114 | − | |
| 130 | + | |
| 115 | 131 | // atomic commit |
| 116 | 132 | void commit() |
| 117 | 133 | { |
| 118 | − assert( scope.size() != 0 ); | |
| 134 | + assert( scope.size() != 0 ); | |
| 119 | 135 | std::map<S_Symbol, Chuck_VM_Object *>::iterator iter; |
| 120 | 136 | |
| 121 | − // go through buffer | |
| 137 | + // go through buffer | |
| 122 | 138 | for( iter = commit_map.begin(); iter != commit_map.end(); iter++ ) |
| 123 | 139 | { |
| 124 | 140 | // add to front/where |
| @@ -135,7 +151,7 @@ public: · 10 unmodified lines | ||
| 135 | 151 | assert( scope.size() != 0 ); |
| 136 | 152 | std::map<S_Symbol, Chuck_VM_Object *>::iterator iter; |
| 137 | 153 | |
| 138 | − // go through buffer | |
| 154 | + // go through buffer | |
| 139 | 155 | for( iter = commit_map.begin(); iter != commit_map.end(); iter++ ) |
| 140 | 156 | { |
| 141 | 157 | // release |
| @@ -175,8 +191,8 @@ public: · 33 unmodified lines | ||
| 175 | 191 | { |
| 176 | 192 | val = (*scope.back())[xid]; |
| 177 | 193 | // look in commit buffer if the back is the front |
| 178 | − if( !val && scope.back() == scope.front() | |
| 179 | − && (commit_map.find(xid) != commit_map.end()) ) | |
| 194 | + if( !val && scope.back() == scope.front() | |
| 195 | + && (commit_map.find(xid) != commit_map.end()) ) | |
| 180 | 196 | val = commit_map[xid]; |
| 181 | 197 | } |
| 182 | 198 | else if( climb > 0 ) |
| @@ -199,8 +215,15 @@ public: · 16 unmodified lines | ||
| 199 | 215 | return (T)val; |
| 200 | 216 | } |
| 201 | 217 | |
| 218 | + // test if a name has been "mangled", e.g., "toString@0@Object" | |
| 219 | + static t_CKBOOL is_mangled( const std::string & name ) | |
| 220 | + { | |
| 221 | + // check for @ in the name, which would not be possible for names in language | |
| 222 | + return ( name.find("@") != std::string::npos ); | |
| 223 | + } | |
| 224 | + | |
| 202 | 225 | // get list of top level |
| 203 | − void get_toplevel( std::vector<Chuck_VM_Object *> & out ) | |
| 226 | + void get_toplevel( std::vector<Chuck_VM_Object *> & out, t_CKBOOL includeMangled = TRUE ) | |
| 204 | 227 | { |
| 205 | 228 | assert( scope.size() != 0 ); |
| 206 | 229 | std::map<S_Symbol, Chuck_VM_Object *>::iterator iter; |
| @@ -213,30 +236,36 @@ public: · 6 unmodified lines | ||
| 213 | 236 | // go through map |
| 214 | 237 | for( iter = m->begin(); iter != m->end(); iter++ ) |
| 215 | 238 | { |
| 239 | + // check mangled name | |
| 240 | + if( !includeMangled && is_mangled( std::string(S_name((*iter).first))) ) | |
| 241 | + continue; | |
| 216 | 242 | // add |
| 217 | 243 | out.push_back( (*iter).second ); |
| 218 | 244 | } |
| 219 | 245 | } |
| 220 | − | |
| 246 | + | |
| 221 | 247 | // get list of top level |
| 222 | − void get_level( int level, std::vector<Chuck_VM_Object *> & out ) | |
| 248 | + void get_level( int level, std::vector<Chuck_VM_Object *> & out, t_CKBOOL includeMangled = TRUE ) | |
| 223 | 249 | { |
| 224 | 250 | assert( scope.size() >= level ); |
| 225 | 251 | std::map<S_Symbol, Chuck_VM_Object *>::iterator iter; |
| 226 | − | |
| 252 | + | |
| 227 | 253 | // clear the out |
| 228 | 254 | out.clear(); |
| 229 | 255 | // get the front of the array |
| 230 | 256 | std::map<S_Symbol, Chuck_VM_Object *> * m = &commit_map; |
| 231 | − | |
| 257 | + | |
| 232 | 258 | // go through map |
| 233 | 259 | for( iter = m->begin(); iter != m->end(); iter++ ) |
| 234 | 260 | { |
| 261 | + // check mangled name | |
| 262 | + if( !includeMangled && is_mangled( std::string(S_name((*iter).first))) ) | |
| 263 | + continue; | |
| 264 | + | |
| 235 | 265 | // add |
| 236 | 266 | out.push_back( (*iter).second ); |
| 237 | 267 | } |
| 238 | 268 | } |
| 239 | − | |
| 240 | 269 | |
| 241 | 270 | protected: |
| 242 | 271 | std::vector<std::map<S_Symbol, Chuck_VM_Object *> *> scope; |
| @@ -288,7 +317,7 @@ struct Chuck_Namespace : public Chuck_VM_Object · 45 unmodified lines | ||
| 288 | 317 | t_CKUINT offset; |
| 289 | 318 | |
| 290 | 319 | // constructor |
| 291 | − Chuck_Namespace() { pre_ctor = NULL; dtor = NULL; parent = NULL; offset = 0; | |
| 320 | + Chuck_Namespace() { pre_ctor = NULL; dtor = NULL; parent = NULL; offset = 0; | |
| 292 | 321 | class_data = NULL; class_data_size = 0; } |
| 293 | 322 | // destructor |
| 294 | 323 | virtual ~Chuck_Namespace() { |
| @@ -308,13 +337,13 @@ struct Chuck_Namespace : public Chuck_VM_Object · 13 unmodified lines | ||
| 308 | 337 | Chuck_Func * lookup_func( S_Symbol name, t_CKINT climb = 1 ); |
| 309 | 338 | |
| 310 | 339 | // commit the maps |
| 311 | − void commit() { | |
| 340 | + void commit() { | |
| 312 | 341 | EM_log( CK_LOG_FINER, "committing namespace: '%s'...", name.c_str() ); |
| 313 | 342 | type.commit(); value.commit(); func.commit(); |
| 314 | 343 | } |
| 315 | − | |
| 344 | + | |
| 316 | 345 | // rollback the maps |
| 317 | − void rollback() { | |
| 346 | + void rollback() { | |
| 318 | 347 | EM_log( CK_LOG_FINER, "rolling back namespace: '%s'...", name.c_str() ); |
| 319 | 348 | type.rollback(); value.rollback(); func.rollback(); |
| 320 | 349 | } |
| @@ -324,7 +353,7 @@ struct Chuck_Namespace : public Chuck_VM_Object · 3 unmodified lines | ||
| 324 | 353 | // get top level values |
| 325 | 354 | void get_values( std::vector<Chuck_Value *> & out ); |
| 326 | 355 | // get top level functions |
| 327 | − void get_funcs( std::vector<Chuck_Func *> & out ); | |
| 356 | + void get_funcs( std::vector<Chuck_Func *> & out, t_CKBOOL includeManged = TRUE ); | |
| 328 | 357 | }; |
| 329 | 358 | |
| 330 | 359 | |
| @@ -334,7 +363,7 @@ struct Chuck_Namespace : public Chuck_VM_Object · 3 unmodified lines | ||
| 334 | 363 | // name: struct Chuck_Context |
| 335 | 364 | // desc: runtime type information pertaining to a file |
| 336 | 365 | //----------------------------------------------------------------------------- |
| 337 | −struct Chuck_Context : public Chuck_VM_Object | |
| 366 | +struct Chuck_Context : public Chuck_VM_Object | |
| 338 | 367 | { |
| 339 | 368 | // src_name |
| 340 | 369 | std::string filename; |
| @@ -370,7 +399,7 @@ struct Chuck_Context : public Chuck_VM_Object · 29 unmodified lines | ||
| 370 | 399 | void rollback(); |
| 371 | 400 | |
| 372 | 401 | // constructor |
| 373 | − Chuck_Context() { parse_tree = NULL; nspc = new Chuck_Namespace; | |
| 402 | + Chuck_Context() { parse_tree = NULL; nspc = new Chuck_Namespace; | |
| 374 | 403 | public_class_def = NULL; has_error = FALSE; |
| 375 | 404 | progress = P_NONE; } |
| 376 | 405 | // destructor |
| @@ -398,10 +427,15 @@ public: · 21 unmodified lines | ||
| 398 | 427 | // constructor |
| 399 | 428 | Chuck_Env(); |
| 400 | 429 | |
| 430 | +public: | |
| 431 | + // initialize | |
| 432 | + t_CKBOOL init(); | |
| 433 | + | |
| 401 | 434 | // REFACTOR-2017: carrier and accessors |
| 402 | 435 | public: |
| 403 | 436 | void set_carrier( Chuck_Carrier * carrier ) { m_carrier = carrier; } |
| 404 | − Chuck_VM * vm() { return m_carrier->vm; } | |
| 437 | + Chuck_VM * vm() { return m_carrier ? m_carrier->vm : NULL; } | |
| 438 | + Chuck_Compiler * compiler() { return m_carrier ? m_carrier->compiler : NULL; } | |
| 405 | 439 | |
| 406 | 440 | protected: |
| 407 | 441 | Chuck_Carrier * m_carrier; |
| @@ -425,7 +459,7 @@ public: · 17 unmodified lines | ||
| 425 | 459 | else |
| 426 | 460 | return user_nspc; |
| 427 | 461 | } |
| 428 | − | |
| 462 | + | |
| 429 | 463 | // namespace stack |
| 430 | 464 | std::vector<Chuck_Namespace *> nspc_stack; |
| 431 | 465 | // expression namespace |
| @@ -482,7 +516,7 @@ public: · 50 unmodified lines | ||
| 482 | 516 | // make sure this is 0 |
| 483 | 517 | class_scope = 0; |
| 484 | 518 | } |
| 485 | − | |
| 519 | + | |
| 486 | 520 | void load_user_namespace() |
| 487 | 521 | { |
| 488 | 522 | // user namespace |
| @@ -492,7 +526,7 @@ public: · 3 unmodified lines | ||
| 492 | 526 | SAFE_ADD_REF(global_nspc); |
| 493 | 527 | SAFE_ADD_REF(user_nspc); |
| 494 | 528 | } |
| 495 | − | |
| 529 | + | |
| 496 | 530 | void clear_user_namespace() |
| 497 | 531 | { |
| 498 | 532 | if(user_nspc) SAFE_RELEASE(user_nspc->parent); |
| @@ -506,11 +540,11 @@ public: · 7 unmodified lines | ||
| 506 | 540 | { assert( nspc_stack.size() > 0 ); return nspc_stack.back(); } |
| 507 | 541 | Chuck_Type * class_top( ) |
| 508 | 542 | { assert( class_stack.size() > 0 ); return class_stack.back(); } |
| 509 | − | |
| 543 | + | |
| 510 | 544 | // check whether the context is the global context |
| 511 | 545 | t_CKBOOL is_global() |
| 512 | 546 | { return class_def == NULL && func == NULL && class_scope == 0; } |
| 513 | − | |
| 547 | + | |
| 514 | 548 | public: |
| 515 | 549 | // REFACTOR-2017: public types |
| 516 | 550 | Chuck_Type * t_void; |
| @@ -533,12 +567,10 @@ public: · 16 unmodified lines | ||
| 533 | 567 | Chuck_Type * t_uanablob; |
| 534 | 568 | Chuck_Type * t_shred; |
| 535 | 569 | Chuck_Type * t_io; |
| 536 | − #ifndef __DISABLE_FILEIO__ | |
| 537 | 570 | Chuck_Type * t_fileio; |
| 538 | − #endif | |
| 539 | 571 | Chuck_Type * t_chout; |
| 540 | 572 | Chuck_Type * t_cherr; |
| 541 | − Chuck_Type * t_thread; | |
| 573 | + // Chuck_Type * t_thread; | |
| 542 | 574 | Chuck_Type * t_class; |
| 543 | 575 | Chuck_Type * t_dac; |
| 544 | 576 | Chuck_Type * t_adc; |
| @@ -563,7 +595,7 @@ struct Chuck_UGen_Info : public Chuck_VM_Object · 18 unmodified lines | ||
| 563 | 595 | t_CKUINT num_ins; |
| 564 | 596 | // number of outgoing channels |
| 565 | 597 | t_CKUINT num_outs; |
| 566 | − | |
| 598 | + | |
| 567 | 599 | // for uana, NULL for ugen |
| 568 | 600 | f_tock tock; |
| 569 | 601 | // number of incoming ana channels |
| @@ -573,7 +605,7 @@ struct Chuck_UGen_Info : public Chuck_VM_Object · 3 unmodified lines | ||
| 573 | 605 | |
| 574 | 606 | // constructor |
| 575 | 607 | Chuck_UGen_Info() |
| 576 | − { tick = NULL; tickf = NULL; pmsg = NULL; num_ins = num_outs = 1; | |
| 608 | + { tick = NULL; tickf = NULL; pmsg = NULL; num_ins = num_outs = 1; | |
| 577 | 609 | tock = NULL; num_ins_ana = num_outs_ana = 1; } |
| 578 | 610 | }; |
| 579 | 611 | |
| @@ -583,8 +615,9 @@ struct Chuck_UGen_Info : public Chuck_VM_Object · 3 unmodified lines | ||
| 583 | 615 | //----------------------------------------------------------------------------- |
| 584 | 616 | // name: struct Chuck_Type |
| 585 | 617 | // desc: class containing information about a type |
| 586 | −//-----------------------------------------------------------------------------_id | |
| 587 | −struct Chuck_Type : public Chuck_VM_Object | |
| 618 | +// note: 1.5.0.0 (ge) Chuck_VM_Object -> Chuck_Object | |
| 619 | +//----------------------------------------------------------------------------- | |
| 620 | +struct Chuck_Type : public Chuck_Object | |
| 588 | 621 | { |
| 589 | 622 | // type id |
| 590 | 623 | te_Type xid; |
| @@ -620,7 +653,9 @@ struct Chuck_Type : public Chuck_VM_Object · 29 unmodified lines | ||
| 620 | 653 | t_CKBOOL has_destructor; |
| 621 | 654 | // custom allocator |
| 622 | 655 | f_alloc allocator; |
| 623 | − | |
| 656 | + // origin hint | |
| 657 | + te_Origin originHint; | |
| 658 | + | |
| 624 | 659 | // documentation |
| 625 | 660 | std::string doc; |
| 626 | 661 | // example files |
| @@ -650,17 +685,23 @@ public: · 23 unmodified lines | ||
| 650 | 685 | const std::string & str(); |
| 651 | 686 | // to c string |
| 652 | 687 | const char * c_name(); |
| 653 | − | |
| 688 | + | |
| 654 | 689 | protected: |
| 655 | 690 | // this for str() and c_name() use only |
| 656 | 691 | std::string ret; |
| 657 | 692 | |
| 658 | 693 | public: // apropos | 1.4.1.0 (ge) |
| 659 | − // dump info to console | |
| 694 | + // generate info; output to console | |
| 660 | 695 | void apropos(); |
| 661 | − // dump info to string | |
| 696 | + // generate info; output to string | |
| 662 | 697 | void apropos( std::string & output ); |
| 663 | 698 | |
| 699 | +public: // dump | 1.4.1.1 (ge) | |
| 700 | + // generate object state; output to console | |
| 701 | + void dump( Chuck_Object * obj ); | |
| 702 | + // generate object state; output to string | |
| 703 | + void dump( Chuck_Object * obj, std::string & output ); | |
| 704 | + | |
| 664 | 705 | protected: // apropos-related helper function |
| 665 | 706 | // dump top level info |
| 666 | 707 | void apropos_top( std::string & output, const std::string & prefix ); |
| @@ -711,7 +752,7 @@ struct Chuck_Value : public Chuck_VM_Object · 44 unmodified lines | ||
| 711 | 752 | Chuck_Func * func_ref; |
| 712 | 753 | // overloads |
| 713 | 754 | t_CKINT func_num_overloads; |
| 714 | − | |
| 755 | + | |
| 715 | 756 | // documentation |
| 716 | 757 | std::string doc; |
| 717 | 758 | |
| @@ -720,7 +761,7 @@ struct Chuck_Value : public Chuck_VM_Object · 2 unmodified lines | ||
| 720 | 761 | t_CKBOOL c = FALSE, t_CKBOOL acc = 0, Chuck_Namespace * o = NULL, |
| 721 | 762 | Chuck_Type * oc = NULL, t_CKUINT s = 0 ) |
| 722 | 763 | { type = t; SAFE_ADD_REF(type); // add reference |
| 723 | − name = n; offset = s; | |
| 764 | + name = n; offset = s; | |
| 724 | 765 | is_const = c; access = acc; |
| 725 | 766 | owner = o; SAFE_ADD_REF(o); // add reference |
| 726 | 767 | owner_class = oc; SAFE_ADD_REF(oc); // add reference |
| @@ -772,13 +813,13 @@ struct Chuck_Func : public Chuck_VM_Object · 45 unmodified lines | ||
| 772 | 813 | Chuck_Func * next; |
| 773 | 814 | // for overriding |
| 774 | 815 | Chuck_Value * up; |
| 775 | − | |
| 816 | + | |
| 776 | 817 | // documentation |
| 777 | 818 | std::string doc; |
| 778 | 819 | |
| 779 | 820 | // constructor |
| 780 | 821 | Chuck_Func() { def = NULL; code = NULL; is_member = FALSE; is_static = FALSE, |
| 781 | − vt_index = 0xffffffff; value_ref = NULL; /*dl_code = NULL;*/ next = NULL; | |
| 822 | + vt_index = CK_NO_VALUE; value_ref = NULL; /*dl_code = NULL;*/ next = NULL; | |
| 782 | 823 | up = NULL; } |
| 783 | 824 | |
| 784 | 825 | // destructor |
| @@ -802,7 +843,7 @@ t_CKBOOL type_engine_load_context( Chuck_Env * env, Chuck_Context * context ); · 17 unmodified lines | ||
| 802 | 843 | t_CKBOOL type_engine_unload_context( Chuck_Env * env ); |
| 803 | 844 | |
| 804 | 845 | // type check a program into the env |
| 805 | −t_CKBOOL type_engine_check_prog( Chuck_Env * env, a_Program prog, | |
| 846 | +t_CKBOOL type_engine_check_prog( Chuck_Env * env, a_Program prog, | |
| 806 | 847 | const std::string & filename ); |
| 807 | 848 | // make a context |
| 808 | 849 | Chuck_Context * type_engine_make_context( a_Program prog, |
| @@ -833,8 +874,11 @@ t_CKBOOL isfunc( Chuck_Env * env, Chuck_Type * type ); · 24 unmodified lines | ||
| 833 | 874 | t_CKBOOL iskindofint( Chuck_Env * env, Chuck_Type * type ); // added 1.3.1.0: this includes int + pointers |
| 834 | 875 | t_CKUINT getkindof( Chuck_Env * env, Chuck_Type * type ); // added 1.3.1.0: to get the kindof a type |
| 835 | 876 | |
| 877 | + | |
| 878 | +//----------------------------------------------------------------------------- | |
| 836 | 879 | // import |
| 837 | −Chuck_Type * type_engine_import_class_begin( Chuck_Env * env, Chuck_Type * type, | |
| 880 | +//----------------------------------------------------------------------------- | |
| 881 | +Chuck_Type * type_engine_import_class_begin( Chuck_Env * env, Chuck_Type * type, | |
| 838 | 882 | Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor = NULL, |
| 839 | 883 | const char * doc = NULL ); |
| 840 | 884 | Chuck_Type * type_engine_import_class_begin( Chuck_Env * env, const char * name, const char * parent, |
| @@ -843,12 +887,14 @@ Chuck_Type * type_engine_import_class_begin( Chuck_Env * env, const char * name, · 2 unmodified lines | ||
| 843 | 887 | Chuck_Type * type_engine_import_ugen_begin( Chuck_Env * env, const char * name, const char * parent, |
| 844 | 888 | Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor, |
| 845 | 889 | f_tick tick, f_tickf tickf, f_pmsg pmsg, // (tickf added 1.3.0.0) |
| 846 | − t_CKUINT num_ins = 0xffffffff, t_CKUINT num_outs = 0xffffffff, | |
| 890 | + t_CKUINT num_ins = CK_NO_VALUE, | |
| 891 | + t_CKUINT num_outs = CK_NO_VALUE, | |
| 847 | 892 | const char * doc = NULL ); |
| 848 | 893 | Chuck_Type * type_engine_import_ugen_begin( Chuck_Env * env, const char * name, const char * parent, |
| 849 | 894 | Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor, |
| 850 | 895 | f_tick tick, f_pmsg pmsg, |
| 851 | − t_CKUINT num_ins = 0xffffffff, t_CKUINT num_outs = 0xffffffff, | |
| 896 | + t_CKUINT num_ins = CK_NO_VALUE, | |
| 897 | + t_CKUINT num_outs = CK_NO_VALUE, | |
| 852 | 898 | const char * doc = NULL ); |
| 853 | 899 | Chuck_Type * type_engine_import_ugen_begin( Chuck_Env * env, const char * name, const char * parent, |
| 854 | 900 | Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor, |
| @@ -856,12 +902,14 @@ Chuck_Type * type_engine_import_ugen_begin( Chuck_Env * env, const char * name, · 1 unmodified line | ||
| 856 | 902 | Chuck_Type * type_engine_import_uana_begin( Chuck_Env * env, const char * name, const char * parent, |
| 857 | 903 | Chuck_Namespace * where, f_ctor pre_ctor, f_dtor dtor, |
| 858 | 904 | f_tick tick, f_tock tock, f_pmsg pmsg, |
| 859 | − t_CKUINT num_ins = 0xffffffff, t_CKUINT num_outs = 0xffffffff, | |
| 860 | − t_CKUINT num_ins_ana = 0xffffffff, t_CKUINT num_outs_ana = 0xffffffff, | |
| 905 | + t_CKUINT num_ins = CK_NO_VALUE, | |
| 906 | + t_CKUINT num_outs = CK_NO_VALUE, | |
| 907 | + t_CKUINT num_ins_ana = CK_NO_VALUE, | |
| 908 | + t_CKUINT num_outs_ana = CK_NO_VALUE, | |
| 861 | 909 | const char * doc = NULL ); |
| 862 | 910 | t_CKBOOL type_engine_import_mfun( Chuck_Env * env, Chuck_DL_Func * mfun ); |
| 863 | 911 | t_CKBOOL type_engine_import_sfun( Chuck_Env * env, Chuck_DL_Func * sfun ); |
| 864 | −t_CKUINT type_engine_import_mvar( Chuck_Env * env, const char * type, | |
| 912 | +t_CKUINT type_engine_import_mvar( Chuck_Env * env, const char * type, | |
| 865 | 913 | const char * name, t_CKUINT is_const, |
| 866 | 914 | const char * doc = NULL ); |
| 867 | 915 | t_CKBOOL type_engine_import_svar( Chuck_Env * env, const char * type, |
| @@ -871,10 +919,13 @@ t_CKBOOL type_engine_import_ugen_ctrl( Chuck_Env * env, const char * type, const · 3 unmodified lines | ||
| 871 | 919 | f_ctrl ctrl, t_CKBOOL write, t_CKBOOL read ); |
| 872 | 920 | t_CKBOOL type_engine_import_add_ex( Chuck_Env * env, const char * ex ); |
| 873 | 921 | t_CKBOOL type_engine_import_class_end( Chuck_Env * env ); |
| 874 | −t_CKBOOL type_engine_register_deprecate( Chuck_Env * env, | |
| 922 | +t_CKBOOL type_engine_register_deprecate( Chuck_Env * env, | |
| 875 | 923 | const std::string & former, const std::string & latter ); |
| 876 | 924 | |
| 877 | −// helpers | |
| 925 | + | |
| 926 | +//----------------------------------------------------------------------------- | |
| 927 | +// helper functions | |
| 928 | +//----------------------------------------------------------------------------- | |
| 878 | 929 | t_CKBOOL type_engine_check_reserved( Chuck_Env * env, const std::string & xid, int pos ); |
| 879 | 930 | t_CKBOOL type_engine_check_reserved( Chuck_Env * env, S_Symbol xid, int pos ); |
| 880 | 931 | // 1.4.1.0 (ge): abilty to toggle reserved words for special cases, such as Math.pi co-existing with pi (use with care!) |
| @@ -883,17 +934,21 @@ t_CKBOOL type_engine_check_primitive( Chuck_Env * env, Chuck_Type * type ); · 2 unmodified lines | ||
| 883 | 934 | t_CKBOOL type_engine_check_const( Chuck_Env * env, a_Exp e, int pos ); // TODO |
| 884 | 935 | t_CKBOOL type_engine_compat_func( a_Func_Def lhs, a_Func_Def rhs, int pos, std::string & err, t_CKBOOL print = TRUE ); |
| 885 | 936 | t_CKBOOL type_engine_get_deprecate( Chuck_Env * env, const std::string & from, std::string & to ); |
| 937 | +t_CKBOOL type_engine_is_base_static( Chuck_Env * env, Chuck_Type * baseType ); // 1.5.0.0 (ge) added | |
| 886 | 938 | Chuck_Type * type_engine_find_common_anc( Chuck_Type * lhs, Chuck_Type * rhs ); |
| 887 | 939 | Chuck_Type * type_engine_find_type( Chuck_Env * env, a_Id_List path ); |
| 940 | +Chuck_Type * type_engine_find_type( Chuck_Env * env, const std::string & name ); // 1.5.0.0 (ge) added | |
| 888 | 941 | Chuck_Value * type_engine_find_value( Chuck_Type * type, const std::string & xid ); |
| 889 | 942 | Chuck_Value * type_engine_find_value( Chuck_Type * type, S_Symbol xid ); |
| 890 | 943 | Chuck_Value * type_engine_find_value( Chuck_Env * env, const std::string & xid, t_CKBOOL climb, int linepos = 0 ); |
| 891 | 944 | Chuck_Namespace * type_engine_find_nspc( Chuck_Env * env, a_Id_List path ); |
| 892 | −/******************************************************************************* | |
| 893 | − * spencer: added this into function to provide the same logic path | |
| 894 | − * for type_engine_check_exp_decl() and ck_add_mvar() when they determine | |
| 895 | − * offsets for mvars -- added 1.3.0.0 | |
| 896 | − ******************************************************************************/ | |
| 945 | + | |
| 946 | + | |
| 947 | +//----------------------------------------------------------------------------- | |
| 948 | +// spencer: added this into function to provide the same logic path | |
| 949 | +// for type_engine_check_exp_decl() and ck_add_mvar() when they determine | |
| 950 | +// offsets for mvars -- added 1.3.0.0 | |
| 951 | +//----------------------------------------------------------------------------- | |
| 897 | 952 | t_CKUINT type_engine_next_offset( t_CKUINT current_offset, Chuck_Type * type ); |
| 898 | 953 | // array verify |
| 899 | 954 | t_CKBOOL verify_array( a_Array_Sub array ); |
| @@ -901,7 +956,14 @@ t_CKBOOL verify_array( a_Array_Sub array ); · 1 unmodified line | ||
| 901 | 956 | Chuck_Type * new_array_type( Chuck_Env * env, Chuck_Type * array_parent, |
| 902 | 957 | t_CKUINT depth, Chuck_Type * base_type, |
| 903 | 958 | Chuck_Namespace * owner_nspc ); |
| 959 | +// make type | 1.4.1.1 (nshaheed) added | |
| 960 | +Chuck_Type * new_array_element_type( Chuck_Env * env, Chuck_Type * base_type, | |
| 961 | + t_CKUINT depth, Chuck_Namespace * owner_nspc); | |
| 962 | + | |
| 963 | + | |
| 964 | +//----------------------------------------------------------------------------- | |
| 904 | 965 | // conversion |
| 966 | +//----------------------------------------------------------------------------- | |
| 905 | 967 | const char * type_path( a_Id_List path ); |
| 906 | 968 | a_Id_List str2list( const std::string & path ); |
| 907 | 969 | a_Id_List str2list( const std::string & path, t_CKBOOL & is_array ); |
| @@ -909,7 +971,19 @@ const char * howmuch2str( te_HowMuch how_much ); · 1 unmodified line | ||
| 909 | 971 | t_CKBOOL escape_str( char * str_lit, int linepos ); |
| 910 | 972 | t_CKINT str2char( const char * char_lit, int linepos ); |
| 911 | 973 | |
| 974 | + | |
| 975 | +//----------------------------------------------------------------------------- | |
| 976 | +// more helper functions for type scan and checking | 1.5.0.0 (ge) added | |
| 977 | +//----------------------------------------------------------------------------- | |
| 978 | +// compare two argument lists to see if they are the same (sequence of types) | |
| 979 | +t_CKBOOL same_arg_lists( a_Arg_List lhs, a_Arg_List rhs ); | |
| 980 | +// generate a string from an argument list (types only) | |
| 981 | +std::string arglist2string( a_Arg_List list ); | |
| 982 | + | |
| 983 | + | |
| 984 | +//----------------------------------------------------------------------------- | |
| 912 | 985 | // REFACTOR-2017: exile! these default types now stored in env |
| 986 | +//----------------------------------------------------------------------------- | |
| 913 | 987 | //extern Chuck_Type t_void; |
| 914 | 988 | //extern Chuck_Type t_int; |
| 915 | 989 | //extern Chuck_Type t_float; |
| @@ -80,7 +80,7 @@ public: // src · 79 unmodified lines | ||
| 80 | 80 | t_CKBOOL alloc_v( t_CKUINT size ); |
| 81 | 81 | t_CKBOOL set_is_buffered( t_CKBOOL buffered ); |
| 82 | 82 | void get_buffer( SAMPLE * buffer, t_CKINT num_elem ); |
| 83 | − | |
| 83 | + | |
| 84 | 84 | Chuck_UGen *src_chan( t_CKUINT chan ); |
| 85 | 85 | Chuck_UGen *dst_for_src_chan( t_CKUINT chan ); |
| 86 | 86 | |
| @@ -133,17 +133,17 @@ public: // data · 46 unmodified lines | ||
| 133 | 133 | SAMPLE m_pan; |
| 134 | 134 | t_CKINT m_op; |
| 135 | 135 | t_CKINT m_max_block_size; |
| 136 | − | |
| 136 | + | |
| 137 | 137 | // SPENCERTODO: combine with block processing (added 1.3.0.0) |
| 138 | 138 | SAMPLE * m_multi_in_v; |
| 139 | 139 | SAMPLE * m_multi_out_v; |
| 140 | − | |
| 140 | + | |
| 141 | 141 | // SPENCERTODO: better way to handle this (added 1.3.0.0) |
| 142 | 142 | t_CKBOOL m_is_subgraph; |
| 143 | 143 | Chuck_UGen * m_inlet, * m_outlet; |
| 144 | 144 | Chuck_UGen * inlet(); |
| 145 | 145 | Chuck_UGen * outlet(); |
| 146 | − | |
| 146 | + | |
| 147 | 147 | // block processing |
| 148 | 148 | SAMPLE * m_sum_v; |
| 149 | 149 | SAMPLE * m_current_v; |
| @@ -154,10 +154,10 @@ public: // data · 4 unmodified lines | ||
| 154 | 154 | Chuck_VM * vm; |
| 155 | 155 | // owner |
| 156 | 156 | Chuck_UGen * owner; |
| 157 | − | |
| 157 | + | |
| 158 | 158 | // what a hack! |
| 159 | 159 | t_CKBOOL m_is_uana; |
| 160 | − | |
| 160 | + | |
| 161 | 161 | // what a hack! (added some time after REFACTOR-2017) |
| 162 | 162 | t_CKBOOL m_is_buffered; |
| 163 | 163 | AccumBuffer m_buffer; |
| @@ -49,7 +49,7 @@ struct U_boolList_ · 48 unmodified lines | ||
| 49 | 49 | }; |
| 50 | 50 | |
| 51 | 51 | |
| 52 | −void * checked_malloc( int size ); | |
| 52 | +void * checked_malloc( t_CKINT size ); | |
| 53 | 53 | c_str cc_str( char * ); |
| 54 | 54 | U_boolList U_BoolList( t_CKBOOL head, U_boolList tail ); |
| 55 | 55 | |
| @@ -145,7 +145,7 @@ public: · 144 unmodified lines | ||
| 145 | 145 | t_CKUINT native_func; |
| 146 | 146 | // is ctor? |
| 147 | 147 | t_CKUINT native_func_type; |
| 148 | − | |
| 148 | + | |
| 149 | 149 | // filename this code came from (added 1.3.0.0) |
| 150 | 150 | std::string filename; |
| 151 | 151 | |
| @@ -169,17 +169,17 @@ public: · 17 unmodified lines | ||
| 169 | 169 | Chuck_VM_Shred( ); |
| 170 | 170 | ~Chuck_VM_Shred( ); |
| 171 | 171 | |
| 172 | − t_CKBOOL initialize( Chuck_VM_Code * c, | |
| 173 | − t_CKUINT mem_st_size = CVM_MEM_STACK_SIZE, | |
| 172 | + t_CKBOOL initialize( Chuck_VM_Code * c, | |
| 173 | + t_CKUINT mem_st_size = CVM_MEM_STACK_SIZE, | |
| 174 | 174 | t_CKUINT reg_st_size = CVM_REG_STACK_SIZE ); |
| 175 | 175 | t_CKBOOL shutdown(); |
| 176 | 176 | t_CKBOOL run( Chuck_VM * vm ); |
| 177 | 177 | t_CKBOOL add( Chuck_UGen * ugen ); |
| 178 | 178 | t_CKBOOL remove( Chuck_UGen * ugen ); |
| 179 | − | |
| 179 | + | |
| 180 | 180 | // add parent object reference (added 1.3.1.2) |
| 181 | 181 | t_CKVOID add_parent_ref( Chuck_Object * obj ); |
| 182 | − | |
| 182 | + | |
| 183 | 183 | #ifndef __DISABLE_SERIAL__ |
| 184 | 184 | // HACK - spencer (added 1.3.2.0) |
| 185 | 185 | // add/remove SerialIO devices to close on shred exit |
| @@ -187,7 +187,7 @@ public: · 1 unmodified line | ||
| 187 | 187 | t_CKVOID add_serialio( Chuck_IO_Serial * serial ); |
| 188 | 188 | t_CKVOID remove_serialio( Chuck_IO_Serial * serial ); |
| 189 | 189 | #endif |
| 190 | − | |
| 190 | + | |
| 191 | 191 | //----------------------------------------------------------------------------- |
| 192 | 192 | // data |
| 193 | 193 | //----------------------------------------------------------------------------- |
| @@ -252,7 +252,7 @@ public: // ge: 1.3.5.3 · 58 unmodified lines | ||
| 252 | 252 | bool popLoopCounter(); |
| 253 | 253 | // loop counter pointer stack |
| 254 | 254 | std::vector<t_CKUINT *> m_loopCounters; |
| 255 | − | |
| 255 | + | |
| 256 | 256 | #ifndef __DISABLE_SERIAL__ |
| 257 | 257 | private: |
| 258 | 258 | std::list<Chuck_IO_Serial *> * m_serials; |
| @@ -272,7 +272,7 @@ public: · 13 unmodified lines | ||
| 272 | 272 | t_CKUINT xid; |
| 273 | 273 | std::string name; |
| 274 | 274 | t_CKTIME start; |
| 275 | − t_CKBOOL has_event; | |
| 275 | + t_CKBOOL has_event; | |
| 276 | 276 | |
| 277 | 277 | public: |
| 278 | 278 | Chuck_VM_Shred_Status( t_CKUINT _id, const std::string & n, t_CKTIME _start, t_CKBOOL e ) |
| @@ -297,7 +297,7 @@ public: · 18 unmodified lines | ||
| 297 | 297 | Chuck_VM_Status(); |
| 298 | 298 | ~Chuck_VM_Status(); |
| 299 | 299 | void clear(); |
| 300 | − | |
| 300 | + | |
| 301 | 301 | public: |
| 302 | 302 | // sample rate |
| 303 | 303 | t_CKUINT srate; |
| @@ -308,7 +308,7 @@ public: · 4 unmodified lines | ||
| 308 | 308 | t_CKUINT t_minute; |
| 309 | 309 | t_CKUINT t_hour; |
| 310 | 310 | // list of shred status |
| 311 | − std::vector<Chuck_VM_Shred_Status *> list; | |
| 311 | + std::vector<Chuck_VM_Shred_Status *> list; | |
| 312 | 312 | }; |
| 313 | 313 | |
| 314 | 314 | |
| @@ -374,10 +374,10 @@ public: · 59 unmodified lines | ||
| 374 | 374 | Chuck_UGen * m_bunghole; |
| 375 | 375 | t_CKUINT m_num_dac_channels; |
| 376 | 376 | t_CKUINT m_num_adc_channels; |
| 377 | − | |
| 377 | + | |
| 378 | 378 | // status cache |
| 379 | 379 | Chuck_VM_Status m_status; |
| 380 | − | |
| 380 | + | |
| 381 | 381 | // max block size for adaptive block processing |
| 382 | 382 | t_CKUINT m_max_block_size; |
| 383 | 383 | t_CKBOOL m_adaptive; |
| @@ -446,7 +446,7 @@ public: // running the machine · 62 unmodified lines | ||
| 446 | 446 | t_CKBOOL compute( ); |
| 447 | 447 | // abort current running shred |
| 448 | 448 | t_CKBOOL abort_current_shred( ); |
| 449 | − | |
| 449 | + | |
| 450 | 450 | public: // invoke functions |
| 451 | 451 | t_CKBOOL invoke_static( Chuck_VM_Shred * shred ); |
| 452 | 452 | |
| @@ -464,7 +464,7 @@ public: // msg · 11 unmodified lines | ||
| 464 | 464 | // added 1.3.0.0 to fix uber-crash |
| 465 | 465 | CBufferSimple * create_event_buffer(); |
| 466 | 466 | void destroy_event_buffer( CBufferSimple * buffer ); |
| 467 | − | |
| 467 | + | |
| 468 | 468 | public: // get error |
| 469 | 469 | const char * last_error() const |
| 470 | 470 | { return m_last_error.c_str(); } |
| @@ -514,7 +514,7 @@ public: · 43 unmodified lines | ||
| 514 | 514 | Chuck_VM_Shred * spork( Chuck_VM_Shred * shred ); |
| 515 | 515 | |
| 516 | 516 | protected: |
| 517 | − t_CKBOOL free( Chuck_VM_Shred * shred, t_CKBOOL cascade, | |
| 517 | + t_CKBOOL free( Chuck_VM_Shred * shred, t_CKBOOL cascade, | |
| 518 | 518 | t_CKBOOL dec = TRUE ); |
| 519 | 519 | void dump( Chuck_VM_Shred * shred ); |
| 520 | 520 | void release_dump(); |
| @@ -536,7 +536,7 @@ protected: · 15 unmodified lines | ||
| 536 | 536 | CBufferSimple * m_msg_buffer; |
| 537 | 537 | CBufferSimple * m_reply_buffer; |
| 538 | 538 | CBufferSimple * m_event_buffer; |
| 539 | − | |
| 539 | + | |
| 540 | 540 | // TODO: vector? (added 1.3.0.0 to fix uber-crash) |
| 541 | 541 | std::list<CBufferSimple *> m_event_buffers; |
| 542 | 542 | |
| @@ -597,10 +597,10 @@ struct Chuck_Msg · 54 unmodified lines | ||
| 597 | 597 | |
| 598 | 598 | Chuck_Msg() : args(NULL) { clear(); } |
| 599 | 599 | ~Chuck_Msg() { SAFE_DELETE( args ); } |
| 600 | − | |
| 600 | + | |
| 601 | 601 | // added 1.3.0.0 |
| 602 | 602 | void clear() { SAFE_DELETE( args ); memset( this, 0, sizeof(*this) ); } |
| 603 | − | |
| 603 | + | |
| 604 | 604 | void set( const std::vector<std::string> & vargs ) |
| 605 | 605 | { |
| 606 | 606 | SAFE_DELETE(args); |
| @@ -266,13 +266,13 @@ · 265 unmodified lines | ||
| 266 | 266 | |
| 267 | 267 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 268 | 268 | typedef union YYSTYPE |
| 269 | −#line 59 "chuck.y" | |
| 269 | +#line 65 "chuck.y" | |
| 270 | 270 | { |
| 271 | 271 | int pos; |
| 272 | 272 | int ival; |
| 273 | 273 | double fval; |
| 274 | 274 | c_str sval; |
| 275 | − | |
| 275 | + | |
| 276 | 276 | a_Program program; |
| 277 | 277 | a_Section program_section; |
| 278 | 278 | a_Stmt_List stmt_list; |
| @@ -294,7 +294,7 @@ typedef union YYSTYPE · 15 unmodified lines | ||
| 294 | 294 | } |
| 295 | 295 | /* Line 1529 of yacc.c. */ |
| 296 | 296 | #line 297 "chuck.tab.h" |
| 297 | − YYSTYPE; | |
| 297 | + YYSTYPE; | |
| 298 | 298 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 299 | 299 | # define YYSTYPE_IS_DECLARED 1 |
| 300 | 300 | # define YYSTYPE_IS_TRIVIAL 1 |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /* |
| 2 | 2 | * dirent.h - dirent API for Microsoft Visual Studio |
| 3 | − * | |
| 3 | + * | |
| 4 | 4 | * Copyright (C) 2006 Toni Ronkko |
| 5 | − * | |
| 5 | + * | |
| 6 | 6 | * Permission is hereby granted, free of charge, to any person obtaining |
| 7 | 7 | * a copy of this software and associated documentation files (the |
| 8 | 8 | * ``Software''), to deal in the Software without restriction, including |
| @@ -10,10 +10,10 @@ · 1 unmodified line | ||
| 10 | 10 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | 12 | * the following conditions: |
| 13 | − * | |
| 13 | + * | |
| 14 | 14 | * The above copyright notice and this permission notice shall be included |
| 15 | 15 | * in all copies or substantial portions of the Software. |
| 16 | − * | |
| 16 | + * | |
| 17 | 17 | * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 | 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| @@ -33,13 +33,13 @@ · 13 unmodified lines | ||
| 33 | 33 | * Bug fix: due to the strncpy_s() function this file only compiled in |
| 34 | 34 | * Visual Studio 2005. Using the new string functions only when the |
| 35 | 35 | * compiler version allows. |
| 36 | − * | |
| 36 | + * | |
| 37 | 37 | * Nov 2, 2006, Toni Ronkko |
| 38 | 38 | * Major update: removed support for Watcom C, MS-DOS and Turbo C to |
| 39 | 39 | * simplify the file, updated the code to compile cleanly on Visual |
| 40 | 40 | * Studio 2005 with both unicode and multi-byte character strings, |
| 41 | 41 | * removed rewinddir() as it had a bug. |
| 42 | − * | |
| 42 | + * | |
| 43 | 43 | * Aug 20, 2006, Toni Ronkko |
| 44 | 44 | * Removed all remarks about MSVC 1.0, which is antiqued now. Simplified |
| 45 | 45 | * comments by removing SGML tags. |
| @@ -115,11 +115,11 @@ opendir( · 69 unmodified lines | ||
| 115 | 115 | dirp = (DIR*) malloc (sizeof (struct DIR)); |
| 116 | 116 | if (dirp != NULL) { |
| 117 | 117 | char *p; |
| 118 | − | |
| 118 | + | |
| 119 | 119 | /* take directory name... */ |
| 120 | 120 | STRNCPY (dirp->patt, dirname, sizeof(dirp->patt)); |
| 121 | 121 | dirp->patt[MAX_PATH] = '\0'; |
| 122 | − | |
| 122 | + | |
| 123 | 123 | /* ... and append search pattern to it */ |
| 124 | 124 | p = strchr (dirp->patt, '\0'); |
| 125 | 125 | if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') { |
| @@ -138,42 +138,42 @@ opendir( · 12 unmodified lines | ||
| 138 | 138 | |
| 139 | 139 | /* there is an un-processed directory entry in memory now */ |
| 140 | 140 | dirp->cached = 1; |
| 141 | − | |
| 141 | + | |
| 142 | 142 | } |
| 143 | 143 | return dirp; |
| 144 | 144 | } |
| 145 | − | |
| 146 | − | |
| 147 | −/* | |
| 148 | − * ge: not a good idea | |
| 149 | − */ | |
| 150 | −static void | |
| 151 | −rewinddir( | |
| 152 | − DIR *dirp) | |
| 153 | −{ | |
| 154 | − assert( dirp != NULL ); | |
| 155 | − | |
| 156 | − /* no cache */ | |
| 157 | − dirp->cached = 0; | |
| 158 | − | |
| 159 | − /* open stream and retrieve first file */ | |
| 160 | − dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data); | |
| 161 | − if (dirp->search_handle == INVALID_HANDLE_VALUE) { | |
| 162 | − /* invalid search pattern? */ | |
| 163 | − return; | |
| 164 | − } | |
| 165 | − | |
| 166 | − /* there is an un-processed directory entry in memory now */ | |
| 167 | − dirp->cached = 1; | |
| 145 | + | |
| 146 | + | |
| 147 | +/* | |
| 148 | + * ge: not a good idea | |
| 149 | + */ | |
| 150 | +static void | |
| 151 | +rewinddir( | |
| 152 | + DIR *dirp) | |
| 153 | +{ | |
| 154 | + assert( dirp != NULL ); | |
| 155 | + | |
| 156 | + /* no cache */ | |
| 157 | + dirp->cached = 0; | |
| 158 | + | |
| 159 | + /* open stream and retrieve first file */ | |
| 160 | + dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data); | |
| 161 | + if (dirp->search_handle == INVALID_HANDLE_VALUE) { | |
| 162 | + /* invalid search pattern? */ | |
| 163 | + return; | |
| 164 | + } | |
| 165 | + | |
| 166 | + /* there is an un-processed directory entry in memory now */ | |
| 167 | + dirp->cached = 1; | |
| 168 | 168 | } |
| 169 | − | |
| 170 | − | |
| 169 | + | |
| 170 | + | |
| 171 | 171 | /* |
| 172 | 172 | * Read a directory entry, and return a pointer to a dirent structure |
| 173 | 173 | * containing the name of the entry in d_name field. Individual directory |
| 174 | 174 | * entries returned by this very function include regular files, |
| 175 | 175 | * sub-directories, pseudo-directories "." and "..", but also volume labels, |
| 176 | − * hidden files and system files may be returned. | |
| 176 | + * hidden files and system files may be returned. | |
| 177 | 177 | */ |
| 178 | 178 | static struct dirent * |
| 179 | 179 | readdir( |
| @@ -203,7 +203,7 @@ readdir( · 23 unmodified lines | ||
| 203 | 203 | /* copy as a multibyte character string */ |
| 204 | 204 | STRNCPY (dirp->current.d_name, dirp->current.data.cFileName, sizeof(dirp->current.d_name)); |
| 205 | 205 | dirp->current.d_name[MAX_PATH] = '\0'; |
| 206 | − | |
| 206 | + | |
| 207 | 207 | return &dirp->current; |
| 208 | 208 | } |
| 209 | 209 | |
| @@ -218,7 +218,7 @@ closedir( · 8 unmodified lines | ||
| 218 | 218 | DIR *dirp) |
| 219 | 219 | { |
| 220 | 220 | assert (dirp != NULL); |
| 221 | − | |
| 221 | + | |
| 222 | 222 | /* release search handle */ |
| 223 | 223 | if (dirp->search_handle != INVALID_HANDLE_VALUE) { |
| 224 | 224 | FindClose (dirp->search_handle); |
| @@ -63,7 +63,7 @@ public: · 62 unmodified lines | ||
| 63 | 63 | t_CKBOOL close(); |
| 64 | 64 | t_CKBOOL good() { return m_valid; } |
| 65 | 65 | t_CKINT num() { return m_valid ? (t_CKINT)m_device_num : -1; } |
| 66 | − | |
| 66 | + | |
| 67 | 67 | public: |
| 68 | 68 | void set_suppress( t_CKBOOL print_or_not ) |
| 69 | 69 | { m_suppress_output = print_or_not; } |
| @@ -131,7 +131,7 @@ public: · 61 unmodified lines | ||
| 131 | 131 | static t_CKBOOL open( HidIn * hin, Chuck_VM * vm, t_CKINT device_type, std::string & device_name ); |
| 132 | 132 | static t_CKBOOL close( HidIn * hin ); |
| 133 | 133 | static void cleanup_buffer( Chuck_VM * vm ); |
| 134 | − | |
| 134 | + | |
| 135 | 135 | static void probeHidIn(); |
| 136 | 136 | static void probeHidOut(); |
| 137 | 137 | |
| @@ -142,9 +142,9 @@ public: · 4 unmodified lines | ||
| 142 | 142 | #endif |
| 143 | 143 | |
| 144 | 144 | static void push_message( HidMsg & msg ); |
| 145 | − | |
| 145 | + | |
| 146 | 146 | static std::map< Chuck_VM *, CBufferSimple * > m_event_buffers; |
| 147 | − | |
| 147 | + | |
| 148 | 148 | protected: |
| 149 | 149 | static std::vector< std::vector<PhyHidDevIn *> > the_matrix; |
| 150 | 150 | static XThread * the_thread; |
| @@ -92,7 +92,7 @@ public: · 91 unmodified lines | ||
| 92 | 92 | t_CKBOOL close(); |
| 93 | 93 | t_CKBOOL good() { return m_valid; } |
| 94 | 94 | t_CKINT num() { return m_valid ? (t_CKINT)m_device_num : -1; } |
| 95 | − | |
| 95 | + | |
| 96 | 96 | public: |
| 97 | 97 | void set_suppress( t_CKBOOL print_or_not ) |
| 98 | 98 | { m_suppress_output = print_or_not; } |
| @@ -187,7 +187,7 @@ public: · 88 unmodified lines | ||
| 187 | 187 | protected: |
| 188 | 188 | MidiInManager(); |
| 189 | 189 | ~MidiInManager(); |
| 190 | − | |
| 190 | + | |
| 191 | 191 | static t_CKBOOL add_vm( Chuck_VM * vm, t_CKINT device_num, t_CKBOOL suppress_output ); |
| 192 | 192 | |
| 193 | 193 | static std::vector<RtMidiIn *> the_mins; |
| @@ -333,7 +333,7 @@ struct MidiNoteEvent · 139 unmodified lines | ||
| 333 | 333 | MidiNoteEvent * simultaneous; |
| 334 | 334 | // link to parent (could be self) |
| 335 | 335 | MidiNoteEvent * parent; |
| 336 | − | |
| 336 | + | |
| 337 | 337 | // more data |
| 338 | 338 | double startTime; |
| 339 | 339 | double endTime; |
| @@ -341,12 +341,12 @@ struct MidiNoteEvent · 1 unmodified line | ||
| 341 | 341 | int bendAmount; |
| 342 | 342 | int programChange; |
| 343 | 343 | bool phrasemark; |
| 344 | − | |
| 344 | + | |
| 345 | 345 | // constructor |
| 346 | 346 | MidiNoteEvent() : data1(0), data2(0), data3(0), time(0.0), untilNext(0.0), |
| 347 | 347 | simultaneous(NULL), parent(NULL), startTime(0), endTime(0), shouldBend(false), |
| 348 | 348 | bendAmount(0), programChange(0), phrasemark(false) { } |
| 349 | − | |
| 349 | + | |
| 350 | 350 | // type of message |
| 351 | 351 | int type() const { return data1 & 0x70; } |
| 352 | 352 | // channel |
| @@ -367,7 +367,7 @@ struct MidiLyricEvent · 14 unmodified lines | ||
| 367 | 367 | // time data |
| 368 | 368 | double time; |
| 369 | 369 | double endTime; |
| 370 | − | |
| 370 | + | |
| 371 | 371 | // constructor |
| 372 | 372 | MidiLyricEvent() : time(0), endTime(0) { } |
| 373 | 373 | }; |
| @@ -390,51 +390,51 @@ class MidiScoreReader · 16 unmodified lines | ||
| 390 | 390 | public: |
| 391 | 391 | MidiScoreReader(); |
| 392 | 392 | ~MidiScoreReader(); |
| 393 | − | |
| 393 | + | |
| 394 | 394 | public: |
| 395 | 395 | bool load( const char * filename, float velScale = 0.0f ); |
| 396 | 396 | void cleanup(); |
| 397 | − | |
| 397 | + | |
| 398 | 398 | public: |
| 399 | 399 | // rewind to beginning |
| 400 | 400 | void rewind(); |
| 401 | 401 | // get current top event (NO simultaneous) |
| 402 | − const MidiNoteEvent * getTopEvent( long track, long offset = 0 ); | |
| 402 | + const MidiNoteEvent * getTopEvent( t_CKINT track, t_CKINT offset = 0 ); | |
| 403 | 403 | // get current event (YES simultaneous) + move to next |
| 404 | − const MidiNoteEvent * scanEvent( long track, bool & isNewSet ); | |
| 404 | + const MidiNoteEvent * scanEvent( t_CKINT track, bool & isNewSet ); | |
| 405 | 405 | // advance to next event |
| 406 | − bool seek( long track, long numToAdvance = 1 ); | |
| 406 | + bool seek( t_CKINT track, t_CKINT numToAdvance = 1 ); | |
| 407 | 407 | // advance to next note on |
| 408 | − bool seekToNoteOn( long track ); | |
| 408 | + bool seekToNoteOn( t_CKINT track ); | |
| 409 | 409 | // get notes in a time window |
| 410 | − void getEvents( long track, double startTime, double endTime, std::vector<const MidiNoteEvent *> & result, | |
| 410 | + void getEvents( t_CKINT track, double startTime, double endTime, std::vector<const MidiNoteEvent *> & result, | |
| 411 | 411 | bool includeSimultaneous = false ); |
| 412 | 412 | // isDone |
| 413 | − bool isDone( long track, double currTime ); | |
| 414 | − | |
| 415 | − | |
| 413 | + bool isDone( t_CKINT track, double currTime ); | |
| 414 | + | |
| 415 | + | |
| 416 | 416 | public: |
| 417 | 417 | // get number of tracks |
| 418 | − long getNumTracks() const; | |
| 418 | + t_CKINT getNumTracks() const; | |
| 419 | 419 | // get number of events per track |
| 420 | − long getNumEvents( long track ) const; | |
| 420 | + t_CKINT getNumEvents( t_CKINT track ) const; | |
| 421 | 421 | // get number of tracks with more than 0 events |
| 422 | − long getNumTracksNonZero() const; | |
| 422 | + t_CKINT getNumTracksNonZero() const; | |
| 423 | 423 | // get a vector of tracks indices that have more than 0 events |
| 424 | − const std::vector<long> & getTracksNonZero() const; | |
| 424 | + const std::vector<t_CKINT> & getTracksNonZero() const; | |
| 425 | 425 | // get BPM |
| 426 | 426 | double getBPM() const; |
| 427 | 427 | // get an entire track's note events |
| 428 | − const std::vector<MidiNoteEvent *> & getNoteEvents( long track ); | |
| 428 | + const std::vector<MidiNoteEvent *> & getNoteEvents( t_CKINT track ); | |
| 429 | 429 | // get an entire track's lyric events |
| 430 | − const std::vector<MidiLyricEvent *> & getLyricEvents( long track ); | |
| 430 | + const std::vector<MidiLyricEvent *> & getLyricEvents( t_CKINT track ); | |
| 431 | 431 | // get count |
| 432 | − long getCount( long track, const std::string & key ); | |
| 432 | + t_CKINT getCount( t_CKINT track, const std::string & key ); | |
| 433 | 433 | // get lowest note for a track |
| 434 | − long getLowestNote( long track, const MidiNoteEvent *start ); | |
| 434 | + t_CKINT getLowestNote( t_CKINT track, const MidiNoteEvent *start ); | |
| 435 | 435 | // get highest note for a track |
| 436 | − long getHighestNote( long track, const MidiNoteEvent *start ); | |
| 437 | − | |
| 436 | + t_CKINT getHighestNote( t_CKINT track, const MidiNoteEvent *start ); | |
| 437 | + | |
| 438 | 438 | public: // TODO: these may as well be a separate object |
| 439 | 439 | // push a event to remember |
| 440 | 440 | void enqueue( const MidiNoteEvent * event ); |
| @@ -444,26 +444,26 @@ public: // TODO: these may as well be a separate object · 3 unmodified lines | ||
| 444 | 444 | void dequeue(); |
| 445 | 445 | // push to front |
| 446 | 446 | void enqueue_front( const MidiNoteEvent * event ); |
| 447 | − | |
| 447 | + | |
| 448 | 448 | public: // track naming |
| 449 | 449 | // sets track name |
| 450 | − void setTrackName( long track, const std::string & name ); | |
| 450 | + void setTrackName( t_CKINT track, const std::string & name ); | |
| 451 | 451 | // gets track name ("" if not present) |
| 452 | − std::string getTrackName( long track ); | |
| 452 | + std::string getTrackName( t_CKINT track ); | |
| 453 | 453 | // gets the track with the given name (-1 if not present) |
| 454 | − long getTrackForName( const std::string & name ); | |
| 455 | − | |
| 454 | + t_CKINT getTrackForName( const std::string & name ); | |
| 455 | + | |
| 456 | 456 | protected: // for use while loading a track |
| 457 | 457 | // load a track |
| 458 | − bool loadTrack( long track, std::vector<MidiNoteEvent *> & data, std::vector<MidiLyricEvent *> & lyricData ); | |
| 458 | + bool loadTrack( t_CKINT track, std::vector<MidiNoteEvent *> & data, std::vector<MidiLyricEvent *> & lyricData ); | |
| 459 | 459 | // apply control to existing event |
| 460 | − bool applyControl( long track, long data2, long data3, MidiNoteEvent * e ); | |
| 460 | + bool applyControl( t_CKINT track, t_CKINT data2, t_CKINT data3, MidiNoteEvent * e ); | |
| 461 | 461 | // increment count for the given key (used for counting the number of notes, glissandi, etc) |
| 462 | − void incrementCount( long track, const std::string & key ); | |
| 462 | + void incrementCount( t_CKINT track, const std::string & key ); | |
| 463 | 463 | // handle note events, managing m_activeNotes and setting the event's endTime |
| 464 | − void handleNoteOn( MidiNoteEvent * e, long note ); | |
| 465 | − void handleNoteOff( long note, double time ); | |
| 466 | − | |
| 464 | + void handleNoteOn( MidiNoteEvent * e, t_CKINT note ); | |
| 465 | + void handleNoteOff( t_CKINT note, double time ); | |
| 466 | + | |
| 467 | 467 | protected: |
| 468 | 468 | // midi |
| 469 | 469 | stk::MidiFileIn * m_midiFile; |
| @@ -472,28 +472,28 @@ protected: · 2 unmodified lines | ||
| 472 | 472 | // vector of tracks of events |
| 473 | 473 | std::vector< std::vector<MidiLyricEvent *> > m_lyricEvents; |
| 474 | 474 | // vector of indices |
| 475 | − std::vector<unsigned long> m_indices; | |
| 475 | + std::vector<t_CKUINT> m_indices; | |
| 476 | 476 | // stack of events |
| 477 | 477 | std::deque<const MidiNoteEvent *> m_queue; |
| 478 | 478 | // vector of event |
| 479 | 479 | std::vector<const MidiNoteEvent *> m_result; |
| 480 | 480 | // search pointer |
| 481 | − std::vector<unsigned long> m_searchIndices; | |
| 481 | + std::vector<t_CKUINT> m_searchIndices; | |
| 482 | 482 | // count map |
| 483 | − std::vector< std::map< std::string, long > > m_countMaps; | |
| 483 | + std::vector< std::map< std::string, t_CKINT > > m_countMaps; | |
| 484 | 484 | // HACK: scale the velocity (0-1) |
| 485 | 485 | float m_velocity_scale; |
| 486 | 486 | // track names |
| 487 | − std::map<std::string, long> m_nameToTrack; | |
| 488 | − std::map<long, std::string> m_trackToName; | |
| 487 | + std::map<std::string, t_CKINT> m_nameToTrack; | |
| 488 | + std::map<t_CKINT, std::string> m_trackToName; | |
| 489 | 489 | // number of non-zero tracks |
| 490 | − long m_numNonZeroTracks; | |
| 490 | + t_CKINT m_numNonZeroTracks; | |
| 491 | 491 | // vector of indices of non-zero tracks |
| 492 | − std::vector<long> m_nonZeroTrackIndices; | |
| 493 | − | |
| 492 | + std::vector<t_CKINT> m_nonZeroTrackIndices; | |
| 493 | + | |
| 494 | 494 | private: // used during track loading |
| 495 | 495 | // active notes, map from MIDI note to event |
| 496 | − std::map<long, MidiNoteEvent *> m_activeNotes; | |
| 496 | + std::map<t_CKINT, MidiNoteEvent *> m_activeNotes; | |
| 497 | 497 | }; |
| 498 | 498 | |
| 499 | 499 | |
| @@ -38,11 +38,11 @@ · 37 unmodified lines | ||
| 38 | 38 | /************************************************************************/ |
| 39 | 39 | /*! \class RtMidiError |
| 40 | 40 | \brief Exception handling class for RtAudio & RtMidi. |
| 41 | − | |
| 41 | + | |
| 42 | 42 | The RtMidiError class is quite simple but it does allow errors to be |
| 43 | 43 | "caught" by RtMidiError::Type. See the RtAudio and RtMidi |
| 44 | 44 | documentation to know which methods can throw an RtMidiError. |
| 45 | − | |
| 45 | + | |
| 46 | 46 | */ |
| 47 | 47 | /************************************************************************/ |
| 48 | 48 | |
| @@ -70,26 +70,26 @@ public: · 21 unmodified lines | ||
| 70 | 70 | SYSTEM_ERROR, /*!< A system error occured. */ |
| 71 | 71 | THREAD_ERROR /*!< A thread error occured. */ |
| 72 | 72 | }; |
| 73 | − | |
| 73 | + | |
| 74 | 74 | //! The constructor. |
| 75 | 75 | RtMidiError( const std::string& message, Type type = RtMidiError::UNSPECIFIED ) |
| 76 | 76 | throw() : message_(message), type_(type) {} |
| 77 | − | |
| 77 | + | |
| 78 | 78 | //! The destructor. |
| 79 | 79 | virtual ~RtMidiError( void ) throw() {} |
| 80 | − | |
| 80 | + | |
| 81 | 81 | //! Prints thrown error message to stderr. |
| 82 | 82 | virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; } |
| 83 | 83 | |
| 84 | 84 | //! Returns the thrown error message type. |
| 85 | 85 | virtual const Type& getType(void) const throw() { return type_; } |
| 86 | − | |
| 86 | + | |
| 87 | 87 | //! Returns the thrown error message string. |
| 88 | 88 | virtual const std::string& getMessage(void) const throw() { return message_; } |
| 89 | − | |
| 89 | + | |
| 90 | 90 | //! Returns the thrown error message as a c-style string. |
| 91 | 91 | virtual const char* what( void ) const throw() { return message_.c_str(); } |
| 92 | − | |
| 92 | + | |
| 93 | 93 | protected: |
| 94 | 94 | std::string message_; |
| 95 | 95 | Type type_; |
| @@ -253,8 +253,8 @@ class RtMidiIn : public RtMidi · 157 unmodified lines | ||
| 253 | 253 | |
| 254 | 254 | // A MIDI structure used internally by the class to store incoming |
| 255 | 255 | // messages. Each message represents one and only one MIDI message. |
| 256 | − struct MidiMessage { | |
| 257 | − std::vector<unsigned char> bytes; | |
| 256 | + struct MidiMessage { | |
| 257 | + std::vector<unsigned char> bytes; | |
| 258 | 258 | double timeStamp; |
| 259 | 259 | |
| 260 | 260 | // Default constructor. |
| @@ -66,11 +66,11 @@ CK_DLL_TICK( pulseosc_tick ); · 65 unmodified lines | ||
| 66 | 66 | // triosc |
| 67 | 67 | CK_DLL_TICK( triosc_tick ); |
| 68 | 68 | |
| 69 | −// sawosc | |
| 69 | +// sawosc | |
| 70 | 70 | CK_DLL_CTOR( sawosc_ctor ); |
| 71 | 71 | CK_DLL_CTRL( sawosc_ctrl_width ); |
| 72 | 72 | |
| 73 | −// sqrosc | |
| 73 | +// sqrosc | |
| 74 | 74 | CK_DLL_CTOR( sqrosc_ctor ); |
| 75 | 75 | CK_DLL_CTRL( sqrosc_ctrl_width ); |
| 76 | 76 | |
| @@ -47,9 +47,6 @@ struct Chuck_Carrier; · 46 unmodified lines | ||
| 47 | 47 | DLL_QUERY stk_query( Chuck_DL_Query * QUERY ); |
| 48 | 48 | t_CKBOOL stk_detach( Chuck_Carrier * carrier ); |
| 49 | 49 | |
| 50 | − | |
| 51 | − | |
| 52 | − | |
| 53 | 50 | // this determines STK float type and de-denormal method |
| 54 | 51 | #ifndef __STK_USE_SINGLE_PRECISION__ |
| 55 | 52 | #define MY_FLOAT double |
| @@ -59,6 +56,9 @@ t_CKBOOL stk_detach( Chuck_Carrier * carrier ); · 3 unmodified lines | ||
| 59 | 56 | #define CK_STK_DDN CK_DDN_SINGLE |
| 60 | 57 | #endif |
| 61 | 58 | |
| 59 | +// 1.4.2.0 (ge) | added as part of switch to snprintf() | |
| 60 | +#define STK_MSG_BUF_LENGTH 256 | |
| 61 | + | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | |
| @@ -88,14 +88,14 @@ t_CKBOOL stk_detach( Chuck_Carrier * carrier ); · 23 unmodified lines | ||
| 88 | 88 | // a "long double" in the future. |
| 89 | 89 | |
| 90 | 90 | //XXX sample is already defined in chuck_def.h!!! |
| 91 | −#if !defined(SAMPLE) | |
| 91 | +#if !defined(SAMPLE) | |
| 92 | 92 | typedef SAMPLE MY_FLOAT; |
| 93 | 93 | #endif |
| 94 | 94 | // The "MY_FLOAT" type will be deprecated in STK |
| 95 | 95 | // versions higher than 4.1.2 and replaced with the variable |
| 96 | 96 | // "StkFloat". |
| 97 | 97 | //typedef double StkFloat; |
| 98 | −//#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) | |
| 98 | +//#if defined(__PLATFORM_WIN32__) || | |
| 99 | 99 | // #pragma deprecated(MY_FLOAT) |
| 100 | 100 | //#else |
| 101 | 101 | // typedef StkFloat MY_FLOAT __attribute__ ((deprecated)); |
| @@ -110,7 +110,7 @@ t_CKBOOL stk_detach( Chuck_Carrier * carrier ); · 8 unmodified lines | ||
| 110 | 110 | class StkError |
| 111 | 111 | { |
| 112 | 112 | public: |
| 113 | − enum TYPE { | |
| 113 | + enum TYPE { | |
| 114 | 114 | WARNING, |
| 115 | 115 | DEBUG_WARNING, |
| 116 | 116 | FUNCTION_ARGUMENT, |
| @@ -126,7 +126,7 @@ public: · 9 unmodified lines | ||
| 126 | 126 | }; |
| 127 | 127 | |
| 128 | 128 | public: // SWAP formerly protected |
| 129 | − char message[256]; | |
| 129 | + char message[STK_MSG_BUF_LENGTH]; | |
| 130 | 130 | TYPE type; |
| 131 | 131 | |
| 132 | 132 | public: |
| @@ -250,7 +250,7 @@ typedef double FLOAT64; · 117 unmodified lines | ||
| 250 | 250 | #if defined(__WINDOWS_PTHREAD__) |
| 251 | 251 | #define __OS_WINDOWS_CYGWIN__ |
| 252 | 252 | #define __STK_REALTIME__ |
| 253 | −#elif defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) | |
| 253 | +#elif defined(__PLATFORM_WIN32__) | |
| 254 | 254 | #define __OS_WINDOWS__ |
| 255 | 255 | #define __STK_REALTIME__ |
| 256 | 256 | #elif defined(__PLATFORM_LINUX__) |
| @@ -492,15 +492,14 @@ class Instrmnt : public Stk · 235 unmodified lines | ||
| 492 | 492 | |
| 493 | 493 | //! Computer \e vectorSize outputs and return them in \e vector. |
| 494 | 494 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 495 | − | |
| 495 | + | |
| 496 | 496 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 497 | 497 | virtual void controlChange(int number, MY_FLOAT value); |
| 498 | 498 | |
| 499 | 499 | public: // SWAP formerly protected |
| 500 | + MY_FLOAT lastOutput; | |
| 500 | 501 | // chuck |
| 501 | 502 | t_CKFLOAT m_frequency; |
| 502 | − | |
| 503 | − MY_FLOAT lastOutput; | |
| 504 | 503 | }; |
| 505 | 504 | |
| 506 | 505 | |
| @@ -635,7 +634,7 @@ public: · 128 unmodified lines | ||
| 635 | 634 | Alternatively, the delay and maximum length |
| 636 | 635 | can be set during instantiation with an |
| 637 | 636 | overloaded constructor. |
| 638 | − | |
| 637 | + | |
| 639 | 638 | A non-interpolating delay line is typically |
| 640 | 639 | used in fixed delay-length applications, such |
| 641 | 640 | as for reverberation. |
| @@ -748,7 +747,7 @@ public: · 106 unmodified lines | ||
| 748 | 747 | DelayL(); |
| 749 | 748 | |
| 750 | 749 | //! Overloaded constructor which specifies the current and maximum delay-line lengths. |
| 751 | − | |
| 750 | + | |
| 752 | 751 | DelayL(MY_FLOAT theDelay, long maxDelay); |
| 753 | 752 | |
| 754 | 753 | //! Class destructor. |
| @@ -770,7 +769,7 @@ public: · 15 unmodified lines | ||
| 770 | 769 | //! Input one sample to the delay-line and return one output. |
| 771 | 770 | MY_FLOAT tick(MY_FLOAT sample); |
| 772 | 771 | |
| 773 | − public: // SWAP formerly protected | |
| 772 | + public: // SWAP formerly protected | |
| 774 | 773 | MY_FLOAT alpha; |
| 775 | 774 | MY_FLOAT omAlpha; |
| 776 | 775 | MY_FLOAT nextOutput; |
| @@ -835,7 +834,7 @@ public: · 58 unmodified lines | ||
| 835 | 834 | //! Take \e vectorSize inputs and return the corresponding function values in \e vector. |
| 836 | 835 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 837 | 836 | |
| 838 | −public: // SWAP formerly protected | |
| 837 | +public: // SWAP formerly protected | |
| 839 | 838 | MY_FLOAT offSet; |
| 840 | 839 | MY_FLOAT slope; |
| 841 | 840 | MY_FLOAT lastOutput; |
| @@ -962,7 +961,7 @@ public: · 120 unmodified lines | ||
| 962 | 961 | Percussion Instruments", Proceedings of the |
| 963 | 962 | 1999 International Computer Music Conference. |
| 964 | 963 | |
| 965 | − Control Change Numbers: | |
| 964 | + Control Change Numbers: | |
| 966 | 965 | - Bow Pressure = 2 |
| 967 | 966 | - Bow Motion = 4 |
| 968 | 967 | - Strike Position = 8 (not implemented) |
| @@ -1018,7 +1017,7 @@ class BandedWG : public Instrmnt · 49 unmodified lines | ||
| 1018 | 1017 | void pluck(MY_FLOAT amp); |
| 1019 | 1018 | |
| 1020 | 1019 | //! Start a note with the given frequency and amplitude. |
| 1021 | − void noteOn(MY_FLOAT amplitude) { noteOn ( freakency, amplitude ); } | |
| 1020 | + void noteOn(MY_FLOAT amplitude) { noteOn ( freakency, amplitude ); } | |
| 1022 | 1021 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 1023 | 1022 | |
| 1024 | 1023 | //! Stop a note with the given amplitude (speed of decay). |
| @@ -1085,7 +1084,7 @@ class BandedWG : public Instrmnt · 60 unmodified lines | ||
| 1085 | 1084 | WvIn supports multi-channel data in interleaved |
| 1086 | 1085 | format. It is important to distinguish the |
| 1087 | 1086 | tick() methods, which return samples produced |
| 1088 | − by averaging across sample frames, from the | |
| 1087 | + by averaging across sample frames, from the | |
| 1089 | 1088 | tickFrame() methods, which return pointers to |
| 1090 | 1089 | multi-channel sample frames. For single-channel |
| 1091 | 1090 | data, these methods return equivalent values. |
| @@ -1161,7 +1160,7 @@ public: · 69 unmodified lines | ||
| 1161 | 1160 | //! Normalize data to a maximum of \e +-peak. |
| 1162 | 1161 | /*! |
| 1163 | 1162 | For large, incrementally loaded files with integer data types, |
| 1164 | − normalization is computed relative to the data type maximum | |
| 1163 | + normalization is computed relative to the data type maximum | |
| 1165 | 1164 | (\e peak/maximum). For incrementally loaded files with floating- |
| 1166 | 1165 | point data types, direct scaling by \e peak is performed. |
| 1167 | 1166 | */ |
| @@ -1255,8 +1254,8 @@ public: // SWAP formerly protected · 87 unmodified lines | ||
| 1255 | 1254 | // Get MAT-file header information. |
| 1256 | 1255 | bool getMatInfo( const char *fileName ); |
| 1257 | 1256 | |
| 1258 | − char msg[256]; | |
| 1259 | − // char m_filename[256]; // chuck data | |
| 1257 | + char msg[STK_MSG_BUF_LENGTH]; | |
| 1258 | + // char m_filename[STK_MSG_BUF_LENGTH]; // chuck data | |
| 1260 | 1259 | Chuck_String str_filename; // chuck data |
| 1261 | 1260 | FILE *fd; |
| 1262 | 1261 | MY_FLOAT *data; |
| @@ -1315,7 +1314,7 @@ public: · 52 unmodified lines | ||
| 1315 | 1314 | WaveLoop( ); |
| 1316 | 1315 | //! Class constructor. |
| 1317 | 1316 | WaveLoop( const char *fileName, bool raw = FALSE, bool generate = true ); |
| 1318 | − | |
| 1317 | + | |
| 1319 | 1318 | virtual void openFile( const char * fileName, bool raw = FALSE, bool n = TRUE ); |
| 1320 | 1319 | |
| 1321 | 1320 | //! Class destructor. |
| @@ -1458,7 +1457,7 @@ class TwoZero : public FilterStk // formerly protected Filter · 136 unmodified lines | ||
| 1458 | 1457 | waves and envelopes, determined via a |
| 1459 | 1458 | constructor argument. |
| 1460 | 1459 | |
| 1461 | − Control Change Numbers: | |
| 1460 | + Control Change Numbers: | |
| 1462 | 1461 | - Control One = 2 |
| 1463 | 1462 | - Control Two = 4 |
| 1464 | 1463 | - LFO Speed = 11 |
| @@ -1529,7 +1528,7 @@ class FM : public Instrmnt · 64 unmodified lines | ||
| 1529 | 1528 | MY_FLOAT getFMTableSusLevel(int index); // programming settings |
| 1530 | 1529 | // 1.4.1.0 (prc): *** END REPAIRATHON2021 BLOCK *** |
| 1531 | 1530 | /****************************************/ |
| 1532 | − | |
| 1531 | + | |
| 1533 | 1532 | //! Set instrument parameters for a particular frequency. |
| 1534 | 1533 | virtual void setFrequency(MY_FLOAT frequency); |
| 1535 | 1534 | |
| @@ -1566,8 +1565,8 @@ class FM : public Instrmnt · 30 unmodified lines | ||
| 1566 | 1565 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 1567 | 1566 | virtual void controlChange(int number, MY_FLOAT value); |
| 1568 | 1567 | |
| 1569 | − public: // SWAP formerly protected | |
| 1570 | − ADSR **adsr; | |
| 1568 | + public: // SWAP formerly protected | |
| 1569 | + ADSR **adsr; | |
| 1571 | 1570 | WaveLoop **waves; |
| 1572 | 1571 | WaveLoop *vibrato; |
| 1573 | 1572 | TwoZero *twozero; |
| @@ -1587,7 +1586,6 @@ class FM : public Instrmnt · 13 unmodified lines | ||
| 1587 | 1586 | MY_FLOAT __FM_gains[100]; |
| 1588 | 1587 | MY_FLOAT __FM_susLevels[16]; |
| 1589 | 1588 | MY_FLOAT __FM_attTimes[32]; |
| 1590 | − | |
| 1591 | 1589 | }; |
| 1592 | 1590 | |
| 1593 | 1591 | #endif |
| @@ -1612,7 +1610,7 @@ class FM : public Instrmnt · 18 unmodified lines | ||
| 1612 | 1610 | 4 -- |
| 1613 | 1611 | \endcode |
| 1614 | 1612 | |
| 1615 | − Control Change Numbers: | |
| 1613 | + Control Change Numbers: | |
| 1616 | 1614 | - Operator 4 (feedback) Gain = 2 |
| 1617 | 1615 | - Operator 3 Gain = 4 |
| 1618 | 1616 | - LFO Speed = 11 |
| @@ -1691,7 +1689,7 @@ public: · 72 unmodified lines | ||
| 1691 | 1689 | //! Take \e vectorSize inputs and return the corresponding function values in \e vector. |
| 1692 | 1690 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 1693 | 1691 | |
| 1694 | −public: // SWAP formerly protected | |
| 1692 | +public: // SWAP formerly protected | |
| 1695 | 1693 | MY_FLOAT lastOutput; |
| 1696 | 1694 | |
| 1697 | 1695 | }; |
| @@ -1832,7 +1830,7 @@ public: · 134 unmodified lines | ||
| 1832 | 1830 | //! Return the last computed value. |
| 1833 | 1831 | MY_FLOAT lastOut() const; |
| 1834 | 1832 | |
| 1835 | −public: // SWAP formerly protected | |
| 1833 | +public: // SWAP formerly protected | |
| 1836 | 1834 | |
| 1837 | 1835 | MY_FLOAT lastOutput; |
| 1838 | 1836 | |
| @@ -1851,7 +1849,7 @@ public: // SWAP formerly protected · 12 unmodified lines | ||
| 1851 | 1849 | (biquad filter) with a polynomial jet |
| 1852 | 1850 | excitation (a la Cook). |
| 1853 | 1851 | |
| 1854 | − Control Change Numbers: | |
| 1852 | + Control Change Numbers: | |
| 1855 | 1853 | - Noise Gain = 4 |
| 1856 | 1854 | - Vibrato Frequency = 11 |
| 1857 | 1855 | - Vibrato Gain = 1 |
| @@ -1901,14 +1899,14 @@ class BlowBotl : public Instrmnt · 43 unmodified lines | ||
| 1901 | 1899 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 1902 | 1900 | void controlChange(int number, MY_FLOAT value); |
| 1903 | 1901 | |
| 1904 | − public: // SWAP formerly protected | |
| 1902 | + public: // SWAP formerly protected | |
| 1905 | 1903 | // chuck |
| 1906 | 1904 | t_CKFLOAT m_rate; |
| 1907 | 1905 | t_CKFLOAT m_noiseGain; |
| 1908 | 1906 | t_CKFLOAT m_vibratoFreq; |
| 1909 | 1907 | t_CKFLOAT m_vibratoGain; |
| 1910 | 1908 | t_CKFLOAT m_volume; |
| 1911 | − | |
| 1909 | + | |
| 1912 | 1910 | void setVibratoFreq(MY_FLOAT freq) |
| 1913 | 1911 | { vibrato->setFrequency( freq ); m_vibratoFreq = vibrato->m_freq; } |
| 1914 | 1912 | void setVibratoGain(MY_FLOAT gain) |
| @@ -1994,7 +1992,7 @@ public: · 79 unmodified lines | ||
| 1994 | 1992 | //! Take \e vectorSize inputs and return the corresponding function values in \e vector. |
| 1995 | 1993 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 1996 | 1994 | |
| 1997 | −public: // SWAP formerly protected | |
| 1995 | +public: // SWAP formerly protected | |
| 1998 | 1996 | MY_FLOAT offSet; |
| 1999 | 1997 | MY_FLOAT slope; |
| 2000 | 1998 | MY_FLOAT lastOutput; |
| @@ -2104,7 +2102,7 @@ class OneZero : public FilterStk // formerly protected Filter · 103 unmodified lines | ||
| 2104 | 2102 | use possibly subject to patents held by Stanford |
| 2105 | 2103 | University, Yamaha, and others. |
| 2106 | 2104 | |
| 2107 | − Control Change Numbers: | |
| 2105 | + Control Change Numbers: | |
| 2108 | 2106 | - Reed Stiffness = 2 |
| 2109 | 2107 | - Noise Gain = 4 |
| 2110 | 2108 | - Tonehole State = 11 |
| @@ -2162,7 +2160,7 @@ class BlowHole : public Instrmnt · 51 unmodified lines | ||
| 2162 | 2160 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 2163 | 2161 | void controlChange(int number, MY_FLOAT value); |
| 2164 | 2162 | |
| 2165 | − public: // SWAP formerly protected | |
| 2163 | + public: // SWAP formerly protected | |
| 2166 | 2164 | |
| 2167 | 2165 | // CHUCK |
| 2168 | 2166 | t_CKFLOAT m_reed; |
| @@ -2283,7 +2281,7 @@ public: · 114 unmodified lines | ||
| 2283 | 2281 | use possibly subject to patents held by |
| 2284 | 2282 | Stanford University, Yamaha, and others. |
| 2285 | 2283 | |
| 2286 | − Control Change Numbers: | |
| 2284 | + Control Change Numbers: | |
| 2287 | 2285 | - Bow Pressure = 2 |
| 2288 | 2286 | - Bow Position = 4 |
| 2289 | 2287 | - Vibrato Frequency = 11 |
| @@ -2323,7 +2321,7 @@ class Bowed : public Instrmnt · 33 unmodified lines | ||
| 2323 | 2321 | //! Decrease breath pressure with given rate of decrease. |
| 2324 | 2322 | void stopBowing(MY_FLOAT rate); |
| 2325 | 2323 | |
| 2326 | − void noteOn(MY_FLOAT amplitude) { noteOn ( m_frequency, amplitude ); } | |
| 2324 | + void noteOn(MY_FLOAT amplitude) { noteOn ( m_frequency, amplitude ); } | |
| 2327 | 2325 | //! Start a note with the given frequency and amplitude. |
| 2328 | 2326 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 2329 | 2327 | |
| @@ -2406,7 +2404,7 @@ public: · 76 unmodified lines | ||
| 2406 | 2404 | DelayA(); |
| 2407 | 2405 | |
| 2408 | 2406 | //! Overloaded constructor which specifies the current and maximum delay-line lengths. |
| 2409 | − | |
| 2407 | + | |
| 2410 | 2408 | DelayA(MY_FLOAT theDelay, long maxDelay); |
| 2411 | 2409 | |
| 2412 | 2410 | //! Class destructor. |
| @@ -2431,7 +2429,7 @@ public: · 18 unmodified lines | ||
| 2431 | 2429 | //! Input one sample to the delay-line and return one output. |
| 2432 | 2430 | MY_FLOAT tick(MY_FLOAT sample); |
| 2433 | 2431 | |
| 2434 | −public: // SWAP formerly protected | |
| 2432 | +public: // SWAP formerly protected | |
| 2435 | 2433 | MY_FLOAT alpha; |
| 2436 | 2434 | MY_FLOAT coeff; |
| 2437 | 2435 | MY_FLOAT apInput; |
| @@ -2455,7 +2453,7 @@ public: // SWAP formerly protected · 17 unmodified lines | ||
| 2455 | 2453 | use possibly subject to patents held by |
| 2456 | 2454 | Stanford University, Yamaha, and others. |
| 2457 | 2455 | |
| 2458 | − Control Change Numbers: | |
| 2456 | + Control Change Numbers: | |
| 2459 | 2457 | - Lip Tension = 2 |
| 2460 | 2458 | - Slide Length = 4 |
| 2461 | 2459 | - Vibrato Frequency = 11 |
| @@ -2506,7 +2504,7 @@ class Brass: public Instrmnt · 44 unmodified lines | ||
| 2506 | 2504 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 2507 | 2505 | void controlChange(int number, MY_FLOAT value); |
| 2508 | 2506 | |
| 2509 | − public: // SWAP formerly protected | |
| 2507 | + public: // SWAP formerly protected | |
| 2510 | 2508 | |
| 2511 | 2509 | // CHUCK |
| 2512 | 2510 | t_CKFLOAT m_rate; |
| @@ -2576,7 +2574,7 @@ class Chorus : public Stk · 63 unmodified lines | ||
| 2576 | 2574 | //! Set modulation frequency. |
| 2577 | 2575 | void setModFrequency(MY_FLOAT frequency); |
| 2578 | 2576 | |
| 2579 | − //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). | |
| 2577 | + //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). | |
| 2580 | 2578 | void setEffectMix(MY_FLOAT mix); |
| 2581 | 2579 | |
| 2582 | 2580 | //! Return the last output value. |
| @@ -2594,7 +2592,7 @@ class Chorus : public Stk · 11 unmodified lines | ||
| 2594 | 2592 | //! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector. |
| 2595 | 2593 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 2596 | 2594 | |
| 2597 | − public: // SWAP formerly protected | |
| 2595 | + public: // SWAP formerly protected | |
| 2598 | 2596 | DelayL *delayLine[2]; |
| 2599 | 2597 | WaveLoop *mods[2]; |
| 2600 | 2598 | MY_FLOAT baseLength; |
| @@ -2623,7 +2621,7 @@ class Chorus : public Stk · 22 unmodified lines | ||
| 2623 | 2621 | use possibly subject to patents held by Stanford |
| 2624 | 2622 | University, Yamaha, and others. |
| 2625 | 2623 | |
| 2626 | − Control Change Numbers: | |
| 2624 | + Control Change Numbers: | |
| 2627 | 2625 | - Reed Stiffness = 2 |
| 2628 | 2626 | - Noise Gain = 4 |
| 2629 | 2627 | - Vibrato Frequency = 11 |
| @@ -2753,7 +2751,7 @@ class Drummer : public Instrmnt · 123 unmodified lines | ||
| 2753 | 2751 | //! Compute one output sample. |
| 2754 | 2752 | MY_FLOAT tick(); |
| 2755 | 2753 | |
| 2756 | − public: // SWAP formerly protected | |
| 2754 | + public: // SWAP formerly protected | |
| 2757 | 2755 | WvIn *waves[DRUM_POLYPHONY]; |
| 2758 | 2756 | OnePole *filters[DRUM_POLYPHONY]; |
| 2759 | 2757 | int sounding[DRUM_POLYPHONY]; |
| @@ -2797,7 +2795,7 @@ public: · 37 unmodified lines | ||
| 2797 | 2795 | void set(MY_FLOAT max); |
| 2798 | 2796 | MY_FLOAT getDelay(); |
| 2799 | 2797 | |
| 2800 | − //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). | |
| 2798 | + //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). | |
| 2801 | 2799 | void setEffectMix(MY_FLOAT mix); |
| 2802 | 2800 | |
| 2803 | 2801 | //! Return the last output value. |
| @@ -2838,7 +2836,7 @@ public: · 34 unmodified lines | ||
| 2838 | 2836 | \->3 -/ |
| 2839 | 2837 | \endcode |
| 2840 | 2838 | |
| 2841 | − Control Change Numbers: | |
| 2839 | + Control Change Numbers: | |
| 2842 | 2840 | - Vowel = 2 |
| 2843 | 2841 | - Spectral Tilt = 4 |
| 2844 | 2842 | - LFO Speed = 11 |
| @@ -2905,7 +2903,7 @@ class FMVoices : public FM · 60 unmodified lines | ||
| 2905 | 2903 | use possibly subject to patents held by Stanford |
| 2906 | 2904 | University, Yamaha, and others. |
| 2907 | 2905 | |
| 2908 | − Control Change Numbers: | |
| 2906 | + Control Change Numbers: | |
| 2909 | 2907 | - Jet Delay = 2 |
| 2910 | 2908 | - Noise Gain = 4 |
| 2911 | 2909 | - Vibrato Frequency = 11 |
| @@ -2973,14 +2971,14 @@ public: // SWAP formerly protected · 61 unmodified lines | ||
| 2973 | 2971 | t_CKFLOAT m_vibratoGain; |
| 2974 | 2972 | t_CKFLOAT m_pressure; |
| 2975 | 2973 | t_CKFLOAT m_rate; |
| 2976 | − | |
| 2974 | + | |
| 2977 | 2975 | void setVibratoFreq(MY_FLOAT freq) |
| 2978 | 2976 | { vibrato->setFrequency( freq ); m_vibratoFreq = vibrato->m_freq; } |
| 2979 | 2977 | void setVibratoGain(MY_FLOAT gain) |
| 2980 | 2978 | { vibratoGain = gain; m_vibratoGain = vibratoGain; } |
| 2981 | 2979 | void setNoiseGain(MY_FLOAT gain) |
| 2982 | 2980 | { noiseGain = gain; m_noiseGain = gain; } |
| 2983 | − | |
| 2981 | + | |
| 2984 | 2982 | DelayL *jetDelay; |
| 2985 | 2983 | DelayL *boreDelay; |
| 2986 | 2984 | JetTabl *jetTable; |
| @@ -3061,7 +3059,7 @@ class FormSwep : public BiQuad · 74 unmodified lines | ||
| 3061 | 3059 | A sweep rate of 1.0 will produce an immediate change in |
| 3062 | 3060 | resonance parameters from their current values to the |
| 3063 | 3061 | target values. A sweep rate of 0.0 will produce no |
| 3064 | − change in resonance parameters. | |
| 3062 | + change in resonance parameters. | |
| 3065 | 3063 | */ |
| 3066 | 3064 | void setSweepRate(MY_FLOAT aRate); |
| 3067 | 3065 | |
| @@ -3079,7 +3077,7 @@ class FormSwep : public BiQuad · 11 unmodified lines | ||
| 3079 | 3077 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 3080 | 3078 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 3081 | 3079 | |
| 3082 | − public: // SWAP formerly protected | |
| 3080 | + public: // SWAP formerly protected | |
| 3083 | 3081 | bool dirty; |
| 3084 | 3082 | MY_FLOAT frequency; |
| 3085 | 3083 | MY_FLOAT radius; |
| @@ -3115,7 +3113,7 @@ class FormSwep : public BiQuad · 29 unmodified lines | ||
| 3115 | 3113 | 3-->2-- + -->1-->Out |
| 3116 | 3114 | \endcode |
| 3117 | 3115 | |
| 3118 | − Control Change Numbers: | |
| 3116 | + Control Change Numbers: | |
| 3119 | 3117 | - Total Modulator Index = 2 |
| 3120 | 3118 | - Modulator Crossfade = 4 |
| 3121 | 3119 | - LFO Speed = 11 |
| @@ -3163,27 +3161,27 @@ class HevyMetl : public FM · 41 unmodified lines | ||
| 3163 | 3161 | /***************************************************/ |
| 3164 | 3162 | /*! \class HnkyTonk |
| 3165 | 3163 | \brief STK Honkey Tonk Piano FM synthesis instrument. |
| 3166 | − | |
| 3164 | + | |
| 3167 | 3165 | This class implements 4 cascade operators with |
| 3168 | 3166 | feedback modulation on the master modulator, |
| 3169 | 3167 | also referred to as algorithm 1 of the TX81Z. |
| 3170 | − | |
| 3168 | + | |
| 3171 | 3169 | Algorithm 1 is : |
| 3172 | 3170 | 4-->3-->2-->1-->Out |
| 3173 | − | |
| 3171 | + | |
| 3174 | 3172 | Control Change Numbers: |
| 3175 | 3173 | - Total Modulator Index = 2 |
| 3176 | 3174 | - Modulator Crossfade = 4 |
| 3177 | 3175 | - LFO Speed = 11 |
| 3178 | 3176 | - LFO Depth = 1 |
| 3179 | 3177 | - ADSR 2 & 4 Target = 128 |
| 3180 | − | |
| 3178 | + | |
| 3181 | 3179 | The basic Chowning/Stanford FM patent expired |
| 3182 | 3180 | in 1995, but there exist follow-on patents, |
| 3183 | 3181 | mostly assigned to Yamaha. If you are of the |
| 3184 | 3182 | type who should worry about this (making |
| 3185 | 3183 | money) worry away. |
| 3186 | − | |
| 3184 | + | |
| 3187 | 3185 | by Perry R. Cook, 2021. |
| 3188 | 3186 | */ |
| 3189 | 3187 | /***************************************************/ |
| @@ -3196,14 +3194,14 @@ class HnkyTonk : public FM · 6 unmodified lines | ||
| 3196 | 3194 | public: |
| 3197 | 3195 | //! Class constructor. |
| 3198 | 3196 | HnkyTonk(); |
| 3199 | − | |
| 3197 | + | |
| 3200 | 3198 | //! Class destructor. |
| 3201 | 3199 | ~HnkyTonk(); |
| 3202 | − | |
| 3200 | + | |
| 3203 | 3201 | //! Start a note with the given frequency and amplitude. |
| 3204 | 3202 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3205 | 3203 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 3206 | − | |
| 3204 | + | |
| 3207 | 3205 | //! Compute one output sample. |
| 3208 | 3206 | MY_FLOAT tick(); |
| 3209 | 3207 | }; |
| @@ -3215,27 +3213,27 @@ public: · 5 unmodified lines | ||
| 3215 | 3213 | /***************************************************/ |
| 3216 | 3214 | /*! \class FrencHrn |
| 3217 | 3215 | \brief NEW STK-style French Horn FM synthesis instrument. |
| 3218 | − | |
| 3216 | + | |
| 3219 | 3217 | This class implements 3 cascade operators with |
| 3220 | 3218 | feedback modulation, also referred to as |
| 3221 | 3219 | algorithm 3 of the TX81Z. |
| 3222 | − | |
| 3220 | + | |
| 3223 | 3221 | Algorithm 3 is : 4--\ |
| 3224 | 3222 | 3-->2-- + -->1-->Out |
| 3225 | − | |
| 3223 | + | |
| 3226 | 3224 | Control Change Numbers: |
| 3227 | 3225 | - Total Modulator Index = 2 |
| 3228 | 3226 | - Modulator Crossfade = 4 |
| 3229 | 3227 | - LFO Speed = 11 |
| 3230 | 3228 | - LFO Depth = 1 |
| 3231 | 3229 | - ADSR 2 & 4 Target = 128 |
| 3232 | − | |
| 3230 | + | |
| 3233 | 3231 | The basic Chowning/Stanford FM patent expired |
| 3234 | 3232 | in 1995, but there exist follow-on patents, |
| 3235 | 3233 | mostly assigned to Yamaha. If you are of the |
| 3236 | 3234 | type who should worry about this (making |
| 3237 | 3235 | money) worry away. |
| 3238 | − | |
| 3236 | + | |
| 3239 | 3237 | by Perry R. Cook, 2021. |
| 3240 | 3238 | */ |
| 3241 | 3239 | /***************************************************/ |
| @@ -3248,14 +3246,14 @@ class FrencHrn : public FM · 6 unmodified lines | ||
| 3248 | 3246 | public: |
| 3249 | 3247 | //! Class constructor. |
| 3250 | 3248 | FrencHrn(); |
| 3251 | − | |
| 3249 | + | |
| 3252 | 3250 | //! Class destructor. |
| 3253 | 3251 | ~FrencHrn(); |
| 3254 | − | |
| 3252 | + | |
| 3255 | 3253 | //! Start a note with the given frequency and amplitude. |
| 3256 | 3254 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3257 | 3255 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 3258 | − | |
| 3256 | + | |
| 3259 | 3257 | //! Compute one output sample. |
| 3260 | 3258 | MY_FLOAT tick(); |
| 3261 | 3259 | }; |
| @@ -3268,28 +3266,28 @@ public: · 6 unmodified lines | ||
| 3268 | 3266 | /***************************************************/ |
| 3269 | 3267 | /*! \class KrstlChr |
| 3270 | 3268 | \brief New STK-style Crystal Choir FM synthesis instrument. |
| 3271 | − | |
| 3269 | + | |
| 3272 | 3270 | This class implements 3 parallel operators with |
| 3273 | 3271 | one modulated, by one with feedback modulation, |
| 3274 | 3272 | also referred to as algorithm 7 of the TX81Z. |
| 3275 | − | |
| 3273 | + | |
| 3276 | 3274 | Algorithm 3 is : 4-->3-->\ |
| 3277 | 3275 | 2--> + -->Out |
| 3278 | 3276 | 1-->/ |
| 3279 | − | |
| 3277 | + | |
| 3280 | 3278 | Control Change Numbers: |
| 3281 | 3279 | - Total Modulator Index = 2 |
| 3282 | 3280 | - Modulator Crossfade = 4 |
| 3283 | 3281 | - LFO Speed = 11 |
| 3284 | 3282 | - LFO Depth = 1 |
| 3285 | 3283 | - ADSR 2 & 4 Target = 128 |
| 3286 | − | |
| 3284 | + | |
| 3287 | 3285 | The basic Chowning/Stanford FM patent expired |
| 3288 | 3286 | in 1995, but there exist follow-on patents, |
| 3289 | 3287 | mostly assigned to Yamaha. If you are of the |
| 3290 | 3288 | type who should worry about this (making |
| 3291 | 3289 | money) worry away. |
| 3292 | − | |
| 3290 | + | |
| 3293 | 3291 | by Perry R. Cook, 2021. |
| 3294 | 3292 | */ |
| 3295 | 3293 | /***************************************************/ |
| @@ -3302,14 +3300,14 @@ class KrstlChr : public FM · 6 unmodified lines | ||
| 3302 | 3300 | public: |
| 3303 | 3301 | //! Class constructor. |
| 3304 | 3302 | KrstlChr(); |
| 3305 | − | |
| 3303 | + | |
| 3306 | 3304 | //! Class destructor. |
| 3307 | 3305 | ~KrstlChr(); |
| 3308 | − | |
| 3306 | + | |
| 3309 | 3307 | //! Start a note with the given frequency and amplitude. |
| 3310 | 3308 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3311 | 3309 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 3312 | − | |
| 3310 | + | |
| 3313 | 3311 | //! Compute one output sample. |
| 3314 | 3312 | MY_FLOAT tick(); |
| 3315 | 3313 | }; |
| @@ -3348,7 +3346,7 @@ class Reverb : public Stk · 32 unmodified lines | ||
| 3348 | 3346 | //! Reset and clear all internal state. |
| 3349 | 3347 | virtual void clear() = 0; |
| 3350 | 3348 | |
| 3351 | − //! Set the mixture of input and "reverberated" levels in the output (0.0 = input only, 1.0 = reverb only). | |
| 3349 | + //! Set the mixture of input and "reverberated" levels in the output (0.0 = input only, 1.0 = reverb only). | |
| 3352 | 3350 | void setEffectMix(MY_FLOAT mix); |
| 3353 | 3351 | |
| 3354 | 3352 | //! Return the last output value. |
| @@ -3495,7 +3493,7 @@ class PluckTwo : public Instrmnt · 140 unmodified lines | ||
| 3495 | 3493 | //! Virtual (abstract) tick function is implemented by subclasses. |
| 3496 | 3494 | virtual MY_FLOAT tick() = 0; |
| 3497 | 3495 | |
| 3498 | − public: // SWAP formerly protected | |
| 3496 | + public: // SWAP formerly protected | |
| 3499 | 3497 | DelayA *delayLine; |
| 3500 | 3498 | DelayA *delayLine2; |
| 3501 | 3499 | DelayL *combDelay; |
| @@ -3535,7 +3533,7 @@ class PluckTwo : public Instrmnt · 33 unmodified lines | ||
| 3535 | 3533 | information, contact the Office of Technology |
| 3536 | 3534 | Licensing, Stanford University. |
| 3537 | 3535 | |
| 3538 | − Control Change Numbers: | |
| 3536 | + Control Change Numbers: | |
| 3539 | 3537 | - Body Size = 2 |
| 3540 | 3538 | - Pluck Position = 4 |
| 3541 | 3539 | - String Sustain = 11 |
| @@ -3580,7 +3578,7 @@ class Mandolin : public PluckTwo · 38 unmodified lines | ||
| 3580 | 3578 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 3581 | 3579 | virtual void controlChange(int number, MY_FLOAT value); |
| 3582 | 3580 | |
| 3583 | − public: // SWAP formerly protected | |
| 3581 | + public: // SWAP formerly protected | |
| 3584 | 3582 | WvIn *soundfile[12]; |
| 3585 | 3583 | MY_FLOAT directBody; |
| 3586 | 3584 | int mic; |
| @@ -3611,7 +3609,7 @@ class Mandolin : public PluckTwo · 24 unmodified lines | ||
| 3611 | 3609 | use possibly subject to patents held by Stanford |
| 3612 | 3610 | University, Yamaha, and others. |
| 3613 | 3611 | |
| 3614 | − Control Change Numbers: | |
| 3612 | + Control Change Numbers: | |
| 3615 | 3613 | - X Dimension = 2 |
| 3616 | 3614 | - Y Dimension = 4 |
| 3617 | 3615 | - Mesh Decay = 11 |
| @@ -3639,7 +3637,7 @@ class Mesh2D : public Instrmnt · 21 unmodified lines | ||
| 3639 | 3637 | ~Mesh2D(); |
| 3640 | 3638 | |
| 3641 | 3639 | //! Reset and clear all internal state. |
| 3642 | − void clear(); | |
| 3640 | + void clear(); | |
| 3643 | 3641 | |
| 3644 | 3642 | //! Set the x dimension size in samples. |
| 3645 | 3643 | void setNX(short lenX); |
| @@ -3769,7 +3767,7 @@ public: // SWAP formerly protected · 123 unmodified lines | ||
| 3769 | 3767 | t_CKFLOAT m_vibratoFreq; |
| 3770 | 3768 | t_CKFLOAT m_volume; |
| 3771 | 3769 | |
| 3772 | − Envelope *envelope; | |
| 3770 | + Envelope *envelope; | |
| 3773 | 3771 | WvIn *wave; |
| 3774 | 3772 | BiQuad **filters; |
| 3775 | 3773 | OnePole *onepole; |
| @@ -3799,7 +3797,7 @@ public: // SWAP formerly protected · 23 unmodified lines | ||
| 3799 | 3797 | struck bar instruments. It inherits from the |
| 3800 | 3798 | Modal class. |
| 3801 | 3799 | |
| 3802 | − Control Change Numbers: | |
| 3800 | + Control Change Numbers: | |
| 3803 | 3801 | - Stick Hardness = 2 |
| 3804 | 3802 | - Stick Position = 4 |
| 3805 | 3803 | - Vibrato Gain = 11 |
| @@ -3889,7 +3887,7 @@ class SubNoise : public Noise · 83 unmodified lines | ||
| 3889 | 3887 | //! Return a sub-sampled random number between -1.0 and 1.0. |
| 3890 | 3888 | MY_FLOAT tick(); |
| 3891 | 3889 | |
| 3892 | − public: // SWAP formerly protected | |
| 3890 | + public: // SWAP formerly protected | |
| 3893 | 3891 | int counter; |
| 3894 | 3892 | int rate; |
| 3895 | 3893 | |
| @@ -4006,8 +4004,8 @@ class Sampler : public Instrmnt · 110 unmodified lines | ||
| 4006 | 4004 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 4007 | 4005 | virtual void controlChange(int number, MY_FLOAT value) = 0; |
| 4008 | 4006 | |
| 4009 | − public: // SWAP formerly protected | |
| 4010 | − ADSR *adsr; | |
| 4007 | + public: // SWAP formerly protected | |
| 4008 | + ADSR *adsr; | |
| 4011 | 4009 | WvIn *attacks[5]; |
| 4012 | 4010 | WaveLoop *loops[5]; |
| 4013 | 4011 | OnePole *filter; |
| @@ -4034,7 +4032,7 @@ class Sampler : public Instrmnt · 20 unmodified lines | ||
| 4034 | 4032 | from the Sampler class) and adds two sweepable |
| 4035 | 4033 | formant (FormSwep) filters. |
| 4036 | 4034 | |
| 4037 | − Control Change Numbers: | |
| 4035 | + Control Change Numbers: | |
| 4038 | 4036 | - Filter Q = 2 |
| 4039 | 4037 | - Filter Sweep Rate = 4 |
| 4040 | 4038 | - Vibrato Frequency = 11 |
| @@ -4132,7 +4130,7 @@ class NRev : public Reverb · 91 unmodified lines | ||
| 4132 | 4130 | //! Compute one output sample. |
| 4133 | 4131 | MY_FLOAT tick(MY_FLOAT input); |
| 4134 | 4132 | |
| 4135 | − public: // SWAP formerly protected | |
| 4133 | + public: // SWAP formerly protected | |
| 4136 | 4134 | Delay *allpassDelays[8]; |
| 4137 | 4135 | Delay *combDelays[6]; |
| 4138 | 4136 | MY_FLOAT allpassCoefficient; |
| @@ -4182,7 +4180,7 @@ public: · 43 unmodified lines | ||
| 4182 | 4180 | //! Compute one output sample. |
| 4183 | 4181 | MY_FLOAT tick(MY_FLOAT input); |
| 4184 | 4182 | |
| 4185 | −public: // SWAP formerly protected | |
| 4183 | +public: // SWAP formerly protected | |
| 4186 | 4184 | Delay *allpassDelays[2]; |
| 4187 | 4185 | Delay *combDelays[2]; |
| 4188 | 4186 | MY_FLOAT allpassCoefficient; |
| @@ -4207,7 +4205,7 @@ public: // SWAP formerly protected · 18 unmodified lines | ||
| 4207 | 4205 | 2-- + -->1-->Out |
| 4208 | 4206 | \endcode |
| 4209 | 4207 | |
| 4210 | − Control Change Numbers: | |
| 4208 | + Control Change Numbers: | |
| 4211 | 4209 | - Total Modulator Index = 2 |
| 4212 | 4210 | - Modulator Crossfade = 4 |
| 4213 | 4211 | - LFO Speed = 11 |
| @@ -4337,7 +4335,7 @@ class PitShift : public Stk · 123 unmodified lines | ||
| 4337 | 4335 | //! Set the pitch shift factor (1.0 produces no shift). |
| 4338 | 4336 | void setShift(MY_FLOAT shift); |
| 4339 | 4337 | |
| 4340 | − //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). | |
| 4338 | + //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). | |
| 4341 | 4339 | void setEffectMix(MY_FLOAT mix); |
| 4342 | 4340 | |
| 4343 | 4341 | //! Return the last output value. |
| @@ -4349,7 +4347,7 @@ class PitShift : public Stk · 5 unmodified lines | ||
| 4349 | 4347 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 4350 | 4348 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 4351 | 4349 | |
| 4352 | − public: // SWAP formerly protected | |
| 4350 | + public: // SWAP formerly protected | |
| 4353 | 4351 | //chuck |
| 4354 | 4352 | t_CKFLOAT m_vibratoGain; |
| 4355 | 4353 | t_CKFLOAT m_vibratoFreq; |
| @@ -4420,7 +4418,7 @@ class Plucked : public Instrmnt · 64 unmodified lines | ||
| 4420 | 4418 | //! Compute one output sample. |
| 4421 | 4419 | virtual MY_FLOAT tick(); |
| 4422 | 4420 | |
| 4423 | − public: // SWAP formerly protected | |
| 4421 | + public: // SWAP formerly protected | |
| 4424 | 4422 | DelayA *delayLine; |
| 4425 | 4423 | OneZero *loopFilter; |
| 4426 | 4424 | OnePole *pickFilter; |
| @@ -4498,7 +4496,7 @@ class Resonate : public Instrmnt · 71 unmodified lines | ||
| 4498 | 4496 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 4499 | 4497 | virtual void controlChange(int number, MY_FLOAT value); |
| 4500 | 4498 | |
| 4501 | − public: // SWAP formerly protected | |
| 4499 | + public: // SWAP formerly protected | |
| 4502 | 4500 | ADSR *adsr; |
| 4503 | 4501 | BiQuad *filter; |
| 4504 | 4502 | Noise *noise; |
| @@ -4529,7 +4527,7 @@ class Resonate : public Instrmnt · 24 unmodified lines | ||
| 4529 | 4527 | 2->1--/ |
| 4530 | 4528 | \endcode |
| 4531 | 4529 | |
| 4532 | − Control Change Numbers: | |
| 4530 | + Control Change Numbers: | |
| 4533 | 4531 | - Modulator Index One = 2 |
| 4534 | 4532 | - Crossfade of Outputs = 4 |
| 4535 | 4533 | - LFO Speed = 11 |
| @@ -4564,7 +4562,7 @@ class Rhodey : public FM · 28 unmodified lines | ||
| 4564 | 4562 | |
| 4565 | 4563 | //! Start a note with the given frequency and amplitude. |
| 4566 | 4564 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 4567 | − void noteOn(MY_FLOAT amplitude) { noteOn(baseFrequency * 0.5, amplitude ); } | |
| 4565 | + void noteOn(MY_FLOAT amplitude) { noteOn(baseFrequency * 0.5, amplitude ); } | |
| 4568 | 4566 | |
| 4569 | 4567 | //! Compute one output sample. |
| 4570 | 4568 | MY_FLOAT tick(); |
| @@ -4729,7 +4727,7 @@ static const double Midi2Pitch[129] = { · 158 unmodified lines | ||
| 4729 | 4727 | use possibly subject to patents held by Stanford |
| 4730 | 4728 | University, Yamaha, and others. |
| 4731 | 4729 | |
| 4732 | − Control Change Numbers: | |
| 4730 | + Control Change Numbers: | |
| 4733 | 4731 | - Reed Stiffness = 2 |
| 4734 | 4732 | - Reed Aperture = 26 |
| 4735 | 4733 | - Noise Gain = 4 |
| @@ -4829,7 +4827,7 @@ class Saxofony : public Instrmnt · 93 unmodified lines | ||
| 4829 | 4827 | breaking sticks, crunchy snow (or not), a |
| 4830 | 4828 | wrench, sandpaper, and more. |
| 4831 | 4829 | |
| 4832 | − Control Change Numbers: | |
| 4830 | + Control Change Numbers: | |
| 4833 | 4831 | - Shake Energy = 2 |
| 4834 | 4832 | - System Decay = 4 |
| 4835 | 4833 | - Number Of Objects = 11 |
| @@ -4885,7 +4883,7 @@ class Shakers : public Instrmnt · 49 unmodified lines | ||
| 4885 | 4883 | Use the instrument numbers above, converted to frequency values |
| 4886 | 4884 | as if MIDI note numbers, to select a particular instrument. |
| 4887 | 4885 | */ |
| 4888 | − virtual void ck_noteOn(MY_FLOAT amplitude ); // chuck single arg call | |
| 4886 | + virtual void ck_noteOn(MY_FLOAT amplitude ); // chuck single arg call | |
| 4889 | 4887 | virtual void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude); |
| 4890 | 4888 | |
| 4891 | 4889 | //! Stop a note with the given amplitude (speed of decay). |
| @@ -4957,7 +4955,7 @@ class Shakers : public Instrmnt · 65 unmodified lines | ||
| 4957 | 4955 | a one-pole filter, and an ADSR envelope |
| 4958 | 4956 | to create some interesting sounds. |
| 4959 | 4957 | |
| 4960 | − Control Change Numbers: | |
| 4958 | + Control Change Numbers: | |
| 4961 | 4959 | - Filter Pole Position = 2 |
| 4962 | 4960 | - Noise/Pitched Cross-Fade = 4 |
| 4963 | 4961 | - Envelope Rate = 11 |
| @@ -5004,8 +5002,8 @@ class Simple : public Instrmnt · 40 unmodified lines | ||
| 5004 | 5002 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 5005 | 5003 | virtual void controlChange(int number, MY_FLOAT value); |
| 5006 | 5004 | |
| 5007 | − public: // SWAP formerly protected | |
| 5008 | − ADSR *adsr; | |
| 5005 | + public: // SWAP formerly protected | |
| 5006 | + ADSR *adsr; | |
| 5009 | 5007 | WaveLoop *loop; |
| 5010 | 5008 | OnePole *filter; |
| 5011 | 5009 | BiQuad *biquad; |
| @@ -5162,7 +5160,7 @@ class Sitar : public Instrmnt · 150 unmodified lines | ||
| 5162 | 5160 | //! Compute one output sample. |
| 5163 | 5161 | MY_FLOAT tick(); |
| 5164 | 5162 | |
| 5165 | − public: // SWAP formerly protected | |
| 5163 | + public: // SWAP formerly protected | |
| 5166 | 5164 | DelayA *delayLine; |
| 5167 | 5165 | OneZero *loopFilter; |
| 5168 | 5166 | Noise *noise; |
| @@ -5195,7 +5193,7 @@ class Sitar : public Instrmnt · 26 unmodified lines | ||
| 5195 | 5193 | The user is responsible for checking the values |
| 5196 | 5194 | returned by the read/write methods. Values |
| 5197 | 5195 | less than or equal to zero indicate a closed |
| 5198 | − or lost connection or the occurence of an error. | |
| 5196 | + or lost connection or the occurrence of an error. | |
| 5199 | 5197 | |
| 5200 | 5198 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5201 | 5199 | */ |
| @@ -5275,7 +5273,7 @@ class Socket : public Stk · 73 unmodified lines | ||
| 5275 | 5273 | |
| 5276 | 5274 | public: // SWAP formerly protected |
| 5277 | 5275 | |
| 5278 | − char msg[256]; | |
| 5276 | + char msg[STK_MSG_BUF_LENGTH]; | |
| 5279 | 5277 | int soket; |
| 5280 | 5278 | int poort; |
| 5281 | 5279 | bool server; |
| @@ -5403,7 +5401,7 @@ public: · 121 unmodified lines | ||
| 5403 | 5401 | |
| 5404 | 5402 | //! Move the sphere for the given time increment. |
| 5405 | 5403 | void tick(double timeIncrement); |
| 5406 | − | |
| 5404 | + | |
| 5407 | 5405 | public: // SWAP formerly private |
| 5408 | 5406 | Vector3D *myPosition; |
| 5409 | 5407 | Vector3D *myVelocity; |
| @@ -5558,7 +5556,7 @@ public: · 148 unmodified lines | ||
| 5558 | 5556 | //! Take \e vectorSize index positions and return the corresponding table values in \e vector. |
| 5559 | 5557 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 5560 | 5558 | |
| 5561 | −public: // SWAP formerly protected | |
| 5559 | +public: // SWAP formerly protected | |
| 5562 | 5560 | long length; |
| 5563 | 5561 | MY_FLOAT *data; |
| 5564 | 5562 | MY_FLOAT lastOutput; |
| @@ -5635,7 +5633,7 @@ class WvOut : public Stk · 70 unmodified lines | ||
| 5635 | 5633 | int fflush(FILE *stream); |
| 5636 | 5634 | int fclose(FILE *stream); |
| 5637 | 5635 | size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream); |
| 5638 | − | |
| 5636 | + | |
| 5639 | 5637 | //! Default constructor. |
| 5640 | 5638 | WvOut(); |
| 5641 | 5639 | |
| @@ -5716,7 +5714,7 @@ class WvOut : public Stk · 74 unmodified lines | ||
| 5716 | 5714 | // Close MAT-file, updating the header. |
| 5717 | 5715 | void closeMatFile( void ); |
| 5718 | 5716 | |
| 5719 | − char msg[256]; | |
| 5717 | + char msg[STK_MSG_BUF_LENGTH]; | |
| 5720 | 5718 | FILE *fd; |
| 5721 | 5719 | MY_FLOAT *data; |
| 5722 | 5720 | FILE_TYPE fileType; |
| @@ -5732,7 +5730,7 @@ class WvOut : public Stk · 9 unmodified lines | ||
| 5732 | 5730 | Chuck_String autoPrefix; |
| 5733 | 5731 | t_CKUINT flush; |
| 5734 | 5732 | t_CKFLOAT fileGain; |
| 5735 | − | |
| 5733 | + | |
| 5736 | 5734 | // spencer: for data asynch write |
| 5737 | 5735 | t_CKBOOL asyncIO; |
| 5738 | 5736 | XWriteThread * asyncWriteThread; |
| @@ -5759,7 +5757,7 @@ class WvOut : public Stk · 20 unmodified lines | ||
| 5759 | 5757 | 2->1--/ |
| 5760 | 5758 | \endcode |
| 5761 | 5759 | |
| 5762 | − Control Change Numbers: | |
| 5760 | + Control Change Numbers: | |
| 5763 | 5761 | - Modulator Index One = 2 |
| 5764 | 5762 | - Crossfade of Outputs = 4 |
| 5765 | 5763 | - LFO Speed = 11 |
| @@ -5862,9 +5860,9 @@ class TwoPole : public FilterStk // formerly protected Filter · 96 unmodified lines | ||
| 5862 | 5860 | MY_FLOAT m_resFreq; |
| 5863 | 5861 | MY_FLOAT m_resRad; |
| 5864 | 5862 | |
| 5865 | − void ck_setResNorm( bool n ) { m_resNorm = n; setResonance(m_resFreq, m_resRad, m_resNorm); } | |
| 5866 | − void ck_setResFreq( MY_FLOAT n ) { m_resFreq = n; setResonance(m_resFreq, m_resRad, m_resNorm); } | |
| 5867 | − void ck_setResRad( MY_FLOAT n ) { m_resRad = n; setResonance(m_resFreq, m_resRad, m_resNorm); } | |
| 5863 | + void ck_setResNorm( bool n ) { m_resNorm = n; setResonance(m_resFreq, m_resRad, m_resNorm); } | |
| 5864 | + void ck_setResFreq( MY_FLOAT n ) { m_resFreq = n; setResonance(m_resFreq, m_resRad, m_resNorm); } | |
| 5865 | + void ck_setResRad( MY_FLOAT n ) { m_resRad = n; setResonance(m_resFreq, m_resRad, m_resNorm); } | |
| 5868 | 5866 | //! Set the filter gain. |
| 5869 | 5867 | /*! |
| 5870 | 5868 | The gain is applied at the filter input and does not affect the |
| @@ -5906,7 +5904,7 @@ class TwoPole : public FilterStk // formerly protected Filter · 35 unmodified lines | ||
| 5906 | 5904 | cascade synthesis is the most natural so |
| 5907 | 5905 | that's what you'll find here. |
| 5908 | 5906 | |
| 5909 | − Control Change Numbers: | |
| 5907 | + Control Change Numbers: | |
| 5910 | 5908 | - Voiced/Unvoiced Mix = 2 |
| 5911 | 5909 | - Vowel/Phoneme Selection = 4 |
| 5912 | 5910 | - Vibrato Frequency = 11 |
| @@ -6143,7 +6141,7 @@ public: // SWAP formerly protected · 230 unmodified lines | ||
| 6143 | 6141 | This class implements a hybrid physical/spectral |
| 6144 | 6142 | model of a police whistle (a la Cook). |
| 6145 | 6143 | |
| 6146 | − Control Change Numbers: | |
| 6144 | + Control Change Numbers: | |
| 6147 | 6145 | - Noise Gain = 4 |
| 6148 | 6146 | - Fipple Modulation Frequency = 11 |
| 6149 | 6147 | - Fipple Modulation Gain = 1 |
| @@ -6191,7 +6189,7 @@ public: · 41 unmodified lines | ||
| 6191 | 6189 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 6192 | 6190 | void controlChange(int number, MY_FLOAT value); |
| 6193 | 6191 | |
| 6194 | −public: // SWAP formerly protected | |
| 6192 | +public: // SWAP formerly protected | |
| 6195 | 6193 | Vector3D *tempVectorP; |
| 6196 | 6194 | Vector3D *tempVector; |
| 6197 | 6195 | OnePole onepole; |
| @@ -6233,7 +6231,7 @@ public: // SWAP formerly protected · 35 unmodified lines | ||
| 6233 | 6231 | 2->1--/ |
| 6234 | 6232 | \endcode |
| 6235 | 6233 | |
| 6236 | − Control Change Numbers: | |
| 6234 | + Control Change Numbers: | |
| 6237 | 6235 | - Modulator Index One = 2 |
| 6238 | 6236 | - Crossfade of Outputs = 4 |
| 6239 | 6237 | - LFO Speed = 11 |
| @@ -6269,7 +6267,7 @@ class Wurley : public FM · 29 unmodified lines | ||
| 6269 | 6267 | //! Start a note with the given frequency and amplitude. |
| 6270 | 6268 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 6271 | 6269 | void noteOn(MY_FLOAT amplitude) { noteOn ( baseFrequency, amplitude ); } |
| 6272 | − | |
| 6270 | + | |
| 6273 | 6271 | // CHUCK HACK: |
| 6274 | 6272 | virtual void controlChange( int which, MY_FLOAT value ); |
| 6275 | 6273 | |
| @@ -6432,7 +6430,7 @@ class BlitSaw : public BLT · 156 unmodified lines | ||
| 6432 | 6430 | Set the phase of the signal, in the range 0 to 1. |
| 6433 | 6431 | */ |
| 6434 | 6432 | virtual void setPhase( MY_FLOAT phase ) { phase_ = ONE_PI * phase; } |
| 6435 | − | |
| 6433 | + | |
| 6436 | 6434 | //! Set the sawtooth oscillator rate in terms of a frequency in Hz. |
| 6437 | 6435 | virtual void setFrequency( MY_FLOAT frequency ); |
| 6438 | 6436 | |
| @@ -6580,11 +6578,11 @@ class BlitSquare : public BLT · 141 unmodified lines | ||
| 6580 | 6578 | #include <sstream> |
| 6581 | 6579 | |
| 6582 | 6580 | namespace stk { |
| 6583 | − | |
| 6581 | + | |
| 6584 | 6582 | /**********************************************************************/ |
| 6585 | 6583 | /*! \class MidiFileIn |
| 6586 | 6584 | \brief A standard MIDI file reading/parsing class. |
| 6587 | − | |
| 6585 | + | |
| 6588 | 6586 | This class can be used to read events from a standard MIDI file. |
| 6589 | 6587 | Event bytes are copied to a C++ vector and must be subsequently |
| 6590 | 6588 | interpreted by the user. The function getNextMidiEvent() skips |
| @@ -6593,7 +6591,7 @@ namespace stk { · 2 unmodified lines | ||
| 6593 | 6591 | function is provided to determine the current "seconds per tick". |
| 6594 | 6592 | Tempo changes are internally tracked by the class and reflected in |
| 6595 | 6593 | the values returned by the function getTickSeconds(). |
| 6596 | − | |
| 6594 | + | |
| 6597 | 6595 | by Gary P. Scavone, 2003 - 2010. |
| 6598 | 6596 | */ |
| 6599 | 6597 | /**********************************************************************/ |
| @@ -6607,16 +6605,16 @@ public: · 7 unmodified lines | ||
| 6607 | 6605 | StkError exception will be thrown. |
| 6608 | 6606 | */ |
| 6609 | 6607 | MidiFileIn( std::string fileName ); |
| 6610 | − | |
| 6608 | + | |
| 6611 | 6609 | //! Class destructor. |
| 6612 | 6610 | ~MidiFileIn(); |
| 6613 | − | |
| 6611 | + | |
| 6614 | 6612 | //! Return the MIDI file format (0, 1, or 2). |
| 6615 | 6613 | int getFileFormat() const; |
| 6616 | − | |
| 6614 | + | |
| 6617 | 6615 | //! Return the number of tracks in the MIDI file. |
| 6618 | 6616 | unsigned int getNumberOfTracks() const; |
| 6619 | − | |
| 6617 | + | |
| 6620 | 6618 | //! Return the MIDI file division value from the file header. |
| 6621 | 6619 | /*! |
| 6622 | 6620 | Note that this value must be "parsed" in accordance with the |
| @@ -6624,14 +6622,14 @@ public: · 1 unmodified line | ||
| 6624 | 6622 | file uses time-code representations for delta-time values. |
| 6625 | 6623 | */ |
| 6626 | 6624 | int getDivision() const; |
| 6627 | − | |
| 6625 | + | |
| 6628 | 6626 | //! Move the specified track event reader to the beginning of its track. |
| 6629 | 6627 | /*! |
| 6630 | 6628 | The relevant track tempo value is reset as well. If an invalid |
| 6631 | 6629 | track number is specified, an StkError exception will be thrown. |
| 6632 | 6630 | */ |
| 6633 | 6631 | void rewindTrack( unsigned int track = 0 ); |
| 6634 | − | |
| 6632 | + | |
| 6635 | 6633 | //! Get the current value, in seconds, of delta-time ticks for the specified track. |
| 6636 | 6634 | /*! |
| 6637 | 6635 | This value can change as events are read (via "Set Tempo" |
| @@ -6641,7 +6639,7 @@ public: · 3 unmodified lines | ||
| 6641 | 6639 | thrown. |
| 6642 | 6640 | */ |
| 6643 | 6641 | double getTickSeconds( unsigned int track = 0 ); |
| 6644 | − | |
| 6642 | + | |
| 6645 | 6643 | //! Fill the user-provided vector with the next event in the specified track and return the event delta-time in ticks. |
| 6646 | 6644 | /*! |
| 6647 | 6645 | MIDI File events consist of a delta time and a sequence of event |
| @@ -6656,7 +6654,7 @@ public: · 8 unmodified lines | ||
| 6656 | 6654 | file, an StkError exception will be thrown. |
| 6657 | 6655 | */ |
| 6658 | 6656 | unsigned long getNextEvent( std::vector<unsigned char> *event, unsigned int track = 0 ); |
| 6659 | − | |
| 6657 | + | |
| 6660 | 6658 | //! Fill the user-provided vector with the next MIDI channel event in the specified track and return the event delta time in ticks. |
| 6661 | 6659 | /*! |
| 6662 | 6660 | All returned MIDI events are complete ... a status byte is |
| @@ -6669,23 +6667,23 @@ public: · 6 unmodified lines | ||
| 6669 | 6667 | StkError exception will be thrown. |
| 6670 | 6668 | */ |
| 6671 | 6669 | unsigned long getNextMidiEvent( std::vector<unsigned char> *midiEvent, unsigned int track = 0 ); |
| 6672 | − | |
| 6670 | + | |
| 6673 | 6671 | //! ge: get the current BPM (I think) |
| 6674 | 6672 | /*! |
| 6675 | 6673 | This value can change as events are read... hmm pretty much |
| 6676 | 6674 | what it says above for getTickSeconds() |
| 6677 | 6675 | */ |
| 6678 | 6676 | double getBPM(); |
| 6679 | − | |
| 6677 | + | |
| 6680 | 6678 | protected: |
| 6681 | − | |
| 6679 | + | |
| 6682 | 6680 | // This protected class function is used for reading variable-length |
| 6683 | 6681 | // MIDI file values. It is assumed that this function is called with |
| 6684 | 6682 | // the file read pointer positioned at the start of a |
| 6685 | 6683 | // variable-length value. The function returns true if the value is |
| 6686 | 6684 | // successfully parsed. Otherwise, it returns false. |
| 6687 | 6685 | bool readVariableLength( unsigned long *value ); |
| 6688 | − | |
| 6686 | + | |
| 6689 | 6687 | std::ifstream file_; |
| 6690 | 6688 | unsigned int nTracks_; |
| 6691 | 6689 | int format_; |
| @@ -6698,11 +6696,11 @@ protected: · 6 unmodified lines | ||
| 6698 | 6696 | std::vector<char> trackStatus_; |
| 6699 | 6697 | // ge: |
| 6700 | 6698 | double bpm_; |
| 6701 | − | |
| 6699 | + | |
| 6702 | 6700 | // This structure and the following variables are used to save and |
| 6703 | 6701 | // keep track of a format 1 tempo map (and the initial tickSeconds |
| 6704 | 6702 | // parameter for formats 0 and 2). |
| 6705 | − struct TempoChange { | |
| 6703 | + struct TempoChange { | |
| 6706 | 6704 | unsigned long count; |
| 6707 | 6705 | double tickSeconds; |
| 6708 | 6706 | }; |
| @@ -6710,7 +6708,7 @@ protected: · 1 unmodified line | ||
| 6710 | 6708 | std::vector<unsigned long> trackCounters_; |
| 6711 | 6709 | std::vector<unsigned int> trackTempoIndex_; |
| 6712 | 6710 | }; |
| 6713 | − | |
| 6711 | + | |
| 6714 | 6712 | } // stk namespace |
| 6715 | 6713 | |
| 6716 | 6714 | #endif |
| @@ -6767,7 +6765,7 @@ protected: · 50 unmodified lines | ||
| 6767 | 6765 | #define __SK_Pan_ 10 |
| 6768 | 6766 | #define __SK_Sustain_ 64 |
| 6769 | 6767 | #define __SK_Damper_ __SK_Sustain_ |
| 6770 | −#define __SK_Expression_ 11 | |
| 6768 | +#define __SK_Expression_ 11 | |
| 6771 | 6769 | |
| 6772 | 6770 | #define __SK_AfterTouch_Cont_ 128 |
| 6773 | 6771 | #define __SK_ModFrequency_ __SK_Expression_ |
| @@ -6812,7 +6810,7 @@ protected: · 38 unmodified lines | ||
| 6812 | 6810 | #define __SK_FilterFreq_ 1062 |
| 6813 | 6811 | #define __SK_FilterSweepRate_ __SK_FootControl_ |
| 6814 | 6812 | |
| 6815 | −#define __SK_ShakerInst_ 1071 | |
| 6813 | +#define __SK_ShakerInst_ 1071 | |
| 6816 | 6814 | #define __SK_ShakerEnergy_ __SK_Breath_ |
| 6817 | 6815 | #define __SK_ShakerDamping_ __SK_ModFrequency_ |
| 6818 | 6816 | #define __SK_ShakerNumObjects_ __SK_FootControl_ |
| @@ -0,0 +1,377 @@ | ||
| 1 | +/*---------------------------------------------------------------------------- | |
| 2 | + ChucK Concurrent, On-the-fly Audio Programming Language | |
| 3 | + Compiler and Virtual Machine | |
| 4 | + | |
| 5 | + Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. | |
| 6 | + http://chuck.stanford.edu/ | |
| 7 | + http://chuck.cs.princeton.edu/ | |
| 8 | + | |
| 9 | + This program is free software; you can redistribute it and/or modify | |
| 10 | + it under the terms of the GNU General Public License as published by | |
| 11 | + the Free Software Foundation; either version 2 of the License, or | |
| 12 | + (at your option) any later version. | |
| 13 | + | |
| 14 | + This program is distributed in the hope that it will be useful, | |
| 15 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | + GNU General Public License for more details. | |
| 18 | + | |
| 19 | + You should have received a copy of the GNU General Public License | |
| 20 | + along with this program; if not, write to the Free Software | |
| 21 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
| 22 | + U.S.A. | |
| 23 | +-----------------------------------------------------------------------------*/ | |
| 24 | + | |
| 25 | +//----------------------------------------------------------------------------- | |
| 26 | +// file: ulib_ai.h | |
| 27 | +// desc: Music and AI class library; part of ChAI (ChucK for AI) | |
| 28 | +// | |
| 29 | +// date: Fall 2022 -- present | |
| 30 | +// authors: Ge Wang (ge@ccrma.stanford.edu) | |
| 31 | +// Yikai Li (yikaili@stanford.edu) | |
| 32 | +// | |
| 33 | +// (HISTORICAL NOTE) | |
| 34 | +// Much of ChAI and its ways of thinking and doing can be foundationally | |
| 35 | +// attributed to the work of Dr. Rebecca Fiebrink, her landmark Ph.D. Thesis, | |
| 36 | +// /Real-time Human Interaction With Supervised Learning Algorithms for Music | |
| 37 | +// Composition and Performance/ (2011) [1], the Wekinator framework [2], her | |
| 38 | +// teaching at the intersections of AI, HCI, and Music [3], as well as earlier | |
| 39 | +// collaborations between Rebecca and Ge [4,5] including SMIRK [6] (Small Musical | |
| 40 | +// Information Retrieval toolKit; 2008; MARSYAS and the MIR work of Dr. George | |
| 41 | +// Tzanetakis; early efforts in on-the-fly learning), the unit analyzer | |
| 42 | +// framework [7] (2007; afford real-time audio feature extraction). All of | |
| 43 | +// these have directly or indirectly contributed the creation of ChAI. | |
| 44 | +// Additionally, ChAI benefitted from the teaching and design philosophy of | |
| 45 | +// Dr. Perry R. Cook (Ph.D. advisor to Rebecca, George, and Ge at Princeton, | |
| 46 | +// and ChucK co-author), who argued for real-time human interaction, parametric | |
| 47 | +// sound synthesis, and the importance of play in the design of musical tools. | |
| 48 | +// | |
| 49 | +// [1] Fiebrink, Rebecca. 2011. /Real-time Human Interaction With Supervised | |
| 50 | +// Learning Algorithms for Music Composition and Performance/ Ph.D. Thesis. | |
| 51 | +// Princeton University. https://www.cs.princeton.edu/techreports/2010/891.pdf | |
| 52 | +// | |
| 53 | +// [2] http://www.wekinator.org/ | |
| 54 | +// Wekinator | Software for real-time, interactive machine learning | |
| 55 | +// | |
| 56 | +// [3] Fiebrink, Rebecca. "Machine Learning for Musicians and Artists" MOOC | |
| 57 | +// https://www.kadenze.com/courses/machine-learning-for-musicians-and-artists/info | |
| 58 | +// | |
| 59 | +// [4] Fiebrink, R., G. Wang, P. R. Cook. 2008. "Foundations for On-the-fly | |
| 60 | +// Learning in the ChucK Programming Language." /International Computer Music | |
| 61 | +// Conference/. https://mcd.stanford.edu/publish/files/2008-icmc-learning.pdf | |
| 62 | +// | |
| 63 | +// [5] Fiebrink, R., G. Wang, P. R. Cook. 2008. "Support for Music Information | |
| 64 | +// Retrieval in the ChucK Programming Language." /International Conference | |
| 65 | +// on Music Information Retrieval/ (ISMIR). | |
| 66 | +// https://mcd.stanford.edu/publish/files/2008-ismir-proto.pdf | |
| 67 | +// | |
| 68 | +// [6] http://smirk.cs.princeton.edu/ | |
| 69 | +// sMIRk | Small Music Information Retrieval toolKit | |
| 70 | +// | |
| 71 | +// [7] Tzanetakis, G. and P. R. Cook. 2000 "MARSYAS: A Framework for Audio | |
| 72 | +// Analysis." Organised Sound. 4:(3) | |
| 73 | +// | |
| 74 | +// [8] Tzanetakis, G. and P. R. Cook. 2002 "Musical Genre Classification of | |
| 75 | +// Audio Signals." IEEE Transaction on Speech and Audio Processing. 10(5). | |
| 76 | +// | |
| 77 | +// [9] Wang, G., R. Fiebrink, P. R. Cook. 2007. "Combining Analysis and | |
| 78 | +// Synthesis in the ChucK Programming Language." /International Computer | |
| 79 | +// Music Conference/. https://mcd.stanford.edu/publish/files/2007-icmc-uana.pdf | |
| 80 | +//----------------------------------------------------------------------------- | |
| 81 | +#ifndef __ULIB_AI_H__ | |
| 82 | +#define __ULIB_AI_H__ | |
| 83 | + | |
| 84 | +#include "chuck_dl.h" | |
| 85 | +#include "chuck_errmsg.h" | |
| 86 | +#include "util_math.h" | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | +// query | |
| 92 | +DLL_QUERY libai_query( Chuck_DL_Query * QUERY ); | |
| 93 | + | |
| 94 | +//----------------------------------------------------------------------------- | |
| 95 | +// name: class ChaiMatrixFast | 1.4.2.0 (ge) added | |
| 96 | +// desc: a templated fast access but not bound-checked 2D matrix | |
| 97 | +// allows arbitrary 2D arrays of arbitrary and non-constant dimensions | |
| 98 | +// to be allocated locally, e.g., int matrix[xDim][yDim] -- which is not | |
| 99 | +// valid syntax with some compilers. | |
| 100 | +//----------------------------------------------------------------------------- | |
| 101 | +template<class T> | |
| 102 | +class ChaiMatrixFast | |
| 103 | +{ | |
| 104 | +public: | |
| 105 | + ChaiMatrixFast() | |
| 106 | + { | |
| 107 | + // zero out | |
| 108 | + m_matrix = NULL; | |
| 109 | + // zero out | |
| 110 | + m_xDim = m_yDim = 0; | |
| 111 | + } | |
| 112 | + | |
| 113 | + ChaiMatrixFast( t_CKINT xDim, t_CKINT yDim ) | |
| 114 | + { | |
| 115 | + // zero out | |
| 116 | + m_matrix = NULL; | |
| 117 | + // allocate | |
| 118 | + allocate( xDim, yDim ); | |
| 119 | + } | |
| 120 | + | |
| 121 | + ~ChaiMatrixFast() | |
| 122 | + { | |
| 123 | + // deallocate | |
| 124 | + cleanup(); | |
| 125 | + } | |
| 126 | + | |
| 127 | + t_CKBOOL allocate( t_CKINT xDim, t_CKINT yDim ) | |
| 128 | + { | |
| 129 | + // delete if necessary | |
| 130 | + if( m_matrix != NULL ) cleanup(); | |
| 131 | + | |
| 132 | + // allocate | |
| 133 | + m_matrix = new T[xDim * yDim]; | |
| 134 | + // check | |
| 135 | + if( !m_matrix ) | |
| 136 | + { | |
| 137 | + // error | |
| 138 | + CK_FPRINTF_STDERR( "[chuck]: ChaiMatrixFast allocation failure: %s, %d x %d...\n", | |
| 139 | + typeid( T ).name(), xDim, yDim ); | |
| 140 | + // bail | |
| 141 | + return FALSE; | |
| 142 | + } | |
| 143 | + // remember | |
| 144 | + m_xDim = xDim; | |
| 145 | + m_yDim = yDim; | |
| 146 | + | |
| 147 | + // done | |
| 148 | + return TRUE; | |
| 149 | + } | |
| 150 | + | |
| 151 | + // get element value | |
| 152 | + T & v( t_CKINT x, t_CKINT y ) | |
| 153 | + { | |
| 154 | + // at least do a check | |
| 155 | + if( x < 0 || x >= m_xDim || y < 0 || y >= m_yDim ) | |
| 156 | + { | |
| 157 | + // error | |
| 158 | + CK_FPRINTF_STDERR( "[chuck]: ChaiMatrixFast out of bound: %s[%d][%d]...\n", | |
| 159 | + typeid( T ).name(), x, y ); | |
| 160 | + // halt | |
| 161 | + // TODO: this should throw (a shred-level, probably) exception | |
| 162 | + assert( FALSE ); | |
| 163 | + } | |
| 164 | + | |
| 165 | + return m_matrix[x * m_yDim + y]; | |
| 166 | + } | |
| 167 | + | |
| 168 | + // overloaded operator | |
| 169 | + T & operator()( t_CKINT x, t_CKINT y ) | |
| 170 | + { | |
| 171 | + return v( x, y ); | |
| 172 | + } | |
| 173 | + | |
| 174 | + // get dimensions | |
| 175 | + t_CKINT xDim() const | |
| 176 | + { return m_xDim; } | |
| 177 | + t_CKINT yDim() const | |
| 178 | + { return m_yDim; } | |
| 179 | + | |
| 180 | + void cleanup() | |
| 181 | + { | |
| 182 | + // reclaim array memory and zero the pointer | |
| 183 | + SAFE_DELETE_ARRAY( m_matrix ); | |
| 184 | + // zero out | |
| 185 | + m_xDim = m_yDim = 0; | |
| 186 | + } | |
| 187 | + | |
| 188 | +protected: | |
| 189 | + T * m_matrix; | |
| 190 | + t_CKINT m_xDim; | |
| 191 | + t_CKINT m_yDim; | |
| 192 | +}; | |
| 193 | + | |
| 194 | +//----------------------------------------------------------------------------- | |
| 195 | +// name: class ChaiVectorFast | 1.4.2.0 (ge) added | |
| 196 | +// desc: a templated fast access but not bound-checked 1D array | |
| 197 | +// allows arbitrary arrays of arbitrary and non-constant dimension | |
| 198 | +// to be allocated locally, e.g., int array[dim] -- which is not | |
| 199 | +// valid syntax with some compilers. | |
| 200 | +//----------------------------------------------------------------------------- | |
| 201 | +template<class T> | |
| 202 | +class ChaiVectorFast | |
| 203 | +{ | |
| 204 | +public: | |
| 205 | + ChaiVectorFast() | |
| 206 | + { | |
| 207 | + // zero out | |
| 208 | + m_vector = NULL; | |
| 209 | + // zero out | |
| 210 | + m_length = 0; | |
| 211 | + } | |
| 212 | + | |
| 213 | + ChaiVectorFast( t_CKINT length ) | |
| 214 | + { | |
| 215 | + // zero out | |
| 216 | + m_vector = NULL; | |
| 217 | + // allocate | |
| 218 | + allocate( length ); | |
| 219 | + } | |
| 220 | + | |
| 221 | + ~ChaiVectorFast() | |
| 222 | + { | |
| 223 | + // deallocate | |
| 224 | + cleanup(); | |
| 225 | + } | |
| 226 | + | |
| 227 | + t_CKBOOL allocate( t_CKINT length ) | |
| 228 | + { | |
| 229 | + // delete if necessary | |
| 230 | + if( m_vector != NULL ) cleanup(); | |
| 231 | + | |
| 232 | + // allocate | |
| 233 | + m_vector = new T[length]; | |
| 234 | + // check | |
| 235 | + if( !m_vector ) | |
| 236 | + { | |
| 237 | + // error | |
| 238 | + CK_FPRINTF_STDERR( "[chuck]: ChaiVectorFast allocation failure: %s[%d]...\n", | |
| 239 | + typeid( T ).name(), length ); | |
| 240 | + // bail | |
| 241 | + return FALSE; | |
| 242 | + } | |
| 243 | + // remember | |
| 244 | + m_length = length; | |
| 245 | + | |
| 246 | + // done | |
| 247 | + return TRUE; | |
| 248 | + } | |
| 249 | + | |
| 250 | + void shuffle() | |
| 251 | + { | |
| 252 | + T temp; | |
| 253 | + t_CKINT j; | |
| 254 | + for( t_CKINT i = m_length - 1; i > 0; i-- ) | |
| 255 | + { | |
| 256 | + j = ck_random() % ( i + 1 ); | |
| 257 | + temp = m_vector[i]; | |
| 258 | + m_vector[i] = m_vector[j]; | |
| 259 | + m_vector[j] = temp; | |
| 260 | + } | |
| 261 | + } | |
| 262 | + | |
| 263 | + t_CKUINT length() | |
| 264 | + { return m_length; } | |
| 265 | + | |
| 266 | + t_CKINT size() | |
| 267 | + { return m_length; } | |
| 268 | + | |
| 269 | + T getMax() | |
| 270 | + { | |
| 271 | + T max = m_vector[0]; | |
| 272 | + for( t_CKINT i = 1; i < m_length; i++ ) | |
| 273 | + { | |
| 274 | + if( m_vector[i] > max ) | |
| 275 | + { | |
| 276 | + max = m_vector[i]; | |
| 277 | + } | |
| 278 | + } | |
| 279 | + return max; | |
| 280 | + } | |
| 281 | + | |
| 282 | + void setAll( T value ) | |
| 283 | + { | |
| 284 | + // iterate | |
| 285 | + for( t_CKINT i = 0; i < m_length; i++ ) | |
| 286 | + { | |
| 287 | + // set to value | |
| 288 | + m_vector[i] = value; | |
| 289 | + } | |
| 290 | + } | |
| 291 | + | |
| 292 | + T & operator[]( t_CKINT i ) | |
| 293 | + { | |
| 294 | + // at least do a check | |
| 295 | + if( i < 0 || i >= m_length ) | |
| 296 | + { | |
| 297 | + // error | |
| 298 | + CK_FPRINTF_STDERR( "[chuck]: ChaiVectorFast out of bound: %s[%d] (capacity=%d)...\n", | |
| 299 | + typeid( T ).name(), i, m_length ); | |
| 300 | + // TODO: this should throw (a shred-level, probably) exception | |
| 301 | + assert( FALSE ); | |
| 302 | + } | |
| 303 | + | |
| 304 | + return m_vector[i]; | |
| 305 | + } | |
| 306 | + | |
| 307 | + // get element value | |
| 308 | + T & v( t_CKINT i ) | |
| 309 | + { | |
| 310 | + return ( *this )[i]; | |
| 311 | + } | |
| 312 | + | |
| 313 | + void cleanup() | |
| 314 | + { | |
| 315 | + // reclaim array memory and zero the pointer | |
| 316 | + SAFE_DELETE_ARRAY( m_vector ); | |
| 317 | + // zero out | |
| 318 | + m_length = 0; | |
| 319 | + } | |
| 320 | + | |
| 321 | +public: | |
| 322 | + T * m_vector; | |
| 323 | + t_CKINT m_length; | |
| 324 | +}; | |
| 325 | + | |
| 326 | +#endif | |
| 327 | + | |
| 328 | +#ifndef _KD_TREE_H | |
| 329 | +#define _KD_TREE_H | |
| 330 | + | |
| 331 | +#include <float.h> | |
| 332 | +// #define DBL_EPSILON 2.2204460492503131e-16 | |
| 333 | + | |
| 334 | +#define KDTREE_MAX_LEVEL 64 | |
| 335 | +#define KDTREE_LEFT_INDEX 0 | |
| 336 | +#define KDTREE_RIGHT_INDEX 1 | |
| 337 | + | |
| 338 | +typedef struct knn_list | |
| 339 | +{ | |
| 340 | + struct kdnode * node; | |
| 341 | + double distance; | |
| 342 | + struct knn_list * prev; | |
| 343 | + struct knn_list * next; | |
| 344 | +} knn_list_t; | |
| 345 | + | |
| 346 | +typedef struct kdnode | |
| 347 | +{ | |
| 348 | + long coord_index; | |
| 349 | + double * coord; | |
| 350 | + struct kdnode * left; | |
| 351 | + struct kdnode * right; | |
| 352 | + t_CKINT r; | |
| 353 | +} kdnode_t; | |
| 354 | + | |
| 355 | +typedef struct kdtree | |
| 356 | +{ | |
| 357 | + struct kdnode * root; | |
| 358 | + size_t count; | |
| 359 | + size_t capacity; | |
| 360 | + double * coords; | |
| 361 | + double ** coord_table; | |
| 362 | + long * coord_indexes; | |
| 363 | + unsigned char * coord_deleted; | |
| 364 | + unsigned char * coord_passed; | |
| 365 | + struct knn_list knn_list_head; | |
| 366 | + t_CKINT dim; | |
| 367 | + t_CKINT knn_num; | |
| 368 | +} kdtree_t; | |
| 369 | + | |
| 370 | +struct kdtree * kdtree_init( t_CKINT dim ); | |
| 371 | +void kdtree_insert( struct kdtree * tree, double * coord ); | |
| 372 | +void kdtree_rebuild( struct kdtree * tree ); | |
| 373 | +void kdtree_knn_search( struct kdtree * tree, double * coord, t_CKINT k ); | |
| 374 | +void kdtree_destroy( struct kdtree * tree ); | |
| 375 | +void kdtree_dump( struct kdtree * tree ); | |
| 376 | + | |
| 377 | +#endif /* _KD_TREE_H */ | |
| @@ -42,22 +42,21 @@ struct Chuck_Compiler; · 41 unmodified lines | ||
| 42 | 42 | |
| 43 | 43 | // query |
| 44 | 44 | DLL_QUERY machine_query( Chuck_DL_Query * QUERY ); |
| 45 | −typedef t_CKUINT (* proc_msg_func)( Chuck_VM *, Chuck_Compiler *, | |
| 45 | + | |
| 46 | +#ifndef __DISABLE_OTF_SERVER__ | |
| 47 | +typedef t_CKUINT (* proc_msg_func)( Chuck_VM *, Chuck_Compiler *, | |
| 46 | 48 | Net_Msg *, t_CKBOOL, void * ); |
| 47 | 49 | t_CKBOOL machine_init( Chuck_Compiler * compiler, proc_msg_func func ); |
| 48 | 50 | // 1.4.0.1: TODO: refactor out of ulib machine; not all platforms have OTF |
| 51 | +#endif // __DISABLE_OTF_SERVER__ | |
| 52 | + | |
| 53 | +// machine exports | |
| 49 | 54 | t_CKUINT machine_intsize(); |
| 50 | 55 | |
| 51 | 56 | |
| 52 | −// exports | |
| 53 | −CK_DLL_SFUN( machine_crash_impl ); | |
| 54 | −CK_DLL_SFUN( machine_add_impl ); | |
| 55 | −CK_DLL_SFUN( machine_spork_impl ); | |
| 56 | −CK_DLL_SFUN( machine_remove_impl ); | |
| 57 | −CK_DLL_SFUN( machine_replace_impl ); | |
| 58 | −CK_DLL_SFUN( machine_status_impl ); | |
| 59 | −CK_DLL_SFUN( machine_intsize_impl ); | |
| 60 | −CK_DLL_SFUN( machine_shreds_impl ); | |
| 57 | +// ckdoc query | |
| 58 | +DLL_QUERY ckdoc_query( Chuck_DL_Query * QUERY ); | |
| 59 | + | |
| 61 | 60 | |
| 62 | 61 | |
| 63 | 62 | #endif |
| @@ -68,6 +68,7 @@ CK_DLL_SFUN( min_impl ); · 67 unmodified lines | ||
| 68 | 68 | CK_DLL_SFUN( max_impl ); |
| 69 | 69 | CK_DLL_SFUN( isinf_impl ); |
| 70 | 70 | CK_DLL_SFUN( isnan_impl ); |
| 71 | +CK_DLL_SFUN( equal_impl ); | |
| 71 | 72 | CK_DLL_SFUN( floatMax_impl ); |
| 72 | 73 | CK_DLL_SFUN( intMax_impl ); |
| 73 | 74 | |
| @@ -89,12 +90,17 @@ CK_DLL_SFUN( srandom_impl ); · 15 unmodified lines | ||
| 89 | 90 | |
| 90 | 91 | CK_DLL_SFUN( gauss_impl ); |
| 91 | 92 | |
| 92 | −// max for random functions | |
| 93 | −#ifdef __WINDOWS_DS__ | |
| 94 | −#define CK_RANDOM_MAX RAND_MAX | |
| 95 | −#else | |
| 96 | −#define CK_RANDOM_MAX 0x7fffffff | |
| 97 | −#endif | |
| 93 | +CK_DLL_SFUN( cossim_impl ); | |
| 94 | +CK_DLL_SFUN( cossim3d_impl ); | |
| 95 | +CK_DLL_SFUN( cossim4d_impl ); | |
| 96 | + | |
| 97 | +CK_DLL_SFUN( euclidean_impl ); | |
| 98 | +CK_DLL_SFUN( euclidean3d_impl ); | |
| 99 | +CK_DLL_SFUN( euclidean4d_impl ); | |
| 100 | + | |
| 101 | +CK_DLL_SFUN( map_impl ); | |
| 102 | +CK_DLL_SFUN( map2_impl ); | |
| 103 | + | |
| 98 | 104 | |
| 99 | 105 | |
| 100 | 106 | |
| @@ -1,21 +1,21 @@ | ||
| 1 | 1 | /*---------------------------------------------------------------------------- |
| 2 | 2 | ChucK Concurrent, On-the-fly Audio Programming Language |
| 3 | 3 | Compiler and Virtual Machine |
| 4 | − | |
| 4 | + | |
| 5 | 5 | Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. |
| 6 | 6 | http://chuck.stanford.edu/ |
| 7 | 7 | http://chuck.cs.princeton.edu/ |
| 8 | − | |
| 8 | + | |
| 9 | 9 | This program is free software; you can redistribute it and/or modify |
| 10 | 10 | it under the terms of the GNU General Public License as published by |
| 11 | 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | 12 | (at your option) any later version. |
| 13 | − | |
| 13 | + | |
| 14 | 14 | This program is distributed in the hope that it will be useful, |
| 15 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | 17 | GNU General Public License for more details. |
| 18 | − | |
| 18 | + | |
| 19 | 19 | You should have received a copy of the GNU General Public License |
| 20 | 20 | along with this program; if not, write to the Free Software |
| 21 | 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| @@ -43,8 +43,8 @@ · 42 unmodified lines | ||
| 43 | 43 | #include <queue> |
| 44 | 44 | #include <iostream> |
| 45 | 45 | |
| 46 | −#define DWORD__ unsigned long | |
| 47 | −#define SINT__ long | |
| 46 | +#define DWORD__ t_CKUINT | |
| 47 | +#define SINT__ t_CKINT | |
| 48 | 48 | #define UINT__ DWORD__ |
| 49 | 49 | #define BOOL__ DWORD__ |
| 50 | 50 | #define BYTE__ unsigned char |
| @@ -103,7 +103,7 @@ protected: · 52 unmodified lines | ||
| 103 | 103 | #ifndef __DISABLE_THREADS__ |
| 104 | 104 | XMutex m_mutex; |
| 105 | 105 | #endif |
| 106 | − | |
| 106 | + | |
| 107 | 107 | CBufferSimple * m_event_buffer; |
| 108 | 108 | }; |
| 109 | 109 | |
| @@ -203,7 +203,7 @@ template<typename T> · 93 unmodified lines | ||
| 203 | 203 | class CircularBuffer |
| 204 | 204 | { |
| 205 | 205 | public: |
| 206 | − | |
| 206 | + | |
| 207 | 207 | CircularBuffer(size_t numElements) : |
| 208 | 208 | m_read(0), |
| 209 | 209 | m_write(0), |
| @@ -211,7 +211,7 @@ public: · 1 unmodified line | ||
| 211 | 211 | { |
| 212 | 212 | m_elements = new T[m_numElements]; |
| 213 | 213 | } |
| 214 | − | |
| 214 | + | |
| 215 | 215 | ~CircularBuffer() |
| 216 | 216 | { |
| 217 | 217 | if(m_elements != NULL) |
| @@ -220,7 +220,7 @@ public: · 2 unmodified lines | ||
| 220 | 220 | m_elements = NULL; |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | − | |
| 223 | + | |
| 224 | 224 | // put one element |
| 225 | 225 | // returns number of elements successfully put |
| 226 | 226 | size_t put(T element) |
| @@ -230,14 +230,14 @@ public: · 3 unmodified lines | ||
| 230 | 230 | // no space |
| 231 | 231 | return 0; |
| 232 | 232 | } |
| 233 | − | |
| 233 | + | |
| 234 | 234 | m_elements[m_write] = element; |
| 235 | − | |
| 235 | + | |
| 236 | 236 | m_write = (m_write+1)%m_numElements; |
| 237 | − | |
| 237 | + | |
| 238 | 238 | return 1; |
| 239 | 239 | } |
| 240 | − | |
| 240 | + | |
| 241 | 241 | // get one element |
| 242 | 242 | // returns number of elements successfully got |
| 243 | 243 | size_t get(T &element) |
| @@ -247,14 +247,14 @@ public: · 3 unmodified lines | ||
| 247 | 247 | // nothing to get |
| 248 | 248 | return 0; |
| 249 | 249 | } |
| 250 | − | |
| 250 | + | |
| 251 | 251 | element = m_elements[m_read]; |
| 252 | − | |
| 252 | + | |
| 253 | 253 | m_read = (m_read+1)%m_numElements; |
| 254 | − | |
| 254 | + | |
| 255 | 255 | return 1; |
| 256 | 256 | } |
| 257 | − | |
| 257 | + | |
| 258 | 258 | // peek at element i without removing it |
| 259 | 259 | // i = 1 would correspond to the least recently put element; |
| 260 | 260 | // i = -1 would correspond to the most recent (not implemented) |
| @@ -263,24 +263,24 @@ public: · 2 unmodified lines | ||
| 263 | 263 | { |
| 264 | 264 | if(i == 0) |
| 265 | 265 | return 0; |
| 266 | − | |
| 266 | + | |
| 267 | 267 | if(i > 0 && i <= numElements()) |
| 268 | 268 | { |
| 269 | 269 | element = m_elements[(m_read+(i-1))%m_numElements]; |
| 270 | 270 | return 1; |
| 271 | 271 | } |
| 272 | − | |
| 272 | + | |
| 273 | 273 | return 0; |
| 274 | 274 | } |
| 275 | − | |
| 275 | + | |
| 276 | 276 | void clear() { m_write = m_read; } |
| 277 | − | |
| 277 | + | |
| 278 | 278 | // return maximum number of elements that can be held |
| 279 | 279 | size_t maxElements() { return m_numElements-1; } |
| 280 | − | |
| 280 | + | |
| 281 | 281 | // return if buffer is full |
| 282 | 282 | bool atMaximum() { return (m_write + 1)%m_numElements == m_read; } |
| 283 | − | |
| 283 | + | |
| 284 | 284 | // return number of valid elements in the buffer |
| 285 | 285 | size_t numElements() |
| 286 | 286 | { |
| @@ -291,7 +291,7 @@ public: · 4 unmodified lines | ||
| 291 | 291 | else |
| 292 | 292 | return m_numElements - m_read + m_write; |
| 293 | 293 | } |
| 294 | − | |
| 294 | + | |
| 295 | 295 | private: |
| 296 | 296 | T * m_elements; |
| 297 | 297 | size_t m_read, m_write; |
| @@ -311,17 +311,17 @@ class FastCircularBuffer · 13 unmodified lines | ||
| 311 | 311 | public: |
| 312 | 312 | FastCircularBuffer(); |
| 313 | 313 | ~FastCircularBuffer(); |
| 314 | − | |
| 314 | + | |
| 315 | 315 | public: |
| 316 | 316 | t_CKUINT initialize( t_CKUINT num_elem, t_CKUINT width ); |
| 317 | 317 | void cleanup(); |
| 318 | − | |
| 318 | + | |
| 319 | 319 | public: |
| 320 | 320 | t_CKUINT get( void * data, t_CKUINT num_elem ); |
| 321 | 321 | t_CKUINT put( void * data, t_CKUINT num_elem ); |
| 322 | 322 | inline bool hasMore() { return (m_read_offset != m_write_offset); } |
| 323 | 323 | inline void clear() { m_read_offset = m_write_offset = 0; } |
| 324 | − | |
| 324 | + | |
| 325 | 325 | protected: |
| 326 | 326 | t_CKBYTE * m_data; |
| 327 | 327 | t_CKUINT m_data_width; |
| @@ -343,7 +343,7 @@ class XCircleBuffer · 15 unmodified lines | ||
| 343 | 343 | public: |
| 344 | 344 | XCircleBuffer( long length = 0 ); |
| 345 | 345 | ~XCircleBuffer(); |
| 346 | − | |
| 346 | + | |
| 347 | 347 | public: |
| 348 | 348 | // reset length of buffer (capacity) |
| 349 | 349 | void init( long length ); |
| @@ -351,7 +351,7 @@ public: · 1 unmodified line | ||
| 351 | 351 | long length() const; |
| 352 | 352 | // clear (does no explicit memory management) |
| 353 | 353 | void clear(); |
| 354 | − | |
| 354 | + | |
| 355 | 355 | public: |
| 356 | 356 | // put an element into the buffer - the item will be copied |
| 357 | 357 | // NOTE: if over-capacity, will discard least recently put item |
| @@ -366,11 +366,11 @@ public: · 8 unmodified lines | ||
| 366 | 366 | long peek( T * array, long numItems, unsigned long stride = 0 ); |
| 367 | 367 | // pop |
| 368 | 368 | long pop( long numItems = 1 ); |
| 369 | − | |
| 369 | + | |
| 370 | 370 | protected: // helper functions |
| 371 | 371 | inline void advanceWrite(); |
| 372 | 372 | inline void advanceRead(); |
| 373 | − | |
| 373 | + | |
| 374 | 374 | protected: |
| 375 | 375 | // the buffer |
| 376 | 376 | T * m_buffer; |
| @@ -397,7 +397,7 @@ XCircleBuffer<T>::XCircleBuffer( long length ) · 20 unmodified lines | ||
| 397 | 397 | // zero out first |
| 398 | 398 | m_buffer = NULL; |
| 399 | 399 | m_length = m_readIndex = m_writeIndex = m_numElements = 0; |
| 400 | − | |
| 400 | + | |
| 401 | 401 | // call init |
| 402 | 402 | this->init( length ); |
| 403 | 403 | } |
| @@ -412,7 +412,7 @@ XCircleBuffer<T>::XCircleBuffer( long length ) · 8 unmodified lines | ||
| 412 | 412 | template <typename T> |
| 413 | 413 | XCircleBuffer<T>::~XCircleBuffer() |
| 414 | 414 | { |
| 415 | − | |
| 415 | + | |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | |
| @@ -433,20 +433,20 @@ void XCircleBuffer<T>::init( long length ) · 14 unmodified lines | ||
| 433 | 433 | // zero out |
| 434 | 434 | m_length = m_readIndex = m_writeIndex = m_numElements = 0; |
| 435 | 435 | } |
| 436 | − | |
| 436 | + | |
| 437 | 437 | // sanity check |
| 438 | 438 | if( length < 0 ) |
| 439 | 439 | { |
| 440 | 440 | // doh |
| 441 | 441 | std::cerr << "[XCircleBuffer]: error invalid length '" |
| 442 | 442 | << length << "' requested" << std::endl; |
| 443 | − | |
| 443 | + | |
| 444 | 444 | return; |
| 445 | 445 | } |
| 446 | − | |
| 446 | + | |
| 447 | 447 | // check for zero length |
| 448 | 448 | if( length == 0 ) return; |
| 449 | − | |
| 449 | + | |
| 450 | 450 | // allocate |
| 451 | 451 | m_buffer = new T[length]; |
| 452 | 452 | // check |
| @@ -455,10 +455,10 @@ void XCircleBuffer<T>::init( long length ) · 2 unmodified lines | ||
| 455 | 455 | // doh |
| 456 | 456 | std::cerr << "[XCircleBuffer]: failed to allocate buffer of length '" |
| 457 | 457 | << length << "'..." << std::endl; |
| 458 | − | |
| 458 | + | |
| 459 | 459 | return; |
| 460 | 460 | } |
| 461 | − | |
| 461 | + | |
| 462 | 462 | // save |
| 463 | 463 | m_length = length; |
| 464 | 464 | // zero out |
| @@ -504,14 +504,14 @@ void XCircleBuffer<T>::advanceWrite() · 39 unmodified lines | ||
| 504 | 504 | { |
| 505 | 505 | // increment |
| 506 | 506 | m_writeIndex++; |
| 507 | − | |
| 507 | + | |
| 508 | 508 | // check for bounds |
| 509 | 509 | if( m_writeIndex >= m_length ) |
| 510 | 510 | { |
| 511 | 511 | // wrap |
| 512 | 512 | m_writeIndex -= m_length; |
| 513 | 513 | } |
| 514 | − | |
| 514 | + | |
| 515 | 515 | // increment count |
| 516 | 516 | m_numElements++; |
| 517 | 517 | } |
| @@ -528,14 +528,14 @@ void XCircleBuffer<T>::advanceRead() · 10 unmodified lines | ||
| 528 | 528 | { |
| 529 | 529 | // increment |
| 530 | 530 | m_readIndex++; |
| 531 | − | |
| 531 | + | |
| 532 | 532 | // check for bounds |
| 533 | 533 | if( m_readIndex >= m_length ) |
| 534 | 534 | { |
| 535 | 535 | // wrap |
| 536 | 536 | m_readIndex -= m_length; |
| 537 | 537 | } |
| 538 | − | |
| 538 | + | |
| 539 | 539 | // decrement count |
| 540 | 540 | m_numElements--; |
| 541 | 541 | } |
| @@ -553,13 +553,13 @@ void XCircleBuffer<T>::put( const T & item ) · 11 unmodified lines | ||
| 553 | 553 | { |
| 554 | 554 | // sanity check |
| 555 | 555 | if( m_buffer == NULL ) return; |
| 556 | − | |
| 556 | + | |
| 557 | 557 | // copy it |
| 558 | 558 | m_buffer[m_writeIndex] = item; |
| 559 | − | |
| 559 | + | |
| 560 | 560 | // advance write index |
| 561 | 561 | advanceWrite(); |
| 562 | − | |
| 562 | + | |
| 563 | 563 | // if read and write pointer are the same, over-capacity |
| 564 | 564 | if( m_writeIndex == m_readIndex ) |
| 565 | 565 | { |
| @@ -609,19 +609,19 @@ long XCircleBuffer<T>::peek( T * array, long numItems, unsigned long stride ) · 43 unmodified lines | ||
| 609 | 609 | { |
| 610 | 610 | // sanity check |
| 611 | 611 | if( m_buffer == NULL ) return 0; |
| 612 | − | |
| 612 | + | |
| 613 | 613 | // sanity check (so the wrap can be sure to land inbounds) |
| 614 | 614 | if( stride >= m_length ) return 0; |
| 615 | − | |
| 615 | + | |
| 616 | 616 | // count |
| 617 | 617 | long count = 0; |
| 618 | 618 | // actual count, taking stride out of the equation |
| 619 | 619 | long actualCount = 0; |
| 620 | − | |
| 620 | + | |
| 621 | 621 | // starting index |
| 622 | 622 | long index = m_writeIndex - 1; |
| 623 | 623 | if( index < 0 ) index += m_length; |
| 624 | − | |
| 624 | + | |
| 625 | 625 | // while need more but haven't reached write index... |
| 626 | 626 | while( (count < numItems) && (count < m_numElements) ) |
| 627 | 627 | { |
| @@ -636,7 +636,7 @@ long XCircleBuffer<T>::peek( T * array, long numItems, unsigned long stride ) · 8 unmodified lines | ||
| 636 | 636 | // wrap |
| 637 | 637 | if( index < 0 ) index += m_length; |
| 638 | 638 | } |
| 639 | − | |
| 639 | + | |
| 640 | 640 | // reverse contents |
| 641 | 641 | for( int i = 0; i < actualCount/2; i++ ) |
| 642 | 642 | { |
| @@ -644,7 +644,7 @@ long XCircleBuffer<T>::peek( T * array, long numItems, unsigned long stride ) · 1 unmodified line | ||
| 644 | 644 | array[i] = array[actualCount-1-i]; |
| 645 | 645 | array[actualCount-1-i] = v; |
| 646 | 646 | } |
| 647 | − | |
| 647 | + | |
| 648 | 648 | return actualCount; |
| 649 | 649 | } |
| 650 | 650 | |
| @@ -660,10 +660,10 @@ long XCircleBuffer<T>::pop( long numItems ) · 9 unmodified lines | ||
| 660 | 660 | { |
| 661 | 661 | // sanity check |
| 662 | 662 | if( m_buffer == NULL ) return 0; |
| 663 | − | |
| 663 | + | |
| 664 | 664 | // count |
| 665 | 665 | long count = 0; |
| 666 | − | |
| 666 | + | |
| 667 | 667 | // while there is more to pop and need to pop more |
| 668 | 668 | while( more() && count < numItems ) |
| 669 | 669 | { |
| @@ -672,7 +672,7 @@ long XCircleBuffer<T>::pop( long numItems ) · 2 unmodified lines | ||
| 672 | 672 | // increment count |
| 673 | 673 | count++; |
| 674 | 674 | } |
| 675 | − | |
| 675 | + | |
| 676 | 676 | return count; |
| 677 | 677 | } |
| 678 | 678 | |
| @@ -688,12 +688,12 @@ bool XCircleBuffer<T>::get( T * result ) · 9 unmodified lines | ||
| 688 | 688 | { |
| 689 | 689 | // sanity check |
| 690 | 690 | if( m_buffer == NULL || m_readIndex == m_writeIndex ) return false; |
| 691 | − | |
| 691 | + | |
| 692 | 692 | // get item to read |
| 693 | 693 | *result = m_buffer[m_readIndex]; |
| 694 | 694 | // advance read |
| 695 | 695 | advanceRead(); |
| 696 | − | |
| 696 | + | |
| 697 | 697 | return true; |
| 698 | 698 | } |
| 699 | 699 | |
| @@ -32,6 +32,8 @@ · 31 unmodified lines | ||
| 32 | 32 | #ifndef __UTIL_HID_H__ |
| 33 | 33 | #define __UTIL_HID_H__ |
| 34 | 34 | |
| 35 | +#include "chuck_def.h" | |
| 36 | + | |
| 35 | 37 | |
| 36 | 38 | |
| 37 | 39 | |
| @@ -50,7 +52,7 @@ struct HidMsg · 12 unmodified lines | ||
| 50 | 52 | t_CKINT idata[4]; // int data |
| 51 | 53 | #endif |
| 52 | 54 | t_CKFLOAT fdata[4]; // float data |
| 53 | − | |
| 55 | + | |
| 54 | 56 | #ifdef __cplusplus |
| 55 | 57 | HidMsg() |
| 56 | 58 | { this->clear(); } |
| @@ -161,7 +163,7 @@ extern const char * Mouse_name( int m ); · 104 unmodified lines | ||
| 161 | 163 | extern int Mouse_buttons( int m ); |
| 162 | 164 | extern int Mouse_start_cursor_track(); |
| 163 | 165 | extern int Mouse_stop_cursor_track(); |
| 164 | − | |
| 166 | + | |
| 165 | 167 | extern void Keyboard_init(); |
| 166 | 168 | extern void Keyboard_poll(); |
| 167 | 169 | extern void Keyboard_quit(); |
| @@ -34,21 +34,36 @@ · 33 unmodified lines | ||
| 34 | 34 | #define __UTIL_MATH_H__ |
| 35 | 35 | |
| 36 | 36 | #include <math.h> |
| 37 | +#include "chuck_def.h" // 1.4.1.0 (ge) for t_CKINT | |
| 37 | 38 | |
| 38 | −#if defined (__cplusplus) || defined(_cplusplus) | |
| 39 | +#if defined (__cplusplus) || defined(_cplusplus) | |
| 39 | 40 | extern "C" { |
| 40 | −#endif | |
| 41 | +#endif | |
| 41 | 42 | |
| 43 | +// 1.4.1.1 (ge) removed -- seems no longer needed on more modern windows | |
| 42 | 44 | #ifdef __PLATFORM_WIN32__ |
| 43 | − | |
| 45 | +#ifdef __CK_MATH_DEFINE_ROUND_TRUNC__ | |
| 44 | 46 | double round( double a ); |
| 45 | 47 | double trunc( double a ); |
| 46 | −#ifndef __WINDOWS_MODERN__ | |
| 47 | − double remainder( long a, long b ); | |
| 48 | 48 | #endif |
| 49 | +#endif | |
| 50 | + | |
| 51 | +// 1.4.1.0 (ge) need this since __WINDOWS_MODERN__ can be defined but remainder still not found (VC++ 2010) | |
| 52 | +double ck_remainder( double a, double b ); | |
| 53 | + | |
| 49 | 54 | |
| 55 | +// max for random functions | |
| 56 | +#ifdef __PLATFORM_WIN32__ | |
| 57 | +#define CK_RANDOM_MAX RAND_MAX | |
| 58 | +#else | |
| 59 | +#define CK_RANDOM_MAX 0x7fffffff | |
| 50 | 60 | #endif |
| 51 | 61 | |
| 62 | +// chuck random wrapper | |
| 63 | +long ck_random(); | |
| 64 | +// chuck srandom wrapper | |
| 65 | +void ck_srandom( unsigned seed ); | |
| 66 | + | |
| 52 | 67 | // mtof |
| 53 | 68 | double mtof( double f ); |
| 54 | 69 | // ftom |
| @@ -66,10 +81,11 @@ unsigned long nextpow2( unsigned long i ); · 11 unmodified lines | ||
| 66 | 81 | // ensurepow2 |
| 67 | 82 | unsigned long ensurepow2( unsigned long i ); |
| 68 | 83 | |
| 69 | −#if defined (__cplusplus) || defined(_cplusplus) | |
| 84 | +#if defined (__cplusplus) || defined(_cplusplus) | |
| 70 | 85 | } |
| 71 | 86 | #endif |
| 72 | 87 | |
| 73 | 88 | |
| 74 | 89 | |
| 75 | −#endif | |
| 90 | + | |
| 91 | +#endif | |
| @@ -41,6 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #include <sys/socket.h> |
| 42 | 42 | #include <netinet/in.h> |
| 43 | 43 | #else |
| 44 | +#define _WINSOCKAPI_ | |
| 44 | 45 | #include <windows.h> |
| 45 | 46 | #endif |
| 46 | 47 | |
| @@ -35,12 +35,13 @@ · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | // chuck high-style artistry |
| 38 | −// let's just cat included files into an enormous code-wad. | |
| 38 | +// let's just cat included files into an enormous code-wad. | |
| 39 | 39 | // keep that bubble gum in your hair. |
| 40 | 40 | |
| 41 | 41 | |
| 42 | −// the included files were from the CNMAT OSC-Kit distrib. | |
| 42 | +// the included files were from the CNMAT OSC-Kit distrib. | |
| 43 | 43 | #ifdef __PLATFORM_WIN32__ |
| 44 | +#define _WINSOCKAPI_ | |
| 44 | 45 | #include <windows.h> |
| 45 | 46 | #endif |
| 46 | 47 | |
| @@ -48,7 +49,7 @@ · 1 unmodified line | ||
| 48 | 49 | // OSC-pattern-match.h |
| 49 | 50 | |
| 50 | 51 | /* |
| 51 | −Copyright � 1998. The Regents of the University of California (Regents). | |
| 52 | +Copyright � 1998. The Regents of the University of California (Regents). | |
| 52 | 53 | All Rights Reserved. |
| 53 | 54 | |
| 54 | 55 | Written by Matt Wright, The Center for New Music and Audio Technologies, |
| @@ -71,7 +72,7 @@ PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED · 16 unmodified lines | ||
| 71 | 72 | HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE |
| 72 | 73 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 73 | 74 | |
| 74 | −The OpenSound Control WWW page is | |
| 75 | +The OpenSound Control WWW page is | |
| 75 | 76 | http://www.cnmat.berkeley.edu/OpenSoundControl |
| 76 | 77 | */ |
| 77 | 78 | |
| @@ -94,7 +95,7 @@ bool PatternMatch (const char *pattern, const char *test); · 16 unmodified lines | ||
| 94 | 95 | |
| 95 | 96 | // - end OSC-pattern-match.h |
| 96 | 97 | |
| 97 | −//#inclue OSC-TimeTag.h | |
| 98 | +//#inclue OSC-TimeTag.h | |
| 98 | 99 | |
| 99 | 100 | /* |
| 100 | 101 | Copyright (c) 1998. The Regents of the University of California (Regents). |
| @@ -123,7 +124,7 @@ University of California, Berkeley. · 22 unmodified lines | ||
| 123 | 124 | REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, |
| 124 | 125 | ENHANCEMENTS, OR MODIFICATIONS. |
| 125 | 126 | |
| 126 | −The OpenSound Control WWW page is | |
| 127 | +The OpenSound Control WWW page is | |
| 127 | 128 | http://www.cnmat.berkeley.edu/OpenSoundControl |
| 128 | 129 | */ |
| 129 | 130 | |
| @@ -134,10 +135,10 @@ The OpenSound Control WWW page is · 4 unmodified lines | ||
| 134 | 135 | Time tags in OSC have the same format as in NTP: 64 bit fixed point, with the |
| 135 | 136 | top 32 bits giving number of seconds sinve midnight 1/1/1900 and the bottom |
| 136 | 137 | 32 bits giving fractional parts of a second. We represent this by a 64-bit |
| 137 | − unsigned long if possible, or else a struct. | |
| 138 | + unsigned long if possible, or else a struct. | |
| 138 | 139 | |
| 139 | 140 | NB: On many architectures with 64-bit ints, it's illegal (like maybe a bus error) |
| 140 | − to dereference a pointer to a 64-bit int that's not 64-bit aligned. | |
| 141 | + to dereference a pointer to a 64-bit int that's not 64-bit aligned. | |
| 141 | 142 | */ |
| 142 | 143 | |
| 143 | 144 | #ifndef OSC_TIMETAG |
| @@ -151,7 +152,7 @@ The OpenSound Control WWW page is · 7 unmodified lines | ||
| 151 | 152 | typedef unsigned long long uint64; |
| 152 | 153 | typedef unsigned long uint32; |
| 153 | 154 | #else |
| 154 | − /* You may have to redefine this typedef if ints on your system | |
| 155 | + /* You may have to redefine this typedef if ints on your system | |
| 155 | 156 | aren't 32 bits. */ |
| 156 | 157 | typedef unsigned int uint32; |
| 157 | 158 | #endif |
| @@ -192,7 +193,7 @@ int OSCTT_Compare(OSCTimeTag left, OSCTimeTag right); · 34 unmodified lines | ||
| 192 | 193 | |
| 193 | 194 | |
| 194 | 195 | //#include "OSC-client.h" |
| 195 | −// OSC-client.h | |
| 196 | +// OSC-client.h | |
| 196 | 197 | /* |
| 197 | 198 | Copyright (c) 1996,1997. The Regents of the University of California (Regents). |
| 198 | 199 | All Rights Reserved. |
| @@ -221,7 +222,7 @@ University of California, Berkeley. · 22 unmodified lines | ||
| 221 | 222 | ENHANCEMENTS, OR MODIFICATIONS. |
| 222 | 223 | */ |
| 223 | 224 | |
| 224 | −/* | |
| 225 | +/* | |
| 225 | 226 | |
| 226 | 227 | OSC-client.h: library for constructing OpenSoundControl messages. |
| 227 | 228 | Derived from SynthControl.h |
| @@ -269,7 +270,7 @@ University of California, Berkeley. · 41 unmodified lines | ||
| 269 | 270 | #endif |
| 270 | 271 | |
| 271 | 272 | /* The maximum depth of bundles within bundles within bundles within... |
| 272 | − This is the size of a static array. If you exceed this limit you'll | |
| 273 | + This is the size of a static array. If you exceed this limit you'll | |
| 273 | 274 | get an error message. */ |
| 274 | 275 | #define MAX_BUNDLE_NESTING 32 |
| 275 | 276 | |
| @@ -284,7 +285,7 @@ typedef struct OSCbuf_struct { · 8 unmodified lines | ||
| 284 | 285 | int size; /* Size of the buffer */ |
| 285 | 286 | char *bufptr; /* Current position as we fill the buffer */ |
| 286 | 287 | int state; /* State of partially-constructed message */ |
| 287 | − int4byte *thisMsgSize; /* Pointer to count field before | |
| 288 | + int4byte *thisMsgSize; /* Pointer to count field before | |
| 288 | 289 | currently-being-written message */ |
| 289 | 290 | int4byte *prevCounts[MAX_BUNDLE_NESTING]; |
| 290 | 291 | /* Pointers to count field before each currently |
| @@ -334,12 +335,12 @@ int OSC_packetSize(OSCbuf *buf); · 43 unmodified lines | ||
| 334 | 335 | |
| 335 | 336 | - Make sure the OSCbuf has been initialized with OSC_initBuffer(). |
| 336 | 337 | |
| 337 | − - To open a bundle, call OSC_openBundle(). You can then write | |
| 338 | + - To open a bundle, call OSC_openBundle(). You can then write | |
| 338 | 339 | messages or open new bundles within the bundle you opened. |
| 339 | 340 | Call OSC_closeBundle() to close the bundle. Note that a packet |
| 340 | − does not have to have a bundle; it can instead consist of just a | |
| 341 | + does not have to have a bundle; it can instead consist of just a | |
| 341 | 342 | single message. |
| 342 | − | |
| 343 | + | |
| 343 | 344 | |
| 344 | 345 | - For each message you want to send: |
| 345 | 346 | |
| @@ -350,7 +351,7 @@ int OSC_packetSize(OSCbuf *buf); · 4 unmodified lines | ||
| 350 | 351 | - Alternately, call OSC_writeAddressAndTypes() with the name of |
| 351 | 352 | your message and with a type string listing the types of all the |
| 352 | 353 | arguments you will be putting in this message. |
| 353 | − | |
| 354 | + | |
| 354 | 355 | - Now write each of the arguments into the buffer, by calling one of: |
| 355 | 356 | OSC_writeFloatArg() |
| 356 | 357 | OSC_writeFloatArgs() |
| @@ -376,7 +377,7 @@ extern const char * OSC_errorMessage; · 19 unmodified lines | ||
| 376 | 377 | |
| 377 | 378 | /* How many bytes will be needed in the OSC format to hold the given |
| 378 | 379 | string? The length of the string, plus the null char, plus any padding |
| 379 | − needed for 4-byte alignment. */ | |
| 380 | + needed for 4-byte alignment. */ | |
| 380 | 381 | int OSC_effectiveStringLength(char *string); |
| 381 | 382 | |
| 382 | 383 | // end OSC-client.h |
| @@ -390,11 +391,11 @@ int OSC_effectiveStringLength(char *string); · 7 unmodified lines | ||
| 390 | 391 | |
| 391 | 392 | class OSC_Address_Space; |
| 392 | 393 | class UDP_Transmitter; |
| 393 | −class UDP_Receiver; | |
| 394 | +class UDP_Receiver; | |
| 394 | 395 | |
| 395 | 396 | class OSC_Transmitter |
| 396 | 397 | { |
| 397 | −protected: | |
| 398 | +protected: | |
| 398 | 399 | char _buffer[2048]; |
| 399 | 400 | OSCbuf _osc; |
| 400 | 401 | UDP_Transmitter * _out; |
| @@ -408,10 +409,10 @@ public: · 7 unmodified lines | ||
| 408 | 409 | void init(); |
| 409 | 410 | void setHost( char * host, int port); |
| 410 | 411 | void addMessage( char * address, char * args, ...); |
| 411 | − | |
| 412 | + | |
| 412 | 413 | void openBundle( OSCTimeTag t); |
| 413 | 414 | void closeBundle(); |
| 414 | − | |
| 415 | + | |
| 415 | 416 | void startMessage( char * spec ); |
| 416 | 417 | void startMessage( char * address, char * args ); |
| 417 | 418 | void addInt( int4byte i ); // gewang: changed from int |
| @@ -423,7 +424,7 @@ public: · 5 unmodified lines | ||
| 423 | 424 | void kickMessage(); |
| 424 | 425 | |
| 425 | 426 | void presend( char * buffer , int size ); |
| 426 | − | |
| 427 | + | |
| 427 | 428 | }; |
| 428 | 429 | |
| 429 | 430 | #define OSCINBUFSIZE 8192 |
| @@ -434,7 +435,7 @@ public: · 4 unmodified lines | ||
| 434 | 435 | //maximum size for the array ( ~2mb is enough, no ) |
| 435 | 436 | #define OSCINBOXMAX 256 |
| 436 | 437 | |
| 437 | −struct OSCMesg { | |
| 438 | +struct OSCMesg { | |
| 438 | 439 | char *address; |
| 439 | 440 | char *types; |
| 440 | 441 | char *data; |
| @@ -453,10 +454,10 @@ public: · 12 unmodified lines | ||
| 453 | 454 | virtual ~UDP_Subscriber() {} |
| 454 | 455 | |
| 455 | 456 | public: |
| 456 | − virtual int& port() = 0; // get/set the value of the subscriber's current port. | |
| 457 | + virtual int& port() = 0; // get/set the value of the subscriber's current port. | |
| 457 | 458 | virtual void onReceive( char * mesg, int mesgLen ) = 0; |
| 458 | 459 | |
| 459 | −protected: | |
| 460 | +protected: | |
| 460 | 461 | virtual bool subscribe( int port ); |
| 461 | 462 | virtual bool unsubscribe(); |
| 462 | 463 | }; |
| @@ -474,12 +475,12 @@ protected: · 11 unmodified lines | ||
| 474 | 475 | // int _mesglen; |
| 475 | 476 | |
| 476 | 477 | protected: |
| 477 | − void onReceive( char * mesg, int mesgLen); | |
| 478 | − int & port(); | |
| 478 | + void onReceive( char * mesg, int mesgLen); | |
| 479 | + int & port(); | |
| 479 | 480 | |
| 480 | 481 | protected: |
| 481 | − int _port; | |
| 482 | − int _tmp_port; | |
| 482 | + int _port; | |
| 483 | + int _tmp_port; | |
| 483 | 484 | XMutex * _io_mutex; |
| 484 | 485 | XMutex * _address_mutex; |
| 485 | 486 | // XThread * _io_thread; |
| @@ -493,37 +494,37 @@ protected: · 7 unmodified lines | ||
| 493 | 494 | OSC_Address_Space ** _address_space; |
| 494 | 495 | int _address_size; |
| 495 | 496 | int _address_num; |
| 496 | − | |
| 497 | + | |
| 497 | 498 | CBufferSimple * m_event_buffer; |
| 498 | − | |
| 499 | + | |
| 499 | 500 | // REFACTOR-2017: VM ref |
| 500 | 501 | Chuck_VM * m_vmRef; |
| 501 | − | |
| 502 | + | |
| 502 | 503 | public: |
| 503 | 504 | OSC_Receiver( Chuck_VM * vm ); |
| 504 | 505 | OSC_Receiver( Chuck_VM * vm, UDP_Receiver * in ); |
| 505 | 506 | virtual ~OSC_Receiver(); |
| 506 | − | |
| 507 | + | |
| 507 | 508 | //setup //takedown |
| 508 | 509 | void init(); |
| 509 | 510 | void bind_to_port(int port = 0); |
| 510 | 511 | void close_sock(); |
| 511 | − | |
| 512 | + | |
| 512 | 513 | void recv_mesg(); |
| 513 | 514 | |
| 514 | − bool listen( int port ); | |
| 515 | + bool listen( int port ); | |
| 515 | 516 | bool listen(); |
| 516 | − void stopListening(); //unsubscribe; | |
| 517 | + void stopListening(); //unsubscribe; | |
| 517 | 518 | |
| 518 | 519 | void parse(char *, int len); |
| 519 | 520 | void handle_mesg(char *, int len); |
| 520 | 521 | void handle_bundle(char *, int len); |
| 521 | 522 | void set_mesg(OSCMesg *m, char * buf, int len ); |
| 522 | − | |
| 523 | + | |
| 523 | 524 | OSCMesg *write() { return _inbox + _in_write;} |
| 524 | 525 | void next_write(); |
| 525 | − | |
| 526 | − OSCMesg *read() { return _inbox + _in_read;} | |
| 526 | + | |
| 527 | + OSCMesg *read() { return _inbox + _in_read;} | |
| 527 | 528 | OSCMesg *next_read(); |
| 528 | 529 | |
| 529 | 530 | |
| @@ -531,7 +532,7 @@ public: · 1 unmodified line | ||
| 531 | 532 | bool get_mesg(OSCMesg* bucket); |
| 532 | 533 | |
| 533 | 534 | void add_address ( OSC_Address_Space * o ); |
| 534 | − void remove_address ( OSC_Address_Space * o ); | |
| 535 | + void remove_address ( OSC_Address_Space * o ); | |
| 535 | 536 | OSC_Address_Space * new_event ( char * spec ); |
| 536 | 537 | OSC_Address_Space * new_event ( char * addr, char * type ); |
| 537 | 538 | void distribute_message( OSCMesg * msg); |
| @@ -541,22 +542,22 @@ enum osc_datatype { OSC_UNTYPED, OSC_NOARGS, OSC_INT, OSC_FLOAT, OSC_STRING, OSC · 3 unmodified lines | ||
| 541 | 542 | |
| 542 | 543 | struct opsc_data |
| 543 | 544 | { |
| 544 | − osc_datatype t; | |
| 545 | + osc_datatype t; | |
| 545 | 546 | OSCTimeTag timetag; |
| 546 | 547 | |
| 547 | − union { | |
| 548 | − int4byte i; // gewang: changed from int | |
| 549 | − unsigned long u; // gewang: changed from unsigned int | |
| 550 | − float f; | |
| 551 | − }; | |
| 548 | + union { | |
| 549 | + int4byte i; // gewang: changed from int | |
| 550 | + unsigned long u; // gewang: changed from unsigned int | |
| 551 | + float f; | |
| 552 | + }; | |
| 552 | 553 | |
| 553 | 554 | char * s; |
| 554 | 555 | |
| 555 | − opsc_data() { | |
| 556 | + opsc_data() { | |
| 556 | 557 | t = OSC_UNTYPED; |
| 557 | 558 | s = NULL; |
| 558 | 559 | } |
| 559 | − ~opsc_data() { | |
| 560 | + ~opsc_data() { | |
| 560 | 561 | s = NULL; |
| 561 | 562 | } |
| 562 | 563 | }; |
| @@ -590,10 +591,10 @@ protected: · 27 unmodified lines | ||
| 590 | 591 | void resizeData(int n); |
| 591 | 592 | void resizeQueue(int n); |
| 592 | 593 | void parseSpec(); |
| 593 | − void scanSpec(); | |
| 594 | + void scanSpec(); | |
| 594 | 595 | |
| 595 | 596 | public: |
| 596 | − Chuck_Object * SELF; | |
| 597 | + Chuck_Object * SELF; | |
| 597 | 598 | Chuck_String p_str; |
| 598 | 599 | OSC_Address_Space(); |
| 599 | 600 | OSC_Address_Space( const char * spec ); |
| @@ -1,21 +1,21 @@ | ||
| 1 | 1 | /*---------------------------------------------------------------------------- |
| 2 | 2 | ChucK Concurrent, On-the-fly Audio Programming Language |
| 3 | 3 | Compiler and Virtual Machine |
| 4 | − | |
| 4 | + | |
| 5 | 5 | Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. |
| 6 | 6 | http://chuck.stanford.edu/ |
| 7 | 7 | http://chuck.cs.princeton.edu/ |
| 8 | − | |
| 8 | + | |
| 9 | 9 | This program is free software; you can redistribute it and/or modify |
| 10 | 10 | it under the terms of the GNU General Public License as published by |
| 11 | 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | 12 | (at your option) any later version. |
| 13 | − | |
| 13 | + | |
| 14 | 14 | This program is distributed in the hope that it will be useful, |
| 15 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | 17 | GNU General Public License for more details. |
| 18 | − | |
| 18 | + | |
| 19 | 19 | You should have received a copy of the GNU General Public License |
| 20 | 20 | along with this program; if not, write to the Free Software |
| 21 | 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| @@ -42,16 +42,15 @@ · 20 unmodified lines | ||
| 42 | 42 | #include <jni.h> |
| 43 | 43 | #include <stdio.h> |
| 44 | 44 | |
| 45 | − | |
| 46 | 45 | //----------------------------------------------------------------------------- |
| 47 | −// name: class ChuckAndroid | |
| 46 | +// name: namespace ChuckAndroid | |
| 48 | 47 | // desc: android specific ChucK utilities |
| 49 | 48 | //----------------------------------------------------------------------------- |
| 50 | −class ChuckAndroid | |
| 49 | +namespace ChuckAndroid | |
| 51 | 50 | { |
| 52 | −public: | |
| 53 | − static JavaVM * getJVM(); | |
| 54 | − static FILE * getTemporaryFile(); | |
| 51 | + JavaVM * getJVM(); | |
| 52 | + FILE * getTemporaryFile() noexcept; | |
| 53 | + bool copyJARURLFileToTemporary(const char * jar_url, int * fd) noexcept; | |
| 55 | 54 | }; |
| 56 | 55 | |
| 57 | 56 | #endif // __ANDROID__ |
| @@ -32,9 +32,10 @@ · 31 unmodified lines | ||
| 32 | 32 | #ifndef __UTIL_SERIAL_H__ |
| 33 | 33 | #define __UTIL_SERIAL_H__ |
| 34 | 34 | |
| 35 | +#include "chuck_def.h" | |
| 36 | + | |
| 35 | 37 | #include <vector> |
| 36 | 38 | #include <string> |
| 37 | −using namespace std; | |
| 38 | 39 | |
| 39 | 40 | |
| 40 | 41 | |
| @@ -46,10 +47,10 @@ using namespace std; · 5 unmodified lines | ||
| 46 | 47 | class SerialIOManager |
| 47 | 48 | { |
| 48 | 49 | public: |
| 49 | − static vector<string> availableSerialDevices(); | |
| 50 | − | |
| 50 | + static std::vector<std::string> availableSerialDevices(); | |
| 51 | + | |
| 51 | 52 | private: |
| 52 | − static vector<string> s_availableSerialDevices; | |
| 53 | + static std::vector<std::string> s_availableSerialDevices; | |
| 53 | 54 | }; |
| 54 | 55 | |
| 55 | 56 | |
| @@ -57,7 +57,7 @@ · 56 unmodified lines | ||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | // XXX philipd this might break things? |
| 60 | −// these defines were placed after the machine-dependent | |
| 60 | +// these defines were placed after the machine-dependent | |
| 61 | 61 | // checks below...i'm not sure why |
| 62 | 62 | |
| 63 | 63 | #define COMPILER_IS_GCC 1 |
| @@ -163,7 +163,7 @@ · 99 unmodified lines | ||
| 163 | 163 | #endif |
| 164 | 164 | |
| 165 | 165 | #ifdef __LINUX_ALSA__ |
| 166 | −#define HAVE_ALSA_ASOUNDLIB_H | |
| 166 | +#define HAVE_ALSA_ASOUNDLIB_H | |
| 167 | 167 | #endif |
| 168 | 168 | |
| 169 | 169 | #if defined(__PLATFORM_LINUX__) |
| @@ -201,11 +201,11 @@ · 31 unmodified lines | ||
| 201 | 201 | |
| 202 | 202 | // XXX 'inline' is necessary for C compilation |
| 203 | 203 | // in the microsoft vc6 compiler... |
| 204 | −// and other ms win32 specialteez. | |
| 204 | +// and other ms win32 specialteez. | |
| 205 | 205 | |
| 206 | 206 | #ifdef __PLATFORM_WIN32__ |
| 207 | 207 | |
| 208 | −#define C_INLINE __inline | |
| 208 | +#define C_INLINE __inline | |
| 209 | 209 | #define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFF |
| 210 | 210 | |
| 211 | 211 | #else |
| @@ -421,7 +421,7 @@ typedef struct SNDFILE_tag SNDFILE ; · 209 unmodified lines | ||
| 421 | 421 | |
| 422 | 422 | |
| 423 | 423 | /* The following typedef is system specific and is defined when libsndfile is. |
| 424 | −** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), | |
| 424 | +** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD), | |
| 425 | 425 | ** off64_t (Solaris), __int64_t (Win32) etc. |
| 426 | 426 | */ |
| 427 | 427 | |
| @@ -1284,53 +1284,53 @@ int sf_dither_double (const SF_DITHER_INFO *dither, const double *in, double · 856 unmodified lines | ||
| 1284 | 1284 | */ |
| 1285 | 1285 | /* |
| 1286 | 1286 | ** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@mega-nerd.com> |
| 1287 | −** | |
| 1287 | +** | |
| 1288 | 1288 | ** This program is free software; you can redistribute it and/or modify |
| 1289 | 1289 | ** it under the terms of the GNU Lesser General Public License as published by |
| 1290 | 1290 | ** the Free Software Foundation; either version 2.1 of the License, or |
| 1291 | 1291 | ** (at your option) any later version. |
| 1292 | −** | |
| 1292 | +** | |
| 1293 | 1293 | ** This program is distributed in the hope that it will be useful, |
| 1294 | 1294 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1295 | 1295 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1296 | 1296 | ** GNU Lesser General Public License for more details. |
| 1297 | −** | |
| 1297 | +** | |
| 1298 | 1298 | ** You should have received a copy of the GNU Lesser General Public License |
| 1299 | −** along with this program; if not, write to the Free Software | |
| 1299 | +** along with this program; if not, write to the Free Software | |
| 1300 | 1300 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 1301 | 1301 | */ |
| 1302 | 1302 | |
| 1303 | 1303 | /* |
| 1304 | 1304 | ** This file is not the same as the original file from Sun Microsystems. Nearly |
| 1305 | −** all the original definitions and function prototypes that were in the file | |
| 1305 | +** all the original definitions and function prototypes that were in the file | |
| 1306 | 1306 | ** of this name have been moved to private.h. |
| 1307 | −*/ | |
| 1307 | +*/ | |
| 1308 | 1308 | |
| 1309 | 1309 | #ifndef G72X_HEADER_FILE |
| 1310 | 1310 | #define G72X_HEADER_FILE |
| 1311 | 1311 | |
| 1312 | −/* | |
| 1313 | −** Number of samples per block to process. | |
| 1312 | +/* | |
| 1313 | +** Number of samples per block to process. | |
| 1314 | 1314 | ** Must be a common multiple of possible bits per sample : 2, 3, 4, 5 and 8. |
| 1315 | 1315 | */ |
| 1316 | −#define G72x_BLOCK_SIZE (3*5*8) | |
| 1316 | +#define G72x_BLOCK_SIZE (3*5*8) | |
| 1317 | 1317 | |
| 1318 | −/* | |
| 1318 | +/* | |
| 1319 | 1319 | ** Identifiers for the differing kinds of G72x ADPCM codecs. |
| 1320 | 1320 | ** The identifiers also define the number of encoded bits per sample. |
| 1321 | 1321 | */ |
| 1322 | 1322 | |
| 1323 | 1323 | enum |
| 1324 | 1324 | { G723_16_BITS_PER_SAMPLE = 2, |
| 1325 | − G723_24_BITS_PER_SAMPLE = 3, | |
| 1326 | − G723_40_BITS_PER_SAMPLE = 5, | |
| 1325 | + G723_24_BITS_PER_SAMPLE = 3, | |
| 1326 | + G723_40_BITS_PER_SAMPLE = 5, | |
| 1327 | 1327 | |
| 1328 | 1328 | G721_32_BITS_PER_SAMPLE = 4, |
| 1329 | 1329 | G721_40_BITS_PER_SAMPLE = 5, |
| 1330 | 1330 | |
| 1331 | 1331 | G723_16_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, |
| 1332 | − G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE), | |
| 1333 | − G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE), | |
| 1332 | + G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE), | |
| 1333 | + G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE), | |
| 1334 | 1334 | |
| 1335 | 1335 | G721_32_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, |
| 1336 | 1336 | G721_40_SAMPLES_PER_BLOCK = G721_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G721_40_BITS_PER_SAMPLE), |
| @@ -1341,11 +1341,11 @@ enum · 4 unmodified lines | ||
| 1341 | 1341 | |
| 1342 | 1342 | G721_32_BYTES_PER_BLOCK = (G721_32_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 1343 | 1343 | G721_40_BYTES_PER_BLOCK = (G721_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8 |
| 1344 | −} ; | |
| 1344 | +} ; | |
| 1345 | 1345 | |
| 1346 | −/* | |
| 1346 | +/* | |
| 1347 | 1347 | ** This is the public structure for passing data between the caller and |
| 1348 | −** the G72x encoder and decoder. | |
| 1348 | +** the G72x encoder and decoder. | |
| 1349 | 1349 | ** The private array is used by the encoder and decoder for internal |
| 1350 | 1350 | ** state information and should not be changed in any way by the caller. |
| 1351 | 1351 | ** When decoding or encoding a stream, the same instance of this struct |
| @@ -1353,9 +1353,9 @@ enum · 1 unmodified line | ||
| 1353 | 1353 | ** correct state data between calls. |
| 1354 | 1354 | */ |
| 1355 | 1355 | |
| 1356 | −typedef struct | |
| 1356 | +typedef struct | |
| 1357 | 1357 | { /* Private data. Don't mess with it. */ |
| 1358 | − unsigned long sprivateo [256 / sizeof (long)] ; | |
| 1358 | + unsigned long sprivateo [256 / sizeof (long)] ; | |
| 1359 | 1359 | |
| 1360 | 1360 | /* Public data. Read only. */ |
| 1361 | 1361 | int blocksize, max_bytes, samplesperblock, bytesperblock ; |
| @@ -1377,23 +1377,23 @@ int g72x_writer_init (G72x_DATA *data, int codec) ; · 15 unmodified lines | ||
| 1377 | 1377 | |
| 1378 | 1378 | int g72x_decode_block (G72x_DATA *data) ; |
| 1379 | 1379 | /* |
| 1380 | −** The caller fills data->block with data->bytes bytes before calling the | |
| 1381 | −** function. The value data->bytes must be an integer multiple of | |
| 1380 | +** The caller fills data->block with data->bytes bytes before calling the | |
| 1381 | +** function. The value data->bytes must be an integer multiple of | |
| 1382 | 1382 | ** data->blocksize and be <= data->max_bytes. |
| 1383 | −** When it returns, the caller can read out data->samples samples. | |
| 1384 | −*/ | |
| 1383 | +** When it returns, the caller can read out data->samples samples. | |
| 1384 | +*/ | |
| 1385 | 1385 | |
| 1386 | 1386 | int g72x_encode_block (G72x_DATA *data) ; |
| 1387 | −/* | |
| 1387 | +/* | |
| 1388 | 1388 | ** The caller fills state->samples some integer multiple data->samples_per_block |
| 1389 | 1389 | ** (up to G72x_BLOCK_SIZE) samples before calling the function. |
| 1390 | −** When it returns, the caller can read out bytes encoded bytes. | |
| 1390 | +** When it returns, the caller can read out bytes encoded bytes. | |
| 1391 | 1391 | */ |
| 1392 | 1392 | |
| 1393 | 1393 | #endif /* !G72X_HEADER_FILE */ |
| 1394 | 1394 | /* |
| 1395 | 1395 | ** Do not edit or modify anything in this comment block. |
| 1396 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 1396 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 1397 | 1397 | ** revision control system. |
| 1398 | 1398 | ** |
| 1399 | 1399 | ** arch-tag: 6ca84e5f-f932-4ba1-87ee-37056d921621 |
| @@ -1432,10 +1432,10 @@ int g72x_encode_block (G72x_DATA *data) ; · 32 unmodified lines | ||
| 1432 | 1432 | /* |
| 1433 | 1433 | ** The following is the definition of the state structure used by the |
| 1434 | 1434 | ** G.721/G.723 encoder and decoder to preserve their internal state |
| 1435 | −** between successive calls. The meanings of the majority of the state | |
| 1436 | −** structure fields are explained in detail in the CCITT Recommendation | |
| 1437 | −** G.721. The field names are essentially identical to variable names | |
| 1438 | −** in the bit level description of the coding algorithm included in this | |
| 1435 | +** between successive calls. The meanings of the majority of the state | |
| 1436 | +** structure fields are explained in detail in the CCITT Recommendation | |
| 1437 | +** G.721. The field names are essentially identical to variable names | |
| 1438 | +** in the bit level description of the coding algorithm included in this | |
| 1439 | 1439 | ** Recommendation. |
| 1440 | 1440 | */ |
| 1441 | 1441 | |
| @@ -1463,19 +1463,19 @@ typedef struct private_g72x · 21 unmodified lines | ||
| 1463 | 1463 | ** format. |
| 1464 | 1464 | */ |
| 1465 | 1465 | char td; /* delayed tone detect, new in 1988 version */ |
| 1466 | − | |
| 1467 | − /* The following struct members were added for libsndfile. The original | |
| 1468 | − ** code worked by calling a set of functions on a sample by sample basis | |
| 1469 | − ** which is slow on architectures like Intel x86. For libsndfile, this | |
| 1466 | + | |
| 1467 | + /* The following struct members were added for libsndfile. The original | |
| 1468 | + ** code worked by calling a set of functions on a sample by sample basis | |
| 1469 | + ** which is slow on architectures like Intel x86. For libsndfile, this | |
| 1470 | 1470 | ** was changed so that the encoding and decoding routines could work on |
| 1471 | 1471 | ** a block of samples at a time to reduce the function call overhead. |
| 1472 | 1472 | */ |
| 1473 | 1473 | int (*encoder) (int, struct private_g72x* state) ; |
| 1474 | 1474 | int (*decoder) (int, struct private_g72x* state) ; |
| 1475 | − | |
| 1475 | + | |
| 1476 | 1476 | int codec_bits ; |
| 1477 | 1477 | int byte_index, sample_index ; |
| 1478 | − | |
| 1478 | + | |
| 1479 | 1479 | } G72x_STATE ; |
| 1480 | 1480 | |
| 1481 | 1481 | |
| @@ -1512,7 +1512,7 @@ void private_init_state (G72x_STATE *state_ptr) ; · 30 unmodified lines | ||
| 1512 | 1512 | #endif /* G72X_PRIVATE_H */ |
| 1513 | 1513 | /* |
| 1514 | 1514 | ** Do not edit or modify anything in this comment block. |
| 1515 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 1515 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 1516 | 1516 | ** revision control system. |
| 1517 | 1517 | ** |
| 1518 | 1518 | ** arch-tag: d9ad4da7-0fa3-471d-8020-720b5cfb5e5b |
| @@ -1615,7 +1615,7 @@ void endswap_long_copy (long *dest, long *src, int len) ; · 96 unmodified lines | ||
| 1615 | 1615 | |
| 1616 | 1616 | /* |
| 1617 | 1617 | ** Do not edit or modify anything in this comment block. |
| 1618 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 1618 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 1619 | 1619 | ** revision control system. |
| 1620 | 1620 | ** |
| 1621 | 1621 | ** arch-tag: f0c5cd54-42d3-4237-90ec-11fe24995de7 |
| @@ -1655,9 +1655,9 @@ typedef gsm_byte gsm_frame[33]; /* 33 * 8 bits */ · 33 unmodified lines | ||
| 1655 | 1655 | gsm gsm_create (void); |
| 1656 | 1656 | |
| 1657 | 1657 | /* Added for libsndfile : May 6, 2002 */ |
| 1658 | −void gsm_init (gsm); | |
| 1658 | +void gsm_init (gsm); | |
| 1659 | 1659 | |
| 1660 | −void gsm_destroy (gsm); | |
| 1660 | +void gsm_destroy (gsm); | |
| 1661 | 1661 | |
| 1662 | 1662 | int gsm_print (FILE *, gsm, gsm_byte *); |
| 1663 | 1663 | int gsm_option (gsm, int, int *); |
| @@ -1671,7 +1671,7 @@ void gsm_implode (gsm, gsm_signal *, gsm_byte *); · 7 unmodified lines | ||
| 1671 | 1671 | #endif /* GSM_H */ |
| 1672 | 1672 | /* |
| 1673 | 1673 | ** Do not edit or modify anything in this comment block. |
| 1674 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 1674 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 1675 | 1675 | ** revision control system. |
| 1676 | 1676 | ** |
| 1677 | 1677 | ** arch-tag: 8cfc7698-5433-4b6f-aeca-967c6fda4dec |
| @@ -1679,19 +1679,19 @@ void gsm_implode (gsm, gsm_signal *, gsm_byte *); · 1 unmodified line | ||
| 1679 | 1679 | |
| 1680 | 1680 | /* |
| 1681 | 1681 | ** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com> |
| 1682 | −** | |
| 1682 | +** | |
| 1683 | 1683 | ** This program is free software; you can redistribute it and/or modify |
| 1684 | 1684 | ** it under the terms of the GNU Lesser General Public License as published by |
| 1685 | 1685 | ** the Free Software Foundation; either version 2.1 of the License, or |
| 1686 | 1686 | ** (at your option) any later version. |
| 1687 | −** | |
| 1687 | +** | |
| 1688 | 1688 | ** This program is distributed in the hope that it will be useful, |
| 1689 | 1689 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1690 | 1690 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1691 | 1691 | ** GNU Lesser General Public License for more details. |
| 1692 | −** | |
| 1692 | +** | |
| 1693 | 1693 | ** You should have received a copy of the GNU Lesser General Public License |
| 1694 | −** along with this program; if not, write to the Free Software | |
| 1694 | +** along with this program; if not, write to the Free Software | |
| 1695 | 1695 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 1696 | 1696 | */ |
| 1697 | 1697 | |
| @@ -1711,7 +1711,7 @@ int au_g72x_writer_init (SF_PRIVATE *psf, int codec) ; · 13 unmodified lines | ||
| 1711 | 1711 | #endif /* AU_HEADER_FILE */ |
| 1712 | 1712 | /* |
| 1713 | 1713 | ** Do not edit or modify anything in this comment block. |
| 1714 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 1714 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 1715 | 1715 | ** revision control system. |
| 1716 | 1716 | ** |
| 1717 | 1717 | ** arch-tag: 63affc81-e204-4468-9705-60abe4d10689 |
| @@ -1748,9 +1748,13 @@ enum · 30 unmodified lines | ||
| 1748 | 1748 | { |
| 1749 | 1749 | /* keep sorted for wav_w64_format_str() */ |
| 1750 | 1750 | WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Corporation */ |
| 1751 | −#ifndef WAVE_FORMAT_PCM | |
| 1752 | − WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM format */ | |
| 1753 | −#endif | |
| 1751 | + WAVE_FORMAT_MS_PCM = 0x0001, /* Microsoft PCM format */ | |
| 1752 | + /* ------------------------------------------------------------------------- | |
| 1753 | + creating and using WAVE_FORMAT_MS_PCM in this module, as WAVE_FORMAT_PCM may | |
| 1754 | + be defined by windows, e.g., in mmeapi.h -- which breaks the build...thanks | |
| 1755 | + important: WAVE_FORMAT_MS_PCM must be 1, as WAV format tag | 1.5.0.0 (ge) | |
| 1756 | + ------------------------------------------------------------------------- */ | |
| 1757 | + /* WAVE_FORMAT_PCM = 0x0001, */ /* Microsoft PCM format */ | |
| 1754 | 1758 | WAVE_FORMAT_MS_ADPCM = 0x0002, /* Microsoft ADPCM */ |
| 1755 | 1759 | WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* Micrososft 32 bit float format */ |
| 1756 | 1760 | WAVE_FORMAT_VSELP = 0x0004, /* Compaq Computer Corporation */ |
| @@ -1995,60 +1999,60 @@ int wav_w64_read_fmt_chunk (SF_PRIVATE *psf, WAV_FMT *wav_fmt, int structsiz · 238 unmodified lines | ||
| 1995 | 1999 | #endif |
| 1996 | 2000 | /* |
| 1997 | 2001 | ** Do not edit or modify anything in this comment block. |
| 1998 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 2002 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 1999 | 2003 | ** revision control system. |
| 2000 | 2004 | ** |
| 2001 | 2005 | ** arch-tag: 877fde12-9be3-4a31-8a5a-fdae39958613 |
| 2002 | 2006 | */ |
| 2003 | 2007 | /* |
| 2004 | 2008 | ** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@mega-nerd.com> |
| 2005 | −** | |
| 2009 | +** | |
| 2006 | 2010 | ** This program is free software; you can redistribute it and/or modify |
| 2007 | 2011 | ** it under the terms of the GNU Lesser General Public License as published by |
| 2008 | 2012 | ** the Free Software Foundation; either version 2.1 of the License, or |
| 2009 | 2013 | ** (at your option) any later version. |
| 2010 | −** | |
| 2014 | +** | |
| 2011 | 2015 | ** This program is distributed in the hope that it will be useful, |
| 2012 | 2016 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2013 | 2017 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2014 | 2018 | ** GNU Lesser General Public License for more details. |
| 2015 | −** | |
| 2019 | +** | |
| 2016 | 2020 | ** You should have received a copy of the GNU Lesser General Public License |
| 2017 | −** along with this program; if not, write to the Free Software | |
| 2021 | +** along with this program; if not, write to the Free Software | |
| 2018 | 2022 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 2019 | 2023 | */ |
| 2020 | 2024 | |
| 2021 | 2025 | /* |
| 2022 | 2026 | ** This file is not the same as the original file from Sun Microsystems. Nearly |
| 2023 | −** all the original definitions and function prototypes that were in the file | |
| 2027 | +** all the original definitions and function prototypes that were in the file | |
| 2024 | 2028 | ** of this name have been moved to private.h. |
| 2025 | −*/ | |
| 2029 | +*/ | |
| 2026 | 2030 | |
| 2027 | 2031 | #ifndef G72X_HEADER_FILE |
| 2028 | 2032 | #define G72X_HEADER_FILE |
| 2029 | 2033 | |
| 2030 | −/* | |
| 2031 | −** Number of samples per block to process. | |
| 2034 | +/* | |
| 2035 | +** Number of samples per block to process. | |
| 2032 | 2036 | ** Must be a common multiple of possible bits per sample : 2, 3, 4, 5 and 8. |
| 2033 | 2037 | */ |
| 2034 | −#define G72x_BLOCK_SIZE (3*5*8) | |
| 2038 | +#define G72x_BLOCK_SIZE (3*5*8) | |
| 2035 | 2039 | |
| 2036 | −/* | |
| 2040 | +/* | |
| 2037 | 2041 | ** Identifiers for the differing kinds of G72x ADPCM codecs. |
| 2038 | 2042 | ** The identifiers also define the number of encoded bits per sample. |
| 2039 | 2043 | */ |
| 2040 | 2044 | |
| 2041 | 2045 | enum |
| 2042 | 2046 | { G723_16_BITS_PER_SAMPLE = 2, |
| 2043 | − G723_24_BITS_PER_SAMPLE = 3, | |
| 2044 | − G723_40_BITS_PER_SAMPLE = 5, | |
| 2047 | + G723_24_BITS_PER_SAMPLE = 3, | |
| 2048 | + G723_40_BITS_PER_SAMPLE = 5, | |
| 2045 | 2049 | |
| 2046 | 2050 | G721_32_BITS_PER_SAMPLE = 4, |
| 2047 | 2051 | G721_40_BITS_PER_SAMPLE = 5, |
| 2048 | 2052 | |
| 2049 | 2053 | G723_16_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, |
| 2050 | − G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE), | |
| 2051 | − G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE), | |
| 2054 | + G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE), | |
| 2055 | + G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE), | |
| 2052 | 2056 | |
| 2053 | 2057 | G721_32_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, |
| 2054 | 2058 | G721_40_SAMPLES_PER_BLOCK = G721_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G721_40_BITS_PER_SAMPLE), |
| @@ -2059,11 +2063,11 @@ enum · 4 unmodified lines | ||
| 2059 | 2063 | |
| 2060 | 2064 | G721_32_BYTES_PER_BLOCK = (G721_32_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 2061 | 2065 | G721_40_BYTES_PER_BLOCK = (G721_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8 |
| 2062 | −} ; | |
| 2066 | +} ; | |
| 2063 | 2067 | |
| 2064 | −/* | |
| 2068 | +/* | |
| 2065 | 2069 | ** This is the public structure for passing data between the caller and |
| 2066 | −** the G72x encoder and decoder. | |
| 2070 | +** the G72x encoder and decoder. | |
| 2067 | 2071 | ** The private array is used by the encoder and decoder for internal |
| 2068 | 2072 | ** state information and should not be changed in any way by the caller. |
| 2069 | 2073 | ** When decoding or encoding a stream, the same instance of this struct |
| @@ -2071,9 +2075,9 @@ enum · 1 unmodified line | ||
| 2071 | 2075 | ** correct state data between calls. |
| 2072 | 2076 | */ |
| 2073 | 2077 | |
| 2074 | −typedef struct | |
| 2078 | +typedef struct | |
| 2075 | 2079 | { /* Private data. Don't mess with it. */ |
| 2076 | − unsigned long sprivateo [256 / sizeof (long)] ; | |
| 2080 | + unsigned long sprivateo [256 / sizeof (long)] ; | |
| 2077 | 2081 | |
| 2078 | 2082 | /* Public data. Read only. */ |
| 2079 | 2083 | int blocksize, max_bytes, samplesperblock, bytesperblock ; |
| @@ -2095,23 +2099,23 @@ int g72x_writer_init (G72x_DATA *data, int codec) ; · 15 unmodified lines | ||
| 2095 | 2099 | |
| 2096 | 2100 | int g72x_decode_block (G72x_DATA *data) ; |
| 2097 | 2101 | /* |
| 2098 | −** The caller fills data->block with data->bytes bytes before calling the | |
| 2099 | −** function. The value data->bytes must be an integer multiple of | |
| 2102 | +** The caller fills data->block with data->bytes bytes before calling the | |
| 2103 | +** function. The value data->bytes must be an integer multiple of | |
| 2100 | 2104 | ** data->blocksize and be <= data->max_bytes. |
| 2101 | −** When it returns, the caller can read out data->samples samples. | |
| 2102 | −*/ | |
| 2105 | +** When it returns, the caller can read out data->samples samples. | |
| 2106 | +*/ | |
| 2103 | 2107 | |
| 2104 | 2108 | int g72x_encode_block (G72x_DATA *data) ; |
| 2105 | −/* | |
| 2109 | +/* | |
| 2106 | 2110 | ** The caller fills state->samples some integer multiple data->samples_per_block |
| 2107 | 2111 | ** (up to G72x_BLOCK_SIZE) samples before calling the function. |
| 2108 | −** When it returns, the caller can read out bytes encoded bytes. | |
| 2112 | +** When it returns, the caller can read out bytes encoded bytes. | |
| 2109 | 2113 | */ |
| 2110 | 2114 | |
| 2111 | 2115 | #endif /* !G72X_HEADER_FILE */ |
| 2112 | 2116 | /* |
| 2113 | 2117 | ** Do not edit or modify anything in this comment block. |
| 2114 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 2118 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 2115 | 2119 | ** revision control system. |
| 2116 | 2120 | ** |
| 2117 | 2121 | ** arch-tag: 6ca84e5f-f932-4ba1-87ee-37056d921621 |
| @@ -2129,7 +2133,7 @@ int g72x_encode_block (G72x_DATA *data) ; · 11 unmodified lines | ||
| 2129 | 2133 | /* Added by Erik de Castro Lopo */ |
| 2130 | 2134 | #define USE_FLOAT_MUL |
| 2131 | 2135 | #define FAST |
| 2132 | −#define WAV49 | |
| 2136 | +#define WAV49 | |
| 2133 | 2137 | /* Added by Erik de Castro Lopo */ |
| 2134 | 2138 | |
| 2135 | 2139 | |
| @@ -2140,7 +2144,7 @@ typedef int longword; /* 32 bit signed int */ · 4 unmodified lines | ||
| 2140 | 2144 | typedef unsigned short uword; /* unsigned word */ |
| 2141 | 2145 | typedef unsigned int ulongword; /* unsigned longword */ |
| 2142 | 2146 | |
| 2143 | −struct gsm_state | |
| 2147 | +struct gsm_state | |
| 2144 | 2148 | { word dp0[ 280 ] ; |
| 2145 | 2149 | |
| 2146 | 2150 | word z1; /* preprocessing.c, Offset_com. */ |
| @@ -2212,7 +2216,7 @@ longword gsm_L_asr (longword a, int n) ; · 65 unmodified lines | ||
| 2212 | 2216 | word gsm_asr (word a, int n) ; |
| 2213 | 2217 | |
| 2214 | 2218 | /* |
| 2215 | − * Inlined functions from add.h | |
| 2219 | + * Inlined functions from add.h | |
| 2216 | 2220 | */ |
| 2217 | 2221 | |
| 2218 | 2222 | static C_INLINE longword |
| @@ -2233,17 +2237,17 @@ GSM_L_MULT (word a, word b) · 14 unmodified lines | ||
| 2233 | 2237 | static C_INLINE longword |
| 2234 | 2238 | GSM_L_ADD (longword a, longword b) |
| 2235 | 2239 | { ulongword utmp ; |
| 2236 | − | |
| 2240 | + | |
| 2237 | 2241 | if (a < 0 && b < 0) |
| 2238 | 2242 | { utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1) ; |
| 2239 | 2243 | return (utmp >= (ulongword) MAX_LONGWORD) ? MIN_LONGWORD : -(longword)utmp-2 ; |
| 2240 | 2244 | } ; |
| 2241 | − | |
| 2245 | + | |
| 2242 | 2246 | if (a > 0 && b > 0) |
| 2243 | 2247 | { utmp = (ulongword) a + (ulongword) b ; |
| 2244 | 2248 | return (utmp >= (ulongword) MAX_LONGWORD) ? MAX_LONGWORD : utmp ; |
| 2245 | 2249 | } ; |
| 2246 | − | |
| 2250 | + | |
| 2247 | 2251 | return a + b ; |
| 2248 | 2252 | } /* GSM_L_ADD */ |
| 2249 | 2253 | |
| @@ -2266,12 +2270,12 @@ GSM_SUB (word a, word b) · 16 unmodified lines | ||
| 2266 | 2270 | { longword ltmp ; |
| 2267 | 2271 | |
| 2268 | 2272 | ltmp = ((longword) a) - ((longword) b) ; |
| 2269 | − | |
| 2273 | + | |
| 2270 | 2274 | if (ltmp >= MAX_WORD) |
| 2271 | 2275 | ltmp = MAX_WORD ; |
| 2272 | 2276 | else if (ltmp <= MIN_WORD) |
| 2273 | 2277 | ltmp = MIN_WORD ; |
| 2274 | − | |
| 2278 | + | |
| 2275 | 2279 | return ltmp ; |
| 2276 | 2280 | } /* GSM_SUB */ |
| 2277 | 2281 | |
| @@ -2319,10 +2323,10 @@ void Gsm_Preprocess ( · 41 unmodified lines | ||
| 2319 | 2323 | |
| 2320 | 2324 | void Gsm_Encoding ( |
| 2321 | 2325 | struct gsm_state * S, |
| 2322 | − word * e, | |
| 2323 | − word * ep, | |
| 2326 | + word * e, | |
| 2327 | + word * ep, | |
| 2324 | 2328 | word * xmaxc, |
| 2325 | − word * Mc, | |
| 2329 | + word * Mc, | |
| 2326 | 2330 | word * xMc) ; |
| 2327 | 2331 | |
| 2328 | 2332 | void Gsm_Short_Term_Analysis_Filter ( |
| @@ -2415,7 +2419,7 @@ extern word gsm_FAC [8] ; · 86 unmodified lines | ||
| 2415 | 2419 | #endif /* PRIVATE_H */ |
| 2416 | 2420 | /* |
| 2417 | 2421 | ** Do not edit or modify anything in this comment block. |
| 2418 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 2422 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 2419 | 2423 | ** revision control system. |
| 2420 | 2424 | ** |
| 2421 | 2425 | ** arch-tag: 8bc5fdf2-e8c8-4686-9bd7-a30b512bef0c |
| @@ -2582,8 +2586,8 @@ extern word gsm_FAC [8] ; · 160 unmodified lines | ||
| 2582 | 2586 | { int res [2] ; |
| 2583 | 2587 | |
| 2584 | 2588 | __asm__ __volatile__ |
| 2585 | − ( "fctiw %1, %1\n\t" | |
| 2586 | − "stfd %1, %0" | |
| 2589 | + ( "fctiw %1, %1\n\t" | |
| 2590 | + "stfd %1, %0" | |
| 2587 | 2591 | : "=m" (res) /* Output */ |
| 2588 | 2592 | : "f" (in) /* Input */ |
| 2589 | 2593 | : "memory" |
| @@ -2597,8 +2601,8 @@ extern word gsm_FAC [8] ; · 7 unmodified lines | ||
| 2597 | 2601 | { int res [2] ; |
| 2598 | 2602 | |
| 2599 | 2603 | __asm__ __volatile__ |
| 2600 | − ( "fctiw %1, %1\n\t" | |
| 2601 | − "stfd %1, %0" | |
| 2604 | + ( "fctiw %1, %1\n\t" | |
| 2605 | + "stfd %1, %0" | |
| 2602 | 2606 | : "=m" (res) /* Output */ |
| 2603 | 2607 | : "f" (in) /* Input */ |
| 2604 | 2608 | : "memory" |
| @@ -2623,7 +2627,7 @@ extern word gsm_FAC [8] ; · 18 unmodified lines | ||
| 2623 | 2627 | |
| 2624 | 2628 | /* |
| 2625 | 2629 | ** Do not edit or modify anything in this comment block. |
| 2626 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 2630 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 2627 | 2631 | ** revision control system. |
| 2628 | 2632 | ** |
| 2629 | 2633 | ** arch-tag: 42db1693-ff61-4051-bac1-e4d24c4e30b7 |
| @@ -2712,7 +2716,7 @@ extern word gsm_FAC [8] ; · 82 unmodified lines | ||
| 2712 | 2716 | */ |
| 2713 | 2717 | /* |
| 2714 | 2718 | ** Do not edit or modify anything in this comment block. |
| 2715 | −** The arch-tag line is a file identity tag for the GNU Arch | |
| 2719 | +** The arch-tag line is a file identity tag for the GNU Arch | |
| 2716 | 2720 | ** revision control system. |
| 2717 | 2721 | ** |
| 2718 | 2722 | ** arch-tag: 253aea6d-6299-46fd-8d06-bc5f6224c8fe |
| @@ -55,7 +55,7 @@ std::string ltrim( const std::string & val ); · 54 unmodified lines | ||
| 55 | 55 | std::string rtrim( const std::string & val ); |
| 56 | 56 | |
| 57 | 57 | // argument extraction |
| 58 | −t_CKBOOL extract_args( const std::string & token, | |
| 58 | +t_CKBOOL extract_args( const std::string & token, | |
| 59 | 59 | std::string & filename, |
| 60 | 60 | std::vector<std::string> & args ); |
| 61 | 61 | |
| @@ -66,8 +66,9 @@ std::string dir_go_up( const std::string & dir, t_CKINT numUp ); · 4 unmodified lines | ||
| 66 | 66 | std::string get_full_path( const std::string & fp ); |
| 67 | 67 | |
| 68 | 68 | // currently just expands ~ to HOME and ~user to user's home directory |
| 69 | −std::string expand_filepath( std::string & fp ); | |
| 69 | +std::string expand_filepath( std::string & fp, t_CKBOOL ensurePathExists = TRUE ); | |
| 70 | 70 | |
| 71 | +// get directory portion of a filepath (minus the file itself) | |
| 71 | 72 | std::string extract_filepath_dir(std::string &filepath); |
| 72 | 73 | |
| 73 | 74 | // convert \ to / (on Windows) |
| @@ -75,7 +76,10 @@ std::string normalize_directory_separator(const std::string &filepath); · 1 unmodified line | ||
| 75 | 76 | |
| 76 | 77 | // determine if the last characters of str match end exactly |
| 77 | 78 | // e.g. to test file extension |
| 78 | −int str_endsin(const char *str, const char *end); | |
| 79 | +t_CKBOOL str_endsin(const char *str, const char *end); | |
| 80 | + | |
| 81 | +// check if path is absolute on the underlying platform | |
| 82 | +t_CKBOOL is_absolute_path( const std::string & path ); | |
| 79 | 83 | |
| 80 | 84 | //----------------------------------------------------------------------------- |
| 81 | 85 | // name: parse_path_list() |
| @@ -148,47 +148,47 @@ protected: · 147 unmodified lines | ||
| 148 | 148 | //----------------------------------------------------------------------------- |
| 149 | 149 | // name: XWriteThread() |
| 150 | 150 | // desc: utility class for scheduling writes to be executed on a separate |
| 151 | −// thread. | |
| 151 | +// thread. | |
| 152 | 152 | //----------------------------------------------------------------------------- |
| 153 | 153 | class XWriteThread |
| 154 | 154 | { |
| 155 | 155 | public: |
| 156 | − // get the shared instance | |
| 156 | + // get the shared instance | |
| 157 | 157 | static XWriteThread * shared(); |
| 158 | 158 | // static buffer size |
| 159 | 159 | const static size_t PRODUCER_BUFFER_SIZE; |
| 160 | 160 | |
| 161 | 161 | public: |
| 162 | − // constructor | |
| 162 | + // constructor | |
| 163 | 163 | XWriteThread( size_t data_buffer_size = 4096, size_t msg_buffer_size = 32 ); |
| 164 | − | |
| 164 | + | |
| 165 | 165 | public: |
| 166 | 166 | size_t fwrite( const void * ptr, size_t size, size_t nitems, FILE * stream ); |
| 167 | 167 | int fseek( FILE * stream, long offset, int whence ); |
| 168 | 168 | int fflush( FILE * stream ); |
| 169 | 169 | int fclose( FILE * stream ); |
| 170 | − | |
| 170 | + | |
| 171 | 171 | // DO NOT DELETE INSTANCES OF XWriteThread |
| 172 | 172 | // instead call shutdown and they will be cleaned up in the background |
| 173 | 173 | void shutdown(); |
| 174 | 174 | |
| 175 | −private: | |
| 175 | +private: | |
| 176 | 176 | // DO NOT DELETE INSTANCES OF XWriteThread |
| 177 | 177 | // instead call shutdown and they will be cleaned up in the background |
| 178 | 178 | ~XWriteThread(); |
| 179 | 179 | |
| 180 | − // flush | |
| 180 | + // flush | |
| 181 | 181 | void flush_data_buffer(); |
| 182 | 182 | |
| 183 | − // callback | |
| 183 | + // callback | |
| 184 | 184 | #if ( defined(__PLATFORM_MACOSX__) || defined(__PLATFORM_LINUX__) || defined(__WINDOWS_PTHREAD__) ) |
| 185 | 185 | static void * write_cb( void * _thiss ); |
| 186 | 186 | #elif defined(__PLATFORM_WIN32__) |
| 187 | 187 | static unsigned THREAD_TYPE write_cb( void * _thiss ); |
| 188 | 188 | #endif |
| 189 | 189 | |
| 190 | − // shared instance | |
| 191 | − static XWriteThread * o_defaultWriteThread; | |
| 190 | + // shared instance | |
| 191 | + static XWriteThread * o_defaultWriteThread; | |
| 192 | 192 | |
| 193 | 193 | private: |
| 194 | 194 | t_CKBOOL m_thread_exit; |
| @@ -198,10 +198,10 @@ private: · 3 unmodified lines | ||
| 198 | 198 | t_CKBYTE * m_thread_buffer; |
| 199 | 199 | FILE * m_stream; |
| 200 | 200 | |
| 201 | − // internal message format | |
| 201 | + // internal message format | |
| 202 | 202 | struct Message |
| 203 | 203 | { |
| 204 | − // operation type | |
| 204 | + // operation type | |
| 205 | 205 | enum |
| 206 | 206 | { |
| 207 | 207 | WRITE, |
| @@ -210,18 +210,18 @@ private: · 2 unmodified lines | ||
| 210 | 210 | CLOSE, |
| 211 | 211 | SHUTDOWN |
| 212 | 212 | } operation; |
| 213 | − | |
| 214 | − // file pointer | |
| 213 | + | |
| 214 | + // file pointer | |
| 215 | 215 | FILE * file; |
| 216 | − | |
| 217 | − // size / offset | |
| 216 | + | |
| 217 | + // size / offset | |
| 218 | 218 | union |
| 219 | 219 | { |
| 220 | 220 | struct |
| 221 | 221 | { |
| 222 | 222 | size_t data_size; |
| 223 | 223 | } write; |
| 224 | − | |
| 224 | + | |
| 225 | 225 | struct |
| 226 | 226 | { |
| 227 | 227 | long offset; |
| @@ -233,7 +233,7 @@ private: · 5 unmodified lines | ||
| 233 | 233 | Message() : file(NULL) { } |
| 234 | 234 | }; |
| 235 | 235 | |
| 236 | − // circular buffer | |
| 236 | + // circular buffer | |
| 237 | 237 | CircularBuffer<Message> * m_msg_buffer; |
| 238 | 238 | }; |
| 239 | 239 | |