ext/CdIo.c in rb_cdio-0.1.0 vs ext/CdIo.c in rb_cdio-0.1.1

- old
+ new

@@ -11,15 +11,14 @@ Init_rb_cdio() { /** module CdIo */ mCdIo = rb_define_module("CdIo"); - rb_define_module_function(mCdIo, "get_devices", rb_cdio_get_devices, - -1); - rb_define_module_function(mCdIo, "get_default_device", + rb_define_module_function(mCdIo, "devices", rb_cdio_get_devices, -1); + rb_define_module_function(mCdIo, "default_device", rb_cdio_get_default_device, -1); - rb_define_module_function(mCdIo, "get_drive_cap_dev", + rb_define_module_function(mCdIo, "drive_cap_dev", rb_cdio_get_drive_cap_dev, 1); rb_define_module_function(mCdIo, "discmode_describe", rb_cdio_discmode_describe, 1); rb_define_module_function(mCdIo, "driver_describe", rb_cdio_driver_describe, 1); @@ -32,52 +31,61 @@ // is rb_define_module_function(mCdIo, "is_binfile", rb_cdio_is_binfile, 1); rb_define_module_function(mCdIo, "is_cuefile", rb_cdio_is_cuefile, 1); rb_define_module_function(mCdIo, "is_nrg", rb_cdio_is_nrg, 1); rb_define_module_function(mCdIo, "is_tocfile", rb_cdio_is_tocfile, 1); - rb_define_module_function(mCdIo, "is_device",rb_cdio_is_device,-1); + rb_define_module_function(mCdIo, "is_device", rb_cdio_is_device, -1); /** * class CdIo::Cd */ cCdIoCd = rb_define_class_under(mCdIo, "Cd", rb_cObject); rb_define_singleton_method(cCdIoCd, "new", rb_cdio_cd_new, -1); rb_define_method(cCdIoCd, "initialize", rb_cdio_cd_init, 2); int i; - #define CDIO_ATTR 9 - const char *attr[CDIO_ATTR] = +#define CDIO_ATTR 9 + const char *attr[CDIO_ATTR] = { "device", "mcn", "driver_name", "driver_id", "first_track_num", "discmode", "num_tracks", "stat_size", "cddb_id" }; for (i = 0; i < CDIO_ATTR; i++) { rb_define_attr(cCdIoCd, attr[i], 1, 0); } - rb_define_method(cCdIoCd, "get_tracks", rb_cdio_cd_get_tracks, 0); - rb_define_method(cCdIoCd, "get_first_track", + rb_define_method(cCdIoCd, "tracks", rb_cdio_cd_get_tracks, 0); + rb_define_method(cCdIoCd, "first_track", rb_cdio_cd_get_first_track, 0); rb_define_method(cCdIoCd, "get_arg", rb_cdio_cd_get_arg, 1); rb_define_method(cCdIoCd, "is_cd?", rb_cdio_cd_is_cd, 0); rb_define_method(cCdIoCd, "is_dvd?", rb_cdio_cd_is_dvd, 0); - rb_define_method(cCdIoCd, "get_freedb", rb_cdio_cd_get_freedb, 0); - rb_define_method(cCdIoCd, "get_cdtext", rb_cdio_cd_get_cdtext, 0); + rb_define_method(cCdIoCd, "freedb", rb_cdio_cd_get_freedb, 0); + rb_define_method(cCdIoCd, "cdtext", rb_cdio_cd_get_cdtext, 0); // device methods - rb_define_method(cCdIoCd, "get_drive_cap", rb_cdio_cd_get_drive_cap, - 0); - rb_define_method(cCdIoCd, "get_hwinfo", rb_cdio_cd_get_hwinfo, 0); + rb_define_method(cCdIoCd, "drive_cap", rb_cdio_cd_get_drive_cap, 0); + rb_define_method(cCdIoCd, "hwinfo", rb_cdio_cd_get_hwinfo, 0); rb_define_method(cCdIoCd, "close", rb_cdio_cd_close, 0); + /** class CdIo::Tracks */ + cCdIoTracks = rb_define_class_under(mCdIo, "Tracks", rb_cObject); + rb_include_module(cCdIoTracks, rb_mEnumerable); + rb_define_method(cCdIoTracks, "initialize", rb_cdio_tracks_init, 1); + rb_define_method(cCdIoTracks, "each", rb_cdio_tracks_each, -1); + rb_define_method(cCdIoTracks, "<=>", rb_cdio_tracks_diff, 2); + rb_define_method(cCdIoTracks, "[]", rb_cdio_tracks_index, 1); + rb_define_attr(cCdIoTracks, "cd", 1, 0); + rb_define_attr(cCdIoTracks, "tracks", 1, 0); /** class CdIo::Track */ cCdIoTrack = rb_define_class_under(mCdIo, "Track", rb_cObject); rb_define_method(cCdIoTrack, "initialize", rb_cdio_track_init, 2); rb_define_method(cCdIoTrack, "green?", rb_cdio_track_green, 0); - rb_define_method(cCdIoTrack, "get_cdtext", rb_cdio_track_get_cdtext, 0); + rb_define_method(cCdIoTrack, "cdtext", rb_cdio_track_get_cdtext, 0); /** :cd :number :format, :green, :lba,:lsn,min,sec,frames,:sec_count*/ - char attr2[11][32] = +#define CDIO_TRACK_ATTR 12 + const char *attr2[CDIO_TRACK_ATTR] = { "cd", "number", "format", "lba", "lsn", "min", "sec", "frames", - "msf", "sec_count", "track_type" + "msf", "sec_count", "track_type", "leadout" }; - for (i = 0; i < 11; i++) { + for (i = 0; i < CDIO_TRACK_ATTR; i++) { rb_define_attr(cCdIoTrack, attr2[i], 1, 0); } /** class CdIo::TrackIso9660 < CdIo::Track */ cCdIoTrackIso9660 = @@ -89,22 +97,22 @@ for (i = 0; i < 6; i++) { rb_define_attr(cCdIoTrackIso9660, attr3[i], 1, 0); } rb_define_method(cCdIoTrackIso9660, "initialize", rb_cdio_trackiso9660_init, 2); - // const for DRIVER + // const for DRIVER rb_define_const(mCdIo, "DRIVER_UNKNOWN", INT2FIX(DRIVER_UNKNOWN)); rb_define_const(mCdIo, "DRIVER_FREEBSD", INT2FIX(DRIVER_FREEBSD)); rb_define_const(mCdIo, "DRIVER_LINUX", INT2FIX(DRIVER_LINUX)); rb_define_const(mCdIo, "DRIVER_SOLARIS", INT2FIX(DRIVER_SOLARIS)); rb_define_const(mCdIo, "DRIVER_OSX", INT2FIX(DRIVER_OSX)); rb_define_const(mCdIo, "DRIVER_WIN32", INT2FIX(DRIVER_WIN32)); rb_define_const(mCdIo, "DRIVER_CDRDAO", INT2FIX(DRIVER_CDRDAO)); rb_define_const(mCdIo, "DRIVER_BINCUE", INT2FIX(DRIVER_BINCUE)); rb_define_const(mCdIo, "DRIVER_NRG", INT2FIX(DRIVER_NRG)); rb_define_const(mCdIo, "DRIVER_DEVICE", INT2FIX(DRIVER_DEVICE)); - // const for CD types + // const for CD types rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_DA", INT2FIX(CDIO_DISC_MODE_CD_DA)); rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_DATA", INT2FIX(CDIO_DISC_MODE_CD_DATA)); rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_XA", @@ -127,6 +135,19 @@ INT2FIX(CDIO_DISC_MODE_DVD_OTHER)); rb_define_const(mCdIo, "CDIO_DISC_MODE_NO_INFO", INT2FIX(CDIO_DISC_MODE_NO_INFO)); rb_define_const(mCdIo, "CDIO_DISC_MODE_ERROR", INT2FIX(CDIO_DISC_MODE_ERROR)); + rb_define_const(mCdIo, "TRACK_FORMAT_AUDIO", + INT2FIX(TRACK_FORMAT_AUDIO)); + rb_define_const(mCdIo, "TRACK_FORMAT_CDI", INT2FIX(TRACK_FORMAT_CDI)); + /**< CD-i. How this is different from DATA below? */ + rb_define_const(mCdIo, "TRACK_FORMAT_XA", INT2FIX(TRACK_FORMAT_XA)); + /**< Mode2 of some sort */ + rb_define_const(mCdIo, "TRACK_FORMAT_DATA", + INT2FIX(TRACK_FORMAT_DATA)); + /**< Mode1 of some sort */ + rb_define_const(mCdIo, "TRACK_FORMAT_PSX", INT2FIX(TRACK_FORMAT_PSX)); + rb_define_const(mCdIo, "TRACK_FORMAT_ERROR", INT2FIX(TRACK_FORMAT_ERROR)); /**< Dunno what is, or some other error. */ + rb_define_const(mCdIo, "CDIO_CDROM_LEADOUT_TRACK", + INT2FIX(CDIO_CDROM_LEADOUT_TRACK)); }