History

a bit batch of #chunreal refactor

Ge Wang committed 3 years ago

Commit 9aac3a41 parent a46220614 files · +195 −124Browse files

Unified · Split

14 files
  1. src/core/chuck_compile.cpp +26 −14
  2. src/core/chuck_def.h +8 −4
  3. src/core/chuck_dl.cpp +13 −1
  4. src/core/chuck_frame.cpp +2 −2
  5. src/core/chuck_instr.cpp +45 −40
  6. src/core/chuck_io.cpp +6 −2
  7. src/core/chuck_oo.cpp +18 −7
  8. src/core/chuck_oo.h +2 −2
  9. src/core/chuck_parse.cpp +27 −12
  10. src/core/chuck_scan.cpp +2 −1
  11. src/core/chuck_symbol.cpp +2 −2
  12. src/core/chuck_ugen.cpp +18 −25
  13. src/core/chuck_vm.cpp +16 −11
  14. src/core/dirent_win32.h +10 −1
src/core/chuck_compile.cpp+26−14
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "chuck_compile.h"
3333 #include "chuck_lang.h"
3434 #include "chuck_errmsg.h"
35+#include "chuck_io.h"
3536 #ifndef __DISABLE_OTF_SERVER__
3637 #include "chuck_otf.h"
3738 #endif
@@ -52,8 +53,10 @@ · 14 unmodified lines
5253 #include "ulib_opsc.h"
5354 #endif
5455
56+// 1.5.0.0 (ge) | chunreal
57+#ifndef __DISABLE_REGEX__
5558 #include "ulib_regex.h"
56−#include "chuck_io.h"
59+#endif
5760
5861 #if defined(__PLATFORM_WIN32__)
5962 #include "dirent_win32.h"
@@ -400,8 +403,8 @@ t_CKBOOL Chuck_Compiler::do_only_classes( Chuck_Context * context ) · 340 unmodified lines
400403 return FALSE;
401404
402405 // emit (pass 4)
403− if( !(code = emit_engine_emit_prog( emitter, g_program , te_do_classes_only )) )
404− return FALSE;
406+ code = emit_engine_emit_prog( emitter, g_program , te_do_classes_only );
407+ if( !code ) return FALSE;
405408
406409 // set the state of the context to done
407410 context->progress = Chuck_Context::P_ALL_DONE;
@@ -433,8 +436,8 @@ t_CKBOOL Chuck_Compiler::do_all_except_classes( Chuck_Context * context ) · 25 unmodified lines
433436 return FALSE;
434437
435438 // emit (pass 4)
436− if( !(code = emit_engine_emit_prog( emitter, g_program, te_do_no_classes )) )
437− return FALSE;
439+ code = emit_engine_emit_prog( emitter, g_program, te_do_no_classes );
440+ if( !code ) return FALSE;
438441
439442 // set the state of the context to done
440443 context->progress = Chuck_Context::P_ALL_DONE;
@@ -490,8 +493,8 @@ t_CKBOOL Chuck_Compiler::do_normal_depend( const string & filename, FILE * fd, · 49 unmodified lines
490493 { ret = FALSE; goto cleanup; }
491494
492495 // emit (pass 4)
493− if( !(code = emit_engine_emit_prog( emitter, g_program, te_do_all )) )
494− { ret = FALSE; goto cleanup; }
496+ code = emit_engine_emit_prog( emitter, g_program, te_do_all );
497+ if( !code ) { ret = FALSE; goto cleanup; }
495498
496499 cleanup:
497500
@@ -543,7 +546,8 @@ t_CKBOOL Chuck_Compiler::do_auto_depend( const string & filename, FILE * fd, · 45 unmodified lines
543546 { ret = FALSE; goto cleanup; }
544547
545548 // get the code
546− if( !(code = context->code()) )
549+ code = context->code();
550+ if( !code )
547551 {
548552 ret = FALSE;
549553 EM_error2( 0, "internal error: context->code() NULL!" );
@@ -633,8 +637,8 @@ t_CKBOOL load_module( Chuck_Compiler * compiler, Chuck_Env * env, f_ck_query que · 83 unmodified lines
633637 // load osc
634638 dll = new Chuck_DLL( compiler->carrier(), name );
635639 // (fixed: 1.3.0.0) query_failed now catches either failure of load or query
636− if( (query_failed = !(dll->load( query ) && dll->query())) ||
637− !type_engine_add_dll( env, dll, nspc ) )
640+ query_failed = !(dll->load( query ) && dll->query());
641+ if( query_failed || !type_engine_add_dll( env, dll, nspc ) )
638642 {
639643 CK_FPRINTF_STDERR(
640644 "[chuck]: internal error loading module '%s.%s'...\n",
@@ -709,8 +713,10 @@ t_CKBOOL load_internal_modules( Chuck_Compiler * compiler ) · 68 unmodified lines
709713 if( !load_module( compiler, env, opensoundcontrol_query, "opsc", "global" ) ) goto error;
710714 #endif
711715
716+ #ifndef __DISABLE_REGEX__
712717 EM_log( CK_LOG_SEVERE, "module 'RegEx'" );
713718 if( !load_module( compiler, env, regex_query, "RegEx", "global" ) ) goto error;
719+ #endif
714720
715721 // deprecated:
716722 // if( !load_module( compiler, env, net_query, "net", "global" ) ) goto error;
@@ -770,8 +776,9 @@ t_CKBOOL load_external_module_at_path( Chuck_Compiler * compiler, · 53 unmodified lines
770776 Chuck_DLL * dll = new Chuck_DLL( compiler->carrier(), name );
771777 t_CKBOOL query_failed = FALSE;
772778
773− if((query_failed = !(dll->load(dl_path) && dll->query())) ||
774− !type_engine_add_dll2(env, dll, "global"))
779+ // try to load and query
780+ query_failed = !(dll->load(dl_path) && dll->query());
781+ if( query_failed || !type_engine_add_dll2(env, dll, "global"))
775782 {
776783 EM_pushlog();
777784 EM_log(CK_LOG_SEVERE, "cannot load chugin '%s', skipping...", name);
@@ -848,9 +855,11 @@ t_CKBOOL load_external_modules_in_directory( Chuck_Compiler * compiler, · 70 unmodified lines
848855 // log
849856 EM_log( CK_LOG_INFO, "examining directory '%s' for chugins", directory );
850857
851− struct dirent *de = NULL;
858+ // do first read | 1.5.0.0 (ge + eito) #chunreal
859+ struct dirent * de = readdir(dir);
852860
853− while( (de = readdir(dir)) )
861+ // while( (de = readdir(dir)) ) <- in ge's opinion clearer than what UE5 forces us to do
862+ while( de != NULL )
854863 {
855864 t_CKBOOL is_regular = false;
856865 t_CKBOOL is_directory = false;
@@ -909,6 +918,9 @@ t_CKBOOL load_external_modules_in_directory( Chuck_Compiler * compiler, · 52 unmodified lines
909918 extension);
910919 }
911920 }
921+
922+ // read next | 1.5.0.0 (ge) moved here due to #chunreal
923+ de = readdir( dir );
912924 }
913925
914926 // close
src/core/chuck_def.h+8−4
@@ -37,7 +37,6 @@ · 36 unmodified lines
3737 #include <memory.h>
3838 #include <assert.h>
3939
40−
4140 // types
4241 #ifndef __EMSCRIPTEN__
4342 #define t_CKTIME double
@@ -193,8 +192,13 @@ typedef struct { SAMPLE re ; SAMPLE im ; } t_CKCOMPLEX_SAMPLE; · 149 unmodified lines
193192
194193 #ifdef __PLATFORM_WIN32__
195194 #ifndef usleep
196− #define usleep(x) Sleep( (x / 1000 <= 0 ? 1 : x / 1000) )
197−#endif
195+ #ifndef __CHUNREAL_ENGINE__
196+ #define usleep(x) Sleep((x / 1000 <= 0 ? 1 : x / 1000) )
197+ #else
198+ // 1.5.0.0 (ge) | #chunreal
199+ #define usleep(x) FPlatformProcess::Sleep( x/1000000.0f <= 0 ? .001 : x/1000000.0f );
200+ #endif // #ifndef __UNREAL_ENGINE__
201+#endif // #ifndef usleep
198202 // 1.4.2.0 (ge and spencer) | added for legacy windows, as part of switch to snprintf
199203 // https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
200204 #if defined(_MSC_VER) && _MSC_VER < 1900
@@ -207,7 +211,7 @@ typedef struct { SAMPLE re ; SAMPLE im ; } t_CKCOMPLEX_SAMPLE; · 6 unmodified lines
207211 #pragma warning (disable : 4244) // truncation
208212 #pragma warning (disable : 4068) // unknown pragma
209213 #pragma warning (disable : 4018) // signed/unsigned mismatch
210−#endif
214+#endif // #ifdef __PLATFORM_WIN32__
211215
212216 #ifdef __CHIP_MODE__
213217 #define __DISABLE_MIDI__
src/core/chuck_dl.cpp+13−1
@@ -1313,11 +1313,23 @@ set_string(ck_set_string) · 1312 unmodified lines
13131313 #if defined(__PLATFORM_WIN32__)
13141314 extern "C"
13151315 {
1316−#include <windows.h>
1316+#ifndef __CHUNREAL_ENGINE__
1317+ #include <windows.h>
1318+#else
1319+ // 1.5.0.0 (ge) | #chunreal
1320+ // unreal engine on windows disallows including windows.h
1321+ #include "Windows/MinWindows.h"
1322+#endif // #ifndef __CHUNREAL_ENGINE__
13171323
13181324 void *dlopen( const char *path, int mode )
13191325 {
1326+#ifndef __CHUNREAL_ENGINE__
13201327 return (void *)LoadLibrary(path);
1328+#else
1329+ // 1.5.0.0 (ge) | #chunreal; explicitly call ASCII version
1330+ // the build envirnment seems to force UNICODE
1331+ return (void *)LoadLibraryA(path);
1332+#endif
13211333 }
13221334
13231335 int dlclose( void *handle )
src/core/chuck_frame.cpp+2−2
@@ -56,7 +56,7 @@ Chuck_Frame::Chuck_Frame() · 55 unmodified lines
5656 // name: alloc_local()
5757 // desc: ...
5858 //-----------------------------------------------------------------------------
59−Chuck_Local * Chuck_Frame::alloc_local( t_CKUINT size, const string & name,
59+Chuck_Local * Chuck_Frame::alloc_local( t_CKUINT size, const string & theName,
6060 t_CKBOOL is_ref, t_CKBOOL is_obj, t_CKBOOL is_global )
6161 {
6262 // alloc
@@ -74,7 +74,7 @@ Chuck_Local * Chuck_Frame::alloc_local( t_CKUINT size, const string & name, · 11 unmodified lines
7474 // the next offset
7575 this->curr_offset += local->size;
7676 // name
77− local->name = name;
77+ local->name = theName;
7878 // push the local
7979 this->stack.push_back( local );
8080
src/core/chuck_instr.cpp+45−40
@@ -69,7 +69,13 @@ Chuck_Instr::Chuck_Instr() · 68 unmodified lines
6969 //-----------------------------------------------------------------------------
7070 const char * Chuck_Instr::name() const
7171 {
72− return mini_type( typeid(*this).name() );
72+#ifndef __CHUNREAL_ENGINE__
73+ return mini_type( typeid(*this).name() );
74+#else
75+ // 1.5.0.0 (ge) | #chureal
76+ // Unreal Engine seems to disable C++ run time type information
77+ return "[chunreal type info disabled]";
78+#endif // #ifndef __CHUNREAL_ENGINE__
7379 }
7480
7581
@@ -3861,15 +3867,15 @@ t_CKBOOL initialize_object( Chuck_Object * object, Chuck_Type * type ) · 3785 unmodified lines
38613867 // reference count
38623868 SAFE_ADD_REF(object->type_ref);
38633869 // get the size
3864− object->size = type->obj_size;
3870+ object->data_size = type->obj_size;
38653871 // allocate memory
3866− if( object->size )
3872+ if( object->data_size )
38673873 {
38683874 // check to ensure enough memory
3869− object->data = new t_CKBYTE[object->size];
3875+ object->data = new t_CKBYTE[object->data_size];
38703876 if( !object->data ) goto out_of_memory;
38713877 // zero it out
3872− memset( object->data, 0, object->size );
3878+ memset( object->data, 0, object->data_size );
38733879 }
38743880 else object->data = NULL;
38753881
@@ -5472,7 +5478,7 @@ Chuck_Object * do_alloc_array( Chuck_VM * vm, // REFACTOR-2017: added · 1596 unmodified lines
54725478 Chuck_Type * type )
54735479 {
54745480 // not top level
5475− Chuck_Array4 * base = NULL;
5481+ Chuck_Array4 * theBase = NULL;
54765482 Chuck_Object * next = NULL;
54775483 Chuck_Type * typeNext = NULL;
54785484 t_CKINT i = 0;
@@ -5487,8 +5493,8 @@ Chuck_Object * do_alloc_array( Chuck_VM * vm, // REFACTOR-2017: added · 8 unmodified lines
54875493 // 1.3.1.0: look at type to use kind instead of size
54885494 if( kind == kindof_INT ) // ISSUE: 64-bit (fixed 1.3.1.0)
54895495 {
5490− Chuck_Array4 * base = new Chuck_Array4( is_obj, *capacity );
5491− if( !base ) goto out_of_memory;
5496+ Chuck_Array4 * baseX = new Chuck_Array4( is_obj, *capacity );
5497+ if( !baseX ) goto out_of_memory;
54925498
54935499 // if object
54945500 if( is_obj && objs )
@@ -5497,59 +5503,59 @@ Chuck_Object * do_alloc_array( Chuck_VM * vm, // REFACTOR-2017: added · 2 unmodified lines
54975503 for( i = 0; i < *capacity; i++ )
54985504 {
54995505 // add to array for later allocation
5500− objs[index++] = base->addr( i );
5506+ objs[index++] = baseX->addr( i );
55015507 }
55025508 }
55035509
55045510 // initialize object | 1.5.0.0 (ge) use array type instead of base t_array
55055511 // for the object->type_ref to contain more specific information
5506− initialize_object( base, type );
5507− // initialize_object( base, vm->env()->t_array );
5508− return base;
5512+ initialize_object( baseX, type );
5513+ // initialize_object( baseX, vm->env()->t_array );
5514+ return baseX;
55095515 }
55105516 else if( kind == kindof_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0)
55115517 {
5512− Chuck_Array8 * base = new Chuck_Array8( *capacity );
5513− if( !base ) goto out_of_memory;
5518+ Chuck_Array8 * baseX = new Chuck_Array8( *capacity );
5519+ if( !baseX ) goto out_of_memory;
55145520
55155521 // initialize object | 1.5.0.0 (ge) use array type instead of base t_array
55165522 // for the object->type_ref to contain more specific information
5517− initialize_object( base, type );
5518− // initialize_object( base, vm->env()->t_array );
5519− return base;
5523+ initialize_object( baseX, type );
5524+ // initialize_object( baseX, vm->env()->t_array );
5525+ return baseX;
55205526 }
55215527 else if( kind == kindof_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0)
55225528 {
5523− Chuck_Array16 * base = new Chuck_Array16( *capacity );
5524− if( !base ) goto out_of_memory;
5529+ Chuck_Array16 * baseX = new Chuck_Array16( *capacity );
5530+ if( !baseX ) goto out_of_memory;
55255531
55265532 // initialize object | 1.5.0.0 (ge) use array type instead of base t_array
55275533 // for the object->type_ref to contain more specific information
5528− initialize_object( base, type );
5529− // initialize_object( base, vm->env()->t_array );
5530− return base;
5534+ initialize_object( baseX, type );
5535+ // initialize_object( baseX, vm->env()->t_array );
5536+ return baseX;
55315537 }
55325538 else if( kind == kindof_VEC3 ) // 1.3.5.3
55335539 {
5534− Chuck_Array24 * base = new Chuck_Array24( *capacity );
5535− if( !base ) goto out_of_memory;
5540+ Chuck_Array24 * baseX = new Chuck_Array24( *capacity );
5541+ if( !baseX ) goto out_of_memory;
55365542
55375543 // initialize object | 1.5.0.0 (ge) use array type instead of base t_array
55385544 // for the object->type_ref to contain more specific information
5539− initialize_object( base, type );
5540− // initialize_object( base, vm->env()->t_array );
5541− return base;
5545+ initialize_object( baseX, type );
5546+ // initialize_object( baseX, vm->env()->t_array );
5547+ return baseX;
55425548 }
55435549 else if( kind == kindof_VEC4 ) // 1.3.5.3
55445550 {
5545− Chuck_Array32 * base = new Chuck_Array32( *capacity );
5546− if( !base ) goto out_of_memory;
5551+ Chuck_Array32 * baseX = new Chuck_Array32( *capacity );
5552+ if( !baseX ) goto out_of_memory;
55475553
55485554 // initialize object | 1.5.0.0 (ge) use array type instead of base t_array
55495555 // for the object->type_ref to contain more specific information
5550− initialize_object( base, type );
5551− // initialize_object( base, vm->env()->t_array );
5552− return base;
5556+ initialize_object( baseX, type );
5557+ // initialize_object( baseX, vm->env()->t_array );
5558+ return baseX;
55535559 }
55545560
55555561 // shouldn't get here
@@ -5557,8 +5563,8 @@ Chuck_Object * do_alloc_array( Chuck_VM * vm, // REFACTOR-2017: added · 1 unmodified line
55575563 }
55585564
55595565 // not top level
5560− base = new Chuck_Array4( TRUE, *capacity );
5561− if( !base ) goto out_of_memory;
5566+ theBase = new Chuck_Array4( TRUE, *capacity );
5567+ if( !theBase) goto out_of_memory;
55625568
55635569 // construct type for next array level | 1.5.0.0 (ge) added
55645570 typeNext = type->copy( vm->env() );
@@ -5575,15 +5581,14 @@ Chuck_Object * do_alloc_array( Chuck_VM * vm, // REFACTOR-2017: added · 10 unmodified lines
55755581 // error if NULL
55765582 if( !next ) goto error;
55775583 // set that, with ref count
5578− base->set( i, (t_CKUINT)next );
5584+ theBase->set( i, (t_CKUINT)next );
55795585 }
55805586
55815587 // initialize object | 1.5.0.0 (ge) use array type instead of base t_array
55825588 // for the object->type_ref to contain more specific information
5583− initialize_object( base, type );
5584− // initialize_object( base, vm->env()->t_array );
5585−
5586− return base;
5589+ initialize_object( theBase, type );
5590+ // initialize_object( theBase, vm->env()->t_array );
5591+ return theBase;
55875592
55885593 internal_error_array_depth:
55895594 // we have a big problem
@@ -5605,7 +5610,7 @@ negative_array_size: · 15 unmodified lines
56055610
56065611 error:
56075612 // base shouldn't have been ref counted
5608− SAFE_DELETE( base );
5613+ SAFE_DELETE( theBase );
56095614 return NULL;
56105615 }
56115616
src/core/chuck_io.cpp+6−2
@@ -31,10 +31,10 @@ · 30 unmodified lines
3131 //-----------------------------------------------------------------------------
3232 #include "chuck_io.h"
3333 #include "chuck_errmsg.h"
34−#include "util_serial.h"
3534 #include "chuck_instr.h"
3635 #include "chuck_type.h"
3736 #include "chuck_vm.h"
37+
3838 #ifndef __DISABLE_HID__
3939 #include "hidio_sdl.h"
4040 #endif
@@ -43,6 +43,10 @@ · 2 unmodified lines
4343 #include "midiio_rtmidi.h"
4444 #endif
4545
46+#ifndef __DISABLE_SERIAL__
47+#include "util_serial.h"
48+#endif
49+
4650 #ifndef __PLATFORM_WIN32__
4751 #include <sys/select.h>
4852 #include <poll.h>
@@ -3308,7 +3312,7 @@ void Chuck_IO_Serial::write( t_CKFLOAT val ) · 3259 unmodified lines
33083312 {
33093313 // assume 4-byte int
33103314 char * buf = (char *) &val;
3311− // 1.5.0.0 (ge and eito) | changed from size to sizeof
3315+ // 1.5.0.0 (ge) | fixed from size to sizeof
33123316 fwrite(buf, 1, sizeof(val), m_cfd);
33133317 }
33143318 }
src/core/chuck_oo.cpp+18−7
@@ -157,8 +157,13 @@ void Chuck_VM_Object::release() · 156 unmodified lines
157157 *(int *)0 = 1;
158158 }
159159
160+ #ifndef __CHUNREAL_ENGINE__
160161 // log | 1.5.0.0 (ge) added
161162 EM_log( CK_LOG_FINEST, "reclaiming %s: 0x%08x", typeid(*this).name(), this );
163+ #else
164+ // #chunreal UE seems to disallow real-time type info
165+ EM_log( CK_LOG_FINEST, "reclaiming object: 0x%08x", this );
166+ #endif // #ifndef __CHUNREAL_ENGINE__
162167
163168 // tell the object manager to set this free
164169 // Chuck_VM_Alloc::instance()->free_object( this );
@@ -322,10 +327,10 @@ Chuck_Object::Chuck_Object() · 157 unmodified lines
322327 vtable = NULL;
323328 // zero type
324329 type_ref = NULL;
325− // zero size
326− size = 0;
327330 // zero data
328331 data = NULL;
332+ // zero size
333+ data_size = 0;
329334
330335 // add to vm allocator
331336 // Chuck_VM_Alloc::instance()->add_object( this );
@@ -3038,11 +3043,12 @@ t_CKBOOL Chuck_IO_File::open( const string & path, t_CKINT flags ) · 2706 unmodified lines
30383043 mode |= ios_base::binary;
30393044
30403045 // close first
3041− if (m_io.is_open())
3046+ if( m_io.is_open() )
30423047 this->close();
30433048
30443049 // try to open as a dir first (fixed 1.3.0.0 removed warning)
3045− if( (m_dir = opendir( path.c_str() )) )
3050+ m_dir = opendir(path.c_str());
3051+ if( m_dir )
30463052 {
30473053 EM_poplog();
30483054 return TRUE;
@@ -3050,7 +3056,7 @@ t_CKBOOL Chuck_IO_File::open( const string & path, t_CKINT flags ) · 1 unmodified line
30503056
30513057 // not a dir, create file if it does not exist unless flag is
30523058 // readonly
3053− if ( !(flags & FLAG_READONLY) )
3059+ if( !(flags & FLAG_READONLY) )
30543060 {
30553061 m_io.open( path.c_str(), ios_base::in );
30563062 if ( m_io.fail() )
@@ -3319,8 +3325,11 @@ Chuck_Array4 * Chuck_IO_File::dirList() · 262 unmodified lines
33193325 // fill vector with entry names
33203326 rewinddir( m_dir );
33213327 std::vector<Chuck_String *> entrylist;
3322− struct dirent *ent;
3323− while( (ent = readdir( m_dir )) ) // fixed 1.3.0.0: removed warning
3328+
3329+ // 1.5.0.0 (ge) | #chunreal UE-forced refactor
3330+ struct dirent * ent = readdir( m_dir );
3331+ // was: while( (ent = readdir( m_dir ) ) <-- in ge's opinion this is cleaner splitting readir() into two places
3332+ while( ent != NULL ) // fixed 1.3.0.0: removed warning
33243333 {
33253334 // pass NULL as shred ref
33263335 Chuck_String *s = (Chuck_String *)instantiate_and_initialize_object( m_vmRef->env()->t_string, NULL, m_vmRef );
@@ -3330,6 +3339,8 @@ Chuck_Array4 * Chuck_IO_File::dirList() · 3 unmodified lines
33303339 // don't include .. and . in the list
33313340 entrylist.push_back( s );
33323341 }
3342+ // #chunreal refactor
3343+ ent = readdir( m_dir );
33333344 }
33343345
33353346 // make array
src/core/chuck_oo.h+2−2
@@ -189,10 +189,10 @@ public: · 188 unmodified lines
189189 Chuck_VTable * vtable;
190190 // reference to type
191191 Chuck_Type * type_ref;
192− // the size of the data region
193− t_CKUINT size;
194192 // data for the object
195193 t_CKBYTE * data;
194+ // the size of the data region
195+ t_CKUINT data_size;
196196 };
197197
198198
src/core/chuck_parse.cpp+27−12
@@ -39,8 +39,14 @@ · 38 unmodified lines
3939 #endif
4040
4141 #ifdef __PLATFORM_WIN32__
42−#include <windows.h> // for win32_tmpfile()
43−#endif
42+#ifndef __CHUNREAL_ENGINE__
43+ #include <windows.h> // for win32_tmpfile()
44+#else
45+ // 1.5.0.0 (ge) | #chunreal
46+ // unreal engine on windows disallows including windows.h
47+ #include "Windows/MinWindows.h"
48+#endif // #ifndef __CHUNREAL_ENGINE__
49+#endif // #ifdef __PLATFORM_WIN32__
4450
4551 using namespace std;
4652
@@ -76,44 +82,53 @@ FILE * open_cat_ck( c_str fname ) · 29 unmodified lines
7682 }
7783 #endif // __ANDROID__
7884
79− FILE * fd = NULL;
80− if( !(fd = fopen( fname, "rb" )) )
85+ FILE * fd = fopen(fname, "rb");
86+ if( !fd )
87+ {
8188 if( !strstr( fname, ".ck" ) && !strstr( fname, ".CK" ) )
8289 {
8390 strcat( fname, ".ck" );
8491 fd = fopen( fname, "rb" );
8592 }
93+ }
8694 return fd;
8795 }
8896
8997
9098
99+
91100 //-----------------------------------------------------------------------------
92101 // name: win32_tmpfile()
93102 // desc: replacement for broken tmpfile() on Windows Vista + 7
94103 //-----------------------------------------------------------------------------
95104 #ifdef __PLATFORM_WIN32__
96−
97−#include <windows.h>
98−
99105 FILE *win32_tmpfile()
100106 {
101107 char tmp_path[MAX_PATH];
102108 char file_path[MAX_PATH];
103109 FILE * file = NULL;
104110
105− if(GetTempPath(256, tmp_path) == 0)
111+#ifndef __CHUNREAL_ENGINE__
112+ if( GetTempPath(256, tmp_path) == 0 )
113+#else
114+ // 1.5.0.0 (ge) | #chunreal explicit call ASCII version
115+ if( GetTempPathA(256, tmp_path) == 0 )
116+#endif
106117 return NULL;
107118
108− if(GetTempFileName(tmp_path, "mA", 0, file_path) == 0)
119+#ifndef __CHUNREAL_ENGINE__
120+ if( GetTempFileName(tmp_path, "mA", 0, file_path) == 0 )
121+#else
122+ // 1.5.0.0 (ge) | #chunreal explicit call ASCII version
123+ if( GetTempFileNameA(tmp_path, "mA", 0, file_path) == 0 )
124+#endif
109125 return NULL;
110126
111− file = fopen(file_path, "wb+D");
127+ file = fopen( file_path, "wb+D" );
112128
113129 return file;
114130 }
115−
116−#endif
131+#endif // #ifdef __PLATFORM_WIN32__
117132
118133
119134
src/core/chuck_scan.cpp+2−1
@@ -2489,7 +2489,8 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f ) · 2488 unmodified lines
24892489 assert( !f->code || f->code->s_type == ae_stmt_code );
24902490
24912491 // look up the value in the current class (can shadow?)
2492− if(( overload = env->curr->lookup_value( f->name, FALSE ) ))
2492+ overload = env->curr->lookup_value( f->name, FALSE );
2493+ if( overload )
24932494 {
24942495 // if value
24952496 if( !isa( overload->type, env->t_function ) )
src/core/chuck_symbol.cpp+2−2
@@ -53,7 +53,7 @@ static S_Symbol mksymbol( c_constr name, S_Symbol next ) · 52 unmodified lines
5353
5454 static S_Symbol hashtable[SIZE];
5555
56−static unsigned int hash(const char *s0)
56+static unsigned int s_hash(const char *s0)
5757 {
5858 unsigned int h=0; const char *s;
5959 for(s=s0; *s; s++)
@@ -69,7 +69,7 @@ static int streq(c_constr a, c_constr b) · 9 unmodified lines
6969 S_Symbol insert_symbol(c_constr name)
7070 {
7171 S_Symbol syms = NULL, sym;
72− int index= hash(name) % SIZE;
72+ int index= s_hash(name) % SIZE;
7373
7474 if( !name ) return NULL;
7575 syms = hashtable[index];
src/core/chuck_ugen.cpp+18−25
@@ -630,19 +630,18 @@ t_CKBOOL Chuck_UGen::remove( Chuck_UGen * src ) · 629 unmodified lines
630630 }
631631
632632 // remove
633− for( t_CKUINT i = 0; i < m_num_src; i++ )
634− if( m_src_list[i] == src )
633+ for( t_CKUINT k = 0; k < m_num_src; k++ )
634+ if( m_src_list[k] == src )
635635 {
636636 ret = TRUE;
637− for( t_CKUINT j = i+1; j < m_num_src; j++ )
637+ for( t_CKUINT j = k+1; j < m_num_src; j++ )
638638 m_src_list[j-1] = m_src_list[j];
639639
640640 m_src_list[--m_num_src] = NULL;
641641 src->remove_by( this );
642642 src->release();
643− --i;
643+ --k;
644644 }
645−
646645 }
647646 /* else if( outs >= 2 && ins == 1 )
648647 {
@@ -866,11 +865,11 @@ t_CKBOOL Chuck_UGen::system_tick( t_CKTIME now ) · 217 unmodified lines
866865 if( m_time >= now )
867866 return m_valid;
868867
869− t_CKUINT i; Chuck_UGen * ugen; SAMPLE multi;
870−
871−
872− /*** Part 1: Tick upstream ugens ***/
868+ t_CKUINT i;
869+ Chuck_UGen * ugen = NULL;
870+ SAMPLE multi;
873871
872+ // part 1: tick upstream ugens
874873 // inc time
875874 m_time = now;
876875 // initial sum
@@ -957,12 +956,10 @@ t_CKBOOL Chuck_UGen::system_tick( t_CKTIME now ) · 80 unmodified lines
957956
958957
959958
960− /*** Part Two: Synthesize with tick function ***/
961−
959+ // part 2: synthesize with tick function
962960 if( m_multi_chan_size && tickf )
963961 {
964− /* evaluate multi-channel tickf (added 1.3.0.0) */
965−
962+ // evaluate multi-channel tickf (added 1.3.0.0)
966963 multi = 0;
967964
968965 if( m_op > 0 ) // UGEN_OP_TICK
@@ -1072,15 +1069,15 @@ t_CKBOOL Chuck_UGen::system_tick_v( t_CKTIME now, t_CKUINT numFrames ) · 103 unmodified lines
10721069 if( m_time >= now )
10731070 return m_valid;
10741071
1075− t_CKUINT i, j; Chuck_UGen * ugen; SAMPLE factor;
1072+ t_CKUINT i, j;
1073+ Chuck_UGen * ugen = NULL;
1074+ SAMPLE factor;
10761075 SAMPLE multi;
10771076
10781077 // inc time
10791078 m_time = now;
10801079
1081−
1082− /*** Part 1: Tick upstream ugens ***/
1083−
1080+ // part 1: tick upstream ugens
10841081 if( m_num_src )
10851082 {
10861083 ugen = m_src_list[0];
@@ -1122,7 +1119,7 @@ t_CKBOOL Chuck_UGen::system_tick_v( t_CKTIME now, t_CKUINT numFrames ) · 35 unmodified lines
11221119 // tick multiple channels
11231120 if( m_multi_chan_size )
11241121 {
1125− if(tickf)
1122+ if( tickf )
11261123 {
11271124 // system tick each input channel (added 1.3.0.0)
11281125 for( int c = 0; c < m_multi_chan_size; c++ )
@@ -1166,13 +1163,10 @@ t_CKBOOL Chuck_UGen::system_tick_v( t_CKTIME now, t_CKUINT numFrames ) · 37 unmodified lines
11661163 }
11671164 }
11681165
1169−
1170− /*** Part Two: Synthesize with tick function ***/
1171−
1166+ // part 2: synthesize with tick function
11721167 if( m_multi_chan_size && tickf )
11731168 {
1174− /* evaluate multi-channel tick (added added 1.3.0.0) */
1175−
1169+ // evaluate multi-channel tick (added added 1.3.0.0)
11761170 if( m_op > 0) // UGEN_OP_TICK
11771171 {
11781172 // compute samples with tickf
@@ -1250,8 +1244,7 @@ t_CKBOOL Chuck_UGen::system_tick_v( t_CKTIME now, t_CKUINT numFrames ) · 71 unmodified lines
12501244 }
12511245 else
12521246 {
1253− /* evaluate single-channel tick */
1254−
1247+ // evaluate single-channel tick
12551248 if( m_op > 0 ) // UGEN_OP_TICK
12561249 {
12571250 // tick the ugen (Chuck_DL_Api::Api::instance() added 1.3.0.0)
src/core/chuck_vm.cpp+16−11
@@ -35,12 +35,12 @@ · 34 unmodified lines
3535 #include "chuck_type.h"
3636 #include "chuck_dl.h"
3737 #include "chuck_globals.h" // added 1.4.1.0 (jack)
38+#include "chuck_errmsg.h"
3839
3940 #ifndef __DISABLE_SERIAL__
4041 #include "chuck_io.h"
4142 #endif
4243
43−#include "chuck_errmsg.h"
4444 #include "ugen_xxx.h"
4545 #include "util_buffers.h"
4646
@@ -56,11 +56,16 @@ · 9 unmodified lines
5656 using namespace std;
5757
5858 #if defined(__PLATFORM_WIN32__)
59− #include <windows.h>
59+ #ifndef __CHUNREAL_ENGINE__
60+ #include <windows.h>
61+ #else
62+ // 1.5.0.0 (ge) | #chunreal
63+ #include "Windows/MinWindows.h"
64+ #endif // #ifndef __CHUNREAL_ENGINE__
6065 #else
6166 #include <unistd.h>
6267 #include <pthread.h>
63−#endif
68+#endif // #if defined(__PLATFORM_WIN32__)
6469
6570 // uncomment to compile VM debug messages
6671 #define CK_VM_DEBUG_ENABLE (0)
@@ -484,15 +489,16 @@ t_CKBOOL Chuck_VM::compute() · 417 unmodified lines
484489 // global manager added 1.4.1.0 (jack)
485490 m_globals_manager->handle_global_queue_messages();
486491
487− // iteration until no more shreds/events/messages
492+ // iterate until no more shreds/events/messages
488493 while( iterate )
489494 {
490495 // get the shreds queued for 'now'
491− while(( shred = m_shreduler->get() ))
496+ shred = m_shreduler->get();
497+ // run all shreds waiting to run 'now'
498+ while( shred != NULL )
492499 {
493500 // set the current time of the shred
494501 shred->now = shred->wake_time;
495−
496502 // track shred activation
497503 CK_TRACK( Chuck_Stats::instance()->activate_shred( shred ) );
498504
@@ -510,9 +516,8 @@ t_CKBOOL Chuck_VM::compute() · 11 unmodified lines
510516
511517 // track shred deactivation
512518 CK_TRACK( if( shred ) Chuck_Stats::instance()->deactivate_shred( shred ) );
513−
514− // zero out
515− shred = NULL;
519+ // get next shred queued for 'now'
520+ shred = m_shreduler->get();
516521 }
517522
518523 // set to false for now
@@ -2385,8 +2390,8 @@ void Chuck_VM_Shreduler::status( Chuck_VM_Status * status ) · 1866 unmodified lines
23852390 }
23862391
23872392 // get current shred
2388− if( ( temp = m_current_shred ) )
2389− list.push_back( temp );
2393+ temp = m_current_shred;
2394+ if( temp ) list.push_back( temp );
23902395
23912396 // sort the list
23922397 SortByID byid;
src/core/dirent_win32.h+10−1
@@ -56,7 +56,16 @@ · 55 unmodified lines
5656 #ifndef DIRENT_H
5757 #define DIRENT_H
5858
59−#include <windows.h>
59+
60+// assume windows...
61+#ifndef __CHUNREAL_ENGINE__
62+ #include <windows.h>
63+#else
64+ // 1.5.0.0 (ge) | #chunreal
65+ // unreal engine on windows disallows including windows.h
66+ #include "Windows/MinWindows.h"
67+#endif // #ifndef __CHUNREAL_ENGINE__
68+
6069 #include <string.h>
6170 #include <assert.h>
6271

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t