diff --git a/VERSIONS b/VERSIONS index 3df0b6ef1..4c916fffc 100644 --- a/VERSIONS +++ b/VERSIONS @@ -2,11 +2,12 @@ ChucK VERSIONS log ------------------ -1.5.3.3 +1.5.4.0 (October 2024) ======= -***************** new language feature *************** -- (added) chuck @import system for .ck and .chug files -- for language specification and examples regarding @import, see: +********** new language feature ************ +@import system for .ck and .chug files +******************************************** +- for language specification and examples regarding @import: *************************************************** https://chuck.stanford.edu/doc/language/import.html *************************************************** @@ -35,6 +36,11 @@ ChucK VERSIONS log - @import can work recursively; can @import files that @import other files - @import has built-in cycle-detection; if an @import cycle is detected, a compiler error will be issued and that compilation will be failed +****************************************************** +- (updated behavior) the one-public-class-per-file restriction has been lifted; i.e., it is + now possible to define more than one public class in a single .ck file; this update is + intended to give programmers and library creators more flexibility in organizing their + public class definiition - (updated behavior) .ck files found in chugin/import search paths (e.g., ~/.chuck/lib) NO LONGER automatically loads; instead these now must be explicitly @imported to be used (FYI just the file name will suffice, assuming there are no filename conflicts elsewhere in the diff --git a/src/core/chuck_compile.h b/src/core/chuck_compile.h index e6d7acad7..1499dec07 100644 --- a/src/core/chuck_compile.h +++ b/src/core/chuck_compile.h @@ -249,7 +249,7 @@ struct Chuck_Compiler Chuck_VM * vm() const { return m_carrier->vm; } // REFACTOR-2017: get associated, per-compiler carrier Chuck_Carrier * carrier() const { return m_carrier; } - // get import registry | 1.5.3.5 (ge) + // get import registry | 1.5.4.0 (ge) Chuck_ImportRegistry * imports() { return &m_importRegistry; } // set carrier t_CKBOOL setCarrier( Chuck_Carrier * c ) { m_carrier = c; return TRUE; } @@ -301,7 +301,7 @@ struct Chuck_Compiler t_CKBOOL importChugin( const std::string & path, const std::string & name = "" ); public: - // compile a target | 1.5.3.5 (ge) + // compile a target | 1.5.4.0 (ge) // NOTE: this function will memory-manage `target` // (do not access or delete `target` after function call) t_CKBOOL compile( Chuck_CompileTarget * target ); diff --git a/src/core/chuck_emit.cpp b/src/core/chuck_emit.cpp index de507c06f..eba94ec21 100644 --- a/src/core/chuck_emit.cpp +++ b/src/core/chuck_emit.cpp @@ -227,7 +227,7 @@ Chuck_VM_Code * emit_engine_emit_prog( Chuck_Emitter * emit, a_Program prog, case ae_section_class: // class definition // 1.5.2.5 (ge) check the compilation criteria // if( !howMuch_criteria_match( how_much, prog->section->class_def ) ) break; - // 1.5.3.5 (ge) commented out (see type_engine_prog0_scan() for explanation) + // 1.5.4.0 (ge) commented out (see type_engine_prog0_scan() for explanation) // emit class definition ret = emit_engine_emit_class_def( emit, prog->section->class_def ); diff --git a/src/core/chuck_errmsg.cpp b/src/core/chuck_errmsg.cpp index 02570f612..98eb3818f 100644 --- a/src/core/chuck_errmsg.cpp +++ b/src/core/chuck_errmsg.cpp @@ -54,7 +54,7 @@ using namespace std; t_CKINT EM_tokPos = 0; t_CKINT EM_lineNum = 1; -// current per-file error message context | 1.5.3.5 (ge) +// current per-file error message context | 1.5.4.0 (ge) static Chuck_CompileTarget * the_compileTarget = NULL; // current filename static const char * the_filename = ""; @@ -1047,7 +1047,7 @@ const char * EM_lasterror() //----------------------------------------------------------------------------- // name: EM_setCurrentTarget() -// desc: set current compile compilation target | 1.5.3.5 (ge) +// desc: set current compile compilation target | 1.5.4.0 (ge) //----------------------------------------------------------------------------- void EM_setCurrentTarget( Chuck_CompileTarget * target ) { diff --git a/src/core/chuck_errmsg.h b/src/core/chuck_errmsg.h index d8664a9a6..754304da5 100644 --- a/src/core/chuck_errmsg.h +++ b/src/core/chuck_errmsg.h @@ -181,10 +181,10 @@ extern "C++" // class forward reference | 1.5.0.5 (ge) added class ChucK; -// struct forward reference | 1.5.3.5 (ge) added +// struct forward reference | 1.5.4.0 (ge) added struct Chuck_CompileTarget; -// set current compile compilation target; used for state | 1.5.3.5 (ge) +// set current compile compilation target; used for state | 1.5.4.0 (ge) void EM_setCurrentTarget( Chuck_CompileTarget * target ); diff --git a/src/core/chuck_instr.cpp b/src/core/chuck_instr.cpp index 02ba4f199..5f11bb32c 100644 --- a/src/core/chuck_instr.cpp +++ b/src/core/chuck_instr.cpp @@ -6269,7 +6269,7 @@ void Chuck_Instr_Array_Init_Literal::execute( Chuck_VM * vm, Chuck_VM_Shred * sh // reg stack pointer t_CKUINT *& reg_sp = (t_CKUINT *&)shred->reg->sp; - // amalgamating array type | 1.5.3.5 (ge, nick, andrew) added after a wild yak hunt + // amalgamating array type | 1.5.4.0 (ge, nick, andrew) added after a wild yak hunt Chuck_Type * arrayType = vm->env()->get_array_type( vm->env()->ckt_array, m_type_ref->array_depth+1, m_type_ref ); // allocate the array @@ -6287,7 +6287,7 @@ void Chuck_Instr_Array_Init_Literal::execute( Chuck_VM * vm, Chuck_VM_Shred * sh // initialize object // should it be this??? initialize_object( array, m_type_ref ); // should it be this??? initialize_object( array, vm->env()->ckt_array, shred, vm ); - // neither! behold -- the amalgamated array type... | 1.5.3.5 (ge, nick, andrew) + // neither! behold -- the amalgamated array type... | 1.5.4.0 (ge, nick, andrew) initialize_object( array, arrayType, shred, vm ); // set size diff --git a/src/core/chuck_oo.cpp b/src/core/chuck_oo.cpp index 443ad82cd..bb8363884 100644 --- a/src/core/chuck_oo.cpp +++ b/src/core/chuck_oo.cpp @@ -952,7 +952,7 @@ void Chuck_ArrayInt::sort() // check size if( size() == 0 ) return; - // if object references | 1.5.3.5 (azaday) added + // if object references | 1.5.4.0 (azaday) added if( m_is_obj ) { // if this is a string[] diff --git a/src/core/chuck_otf.cpp b/src/core/chuck_otf.cpp index bb2aeb360..b62c21438 100644 --- a/src/core/chuck_otf.cpp +++ b/src/core/chuck_otf.cpp @@ -212,7 +212,7 @@ t_CKUINT otf_process_msg( Chuck_VM * vm, Chuck_Compiler * compiler, // (added 1.3.5.2) std::string full_path = get_full_path( msg->buffer ); - // construct a target to be compiled | 1.5.3.5 (ge) + // construct a target to be compiled | 1.5.4.0 (ge) Chuck_CompileTarget * target = new Chuck_CompileTarget(); // set file descriptor target->fd2parse = fd; diff --git a/src/core/chuck_parse.cpp b/src/core/chuck_parse.cpp index 2d5ffb101..5f7cd3131 100644 --- a/src/core/chuck_parse.cpp +++ b/src/core/chuck_parse.cpp @@ -97,7 +97,7 @@ t_CKBOOL chuck_parse( Chuck_CompileTarget * target ) // check for conflict if( fd && target->codeLiteral != "" ) { - // no warning... quietly let the code literal take precedence | 1.5.3.5 (ge) + // no warning... quietly let the code literal take precedence | 1.5.4.0 (ge) // CK_FPRINTF_STDERR( "[chuck](parser): (internal) code and FILE descriptor both present!\n" ); // CK_FPRINTF_STDERR( "[chuck](parser): |- ignoring FILE descriptor...\n" ); } diff --git a/src/core/chuck_scan.cpp b/src/core/chuck_scan.cpp index 2388b9533..1cef8459d 100644 --- a/src/core/chuck_scan.cpp +++ b/src/core/chuck_scan.cpp @@ -164,7 +164,7 @@ t_CKBOOL type_engine_scan0_prog( Chuck_Env * env, a_Program prog, // 1.5.2.5 (ge) check the compilation criteria // if( !howMuch_criteria_match( how_much, prog->section->class_def ) ) break; // ----------------------------------------- - // 1.5.3.5 (ge) commented out above howMuch_criteria_match() + // 1.5.4.0 (ge) commented out above howMuch_criteria_match() // * go ahead and compile all classes (public or non-public) even if import_only // ...there is logic within to further sort out public vs. non-public classes // * this is needed because public classes could make use of non-public classes @@ -174,7 +174,7 @@ t_CKBOOL type_engine_scan0_prog( Chuck_Env * env, a_Program prog, // make global, if marked public if( prog->section->class_def->decl == ae_key_public ) { - // 1.5.3.5 (ge) removing restriction of one public class per file + // 1.5.4.0 (ge) removing restriction of one public class per file // ---------------- legacy note ------------ // make sure the context has no public class // if( env->context->public_class_def != NULL ) @@ -279,7 +279,7 @@ t_CKBOOL type_engine_scan0_class_def( Chuck_Env * env, a_Class_Def class_def ) the_class->info = env->context->new_Chuck_Namespace(); CK_SAFE_ADD_REF( the_class->info ); the_class->info->name = the_class->base_name; - // public? | 1.5.3.5 (ge) added + // public? | 1.5.4.0 (ge) added the_class->is_public = (class_def->decl == ae_key_public); // if public class, then set parent to context // ... allowing the class to address current context @@ -323,7 +323,7 @@ t_CKBOOL type_engine_scan0_class_def( Chuck_Env * env, a_Class_Def class_def ) break; case ae_section_class: - // check for public | 1.5.3.5 (ge) added + // check for public | 1.5.4.0 (ge) added if( body->section->class_def->decl == ae_key_public ) { EM_error2( class_def->where, @@ -437,7 +437,7 @@ t_CKBOOL type_engine_scan1_prog( Chuck_Env * env, a_Program prog, case ae_section_class: // 1.5.2.5 (ge) check the compilation criteria // if( !howMuch_criteria_match( how_much, prog->section->class_def ) ) break; - // 1.5.3.5 (ge) commented out (see type_engine_prog0_scan() for explanation) + // 1.5.4.0 (ge) commented out (see type_engine_prog0_scan() for explanation) // scan the class definition ret = type_engine_scan1_class_def( env, prog->section->class_def ); @@ -1708,7 +1708,7 @@ t_CKBOOL type_engine_scan2_prog( Chuck_Env * env, a_Program prog, case ae_section_class: // 1.5.2.5 (ge) check the compilation criteria // if( !howMuch_criteria_match( how_much, prog->section->class_def ) ) break; - // 1.5.3.5 (ge) commented out (see type_engine_prog0_scan() for explanation) + // 1.5.4.0 (ge) commented out (see type_engine_prog0_scan() for explanation) // scan the class definition ret = type_engine_scan2_class_def( env, prog->section->class_def ); diff --git a/src/core/chuck_type.cpp b/src/core/chuck_type.cpp index cd53f4d28..b397436be 100644 --- a/src/core/chuck_type.cpp +++ b/src/core/chuck_type.cpp @@ -559,7 +559,7 @@ t_CKBOOL type_engine_init( Chuck_Carrier * carrier ) EM_pushlog(); //------------------------- - // disable array type cache until ckt_array is initialized | 1.5.3.5 (ge) added + // disable array type cache until ckt_array is initialized | 1.5.4.0 (ge) added env->arrayTypeCache()->enable( FALSE ); // special: Object and Type, whose initializations mutually depend init_class_object( env, env->ckt_object ); @@ -570,7 +570,7 @@ t_CKBOOL type_engine_init( Chuck_Carrier * carrier ) // initialize of Object's and @array's Type objects are deferred until after init_class_type() type_engine_init_special( env, env->ckt_object ); type_engine_init_special( env, env->ckt_array ); - // enable array type cache now that ckt_array is initialized | 1.5.3.5 (ge) added + // enable array type cache now that ckt_array is initialized | 1.5.4.0 (ge) added env->arrayTypeCache()->enable( TRUE ); //------------------------- @@ -898,7 +898,7 @@ t_CKBOOL type_engine_check_context( Chuck_Env * env, case ae_section_class: // 1.5.2.5 (ge) check the compilation criteria // if( !howMuch_criteria_match( how_much, prog->section->class_def ) ) break; - // 1.5.3.5 (ge) commented out (see type_engine_prog0_scan() for explanation) + // 1.5.4.0 (ge) commented out (see type_engine_prog0_scan() for explanation) // check the class definition ret = type_engine_check_class_def( env, prog->section->class_def ); @@ -3445,7 +3445,7 @@ t_CKTYPE type_engine_check_exp_primary( Chuck_Env * env, a_Exp_Primary exp ) "undefined variable/function '%s' in class/namespace '%s'", S_name(exp->var), env->class_def->base_name.c_str() ); - // check if we are being imported | 1.5.3.5 (ge) added + // check if we are being imported | 1.5.4.0 (ge) added if( env->context->progress == Chuck_Context::P_IMPORTING ) { // more info / a hint @@ -5824,7 +5824,7 @@ t_CKBOOL isa_levels( const Chuck_Type & lhs, const Chuck_Type & rhs, t_CKUINT & // if lhs is null and rhs isa Object if( (lhs == *(lhs.env()->ckt_null)) && (rhs <= *(rhs.env()->ckt_object)) ) return TRUE; //-------------------------------------------- - // all arrays isa base @array type | 1.5.3.5 (ge & nick) added + // all arrays isa base @array type | 1.5.4.0 (ge & nick) added if( lhs.array_depth > 0 && (rhs == *(rhs.env()->ckt_array) ) ) return TRUE; // all arrays or base @array type isa Object if( (lhs.array_depth > 0 || (lhs == *(lhs.env()->ckt_array))) && (rhs == *(rhs.env()->ckt_object) ) ) return TRUE; @@ -7937,7 +7937,7 @@ Chuck_Namespace * Chuck_Context::new_Chuck_Namespace() //----------------------------------------------------------------------------- // name: get_array_type() -// desc: retrieve array type based on parameters | 1.5.3.5 (ge, nick, andrew) added +// desc: retrieve array type based on parameters | 1.5.4.0 (ge, nick, andrew) added //----------------------------------------------------------------------------- Chuck_Type * Chuck_Env::get_array_type( Chuck_Type * array_parent, t_CKUINT depth, Chuck_Type * base_type /*, @@ -7994,7 +7994,7 @@ void Chuck_ArrayTypeCache::clear() //----------------------------------------------------------------------------- -// name: getOrCreate() | 1.5.3.5 (ge, nick, andrew) added +// name: getOrCreate() | 1.5.4.0 (ge, nick, andrew) added // desc: lookup an array type; if not already cached, create and insert //----------------------------------------------------------------------------- Chuck_Type * Chuck_ArrayTypeCache::getOrCreate( Chuck_Env * env, @@ -8058,7 +8058,7 @@ Chuck_Type * create_new_array_type( Chuck_Env * env, Chuck_Type * array_parent, // 1.4.1.1 (nshaheed) added to allow declaring arrays with subclasses as elements (PR #211) // example: [ new SinOsc, new Sinosc ] @=> Osc arr[]; // this previously would fail type check - // 1.5.3.5 (ge & nick) this is now handled in isa_levels() + // 1.5.4.0 (ge & nick) this is now handled in isa_levels() // parent type t->parent = array_parent; diff --git a/src/core/chuck_type.h b/src/core/chuck_type.h index 578c0d42f..414931664 100644 --- a/src/core/chuck_type.h +++ b/src/core/chuck_type.h @@ -79,8 +79,8 @@ typedef enum { te_globalTypeNone, //----------------------------------------------------------------------------- typedef enum { te_do_all = 0, - te_do_import_only, // attend only to things to be imported | 1.5.3.5 (ge) - te_skip_import, // do everything except things to be imported | 1.5.3.5 (ge) + te_do_import_only, // attend only to things to be imported | 1.5.4.0 (ge) + te_skip_import, // do everything except things to be imported | 1.5.4.0 (ge) } te_HowMuch; // function to if a function matches a particular criteria @@ -651,7 +651,7 @@ struct Chuck_Op_Overload //----------------------------------------------------------------------------- // name: struct Chuck_ArrayTypeKey -// desc: a 4-tuple key | 1.5.3.5 (ge & nick) added +// desc: a 4-tuple key | 1.5.4.0 (ge & nick) added //----------------------------------------------------------------------------- struct Chuck_ArrayTypeKey { @@ -677,7 +677,7 @@ struct Chuck_ArrayTypeKeyCmp //----------------------------------------------------------------------------- // name: struct Chuck_ArrayTypeCache -// desc: cache for array types | 1.5.3.5 (ge & nick & andrew) added +// desc: cache for array types | 1.5.4.0 (ge & nick & andrew) added //----------------------------------------------------------------------------- struct Chuck_ArrayTypeCache { @@ -753,7 +753,7 @@ struct Chuck_Env : public Chuck_VM_Object public: // array type cache Chuck_ArrayTypeCache * arrayTypeCache() { return &array_types; } - // retrieve array type based on parameters | 1.5.3.5 (ge, nick, andrew) added + // retrieve array type based on parameters | 1.5.4.0 (ge, nick, andrew) added Chuck_Type * get_array_type( Chuck_Type * array_parent, t_CKUINT depth, Chuck_Type * base_type /*, Chuck_Namespace * owner_nspc */ ); @@ -996,7 +996,7 @@ struct Chuck_Type : public Chuck_Object Chuck_Func * func; // ugen Chuck_UGen_Info * ugen_info; - // is public class | 1.5.3.5 (ge) added + // is public class | 1.5.4.0 (ge) added t_CKBOOL is_public; // copy t_CKBOOL is_copy; diff --git a/src/core/util_string.cpp b/src/core/util_string.cpp index 72c2261aa..f04d241b6 100644 --- a/src/core/util_string.cpp +++ b/src/core/util_string.cpp @@ -894,7 +894,7 @@ std::string extract_filepath_file( const std::string & filepath ) //----------------------------------------------------------------------------- -// name: extract_filepath_ext() | 1.5.3.5 (ge) added +// name: extract_filepath_ext() | 1.5.4.0 (ge) added // desc: return the extension portion of a file path, including the . //----------------------------------------------------------------------------- std::string extract_filepath_ext( const std::string & filepath ) @@ -1265,7 +1265,7 @@ std::string autoFilename( const std::string & prefix, const std::string & fileEx #endif //----------------------------------------------------------------------------- // name: file_last_write_time() -// desc: unformatted last-write timestamp of a file | 1.5.3.5 (ge) +// desc: unformatted last-write timestamp of a file | 1.5.4.0 (ge) //----------------------------------------------------------------------------- time_t file_last_write_time( const std::string & filename ) { diff --git a/src/core/util_string.h b/src/core/util_string.h index 880bc5f26..fcf105524 100644 --- a/src/core/util_string.h +++ b/src/core/util_string.h @@ -110,7 +110,7 @@ std::string extract_filepath_dir( const std::string & filepath ); // get filename portion of a filepath (minus the directory portion) | 1.5.2.5 (ge) added std::string extract_filepath_file( const std::string & filepath ); -// get extension portion of a filepath (minus the directory and file portions) | 1.5.3.5 (ge) added +// get extension portion of a filepath (minus the directory and file portions) | 1.5.4.0 (ge) added std::string extract_filepath_ext( const std::string & filepath ); // desc: create absolute path using existing filepath and incoming path @@ -158,7 +158,7 @@ t_CKBOOL subdir_ok2recurse( const std::string & dirName, // get formatted timestamp of current system time; no new line std::string timestamp_formatted(); // e.g., "Sat Jun 24 04:18:42 2023" -// unformatted last-write timestamp of a file | 1.5.3.5 (ge) +// unformatted last-write timestamp of a file | 1.5.4.0 (ge) time_t file_last_write_time( const std::string & filename ); // tokenize a string into a vector of strings, by delimiters