static VALUE rb_thrift_struct_read(VALUE self, VALUE protocol) { // check_native_proto_method_table(protocol); // read struct begin mt->read_struct_begin(protocol); VALUE struct_fields = STRUCT_FIELDS(self); // read each field while (true) { VALUE field_header = mt->read_field_begin(protocol); VALUE field_type_value = rb_ary_entry(field_header, 1); int field_type = FIX2INT(field_type_value); if (field_type == TTYPE_STOP) { break; } // make sure we got a type we expected VALUE field_info = rb_hash_aref(struct_fields, rb_ary_entry(field_header, 2)); if (!NIL_P(field_info)) { int specified_type = FIX2INT(rb_hash_aref(field_info, type_sym)); if (field_type == specified_type) { // read the value VALUE name = rb_hash_aref(field_info, name_sym); set_field_value(self, name, read_anything(protocol, field_type, field_info)); } else { rb_funcall(protocol, skip_method_id, 1, field_type_value); } } else { rb_funcall(protocol, skip_method_id, 1, field_type_value); } // read field end mt->read_field_end(protocol); } // read struct end mt->read_struct_end(protocol); // call validate rb_funcall(self, validate_method_id, 0); return Qnil; }
/*********************************************************************** * * masterFpgaSerialInit2 - connect serial device interrupts * * This routine connects the serial device interrupts. It is called from * sysHwInit2(). * * RETURNS: N/A * */ void masterFpgaSerialInit2 ( void ) { SIO_CHAN * masterFpgaSerialChanGet(int); int intLevel = intLock (); /* * Connect serial interrupt handlers for S0 (UART 0) * to the FPGA Base ISR and enable serial interrupts for the * FPGA ns16550 serial ports */ (void) fpgaIntConnect ( masterFpgaNs16550Isr, (int) masterFpgaSerialChanGet(0), set_field_value(MASTER,uart_int_status,0xf)); /* enable serial port interrupts */ set_field(MASTER,uart_int_enable,0xf); /* enable all 4 uarts */ /* clear the interrupts */ *((volatile unsigned int *)(MASTER_BASE+MASTER_uart_int_clear_addr)) = 0; *((volatile unsigned int *)(MASTER_BASE+MASTER_uart_int_clear_addr)) = 0xf << MASTER_uart_int_clear_pos; intUnlock (intLevel); }