Skip to content

Commit

Permalink
rename USB::InterfaceDescriptor to USB::Setting.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.a-k-r.org/akr/ruby-usb/trunk@339 0ecacc03-ac1b-0410-941d-e442c79421a6
  • Loading branch information
akr committed Jan 6, 2007
1 parent 3044f2a commit 4b80bd1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 51 deletions.
20 changes: 10 additions & 10 deletions lib/usb.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def USB.busses
def USB.devices() USB.busses.map {|b| b.devices }.flatten end def USB.devices() USB.busses.map {|b| b.devices }.flatten end
def USB.configurations() USB.devices.map {|d| d.configurations }.flatten end def USB.configurations() USB.devices.map {|d| d.configurations }.flatten end
def USB.interfaces() USB.configurations.map {|d| d.interfaces }.flatten end def USB.interfaces() USB.configurations.map {|d| d.interfaces }.flatten end
def USB.interface_descriptors() USB.interfaces.map {|d| d.altsettings }.flatten end def USB.settings() USB.interfaces.map {|d| d.altsettings }.flatten end


def USB.find_bus(n) def USB.find_bus(n)
bus = USB.first_bus bus = USB.first_bus
Expand Down Expand Up @@ -64,7 +64,7 @@ def devices


def configurations() self.devices.map {|d| d.configurations }.flatten end def configurations() self.devices.map {|d| d.configurations }.flatten end
def interfaces() self.configurations.map {|d| d.interfaces }.flatten end def interfaces() self.configurations.map {|d| d.interfaces }.flatten end
def interface_descriptors() self.interfaces.map {|d| d.altsettings }.flatten end def settings() self.interfaces.map {|d| d.altsettings }.flatten end


def find_device(n) def find_device(n)
device = self.first_device device = self.first_device
Expand Down Expand Up @@ -148,7 +148,7 @@ def inspect
product_id = self.descriptor_idProduct product_id = self.descriptor_idProduct
prod = [self.manufacturer, self.product, self.serial_number].compact.join(" ") prod = [self.manufacturer, self.product, self.serial_number].compact.join(" ")
if self.descriptor_bDeviceClass == USB::USB_CLASS_PER_INTERFACE if self.descriptor_bDeviceClass == USB::USB_CLASS_PER_INTERFACE
devclass = self.interface_descriptors.map {|i| devclass = self.settings.map {|i|
USB.devsubclass_string(i.bInterfaceClass, i.bInterfaceSubClass) USB.devsubclass_string(i.bInterfaceClass, i.bInterfaceSubClass)
}.join(", ") }.join(", ")
else else
Expand Down Expand Up @@ -188,7 +188,7 @@ def open
end end


def interfaces() self.configurations.map {|d| d.interfaces }.flatten end def interfaces() self.configurations.map {|d| d.interfaces }.flatten end
def interface_descriptors() self.interfaces.map {|d| d.altsettings }.flatten end def settings() self.interfaces.map {|d| d.altsettings }.flatten end
end end


class Configuration class Configuration
Expand All @@ -205,7 +205,7 @@ def configuration
@configuration = self.device.open {|h| h.get_string_simple(self.iConfiguration) } @configuration = self.device.open {|h| h.get_string_simple(self.iConfiguration) }
end end


def interface_descriptors() self.interfaces.map {|d| d.altsettings }.flatten end def settings() self.interfaces.map {|d| d.altsettings }.flatten end


def bus() self.device.bus end def bus() self.device.bus end
end end
Expand All @@ -223,7 +223,7 @@ def bus() self.configuration.device.bus end
def device() self.configuration.device end def device() self.configuration.device end
end end


class InterfaceDescriptor class Setting
def inspect def inspect
if self.revoked? if self.revoked?
"\#<#{self.class} revoked>" "\#<#{self.class} revoked>"
Expand All @@ -239,10 +239,10 @@ def configuration() self.interface.configuration end
end end


class EndpointDescriptor class EndpointDescriptor
def bus() self.interface_descriptor.interface.configuration.device.bus end def bus() self.setting.interface.configuration.device.bus end
def device() self.interface_descriptor.interface.configuration.device end def device() self.setting.interface.configuration.device end
def configuration() self.interface_descriptor.interface.configuration end def configuration() self.setting.interface.configuration end
def interface() self.interface_descriptor.interface end def interface() self.setting.interface end
end end


class DevHandle class DevHandle
Expand Down
82 changes: 41 additions & 41 deletions usb.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ define_usb_struct(bus, Bus)
define_usb_struct(device, Device) define_usb_struct(device, Device)
define_usb_struct(config_descriptor, Configuration) define_usb_struct(config_descriptor, Configuration)
define_usb_struct(interface, Interface) define_usb_struct(interface, Interface)
define_usb_struct(interface_descriptor, InterfaceDescriptor) define_usb_struct(interface_descriptor, Setting)
define_usb_struct(endpoint_descriptor, EndpointDescriptor) define_usb_struct(endpoint_descriptor, EndpointDescriptor)


static int mark_data_i(st_data_t key, st_data_t val, st_data_t arg) static int mark_data_i(st_data_t key, st_data_t val, st_data_t arg)
Expand Down Expand Up @@ -337,48 +337,48 @@ rusb_interface_altsettings(VALUE v)
return altsetting; return altsetting;
} }


/* -------- USB::InterfaceDescriptor -------- */ /* -------- USB::Setting -------- */


/* USB::InterfaceDescriptor#revoked? */ /* USB::Setting#revoked? */
static VALUE static VALUE
rusb_ifdesc_revoked_p(VALUE v) rusb_setting_revoked_p(VALUE v)
{ {
return RTEST(!check_usb_interface_descriptor(v)); return RTEST(!check_usb_interface_descriptor(v));
} }


/* USB::Interface#interface */ /* USB::Interface#interface */
static VALUE rusb_ifdesc_interface(VALUE v) { return get_rusb_interface_descriptor(v)->parent; } static VALUE rusb_setting_interface(VALUE v) { return get_rusb_interface_descriptor(v)->parent; }


/* USB::InterfaceDescriptor#bLength */ /* USB::Setting#bLength */
static VALUE rusb_ifdesc_bLength(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bLength); } static VALUE rusb_setting_bLength(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bLength); }


/* USB::InterfaceDescriptor#bDescriptorType */ /* USB::Setting#bDescriptorType */
static VALUE rusb_ifdesc_bDescriptorType(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bDescriptorType); } static VALUE rusb_setting_bDescriptorType(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bDescriptorType); }


/* USB::InterfaceDescriptor#bInterfaceNumber */ /* USB::Setting#bInterfaceNumber */
static VALUE rusb_ifdesc_bInterfaceNumber(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bInterfaceNumber); } static VALUE rusb_setting_bInterfaceNumber(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bInterfaceNumber); }


/* USB::InterfaceDescriptor#bAlternateSetting */ /* USB::Setting#bAlternateSetting */
static VALUE rusb_ifdesc_bAlternateSetting(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bAlternateSetting); } static VALUE rusb_setting_bAlternateSetting(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bAlternateSetting); }


/* USB::InterfaceDescriptor#bNumEndpoints */ /* USB::Setting#bNumEndpoints */
static VALUE rusb_ifdesc_bNumEndpoints(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bNumEndpoints); } static VALUE rusb_setting_bNumEndpoints(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bNumEndpoints); }


/* USB::InterfaceDescriptor#bInterfaceClass */ /* USB::Setting#bInterfaceClass */
static VALUE rusb_ifdesc_bInterfaceClass(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bInterfaceClass); } static VALUE rusb_setting_bInterfaceClass(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bInterfaceClass); }


/* USB::InterfaceDescriptor#bInterfaceSubClass */ /* USB::Setting#bInterfaceSubClass */
static VALUE rusb_ifdesc_bInterfaceSubClass(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bInterfaceSubClass); } static VALUE rusb_setting_bInterfaceSubClass(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bInterfaceSubClass); }


/* USB::InterfaceDescriptor#bInterfaceProtocol */ /* USB::Setting#bInterfaceProtocol */
static VALUE rusb_ifdesc_bInterfaceProtocol(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bInterfaceProtocol); } static VALUE rusb_setting_bInterfaceProtocol(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->bInterfaceProtocol); }


/* USB::InterfaceDescriptor#iInterface */ /* USB::Setting#iInterface */
static VALUE rusb_ifdesc_iInterface(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->iInterface); } static VALUE rusb_setting_iInterface(VALUE v) { return INT2FIX(get_usb_interface_descriptor(v)->iInterface); }


/* USB::InterfaceDescriptor#endpoints */ /* USB::Setting#endpoints */
static VALUE static VALUE
rusb_ifdesc_endpoints(VALUE v) rusb_setting_endpoints(VALUE v)
{ {
struct usb_interface_descriptor *p = get_usb_interface_descriptor(v); struct usb_interface_descriptor *p = get_usb_interface_descriptor(v);
int i; int i;
Expand All @@ -397,8 +397,8 @@ rusb_epdesc_revoked_p(VALUE v)
return RTEST(!check_usb_endpoint_descriptor(v)); return RTEST(!check_usb_endpoint_descriptor(v));
} }


/* USB::EndpointDescriptor#interface_descriptor */ /* USB::EndpointDescriptor#setting */
static VALUE rusb_epdesc_interface_descriptor(VALUE v) { return get_rusb_endpoint_descriptor(v)->parent; } static VALUE rusb_epdesc_setting(VALUE v) { return get_rusb_endpoint_descriptor(v)->parent; }


/* USB::EndpointDescriptor#bLength */ /* USB::EndpointDescriptor#bLength */
static VALUE rusb_epdesc_bLength(VALUE v) { return INT2FIX(get_usb_endpoint_descriptor(v)->bLength); } static VALUE rusb_epdesc_bLength(VALUE v) { return INT2FIX(get_usb_endpoint_descriptor(v)->bLength); }
Expand Down Expand Up @@ -813,7 +813,7 @@ Init_usb()
rb_cUSB_Interface = rb_define_class_under(rb_cUSB, "Interface", rb_cData); rb_cUSB_Interface = rb_define_class_under(rb_cUSB, "Interface", rb_cData);


interface_descriptor_objects = st_init_numtable(); interface_descriptor_objects = st_init_numtable();
rb_cUSB_InterfaceDescriptor = rb_define_class_under(rb_cUSB, "InterfaceDescriptor", rb_cData); rb_cUSB_Setting = rb_define_class_under(rb_cUSB, "Setting", rb_cData);


endpoint_descriptor_objects = st_init_numtable(); endpoint_descriptor_objects = st_init_numtable();
rb_cUSB_EndpointDescriptor = rb_define_class_under(rb_cUSB, "EndpointDescriptor", rb_cData); rb_cUSB_EndpointDescriptor = rb_define_class_under(rb_cUSB, "EndpointDescriptor", rb_cData);
Expand Down Expand Up @@ -880,21 +880,21 @@ Init_usb()
rb_define_method(rb_cUSB_Interface, "num_altsetting", rusb_interface_num_altsetting, 0); rb_define_method(rb_cUSB_Interface, "num_altsetting", rusb_interface_num_altsetting, 0);
rb_define_method(rb_cUSB_Interface, "altsettings", rusb_interface_altsettings, 0); rb_define_method(rb_cUSB_Interface, "altsettings", rusb_interface_altsettings, 0);


rb_define_method(rb_cUSB_InterfaceDescriptor, "revoked?", rusb_ifdesc_revoked_p, 0); rb_define_method(rb_cUSB_Setting, "revoked?", rusb_setting_revoked_p, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "interface", rusb_ifdesc_interface, 0); rb_define_method(rb_cUSB_Setting, "interface", rusb_setting_interface, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "bLength", rusb_ifdesc_bLength, 0); rb_define_method(rb_cUSB_Setting, "bLength", rusb_setting_bLength, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "bDescriptorType", rusb_ifdesc_bDescriptorType, 0); rb_define_method(rb_cUSB_Setting, "bDescriptorType", rusb_setting_bDescriptorType, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "bInterfaceNumber", rusb_ifdesc_bInterfaceNumber, 0); rb_define_method(rb_cUSB_Setting, "bInterfaceNumber", rusb_setting_bInterfaceNumber, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "bAlternateSetting", rusb_ifdesc_bAlternateSetting, 0); rb_define_method(rb_cUSB_Setting, "bAlternateSetting", rusb_setting_bAlternateSetting, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "bNumEndpoints", rusb_ifdesc_bNumEndpoints, 0); rb_define_method(rb_cUSB_Setting, "bNumEndpoints", rusb_setting_bNumEndpoints, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "bInterfaceClass", rusb_ifdesc_bInterfaceClass, 0); rb_define_method(rb_cUSB_Setting, "bInterfaceClass", rusb_setting_bInterfaceClass, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "bInterfaceSubClass", rusb_ifdesc_bInterfaceSubClass, 0); rb_define_method(rb_cUSB_Setting, "bInterfaceSubClass", rusb_setting_bInterfaceSubClass, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "bInterfaceProtocol", rusb_ifdesc_bInterfaceProtocol, 0); rb_define_method(rb_cUSB_Setting, "bInterfaceProtocol", rusb_setting_bInterfaceProtocol, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "iInterface", rusb_ifdesc_iInterface, 0); rb_define_method(rb_cUSB_Setting, "iInterface", rusb_setting_iInterface, 0);
rb_define_method(rb_cUSB_InterfaceDescriptor, "endpoints", rusb_ifdesc_endpoints, 0); rb_define_method(rb_cUSB_Setting, "endpoints", rusb_setting_endpoints, 0);


rb_define_method(rb_cUSB_EndpointDescriptor, "revoked?", rusb_epdesc_revoked_p, 0); rb_define_method(rb_cUSB_EndpointDescriptor, "revoked?", rusb_epdesc_revoked_p, 0);
rb_define_method(rb_cUSB_EndpointDescriptor, "interface_descriptor", rusb_epdesc_interface_descriptor, 0); rb_define_method(rb_cUSB_EndpointDescriptor, "setting", rusb_epdesc_setting, 0);
rb_define_method(rb_cUSB_EndpointDescriptor, "bLength", rusb_epdesc_bLength, 0); rb_define_method(rb_cUSB_EndpointDescriptor, "bLength", rusb_epdesc_bLength, 0);
rb_define_method(rb_cUSB_EndpointDescriptor, "bDescriptorType", rusb_epdesc_bDescriptorType, 0); rb_define_method(rb_cUSB_EndpointDescriptor, "bDescriptorType", rusb_epdesc_bDescriptorType, 0);
rb_define_method(rb_cUSB_EndpointDescriptor, "bEndpointAddress", rusb_epdesc_bEndpointAddress, 0); rb_define_method(rb_cUSB_EndpointDescriptor, "bEndpointAddress", rusb_epdesc_bEndpointAddress, 0);
Expand Down

0 comments on commit 4b80bd1

Please sign in to comment.