Index: /trunk/src/util_hid.cpp =================================================================== --- /trunk/src/util_hid.cpp (revision 177) +++ /trunk/src/util_hid.cpp (revision 213) @@ -1990,9 +1990,11 @@ #ifndef __CK_HID_CURSOR_TRACK__ - Point p; - GetGlobalMouse( &p ); - - msg.idata[2] = p.h; - msg.idata[3] = p.v; + + CGEventRef event = CGEventCreate(NULL); + CGPoint cursor = CGEventGetLocation(event); + CFRelease(event); + + msg.idata[2] = cursor.x; + msg.idata[3] = cursor.y; CGDirectDisplayID display; @@ -2000,6 +2002,6 @@ CGPoint cgp; - cgp.x = p.h; - cgp.y = p.v; + cgp.x = cursor.x; + cgp.y = cursor.y; if( CGGetDisplaysWithPoint( cgp, 1, &display, &displayCount ) == @@ -2008,7 +2010,7 @@ CGRect bounds = CGDisplayBounds( display ); - msg.fdata[0] = ( ( t_CKFLOAT ) ( p.h - bounds.origin.x ) ) / + msg.fdata[0] = ( ( t_CKFLOAT ) ( cursor.x - bounds.origin.x ) ) / ( bounds.size.width - 1 ); - msg.fdata[1] = ( ( t_CKFLOAT ) ( p.v - bounds.origin.y ) ) / + msg.fdata[1] = ( ( t_CKFLOAT ) ( cursor.y - bounds.origin.y ) ) / ( bounds.size.height - 1 ); } @@ -2808,5 +2810,5 @@ IOItemCount structureInputSize; - IOByteCount structureOutputSize; + size_t structureOutputSize; // log @@ -2852,10 +2854,16 @@ memset( &TiltSensor_data.data, 0, sizeof( TiltSensor_data.data ) ); - result = IOConnectMethodStructureIStructureO( dataPort, - kernFunc, - structureInputSize, - &structureOutputSize, - &TiltSensor_data.data, - &TiltSensor_data.data ); +// result = IOConnectMethodStructureIStructureO( dataPort, +// kernFunc, +// structureInputSize, +// &structureOutputSize, +// &TiltSensor_data.data, +// &TiltSensor_data.data ); + result = IOConnectCallStructMethod( dataPort, + kernFunc, + &TiltSensor_data.data, + structureInputSize, + &TiltSensor_data.data, + &structureOutputSize ); if ( result != KERN_SUCCESS ) @@ -2875,5 +2883,5 @@ kern_return_t result; IOItemCount structureInputSize; - IOByteCount structureOutputSize; + size_t structureOutputSize; // log @@ -2899,11 +2907,17 @@ memset( &TiltSensor_data.data, 0, sizeof( TiltSensor_data.data ) ); - result = IOConnectMethodStructureIStructureO( TiltSensor_data.dataPort, - TiltSensor_data.kernFunc, - structureInputSize, - &structureOutputSize, - &TiltSensor_data.data, - &TiltSensor_data.data ); - +// result = IOConnectMethodStructureIStructureO( TiltSensor_data.dataPort, +// TiltSensor_data.kernFunc, +// structureInputSize, +// &structureOutputSize, +// &TiltSensor_data.data, +// &TiltSensor_data.data ); + result = IOConnectCallStructMethod( TiltSensor_data.dataPort, + TiltSensor_data.kernFunc, + &TiltSensor_data.data, + structureInputSize, + &TiltSensor_data.data, + &structureOutputSize ); + return 1; } @@ -2929,6 +2943,7 @@ else powerbookKernFunc = 21; - - fprintf( stdout, "osx_version = %ld \n", osx_version ); + + // 1.3.1.0: added cast to t_CKINT + fprintf( stdout, "osx_version = %ld \n", (t_CKINT)osx_version ); // ibook/powerbook (OS X 10.4.x) tilt sensor interface Index: /trunk/src/chuck_instr.cpp =================================================================== --- /trunk/src/chuck_instr.cpp (revision 174) +++ /trunk/src/chuck_instr.cpp (revision 213) @@ -1202,6 +1202,6 @@ Chuck_String * result = NULL; - // pop word from reg stack - pop_( reg_sp, 3 ); + // pop word from reg stack (1.3.1.0: add size check) + pop_( reg_sp, 1 + (sz_FLOAT / sz_UINT) ); // ISSUE: 64-bit (fixed 1.3.1.0) // left lhs = (Chuck_String *)(*(reg_sp)); @@ -1298,10 +1298,10 @@ Chuck_String * result = NULL; - // pop word from reg stack - pop_( reg_sp, 3 ); + // pop word from reg stack (1.3.1.0: added size check) + pop_( reg_sp, 1 + (sz_FLOAT / sz_UINT) ); // ISSUE: 64-bit (fixed 1.3.1.0) // left (2 word) lhs = (*(t_CKFLOAT *)(reg_sp)); - // right - rhs = (Chuck_String *)(*(reg_sp+2)); + // right (1.3.1.0: added size) + rhs = (Chuck_String *)(*(reg_sp+(sz_FLOAT/sz_INT))); // ISSUE: 64-bit (fixed 1.3.1.0) // make sure no null @@ -1389,8 +1389,8 @@ Chuck_String ** rhs_ptr = NULL; - // pop word from reg stack - pop_( reg_sp, 3 ); - // the previous reference - rhs_ptr = (Chuck_String **)(*(reg_sp+2)); + // pop word from reg stack (1.3.1.0: added size check) + pop_( reg_sp, 1 + (sz_FLOAT / sz_UINT) ); // ISSUE: 64-bit (fixed 1.3.1.0) + // the previous reference (1.3.1.0: added size check) + rhs_ptr = (Chuck_String **)(*(reg_sp+(sz_FLOAT/sz_UINT))); // ISSUE: 64-bit (fixed 1.3.1.0) // copy popped value into memory lhs = (*(t_CKFLOAT *)(reg_sp)); @@ -1582,14 +1582,24 @@ void Chuck_Instr_Reg_Push_Deref::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { - if( m_size == 4 ) // ISSUE: 64-bit - { - t_CKUINT *& reg_sp = (t_CKUINT *&)shred->reg->sp; - push_( reg_sp, *((t_CKUINT *)m_val) ); - } - else - { - t_CKFLOAT *& reg_sp = (t_CKFLOAT *&)shred->reg->sp; - push_( reg_sp, *((t_CKFLOAT *)m_val) ); - } + t_CKUINT *& reg_sp = (t_CKUINT *&)shred->reg->sp; + + // (added 1.3.1.0: made this integer only) + // ISSUE: 64-bit (fixed 1.3.1.0) + push_( reg_sp, *((t_CKUINT *)m_val) ); +} + + + + +//----------------------------------------------------------------------------- +// name: execute() +// desc: push the value pointed to by m_val onto register stack +//----------------------------------------------------------------------------- +void Chuck_Instr_Reg_Push_Deref2::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) +{ + t_CKFLOAT *& reg_sp = (t_CKFLOAT *&)shred->reg->sp; + + // (added 1.3.1.0) + push_( reg_sp, *((t_CKFLOAT *)m_val) ); } @@ -1715,8 +1725,23 @@ void Chuck_Instr_Reg_Pop_Word3::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { - t_CKUINT *& reg_sp = (t_CKUINT *&)shred->reg->sp; - + t_CKCOMPLEX *& reg_sp = (t_CKCOMPLEX *&)shred->reg->sp; + // pop word from reg stack - pop_( reg_sp, m_val ); + pop_( reg_sp, 1 ); +} + + + + +//----------------------------------------------------------------------------- +// name: execute() +// desc: ... +//----------------------------------------------------------------------------- +void Chuck_Instr_Reg_Pop_Word4::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) +{ + t_CKBYTE *& reg_sp = (t_CKBYTE *&)shred->reg->sp; + + // pop word from reg stack (changed 1.3.1.0 to use sz_WORD) + pop_( reg_sp, m_val * sz_WORD ); } @@ -3000,8 +3025,8 @@ t_CKUINT *& reg_sp = (t_CKUINT *&)shred->reg->sp; - // pop word from reg stack // ISSUE: 64-bit - pop_( reg_sp, 3 ); - // copy popped value into mem stack - *( (t_CKFLOAT *)(*(reg_sp+2)) ) = *(t_CKFLOAT *)reg_sp; + // pop word from reg stack // ISSUE: 64-bit (fixed 1.3.1.0) + pop_( reg_sp, 1 + (sz_FLOAT / sz_UINT) ); + // copy popped value into mem stack // ISSUE: 64-bit (fixed 1.3.1.0) + *( (t_CKFLOAT *)(*(reg_sp+(sz_FLOAT/sz_UINT))) ) = *(t_CKFLOAT *)reg_sp; t_CKFLOAT *& sp_double = (t_CKFLOAT *&)reg_sp; @@ -3021,7 +3046,7 @@ // pop word from reg stack - pop_( reg_sp, 5 ); - // copy popped value into mem stack - *( (t_CKCOMPLEX*)(*(reg_sp+4)) ) = *(t_CKCOMPLEX *)reg_sp; + pop_( reg_sp, 1 + (sz_COMPLEX / sz_UINT) ); // ISSUE: 64-bit (fixed 1.3.1.0) + // copy popped value into mem stack + *( (t_CKCOMPLEX*)(*(reg_sp+(sz_COMPLEX/sz_UINT))) ) = *(t_CKCOMPLEX *)reg_sp; // ISSUE: 64-bit (fixed 1.3.1.0) t_CKCOMPLEX *& sp_complex = (t_CKCOMPLEX *&)reg_sp; @@ -3272,10 +3297,10 @@ // get the local stack depth - caller local variables t_CKUINT local_depth = *(reg_sp+1); - // convert to number of 4-byte words, extra partial word counts as additional word - local_depth = ( local_depth >> 2 ) + ( local_depth & 0x3 ? 1 : 0 ); + // convert to number of int's (was: 4-byte words), extra partial word counts as additional word + local_depth = ( local_depth / sz_INT ) + ( local_depth & 0x3 ? 1 : 0 ); // ISSUE: 64-bit (fixed 1.3.1.0) // get the stack depth of the callee function args - t_CKUINT stack_depth = ( func->stack_depth >> 2 ) + ( func->stack_depth & 0x3 ? 1 : 0 ); + t_CKUINT stack_depth = ( func->stack_depth / sz_INT ) + ( func->stack_depth & 0x3 ? 1 : 0 ); // ISSUE: 64-bit (fixed 1.3.1.0) // get the previous stack depth - caller function args - t_CKUINT prev_stack = ( *(mem_sp-1) >> 2 ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); + t_CKUINT prev_stack = ( *(mem_sp-1) / sz_INT ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); // ISSUE: 64-bit (fixed 1.3.1.0) // jump the sp @@ -3351,8 +3376,8 @@ // get the local stack depth - caller local variables t_CKUINT local_depth = *(reg_sp+1); - // convert to number of 4-byte words, extra partial word counts as additional word - local_depth = ( local_depth >> 2 ) + ( local_depth & 0x3 ? 1 : 0 ); + // convert to number of int's (was: 4-byte words), extra partial word counts as additional word + local_depth = ( local_depth / sz_INT ) + ( local_depth & 0x3 ? 1 : 0 ); // ISSUE: 64-bit (fixed 1.3.1.0) // get the stack depth of the callee function args - t_CKUINT stack_depth = ( func->stack_depth >> 2 ) + ( func->stack_depth & 0x3 ? 1 : 0 ); + t_CKUINT stack_depth = ( func->stack_depth / sz_INT ) + ( func->stack_depth & 0x3 ? 1 : 0 ); // ISSUE: 64-bit (fixed 1.3.1.0) // UNUSED: get the previous stack depth - caller function args // UNUSED: t_CKUINT prev_stack = ( *(mem_sp-1) >> 2 ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); @@ -3407,10 +3432,11 @@ // push the return - if( m_val == 4 ) // ISSUE: 64-bit + // 1.3.1.0: check type to use kind instead of size + if( m_val == kindof_INT ) // ISSUE: 64-bit (fixed: 1.3.1.0) { // push the return args push_( reg_sp, retval.v_uint ); } - else if( m_val == 8 ) // ISSUE: 64-bit + else if( m_val == kindof_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // push the return args @@ -3418,5 +3444,5 @@ push_( sp_double, retval.v_float ); } - else if( m_val == 16 ) // ISSUE: 64-bit + else if( m_val == kindof_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { // push the return args @@ -3425,5 +3451,5 @@ push_( sp_complex, retval.v_complex ); } - else if( m_val == 0 ) { } + else if( m_val == kindof_VOID ) { } else assert( FALSE ); @@ -3456,8 +3482,8 @@ // get the local stack depth - caller local variables t_CKUINT local_depth = *(reg_sp+1); - // convert to number of 4-byte words, extra partial word counts as additional word - local_depth = ( local_depth >> 2 ) + ( local_depth & 0x3 ? 1 : 0 ); + // convert to number of int's (was: 4-byte words), extra partial word counts as additional word + local_depth = ( local_depth / sz_INT ) + ( local_depth & 0x3 ? 1 : 0 ); // ISSUE: 64-bit (fixed 1.3.1.0) // get the stack depth of the callee function args - t_CKUINT stack_depth = ( func->stack_depth >> 2 ) + ( func->stack_depth & 0x3 ? 1 : 0 ); + t_CKUINT stack_depth = ( func->stack_depth / sz_INT ) + ( func->stack_depth & 0x3 ? 1 : 0 ); // ISSUE: 64-bit (fixed 1.3.1.0) // UNUSED: get the previous stack depth - caller function args // UNUSED: t_CKUINT prev_stack = ( *(mem_sp-1) >> 2 ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); @@ -3500,10 +3526,11 @@ // push the return - if( m_val == 4 ) // ISSUE: 64-bit + // 1.3.1.0: check type to use kind instead of size + if( m_val == kindof_INT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // push the return args push_( reg_sp, retval.v_uint ); } - else if( m_val == 8 ) // ISSUE: 64-bit + else if( m_val == kindof_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // push the return args @@ -3511,5 +3538,5 @@ push_( sp_double, retval.v_float ); } - else if( m_val == 16 ) // ISSUE: 64-bit + else if( m_val == kindof_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { // push the return args @@ -3518,5 +3545,5 @@ push_( sp_complex, retval.v_complex ); } - else if( m_val == 0 ) { } + else if( m_val == kindof_VOID ) { } else assert( FALSE ); @@ -3589,5 +3616,5 @@ if( m_val ) { - // ISSUE: 64-bit? + // ISSUE: 64-bit? (1.3.1.0: this should be OK as long as shred->reg->sp is t_CKBYTE *) pop_( shred->reg->sp, m_val ); memcpy( sh->reg->sp, shred->reg->sp, m_val ); @@ -3732,10 +3759,10 @@ t_CKUINT len = strlen( str ); // copy - if( len < 45 ) + if( len < 48 ) strcpy( m_param_str, str ); else { - strncpy( m_param_str, str, 45 ); - strcpy( m_param_str + 45, "..." ); + strncpy( m_param_str, str, 48 ); + strcpy( m_param_str + 48, "..." ); } @@ -3776,6 +3803,7 @@ // allocate the array - if( m_type_ref->size == 4 ) // ISSUE: 64-bit - { + if( m_type_ref->size == sz_INT ) // ISSUE: 64-bit (fixed 1.3.1.0) + { + // TODO: look at size and treat Chuck_Array4 as ChuckArrayInt // pop the values pop_( reg_sp, m_length ); @@ -3794,8 +3822,8 @@ push_( reg_sp, (t_CKUINT)array ); } - else if( m_type_ref->size == 8 ) // ISSUE: 64-bit + else if( m_type_ref->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // pop the values - pop_( reg_sp, 2 * m_length ); + pop_( reg_sp, m_length * (sz_FLOAT / sz_INT) ); // 1.3.1.0 added size division // instantiate array Chuck_Array8 * array = new Chuck_Array8( m_length ); @@ -3814,8 +3842,8 @@ push_( reg_sp, (t_CKUINT)array ); } - else if( m_type_ref->size == 16 ) // ISSUE: 64-bit + else if( m_type_ref->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { // pop the values - pop_( reg_sp, 4 * m_length ); + pop_( reg_sp, m_length * (sz_COMPLEX / sz_INT) ); // 1.3.1.0 added size division // instantiate array Chuck_Array16 * array = new Chuck_Array16( m_length ); @@ -3907,8 +3935,8 @@ //----------------------------------------------------------------------------- // name: do_alloc_array() -// desc: ... +// desc: 1.3.1.0 -- changed size to kind //----------------------------------------------------------------------------- Chuck_Object * do_alloc_array( t_CKINT * capacity, const t_CKINT * top, - t_CKUINT size, t_CKBOOL is_obj, + t_CKUINT kind, t_CKBOOL is_obj, t_CKUINT * objs, t_CKINT & index ) { @@ -3925,5 +3953,6 @@ { // check size - if( size == 4 ) // ISSUE: 64-bit + // 1.3.1.0: look at type to use kind instead of size + if( kind == kindof_INT ) // ISSUE: 64-bit (fixed 1.3.1.0) { Chuck_Array4 * base = new Chuck_Array4( is_obj, *capacity ); @@ -3945,14 +3974,14 @@ return base; } - else if( size == 8 ) // ISSUE: 64-bit + else if( kind == kindof_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { Chuck_Array8 * base = new Chuck_Array8( *capacity ); if( !base ) goto out_of_memory; - + // initialize object initialize_object( base, &t_array ); return base; } - else if( size == 16 ) // ISSUE: 64-bit + else if( kind == kindof_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { Chuck_Array16 * base = new Chuck_Array16( *capacity ); @@ -3976,5 +4005,5 @@ { // the next - next = do_alloc_array( capacity+1, top, size, is_obj, objs, index ); + next = do_alloc_array( capacity+1, top, kind, is_obj, objs, index ); // error if NULL if( !next ) goto error; @@ -4078,5 +4107,5 @@ (t_CKINT *)(reg_sp - m_depth), (t_CKINT *)(reg_sp - 1), - m_type_ref->size, + getkindof(m_type_ref), // 1.3.1.0: changed; was 'm_type_ref->size' m_is_obj, obj_array, index @@ -4129,4 +4158,6 @@ shred->is_done = TRUE; } + + @@ -4154,5 +4185,6 @@ // 4 or 8 or 16 - if( m_size == 4 ) // ISSUE: 64-bit + // 1.3.1.0: look at type to use kind instead of size + if( m_kind == kindof_INT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4176,5 +4208,5 @@ } } - else if( m_size == 8 ) // ISSUE: 64-bit + else if( m_kind == kindof_FLOAT ) // ISSUE: 64-bit (1.3.1.0) { // get array @@ -4198,5 +4230,5 @@ } } - else if( m_size == 16 ) // ISSUE: 64-bit + else if( m_kind == kindof_COMPLEX ) // ISSUE: 64-bit { // get array @@ -4271,5 +4303,6 @@ // 4 or 8 or 16 - if( m_size == 4 ) // ISSUE: 64-bit + // 1.3.1.0: look at type to use kind instead of size + if( m_kind == kindof_INT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4293,5 +4326,5 @@ } } - else if( m_size == 8 ) // ISSUE: 64-bit + else if( m_kind == kindof_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4315,5 +4348,5 @@ } } - else if( m_size == 16 ) // ISSUE: 64-bit + else if( m_kind == kindof_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4414,5 +4447,6 @@ // 4 or 8 or 16 - if( m_size == 4 ) // ISSUE: 64-bit + // 1.3.1.0: look at type and use kind instead of size + if( m_kind == kindof_INT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get arry @@ -4436,5 +4470,5 @@ } } - else if( m_size == 8 ) // ISSUE: 64-bit + else if( m_kind == kindof_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4458,5 +4492,5 @@ } } - else if( m_size == 16 ) // ISSUE: 64-bit + else if( m_kind == kindof_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4537,6 +4571,12 @@ cval.im = 0; - // pop - pop_( sp, 1+(m_val/4) ); + // how much to pop (added 1.3.1.0) + t_CKUINT howmuch = 0; + // check kind + if( m_val == kindof_INT ) howmuch = 1; + else if( m_val == kindof_FLOAT ) howmuch = sz_FLOAT / sz_INT; + else if( m_val == kindof_COMPLEX) howmuch = sz_COMPLEX / sz_INT; + // pop (1.3.1.0: use howmuch instead of m_val/4) + pop_( sp, 1 + howmuch ); // ISSUE: 64-bit (fixed 1.3.1.0) // check pointer @@ -4544,5 +4584,6 @@ // 4 or 8 or 16 - if( m_val == 4 ) // ISSUE: 64-bit + // 1.3.1.0: changed to look at type (instead of size) + if( m_val == kindof_INT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4553,5 +4594,5 @@ arr->push_back( val ); } - else if( m_val == 8 ) // ISSUE: 64-bit + else if( m_val == kindof_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4562,5 +4603,5 @@ arr->push_back( fval ); } - else if( m_val == 16 ) // ISSUE: 64-bit + else if( m_val == kindof_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { // get array @@ -4624,7 +4665,8 @@ { // 4 or 8 or 16 - if( m_size == 4 ) { push_( sp, *((t_CKUINT *)data) ); } // ISSUE: 64-bit - else if( m_size == 8 ) { push_float( sp, *((t_CKFLOAT *)data) ); } // ISSUE: 64-bit - else if( m_size == 16 ) { push_complex( sp, *((t_CKCOMPLEX *)data) ); } // ISSUE: 64-bit // TODO: polar same? + // 1.3.1.0: check type to use kind instead of size + if( m_kind == kindof_INT ) { push_( sp, *((t_CKUINT *)data) ); } // ISSUE: 64-bit (fixed 1.3.1.0) + else if( m_kind == kindof_FLOAT ) { push_float( sp, *((t_CKFLOAT *)data) ); } // ISSUE: 64-bit (fixed 1.3.1.0) + else if( m_kind == kindof_COMPLEX ) { push_complex( sp, *((t_CKCOMPLEX *)data) ); } // ISSUE: 64-bit (fixed 1.3.1.0) // TODO: polar same? else assert( FALSE ); } @@ -4716,7 +4758,8 @@ { // 4 or 8 or 16 - if( m_size == 4 ) { push_( sp, *((t_CKUINT *)data) ); } // ISSUE: 64-bit - else if( m_size == 8 ) { push_float( sp, *((t_CKFLOAT *)data) ); } // ISSUE: 64-bit - else if( m_size == 16 ) { push_complex( sp, *((t_CKCOMPLEX *)data) ); } // ISSUE: 64-bit // TODO: polar same? + // 1.3.1.0: check type to use kind instead of size + if( m_kind == kindof_INT ) { push_( sp, *((t_CKUINT *)data) ); } // ISSUE: 64-bit (fixed 1.3.1.0) + else if( m_kind == kindof_FLOAT ) { push_float( sp, *((t_CKFLOAT *)data) ); } // ISSUE: 64-bit (fixed 1.3.1.0) + else if( m_kind == kindof_COMPLEX ) { push_complex( sp, *((t_CKCOMPLEX *)data) ); } // ISSUE: 64-bit (fixed 1.3.1.0) // TODO: polar same? else assert( FALSE ); } @@ -4744,7 +4787,8 @@ { // 4 or 8 or 16 - if( m_size == 4 ) { push_( sp, *((t_CKUINT *)m_addr) ); } // ISSUE: 64-bit - else if( m_size == 8 ) { push_float( sp, *((t_CKFLOAT *)m_addr) ); } // ISSUE: 64-bit - else if( m_size == 16 ) { push_complex( sp, *((t_CKCOMPLEX *)m_addr) ); } // ISSUE: 64-bit // TODO: polar same? + // 1.3.1.0: check type to use kind instead of size + if( m_kind == kindof_INT ) { push_( sp, *((t_CKUINT *)m_addr) ); } // ISSUE: 64-bit (fixed 1.3.1.0) + else if( m_kind == kindof_FLOAT ) { push_float( sp, *((t_CKFLOAT *)m_addr) ); } // ISSUE: 64-bit (fixed 1.3.1.0) + else if( m_kind == kindof_COMPLEX ) { push_complex( sp, *((t_CKCOMPLEX *)m_addr) ); } // ISSUE: 64-bit (fixed 1.3.1.0) // TODO: polar same? else assert( FALSE ); } @@ -5350,5 +5394,5 @@ pop_( sp, 2 ); - // issue: 64-bit + // ISSUE: 64-bit? // the IO Chuck_IO **& ppIO = (Chuck_IO **&)sp; @@ -5518,7 +5562,7 @@ // pop the value - pop_( sp, 3 ); - - // issue: 64-bit + pop_( sp, 1 + (sz_FLOAT / sz_INT) ); // ISSUE: 64-bit (fixed 1.3.1.0) + + // ISSUE: 64-bit // the IO Chuck_IO **& ppIO = (Chuck_IO **&)sp; @@ -5562,5 +5606,5 @@ pop_( sp, 2 ); - // issue: 64-bit + // ISSUE: 64-bit // the IO Chuck_IO ** ppIO = (Chuck_IO **)sp; @@ -5609,6 +5653,6 @@ void Chuck_Instr_Hack::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { - // look at the type - if( m_type_ref->size == 4 ) // ISSUE: 64-bit + // look at the type (1.3.1.0: added iskindofint) + if( m_type_ref->size == sz_INT && iskindofint(m_type_ref) ) // ISSUE: 64-bit (fixed 1.3.1.0) { t_CKINT * sp = (t_CKINT *)shred->reg->sp; @@ -5619,5 +5663,5 @@ fprintf( stderr, "\"%s\" : (%s)\n", ((Chuck_String *)*(sp-1))->str.c_str(), m_type_ref->c_name() ); } - else if( m_type_ref->size == 8 ) // ISSUE: 64-bit + else if( m_type_ref->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { t_CKFLOAT * sp = (t_CKFLOAT *)shred->reg->sp; @@ -5625,5 +5669,5 @@ fprintf( stderr, "%f :(%s)\n", *(sp-1), m_type_ref->c_name() ); } - else if( m_type_ref->size == 16 ) // ISSUE: 64-bit + else if( m_type_ref->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { if( m_type_ref->xid == te_complex ) @@ -5704,6 +5748,6 @@ Chuck_Type * type = m_type_refs[i]; - // look at the type - if( type->size == 4 ) // ISSUE: 64-bit + // look at the type (1.3.1.0: added is kindofint) + if( type->size == sz_INT && iskindofint(type) ) // ISSUE: 64-bit (fixed 1.3.1.0) { t_CKINT * sp = (t_CKINT *)the_sp; @@ -5720,7 +5764,7 @@ fprintf( stderr, "%s ", ((Chuck_String *)*(sp))->str.c_str() ); - the_sp += 4; + the_sp += sz_INT; // ISSUE: 64-bit (fixed 1.3.1.0) } - else if( type->size == 8 ) // ISSUE: 64-bit + else if( type->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) { t_CKFLOAT * sp = (t_CKFLOAT *)the_sp; @@ -5728,7 +5772,7 @@ fprintf( stderr, "%f ", *(sp) ); - the_sp += 8; + the_sp += sz_FLOAT; // ISSUE: 64-bit (fixed 1.3.1.0) } - else if( type->size == 16 ) // ISSUE: 64-bit + else if( type->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) { t_CKFLOAT * sp = (t_CKFLOAT *)the_sp; @@ -5740,5 +5784,5 @@ fprintf( stderr, "%%(%.4f,%.4f*pi) ", *(sp), *(sp+1)/ONE_PI ); - the_sp += 16; + the_sp += sz_COMPLEX; // ISSUE: 64-bit (fixed 1.3.1.0) } else if( type->size == 0 ) Index: /trunk/src/makefile.osx =================================================================== --- /trunk/src/makefile.osx (revision 178) +++ /trunk/src/makefile.osx (revision 213) @@ -17,10 +17,10 @@ endif -CFLAGS+= -D__MACOSX_CORE__ -m32 $(ISYSROOT) +CFLAGS+= -D__MACOSX_CORE__ $(ISYSROOT) CFLAGSDEPEND+= -D__MACOSX_CORE__ $(ISYSROOT) FRAMEWORKS+= CoreAudio CoreMIDI CoreFoundation IOKit Carbon AppKit Foundation LDFLAGS+= $(ISYSROOT) $(addprefix -framework ,$(FRAMEWORKS)) \ - $(LINK_EXTRAS) -lstdc++ -lm -m32 + $(LINK_EXTRAS) -lstdc++ -lm CSRCS+= util_sndfile.c Index: /trunk/src/ulib_std.cpp =================================================================== --- /trunk/src/ulib_std.cpp (revision 83) +++ /trunk/src/ulib_std.cpp (revision 213) @@ -559,6 +559,7 @@ CK_DLL_SFUN( rand2_impl ) // inclusive. { - int min = *(int *)ARGS, max = *((int *)ARGS + 1); - int range = max - min; + // 1.3.1.0: converted int to t_CKINT for 64-bit compatibility + t_CKINT min = *(t_CKINT *)ARGS, max = *((t_CKINT *)ARGS + 1); + t_CKINT range = max - min; if ( range == 0 ) { @@ -572,9 +573,9 @@ if( range > 0 ) { - RETURN->v_int = min + (int) ( (1.0 + range) * ( ::rand()/(RAND_MAX+1.0) ) ); + RETURN->v_int = min + (t_CKINT)( (1.0 + range) * ( ::rand()/(RAND_MAX+1.0) ) ); } else { - RETURN->v_int = min - (int) ( (-range + 1.0) * ( ::rand()/(RAND_MAX+1.0) ) ); + RETURN->v_int = min - (t_CKINT)( (-range + 1.0) * ( ::rand()/(RAND_MAX+1.0) ) ); } } Index: /trunk/src/chuck_emit.cpp =================================================================== --- /trunk/src/chuck_emit.cpp (revision 191) +++ /trunk/src/chuck_emit.cpp (revision 213) @@ -383,12 +383,14 @@ { // if decl, then expect only one word per var + // added 1.3.1.0: iskindofint -- since on some 64-bit systems sz_INT == sz_FLOAT if( exp->s_type == ae_exp_decl ) - emit->append( new Chuck_Instr_Reg_Pop_Word3( exp->decl.num_var_decls ) ); - else if( exp->type->size == 4 ) // ISSUE: 64-bit + // (added 1.3.1.0 -- multiply by type size; #64-bit) + emit->append( new Chuck_Instr_Reg_Pop_Word4( exp->decl.num_var_decls * exp->type->size / sz_WORD ) ); + else if( exp->type->size == sz_INT && iskindofint(exp->type) ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Reg_Pop_Word ); - else if( exp->type->size == 8 ) // ISSUE: 64-bit + else if( exp->type->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Reg_Pop_Word2 ); - else if( exp->type->size == 16 ) // ISSUE: 64-bit - emit->append( new Chuck_Instr_Reg_Pop_Word3( 4 ) ); + else if( exp->type->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) + emit->append( new Chuck_Instr_Reg_Pop_Word3 ); else { @@ -659,10 +661,10 @@ while( e ) { - if( e->type->size == 8 ) // ISSUE: 64-bit - num_words += 2; - else if( e->type->size == 4 ) // ISSUE: 64-bit - num_words += 1; - else if( e->type->size == 16 ) // ISSUE: 64-bit - num_words += 4; + if( e->type->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) + num_words += sz_FLOAT / sz_WORD; // changed to compute number of words; 1.3.1.0 + else if( e->type->size == sz_INT ) // ISSUE: 64-bit (fixed 1.3.1.0) + num_words += sz_INT / sz_WORD; // changed to compute number of words; 1.3.1.0 + else if( e->type->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) + num_words += sz_COMPLEX / sz_WORD; // changed to compute number of words; 1.3.1.0 else if( e->type->size != 0 ) { @@ -677,6 +679,6 @@ } - // pop - if( num_words > 0 ) emit->append( new Chuck_Instr_Reg_Pop_Word3( num_words ) ); + // pop (changed to Chuck_Instr_Reg_Pop_Word4 in 1.3.1.0) + if( num_words > 0 ) emit->append( new Chuck_Instr_Reg_Pop_Word4( num_words ) ); } @@ -1106,4 +1108,5 @@ // initialize our loop counter + // TODO: memory-manage the counter? emit->append( new Chuck_Instr_Init_Loop_Counter( (t_CKUINT)(counter = new t_CKINT) ) ); @@ -1116,6 +1119,6 @@ // push the value of the loop counter - // TODO: get rid of hard code 4 - emit->append( new Chuck_Instr_Reg_Push_Deref( (t_CKUINT)counter, 4 ) ); // ISSUE: 64-bit + // (changed 1.3.1.0 to not pass in the size parameter, assume to be t_CKUINT *) + emit->append( new Chuck_Instr_Reg_Push_Deref( (t_CKUINT)counter ) ); // ISSUE: 64-bit (fixed 1.3.1.0) // get the type, taking cast into account @@ -1809,6 +1812,6 @@ case te_array: - // check size - emit->append( instr = new Chuck_Instr_Array_Append( t_left->array_type->size ) ); + // check size (1.3.1.0: changed to getkindof) + emit->append( instr = new Chuck_Instr_Array_Append( getkindof( t_left->array_type ) ) ); break; @@ -2424,9 +2427,10 @@ { // assign primitive - if( right->size == 4 ) // ISSUE: 64-bit + // added 1.3.1.0: iskindofint -- since on some 64-bit systems, sz_INT == sz_FLOAT + if( right->size == sz_INT && iskindofint(right) ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Assign_Primitive ); - else if( right->size == 8 ) // ISSUE: 64-bit + else if( right->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Assign_Primitive2 ); - else if( right->size == 16 ) // ISSUE: 64-bit + else if( right->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Assign_Primitive4 ); else @@ -3040,5 +3044,6 @@ // make sure - if( type->size != 4 && type->size != 8 && type->size != 16 ) // ISSUE: 64-bit + // ISSUE: 64-bit (fixed 1.3.1.0) + if( type->size != sz_INT && type->size != sz_FLOAT && type->size != sz_COMPLEX ) { EM_error2( array->linepos, @@ -3050,14 +3055,14 @@ if( depth == 1 ) { - // emit the array access + // emit the array access (1.3.1.0: use getkindof instead of type->size) if( is_str ) - emit->append( new Chuck_Instr_Array_Map_Access( type->size, is_var ) ); + emit->append( new Chuck_Instr_Array_Map_Access( getkindof(type), is_var ) ); else - emit->append( new Chuck_Instr_Array_Access( type->size, is_var ) ); + emit->append( new Chuck_Instr_Array_Access( getkindof(type), is_var ) ); } else { - // emit the multi array access - emit->append( new Chuck_Instr_Array_Access_Multi( depth, type->size, is_var ) ); + // emit the multi array access (1.3.1.0: use getkindof instead of type->size) + emit->append( new Chuck_Instr_Array_Access_Multi( depth, getkindof(type), is_var ) ); } @@ -3099,13 +3104,15 @@ // call the function t_CKUINT size = type->size; + t_CKUINT kind = getkindof( type ); // added 1.3.1.0 if( func->def->s_type == ae_func_builtin ) { - if( size == 0 || size == 4 || size == 8 || size == 16 ) // ISSUE: 64-bit - { - // is member + // ISSUE: 64-bit (fixed 1.3.1.0) + if( size == 0 || size == sz_INT || size == sz_FLOAT || size == sz_COMPLEX ) + { + // is member (1.3.1.0: changed to use kind instead of size) if( is_member ) - emit->append( new Chuck_Instr_Func_Call_Member( size ) ); + emit->append( new Chuck_Instr_Func_Call_Member( kind ) ); else - emit->append( new Chuck_Instr_Func_Call_Static( size ) ); + emit->append( new Chuck_Instr_Func_Call_Static( kind ) ); } else @@ -3316,7 +3323,7 @@ // emit the base (TODO: return on error?) emit_engine_emit_exp( emit, member->base ); - // lookup the member + // lookup the member (1.3.1.0: changed to use getkindof instead of type size) emit->append( new Chuck_Instr_Dot_Member_Data( - offset, member->self->type->size, emit_addr ) ); + offset, getkindof(member->self->type), emit_addr ) ); } else @@ -3325,7 +3332,7 @@ if( value->addr ) { - // emit builtin + // emit builtin (1.3.1.0: changed to use getkindof instead of type size) emit->append( new Chuck_Instr_Dot_Static_Import_Data( - value->addr, member->self->type->size, emit_addr ) ); + value->addr, getkindof(member->self->type), emit_addr ) ); } else @@ -3333,7 +3340,7 @@ // emit the type emit->append( new Chuck_Instr_Reg_Push_Imm( (t_CKUINT)t_base ) ); - // emit the static value + // emit the static value (1.3.1.0: changed to use getkindof in addition to size) emit->append( new Chuck_Instr_Dot_Static_Data( - offset, member->self->type->size, emit_addr ) ); + offset, member->self->type->size, getkindof(member->self->type), emit_addr ) ); } } @@ -3369,7 +3376,7 @@ if( value->addr ) { - // emit + // emit (1.3.1.0: changed to use getkindof instead of type size) emit->append( new Chuck_Instr_Dot_Static_Import_Data( - value->addr, member->self->type->size, emit_addr ) ); + value->addr, getkindof(member->self->type), emit_addr ) ); } else @@ -3379,7 +3386,7 @@ // find the offset for data offset = value->offset; - // emit the member + // emit the member (1.3.1.0: changed to use getkindof in addition to size) emit->append( new Chuck_Instr_Dot_Static_Data( - offset, member->self->type->size, emit_addr ) ); + offset, member->self->type->size, getkindof(member->self->type), emit_addr ) ); } } @@ -3620,9 +3627,9 @@ { // push 0 - if( type->size == 4 ) // ISSUE: 64-bit + if( type->size == sz_INT ) // ISSUE: 64-bit emit->append( new Chuck_Instr_Reg_Push_Imm( 0 ) ); - else if( type->size == 8 ) // ISSUE: 64-bit + else if( type->size == sz_FLOAT ) // ISSUE: 64-bit emit->append( new Chuck_Instr_Reg_Push_Imm2( 0.0 ) ); - else if( type->size == 16 ) // ISSUE: 64-bit + else if( type->size == sz_COMPLEX ) // ISSUE: 64-bit emit->append( new Chuck_Instr_Reg_Push_Imm4( 0.0, 0.0 ) ); else @@ -3641,9 +3648,10 @@ { // zero out location in object, and leave addr on operand stack - if( type->size == 4 ) // ISSUE: 64-bit + // added 1.3.1.0: iskindofint -- on some 64-bit systems, sz_int == sz_FLOAT + if( type->size == sz_INT && iskindofint(type) ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Alloc_Member_Word( value->offset ) ); - else if( type->size == 8 ) // ISSUE: 64-bit + else if( type->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Alloc_Member_Word2( value->offset ) ); - else if( type->size == 16 ) // ISSUE: 64-bit + else if( type->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Alloc_Member_Word4( value->offset ) ); else @@ -3678,10 +3686,18 @@ // BAD: // FIX: - if( type->size == 4 ) // ISSUE: 64-bit (added 1.3.0.0 -- is_obj) + // added 1.3.1.0: iskindofint -- since on some 64-bit systems, sz_INT == sz_FLOAT + if( type->size == sz_INT && iskindofint(type) ) // ISSUE: 64-bit (fixed 1.3.1.0) + { + // (added 1.3.0.0 -- is_obj) emit->append( new Chuck_Instr_Alloc_Word( local->offset, is_obj ) ); - else if( type->size == 8 ) // ISSUE: 64-bit + } + else if( type->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) + { emit->append( new Chuck_Instr_Alloc_Word2( local->offset ) ); - else if( type->size == 16 ) // ISSUE: 64-bit + } + else if( type->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) + { emit->append( new Chuck_Instr_Alloc_Word4( local->offset ) ); + } else { @@ -3696,7 +3712,7 @@ // emit the type emit->append( new Chuck_Instr_Reg_Push_Imm( (t_CKUINT)emit->env->class_def ) ); - // emit the static value + // emit the static value (1.3.1.0: changed to use getkindof in addition to size) emit->append( new Chuck_Instr_Dot_Static_Data( - value->offset, value->type->size, TRUE ) ); + value->offset, value->type->size, getkindof(value->type), TRUE ) ); } } @@ -3736,11 +3752,12 @@ emit->append( new Chuck_Instr_Assign_Object ); // size 4 primitive - else if( type->size == 4 ) // ISSUE: 64-bit + // added 1.3.1.0: iskindofint -- since on some 64-bit systems, sz_INT == sz_FLOAT + else if( type->size == sz_INT && iskindofint(type) ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Assign_Primitive ); // size 8 primitive - else if( type->size == 8 ) // ISSUE: 64-bit + else if( type->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Assign_Primitive2 ); // size 16 primitive - else if( type->size == 16 ) // ISSUE: 64-bit + else if( type->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Assign_Primitive4 ); else @@ -4165,6 +4182,6 @@ // TODO: this is a hack - what if exp is not func_call? // if( emit->code->need_this ) - // size += 4; - + // size += sz_INT; // (changed 1.3.1.0: 4 to sz_INT) + // emit instruction that will put the code on the stack emit->append( new Chuck_Instr_Reg_Push_Imm( (t_CKUINT)code ) ); @@ -4289,9 +4306,10 @@ emit->append( new Chuck_Instr_Reg_Push_Imm( (t_CKUINT)v->func_ref ) ); // check size - else if( v->type->size == 4 ) // ISSUE: 64-bit + // (added 1.3.1.0: iskindofint -- since in some 64-bit systems, sz_INT == sz_FLOAT) + else if( v->type->size == sz_INT && iskindofint(v->type) ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Reg_Push_Mem( v->offset, v->is_context_global ) ); - else if( v->type->size == 8 ) // ISSUE: 64-bit + else if( v->type->size == sz_FLOAT ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Reg_Push_Mem2( v->offset, v->is_context_global ) ); - else if( v->type->size == 16 ) // ISSUE: 64-bit + else if( v->type->size == sz_COMPLEX ) // ISSUE: 64-bit (fixed 1.3.1.0) emit->append( new Chuck_Instr_Reg_Push_Mem4( v->offset, v->is_context_global ) ); else Index: /trunk/src/chuck_instr.h =================================================================== --- /trunk/src/chuck_instr.h (revision 174) +++ /trunk/src/chuck_instr.h (revision 213) @@ -1540,10 +1540,23 @@ //----------------------------------------------------------------------------- // name: struct Chuck_Instr_Reg_Pop_Word3 -// desc: pop arbitrary num of word from reg stack -//----------------------------------------------------------------------------- -struct Chuck_Instr_Reg_Pop_Word3 : public Chuck_Instr_Unary_Op -{ -public: - Chuck_Instr_Reg_Pop_Word3( t_CKUINT num ) { this->set( num ); } +// desc: pop a complex value from reg stack (change 1.3.1.0) +//----------------------------------------------------------------------------- +struct Chuck_Instr_Reg_Pop_Word3 : public Chuck_Instr +{ +public: + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); +}; + + + + +//----------------------------------------------------------------------------- +// name: struct Chuck_Instr_Reg_Pop_Word4 +// desc: pop arbitrary num of word from reg stack (added 1.3.1.0) +//----------------------------------------------------------------------------- +struct Chuck_Instr_Reg_Pop_Word4 : public Chuck_Instr_Unary_Op +{ +public: + Chuck_Instr_Reg_Pop_Word4( t_CKUINT num ) { this->set( num ); } virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); }; @@ -1826,27 +1839,27 @@ // name: struct Chuck_Instr_Reg_Push_Deref // desc: push value from pointer +// changed 1.3.1.0 to not use a separate size param; now int-only //----------------------------------------------------------------------------- struct Chuck_Instr_Reg_Push_Deref : public Chuck_Instr_Unary_Op { public: - Chuck_Instr_Reg_Push_Deref( t_CKUINT src, t_CKUINT size ) - { this->set( src ); m_size = size; } - -public: - virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); - t_CKUINT m_size; -}; - - - - -//----------------------------------------------------------------------------- -// name: struct Chuck_Instr_Reg_Push_Deref -// desc: push a t_CKFLOAT variable from main memory to reg stack -//----------------------------------------------------------------------------- -struct Chuck_Instr_Reg_Push_Deref2 : public Chuck_Instr_Unary_Op2 -{ -public: - Chuck_Instr_Reg_Push_Deref2( t_CKFLOAT src ) + Chuck_Instr_Reg_Push_Deref( t_CKUINT src ) + { this->set( src ); } + +public: + virtual void execute( Chuck_VM * vm, Chuck_VM_Shred * shred ); +}; + + + + +//----------------------------------------------------------------------------- +// name: struct Chuck_Instr_Reg_Push_Deref2 +// desc: push a t_CKFLOAT value from pointer +//----------------------------------------------------------------------------- +struct Chuck_Instr_Reg_Push_Deref2 : public Chuck_Instr_Unary_Op +{ +public: + Chuck_Instr_Reg_Push_Deref2( t_CKUINT src ) { this->set( src ); } @@ -1967,5 +1980,5 @@ //----------------------------------------------------------------------------- -// name: struct Chuck_Instr_Mem_Pop_Word2 +// name: struct Chuck_Instr_Mem_Pop_Word3 // desc: pop a value from mem stack //----------------------------------------------------------------------------- @@ -2565,7 +2578,7 @@ { public: - Chuck_Instr_Array_Access( t_CKUINT size, t_CKUINT emit_addr, + Chuck_Instr_Array_Access( t_CKUINT kind, t_CKUINT emit_addr, t_CKUINT istr = FALSE ) - { m_size = size; m_emit_addr = emit_addr; m_istr = istr; } + { m_kind = kind; m_emit_addr = emit_addr; m_istr = istr; } public: @@ -2573,10 +2586,10 @@ virtual const char * params() const { static char buffer[256]; - sprintf( buffer, "size=%ld, emit_addr=%ld istr=%ld", - m_size, m_emit_addr, m_istr ); + sprintf( buffer, "kind=%ld, emit_addr=%ld istr=%ld", + m_kind, m_emit_addr, m_istr ); return buffer; } protected: - t_CKUINT m_size; + t_CKUINT m_kind; t_CKUINT m_emit_addr; t_CKUINT m_istr; @@ -2593,6 +2606,6 @@ { public: - Chuck_Instr_Array_Map_Access( t_CKUINT size, t_CKUINT emit_addr ) - { m_size = size; m_emit_addr = emit_addr; } + Chuck_Instr_Array_Map_Access( t_CKUINT kind, t_CKUINT emit_addr ) + { m_kind = kind; m_emit_addr = emit_addr; } public: @@ -2600,9 +2613,9 @@ virtual const char * params() const { static char buffer[256]; - sprintf( buffer, "size=%ld, emit_addr=%ld", m_size, m_emit_addr ); + sprintf( buffer, "kind=%ld, emit_addr=%ld", m_kind, m_emit_addr ); return buffer; } protected: - t_CKUINT m_size; + t_CKUINT m_kind; t_CKUINT m_emit_addr; }; @@ -2618,6 +2631,6 @@ { public: - Chuck_Instr_Array_Access_Multi( t_CKUINT depth, t_CKUINT size, t_CKUINT emit_addr ) - { m_size = size; m_depth = depth; m_emit_addr = emit_addr; } + Chuck_Instr_Array_Access_Multi( t_CKUINT depth, t_CKUINT kind, t_CKUINT emit_addr ) + { m_kind = kind; m_depth = depth; m_emit_addr = emit_addr; } public: @@ -2625,10 +2638,10 @@ virtual const char * params() const { static char buffer[256]; - sprintf( buffer, "depth=%ld, size=%ld, emit_addr=%ld", m_depth, m_size, m_emit_addr ); + sprintf( buffer, "depth=%ld, kind=%ld, emit_addr=%ld", m_depth, m_kind, m_emit_addr ); return buffer; } protected: t_CKUINT m_depth; - t_CKUINT m_size; + t_CKUINT m_kind; t_CKUINT m_emit_addr; }; @@ -2644,6 +2657,6 @@ { public: - Chuck_Instr_Dot_Member_Data( t_CKUINT offset, t_CKUINT size, t_CKUINT emit_addr ) - { m_offset = offset; m_size = size; m_emit_addr = emit_addr; } + Chuck_Instr_Dot_Member_Data( t_CKUINT offset, t_CKUINT kind, t_CKUINT emit_addr ) + { m_offset = offset; m_kind = kind; m_emit_addr = emit_addr; } public: @@ -2651,10 +2664,10 @@ virtual const char * params() const { static char buffer[256]; - sprintf( buffer, "offset=%ld, size=%ld, emit_addr=%ld", m_offset, m_size, m_emit_addr ); + sprintf( buffer, "offset=%ld, kind=%ld, emit_addr=%ld", m_offset, m_kind, m_emit_addr ); return buffer; } protected: t_CKUINT m_offset; - t_CKUINT m_size; + t_CKUINT m_kind; t_CKUINT m_emit_addr; }; @@ -2694,6 +2707,6 @@ { public: - Chuck_Instr_Dot_Static_Data( t_CKUINT offset, t_CKUINT size, t_CKUINT emit_addr ) - { m_offset = offset; m_size = size; m_emit_addr = emit_addr; } + Chuck_Instr_Dot_Static_Data( t_CKUINT offset, t_CKUINT size, t_CKUINT kind, t_CKUINT emit_addr ) + { m_offset = offset; m_size = size; m_kind = kind; m_emit_addr = emit_addr; } public: @@ -2701,5 +2714,5 @@ virtual const char * params() const { static char buffer[256]; - sprintf( buffer, "offset=%ld, size=%ld, emit_addr=%ld", m_offset, m_size, m_emit_addr ); + sprintf( buffer, "offset=%ld, size=%ld, kind=%ld, emit_addr=%ld", m_offset, m_size, m_kind, m_emit_addr ); return buffer; } @@ -2707,4 +2720,5 @@ t_CKUINT m_offset; t_CKUINT m_size; + t_CKUINT m_kind; t_CKUINT m_emit_addr; }; @@ -2720,6 +2734,6 @@ { public: - Chuck_Instr_Dot_Static_Import_Data( void * addr, t_CKUINT size, t_CKUINT emit_addr ) - { m_addr = addr; m_size = size; m_emit_addr = emit_addr; } + Chuck_Instr_Dot_Static_Import_Data( void * addr, t_CKUINT kind, t_CKUINT emit_addr ) + { m_addr = addr; m_kind = kind; m_emit_addr = emit_addr; } public: @@ -2727,10 +2741,10 @@ virtual const char * params() const { static char buffer[256]; - sprintf( buffer, "addr=%ld, size=%ld, emit_addr=%ld", (t_CKUINT)m_addr, m_size, m_emit_addr ); + sprintf( buffer, "addr=%ld, kind=%ld, emit_addr=%ld", (t_CKUINT)m_addr, m_kind, m_emit_addr ); return buffer; } protected: void * m_addr; - t_CKUINT m_size; + t_CKUINT m_kind; t_CKUINT m_emit_addr; }; Index: /trunk/src/makefile =================================================================== --- /trunk/src/makefile (revision 193) +++ /trunk/src/makefile (revision 213) @@ -21,5 +21,5 @@ osx linux-oss linux-jack linux-alsa win32 osx-rl: chuck -CK_VERSION=1.3.0.2 +CK_VERSION=1.3.1.0 LEX=flex @@ -116,5 +116,5 @@ clean: - @rm -f $(wildcard chuck chuck.exe) $(OBJS) $(patsubst %.o,%.d,$(OBJS)) \ + @rm -f $(wildcard chuck chuck.exe) *.o *.d $(OBJS) $(patsubst %.o,%.d,$(OBJS)) \ *~ chuck.output chuck.tab.h chuck.tab.c chuck.yy.c $(DIST_DIR){,.tgz,.zip} Index: /trunk/src/chuck_type.cpp =================================================================== --- /trunk/src/chuck_type.cpp (revision 166) +++ /trunk/src/chuck_type.cpp (revision 213) @@ -4243,4 +4243,22 @@ t_CKBOOL isfunc( Chuck_Type * type ) { return isa( type, &t_function ); } +t_CKBOOL iskindofint( Chuck_Type * type ) // added 1.3.1.0 +{ return isa( type, &t_int ) || isobj( type ); } +t_CKUINT getkindof( Chuck_Type * type ) // added 1.3.1.0 +{ + // the kind (1.3.1.0) + t_CKUINT kind = kindof_VOID; + + // check size + if( type->size == sz_INT && iskindofint(type) ) + kind = kindof_INT; + else if( type->size == sz_FLOAT ) + kind = kindof_FLOAT; + else if( type->size == sz_COMPLEX ) + kind = kindof_COMPLEX; + + // done + return kind; +} Index: /trunk/src/chuck_globals.cpp =================================================================== --- /trunk/src/chuck_globals.cpp (revision 192) +++ /trunk/src/chuck_globals.cpp (revision 213) @@ -42,5 +42,5 @@ // current version -const char CK_VERSION[] = "1.3.0.2 (chimera)"; +const char CK_VERSION[] = "1.3.1.0:beta-1 (chimera)"; // global virtual machine Index: /trunk/src/ugen_xxx.cpp =================================================================== --- /trunk/src/ugen_xxx.cpp (revision 172) +++ /trunk/src/ugen_xxx.cpp (revision 213) @@ -1198,5 +1198,6 @@ data->vm = SHRED->vm_ref; - OBJ_MEMBER_UINT(SELF, foogen_offset_data) = (unsigned int) data; + // 1.3.1.0: changed from unsigned int to t_CKUINT + OBJ_MEMBER_UINT(SELF, foogen_offset_data) = (t_CKUINT)data; Chuck_UGen * ugen = (Chuck_UGen *)SELF; @@ -1214,5 +1215,5 @@ func->def->arg_list->next == NULL && // ensure returns float - func->def->ret_type == &t_float) + func->def->ret_type == &t_float ) { tick_fun_index = i; @@ -1221,15 +1222,15 @@ } - if(tick_fun_index != -1) + if( tick_fun_index != -1 ) { vector instrs; // push arg (float input) - instrs.push_back(new Chuck_Instr_Reg_Push_Deref((t_CKUINT) &data->input, 8)); + instrs.push_back(new Chuck_Instr_Reg_Push_Deref2( (t_CKUINT)&data->input ) ); // push this (as func arg) - instrs.push_back(new Chuck_Instr_Reg_Push_Imm((unsigned int) SELF)); + instrs.push_back(new Chuck_Instr_Reg_Push_Imm((t_CKUINT)SELF) ); // 1.3.1.0: changed to t_CKUINT // reg dup last (push this again) (for member func resolution) instrs.push_back(new Chuck_Instr_Reg_Dup_Last); // dot member func - instrs.push_back(new Chuck_Instr_Dot_Member_Func(tick_fun_index)); + instrs.push_back(new Chuck_Instr_Dot_Member_Func(tick_fun_index) ); // func to code instrs.push_back(new Chuck_Instr_Func_To_Code); @@ -1239,5 +1240,5 @@ instrs.push_back(new Chuck_Instr_Func_Call()); // push immediate - instrs.push_back(new Chuck_Instr_Reg_Push_Imm((unsigned int) &data->output)); + instrs.push_back(new Chuck_Instr_Reg_Push_Imm((t_CKUINT)&data->output) ); // 1.3.1.0: changed to t_CKUINT // assign primitive instrs.push_back(new Chuck_Instr_Assign_Primitive2); Index: /trunk/src/chuck_def.h =================================================================== --- /trunk/src/chuck_def.h (revision 8) +++ /trunk/src/chuck_def.h (revision 213) @@ -46,7 +46,6 @@ #define t_CKSINGLE float #define t_CKINT long -#define t_CKDWORD unsigned long -#define t_CKUINT t_CKDWORD -#define t_CKBOOL t_CKDWORD +#define t_CKUINT unsigned t_CKINT +#define t_CKBOOL unsigned t_CKINT #define t_CKBYTE unsigned char #define t_CKVOID void @@ -59,18 +58,25 @@ // size -#define sz_TIME sizeof(double) -#define sz_DUR sizeof(double) -#define sz_FLOAT sizeof(double) -#define sz_DOUBLE sizeof(double) -#define sz_SINGLE sizeof(float) -#define sz_INT sizeof(long) -#define sz_DWORD sizeof(unsigned long) -#define sz_UINT sizeof(t_CKDWORD) -#define sz_BOOL sizeof(t_CKDWORD) -#define sz_BYTE sizeof(unsigned char) -#define sz_VOID 0 -#define sz_VOIDPTR sizeof(void *) +#define sz_TIME sizeof(t_CKTIME) +#define sz_DUR sizeof(t_CKDUR) +#define sz_FLOAT sizeof(t_CKFLOAT) +#define sz_DOUBLE sizeof(t_CKDOUBLE) +#define sz_SINGLE sizeof(t_CKSINGLE) +#define sz_INT sizeof(t_CKINT) +#define sz_UINT sizeof(t_CKUINT) +#define sz_BOOL sizeof(t_CKBOOL) +#define sz_BYTE sizeof(t_CKBYTE) +#define sz_VOIDPTR sizeof(t_CKVOIDPTR) #define sz_COMPLEX sizeof(t_CKCOMPLEX) #define sz_POLAR sizeof(t_CKPOLAR) +#define sz_VOID 0 +#define sz_WORD 4 + +// kinds (added 1.3.1.0 to faciliate 64-bit support) +// to differentiate in case int and float have same size +#define kindof_VOID 0 +#define kindof_INT 1 +#define kindof_FLOAT 2 +#define kindof_COMPLEX 3 typedef char * c_str; Index: /trunk/src/rtmidi.cpp =================================================================== --- /trunk/src/rtmidi.cpp (revision 83) +++ /trunk/src/rtmidi.cpp (revision 213) @@ -286,5 +286,5 @@ { int ret; - void *object; + MIDIObjectRef object = NULL; // 1.3.1.0 MIDIObjectType type; @@ -321,5 +321,5 @@ // unknown type printf("Unknown type %d returned from findobject\n", (int) type); - CFRelease(object); + CFRelease( &object ); // 1.3.1.0 return -1; } @@ -520,5 +520,5 @@ // Get the desired input source identifier. MIDIEndpointRef endpoint = MIDIGetSource( portNumber ); - if ( endpoint == NULL ) { + if ( endpoint == 0 ) { // 1.3.1.0: changed from NULL to 0 MIDIPortDispose( port ); MIDIClientDispose( data->client ); @@ -691,5 +691,5 @@ // Get the desired output port identifier. MIDIEndpointRef destination = MIDIGetDestination( portNumber ); - if ( destination == NULL ) { + if ( destination == 0 ) { // 1.3.1.0: changed from NULL to 0 MIDIPortDispose( port ); MIDIClientDispose( data->client ); Index: /trunk/src/chuck_lang.cpp =================================================================== --- /trunk/src/chuck_lang.cpp (revision 161) +++ /trunk/src/chuck_lang.cpp (revision 213) @@ -3100,10 +3100,10 @@ { Chuck_Array * array = (Chuck_Array *)SELF; - // TODO: make this safe! - if( array->data_type_size() == CHUCK_ARRAY4_DATASIZE ) + // ISSUE: 64-bit (fixed 1.3.1.0 using data kind) + if( array->data_type_kind() == CHUCK_ARRAY4_DATAKIND ) RETURN->v_int = ((Chuck_Array4 *)array)->push_back( GET_NEXT_UINT( ARGS ) ); - else if( array->data_type_size() == CHUCK_ARRAY8_DATASIZE ) + else if( array->data_type_kind() == CHUCK_ARRAY8_DATAKIND ) RETURN->v_int = ((Chuck_Array8 *)array)->push_back( GET_NEXT_FLOAT( ARGS ) ); - else if( array->data_type_size() == CHUCK_ARRAY16_DATASIZE ) + else if( array->data_type_kind() == CHUCK_ARRAY16_DATAKIND ) RETURN->v_int = ((Chuck_Array16 *)array)->push_back( GET_NEXT_COMPLEX( ARGS ) ); else @@ -3115,10 +3115,10 @@ { Chuck_Array * array = (Chuck_Array *)SELF; - // TODO: make this safe! - if( array->data_type_size() == CHUCK_ARRAY4_DATASIZE ) + // ISSUE: 64-bit (fixed 1.3.1.0 using data kind) + if( array->data_type_kind() == CHUCK_ARRAY4_DATAKIND ) RETURN->v_int = ((Chuck_Array4 *)array)->pop_back( ); - else if( array->data_type_size() == CHUCK_ARRAY8_DATASIZE ) + else if( array->data_type_kind() == CHUCK_ARRAY8_DATAKIND ) RETURN->v_int = ((Chuck_Array8 *)array)->pop_back( ); - else if( array->data_type_size() == CHUCK_ARRAY16_DATASIZE ) + else if( array->data_type_kind() == CHUCK_ARRAY16_DATAKIND ) RETURN->v_int = ((Chuck_Array16 *)array)->pop_back( ); else Index: /trunk/src/chuck_oo.h =================================================================== --- /trunk/src/chuck_oo.h (revision 179) +++ /trunk/src/chuck_oo.h (revision 213) @@ -169,7 +169,11 @@ -#define CHUCK_ARRAY4_DATASIZE 4 -#define CHUCK_ARRAY8_DATASIZE 8 -#define CHUCK_ARRAY16_DATASIZE 16 +// ISSUE: 64-bit (fixed 1.3.1.0) +#define CHUCK_ARRAY4_DATASIZE sz_INT +#define CHUCK_ARRAY8_DATASIZE sz_FLOAT +#define CHUCK_ARRAY16_DATASIZE sz_COMPLEX +#define CHUCK_ARRAY4_DATAKIND kindof_INT +#define CHUCK_ARRAY8_DATAKIND kindof_FLOAT +#define CHUCK_ARRAY16_DATAKIND kindof_COMPLEX //----------------------------------------------------------------------------- // name: struct Chuck_Array @@ -188,5 +192,6 @@ virtual t_CKINT set_size( t_CKINT size ) = 0; // array size virtual t_CKINT set_capacity( t_CKINT capacity ) = 0; // set - virtual t_CKINT data_type_size( ) = 0; // size of stored type ( from type_ref ) + virtual t_CKINT data_type_size( ) = 0; // size of stored type (from type_ref) + virtual t_CKINT data_type_kind( ) = 0; // kind of stored type (from kindof) virtual t_CKINT find( const std::string & key ) = 0; // find virtual t_CKINT erase( const std::string & key ) = 0; // erase @@ -227,4 +232,5 @@ virtual t_CKINT erase( const std::string & key ); virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY4_DATASIZE; } + virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY4_DATAKIND; } public: @@ -269,4 +275,5 @@ virtual t_CKINT erase( const std::string & key ); virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY8_DATASIZE; } + virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY8_DATAKIND; } public: @@ -310,4 +317,5 @@ virtual t_CKINT erase( const std::string & key ); virtual t_CKINT data_type_size( ) { return CHUCK_ARRAY16_DATASIZE; } + virtual t_CKINT data_type_kind( ) { return CHUCK_ARRAY16_DATAKIND; } public: Index: /trunk/src/chuck_type.h =================================================================== --- /trunk/src/chuck_type.h (revision 165) +++ /trunk/src/chuck_type.h (revision 213) @@ -744,4 +744,6 @@ t_CKBOOL isobj( Chuck_Type * type ); t_CKBOOL isfunc( Chuck_Type * type ); +t_CKBOOL iskindofint( Chuck_Type * type ); // added 1.3.1.0: this includes int + pointers +t_CKUINT getkindof( Chuck_Type * type ); // added 1.3.1.0: to get the kindof a type // import Index: /trunk/src/examples/deep/unclap.ck =================================================================== --- /trunk/src/examples/deep/unclap.ck (revision 8) +++ /trunk/src/examples/deep/unclap.ck (revision 213) @@ -29,5 +29,5 @@ // infinite time loop - for( ; ; shifts++ ) + for( ; true; shifts++ ) { // one measure