mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj) { struct RBasic *p; mrb_value dup; if (mrb_special_const_p(obj)) { mrb_raisef(mrb, E_TYPE_ERROR, "can't dup %s", mrb_obj_classname(mrb, obj)); } p = mrb_obj_alloc(mrb, mrb_type(obj), mrb_obj_class(mrb, obj)); dup = mrb_obj_value(p); init_copy(mrb, dup, obj); return dup; }
/* * call-seq: * obj.clone -> an_object * * Produces a shallow copy of <i>obj</i>---the instance variables of * <i>obj</i> are copied, but not the objects they reference. Copies * the frozen state of <i>obj</i>. See also the discussion * under <code>Object#dup</code>. * * class Klass * attr_accessor :str * end * s1 = Klass.new #=> #<Klass:0x401b3a38> * s1.str = "Hello" #=> "Hello" * s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello"> * s2.str[1,4] = "i" #=> "i" * s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">" * s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">" * * This method may have class-specific behavior. If so, that * behavior will be documented under the #+initialize_copy+ method of * the class. * * Some Class(True False Nil Symbol Fixnum Float) Object cannot clone. */ mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self) { struct RObject *p; mrb_value clone; if (mrb_special_const_p(self)) { mrb_raisef(mrb, E_TYPE_ERROR, "can't clone %S", self); } p = (struct RObject*)mrb_obj_alloc(mrb, mrb_type(self), mrb_obj_class(mrb, self)); p->c = mrb_singleton_class_clone(mrb, self); clone = mrb_obj_value(p); init_copy(mrb, clone, self); return clone; }
/* * call-seq: * obj.clone -> an_object * * Produces a shallow copy of <i>obj</i>---the instance variables of * <i>obj</i> are copied, but not the objects they reference. Copies * the frozen state of <i>obj</i>. See also the discussion * under <code>Object#dup</code>. * * class Klass * attr_accessor :str * end * s1 = Klass.new #=> #<Klass:0x401b3a38> * s1.str = "Hello" #=> "Hello" * s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello"> * s2.str[1,4] = "i" #=> "i" * s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">" * s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">" * * This method may have class-specific behavior. If so, that * behavior will be documented under the #+initialize_copy+ method of * the class. * * Some Class(True False Nil Symbol Fixnum Float) Object cannot clone. */ mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self) { struct RObject *clone; if (mrb_special_const_p(self)) { mrb_raise(mrb, E_TYPE_ERROR, "can't clone %s", mrb_obj_classname(mrb, self)); } clone = (struct RObject*)mrb_obj_alloc(mrb, self.tt, mrb_obj_class(mrb, self)); clone->c = mrb_singleton_class_clone(mrb, self); init_copy(mrb, mrb_obj_value(clone), self); //1-9-2 no bug mrb_funcall(mrb, clone, "initialize_clone", 1, self); //RBASIC(clone)->flags |= RBASIC(obj)->flags & FL_FREEZE; return mrb_obj_value(clone); }
MRB_API mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj) { struct RBasic *p; mrb_value dup; if (mrb_immediate_p(obj)) { mrb_raisef(mrb, E_TYPE_ERROR, "can't dup %S", obj); } if (mrb_type(obj) == MRB_TT_SCLASS) { mrb_raise(mrb, E_TYPE_ERROR, "can't dup singleton class"); } p = mrb_obj_alloc(mrb, mrb_type(obj), mrb_obj_class(mrb, obj)); dup = mrb_obj_value(p); init_copy(mrb, dup, obj); return dup; }
/* * call-seq: * obj.clone -> an_object * * Produces a shallow copy of <i>obj</i>---the instance variables of * <i>obj</i> are copied, but not the objects they reference. Copies * the frozen state of <i>obj</i>. See also the discussion * under <code>Object#dup</code>. * * class Klass * attr_accessor :str * end * s1 = Klass.new #=> #<Klass:0x401b3a38> * s1.str = "Hello" #=> "Hello" * s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello"> * s2.str[1,4] = "i" #=> "i" * s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">" * s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">" * * This method may have class-specific behavior. If so, that * behavior will be documented under the #+initialize_copy+ method of * the class. * * Some Class(True False Nil Symbol Fixnum Float) Object cannot clone. */ MRB_API mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self) { struct RObject *p; mrb_value clone; if (mrb_immediate_p(self)) { mrb_raisef(mrb, E_TYPE_ERROR, "can't clone %S", self); } if (mrb_type(self) == MRB_TT_SCLASS) { mrb_raise(mrb, E_TYPE_ERROR, "can't clone singleton class"); } p = (struct RObject*)mrb_obj_alloc(mrb, mrb_type(self), mrb_obj_class(mrb, self)); p->c = mrb_singleton_class_clone(mrb, self); clone = mrb_obj_value(p); init_copy(mrb, clone, self); return clone; }
/* * call-seq: * obj.clone -> an_object * * Produces a shallow copy of <i>obj</i>---the instance variables of * <i>obj</i> are copied, but not the objects they reference. Copies * the frozen state of <i>obj</i>. See also the discussion * under <code>Object#dup</code>. * * class Klass * attr_accessor :str * end * s1 = Klass.new #=> #<Klass:0x401b3a38> * s1.str = "Hello" #=> "Hello" * s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello"> * s2.str[1,4] = "i" #=> "i" * s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">" * s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">" * * This method may have class-specific behavior. If so, that * behavior will be documented under the #+initialize_copy+ method of * the class. * * Some Class(True False Nil Symbol Fixnum Float) Object cannot clone. */ MRB_API mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self) { struct RObject *p; mrb_value clone; if (mrb_immediate_p(self)) { mrb_raisef(mrb, E_TYPE_ERROR, "can't clone %S", self); } if (mrb_type(self) == MRB_TT_SCLASS) { mrb_raise(mrb, E_TYPE_ERROR, "can't clone singleton class"); } p = (struct RObject*)mrb_obj_alloc(mrb, mrb_type(self), mrb_obj_class(mrb, self)); p->c = mrb_singleton_class_clone(mrb, self); mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)p->c); clone = mrb_obj_value(p); init_copy(mrb, clone, self); p->flags |= mrb_obj_ptr(self)->flags & MRB_FL_OBJ_IS_FROZEN; return clone; }
//Audio interrupt function, plays sound effects and/or loops audio //REQ: audmode->id must point to correct id void audio_isr(audisr * audmode, alt_u32 irq_id) { int i; unsigned int ** temp; unsigned int * second; if (audmode->resetmix == true) { audmode->resetmix = false; audio_isr_2 = 0; } //if (audmode->mode == 0) { if (audmode->id != audmode->oldid) { audio_isr_k = 0; seek = 0; init_copy(audmode->id, audmode->oldid); audmode->oldid = audmode->id; } if (audmode->id2 != audmode->oldid2) { audio_isr_2 = 0; audmode->oldid2 = audmode->id2; } if (audio_isr_k == 0) { copy_bgm(audmode->id); alt_up_rs232_write_data(uart, 0x6); alt_up_rs232_write_data(uart, (int)audiosecs[audmode->id]); } audio_log.bgmin = copyarr[audio_isr_k]; //Mode 0, loop music if (audmode->mode == 0) { for (i = 0; i < 96; i++) { audio_log.bgmin[i] = volume_adjust(audio_log.bgmin[i], audmode->newvolume); } } else if (audmode->mode == 1) { temp = arr[audmode->id2]; second = temp[audio_isr_2]; for (i = 0; i < 96; i++) { unsigned int tempmix = audio_log.bgmin[i]; audio_log.bgmin[i] = mix_adjust(tempmix,second[i],5); } audio_isr_2++; if (audio_isr_2 > audiosize[audmode->id2]) { audio_isr_2 = 0; audmode->mode = 0; } } if (alt_up_audio_write_interrupt_pending(audio) == 1) { alt_up_audio_write_fifo(audio, audio_log.bgmin, 96, ALT_UP_AUDIO_LEFT); alt_up_audio_write_fifo(audio, audio_log.bgmin, 96, ALT_UP_AUDIO_RIGHT); if (audmode->loop == true){ audio_isr_k = (audio_isr_k + 1) % audiosize[audmode->id]; seek = (seek + 1) % 333; if (seek == 0) { //alt_up_rs232_write_data(uart, 0x0A); } if (audio_isr_k == 0) { alt_up_rs232_write_data(uart, 0x3); } } else { if(audio_isr_k <= audiosize[audmode->id]) { audio_isr_k += 1; seek = (seek + 1) % 333; if (seek == 0) { //alt_up_rs232_write_data(uart, 0x0A); } } else { seek = 0; audmode->mode = 0; audio_isr_2 = 0; audio_isr_k = 0; //alt_up_rs232_write_data(uart, 0x3); alt_up_rs232_write_data(uart, 0x4); wait(); if (audmode->shuffle == false) { audmode->id += 1; if ((audmode->id >= audmode->files) && (audmode->listloop == true)) { audmode->id = 0; //printf("Restarting songs\n"); } else if((audmode->id >= audmode->files) && (audmode->listloop == false)) { printf("End of Playlist\n"); audmode->id = 0; alt_up_audio_disable_write_interrupt(audio); } } else { /* do { while(rs_flag == false); alt_up_rs232_read_data(uart, &data, &parity); }while((int)data == 0); */ wait(); alt_up_rs232_read_data(uart, &data, &parity); int nextindex = (int)data; nextindex -= 4; //printf("Next Index: %d\n", nextindex); if ((nextindex < 0) || (nextindex > audmode->files)) { nextindex = 0; printf("Error, next Index: %d\n", nextindex); } audmode->id = nextindex; } } } } //} /* else if (audmode->mode == 1) { if (audmode->id != audmode->oldid) { //TEMP audmode->id2 = audmode->id++; if (audmode->id2 >= audmode->files) { audmode->id2 = 0; } if (audiosize[audmode->id] > audiosize[audmode->id2]) { audmode->large = audmode->id; } else { audmode->large = audmode->id2; } // audio_isr_k = 0; init_copy(audmode->large, audmode->oldid); audmode->oldid = audmode->id; } if (audio_isr_k == 0) { copy_bgm(audmode->large); alt_up_rs232_write_data(uart, 0x6); } audio_log.bgmin = copyarr[audio_isr_k]; for (i = 0; i < 96; i++) { //audio_log.bgmin[i] = mix_adjust(audio_log.bgmin[i], ,audmode->newvolume); } if (alt_up_audio_write_interrupt_pending(audio) == 1) { audio_isr_k = 0; audmode->id += 1; alt_up_rs232_write_data(uart, 0x3); if ((audmode->id >= audmode->files) && (audmode->listloop == true)) { audmode->id = 0; printf("Restarting songs\n"); } else if((audmode->id >= audmode->files) && (audmode->listloop == false)) { printf("End of Playlist\n"); audmode->id = 0; alt_up_audio_disable_write_interrupt(audio); } } } */ }