Skip to content

Commit

Permalink
renaming, adding decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Feb 11, 2009
1 parent a7c8af4 commit 581c773
Show file tree
Hide file tree
Showing 42 changed files with 125 additions and 83 deletions.
16 changes: 8 additions & 8 deletions .gitignore
@@ -1,12 +1,12 @@
.*.swp
*.tmproj
ext/qrdecode/*.o
ext/qrdecode/*.dll
ext/qrdecode/Makefile
ext/qrdecode/*.log
ext/qrdecode/*.bundle
ext/qrdecode/*.a
ext/qrdecode/*.so
ext/qrdecode/conftest.dSYM
ext/qrtools/*.o
ext/qrtools/*.dll
ext/qrtools/Makefile
ext/qrtools/*.log
ext/qrtools/*.bundle
ext/qrtools/*.a
ext/qrtools/*.so
ext/qrtools/conftest.dSYM
tags
.rake_tasks
20 changes: 10 additions & 10 deletions Rakefile
Expand Up @@ -6,26 +6,26 @@ require 'hoe'
kind = Config::CONFIG['DLEXT']
windows = RUBY_PLATFORM =~ /mswin/i ? true : false

EXT = "ext/qrdecode/qrdecode.#{kind}"
EXT = "ext/qrtools/qrtools.#{kind}"

Hoe.new('qrdecode', '1.0.0') do |p|
Hoe.new('qrtools', '1.0.0') do |p|
p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
p.clean_globs = [
'ext/qrdecode/Makefile',
'ext/qrdecode/*.{o,so,bundle,a,log,dll}',
'ext/qrdecode/conftest.dSYM',
'ext/qrtools/Makefile',
'ext/qrtools/*.{o,so,bundle,a,log,dll}',
'ext/qrtools/conftest.dSYM',
]
p.spec_extras = { :extensions => ["ext/qrdecode/extconf.rb"] }
p.spec_extras = { :extensions => ["ext/qrtools/extconf.rb"] }
end

task 'ext/qrdecode/Makefile' do
Dir.chdir('ext/qrdecode') do
task 'ext/qrtools/Makefile' do
Dir.chdir('ext/qrtools') do
ruby "extconf.rb #{ENV['EXTOPTS']}"
end
end

task EXT => 'ext/qrdecode/Makefile' do
Dir.chdir('ext/qrdecode') do
task EXT => 'ext/qrtools/Makefile' do
Dir.chdir('ext/qrtools') do
sh 'make'
end
end
Expand Down
11 changes: 0 additions & 11 deletions ext/qrdecode/qrdecode.c

This file was deleted.

13 changes: 0 additions & 13 deletions ext/qrdecode/qrdecode.h

This file was deleted.

20 changes: 0 additions & 20 deletions ext/qrdecode/qrdecode_image.c

This file was deleted.

11 changes: 0 additions & 11 deletions ext/qrdecode/qrdecode_image.h

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ext/qrdecode/extconf.rb → ext/qrtools/extconf.rb
Expand Up @@ -22,4 +22,4 @@
abort "need #{lib}" unless have_library(lib)
end
have_library('stdc++')
create_makefile('qrdecode')
create_makefile('qrtools')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions ext/qrtools/qrtools.c
@@ -0,0 +1,12 @@
#include <qrtools.h>

VALUE mQRTools;

void Init_qrtools()
{
VALUE qrtools = rb_define_module("QRTools");
mQRTools = qrtools;

init_qrtools_image();
init_qrtools_decoder();
}
14 changes: 14 additions & 0 deletions ext/qrtools/qrtools.h
@@ -0,0 +1,14 @@
#ifndef QRTOOLS_QRTOOLS
#define QRTOOLS_QRTOOLS

#include <stdlib.h>
#include <stdio.h>
#include <ruby.h>
#include <decodeqr.h>

#include <qrtools_image.h>
#include <qrtools_decoder.h>

extern VALUE mQRTools;

#endif
19 changes: 19 additions & 0 deletions ext/qrtools/qrtools_decoder.c
@@ -0,0 +1,19 @@
#include <qrtools_decoder.h>

static VALUE allocate(VALUE klass)
{
QrDecoderHandle decoder = qr_decoder_open();

return Data_Wrap_Struct(klass, NULL, qr_decoder_close, decoder);
}

VALUE cQRToolsDecoder;
void init_qrtools_decoder()
{
VALUE qrtools = rb_define_module("QRTools");
VALUE klass = rb_define_class_under(qrtools, "Decoder", rb_cObject);

cQRToolsDecoder = klass;

rb_define_alloc_func(klass, allocate);
}
10 changes: 10 additions & 0 deletions ext/qrtools/qrtools_decoder.h
@@ -0,0 +1,10 @@
#ifndef QRTOOLS_DECODER
#define QRTOOLS_DECODER

#include <qrtools.h>

extern VALUE cQRToolsDecoder;

void init_qrtools_decoder();

#endif
24 changes: 24 additions & 0 deletions ext/qrtools/qrtools_image.c
@@ -0,0 +1,24 @@
#include <qrtools_image.h>

static void dealloc(IplImage * img)
{
cvReleaseImage(&img);
}

static VALUE load(VALUE klass, VALUE path)
{
IplImage *src = cvLoadImage(StringValuePtr(path), 1);
return Data_Wrap_Struct(klass, NULL, dealloc, src);
}

VALUE cQRToolsImage;

void init_qrtools_image()
{
VALUE qrtools = rb_define_module("QRTools");
VALUE klass = rb_define_class_under(qrtools, "Image", rb_cObject);

cQRToolsImage = klass;

rb_define_singleton_method(klass, "load", load, 1);
}
10 changes: 10 additions & 0 deletions ext/qrtools/qrtools_image.h
@@ -0,0 +1,10 @@
#ifndef QRTOOLS_IMAGE
#define QRTOOLS_IMAGE

#include <qrtools.h>

extern VALUE cQRToolsImage;

void init_qrtools_image();

#endif
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions lib/qrdecode.rb

This file was deleted.

5 changes: 5 additions & 0 deletions lib/qrtools.rb
@@ -0,0 +1,5 @@
require 'qrtools/qrtools' # native

module QRTools
VERSION = '1.0.0'
end
4 changes: 2 additions & 2 deletions test/helper.rb
Expand Up @@ -4,9 +4,9 @@
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), path)))
end

require 'qrdecode'
require 'qrtools'

class QRDecodeTestCase < Test::Unit::TestCase
class QRToolsTestCase < Test::Unit::TestCase
ASSETS = File.expand_path(File.join(File.dirname(__FILE__), 'assets'))

unless RUBY_VERSION >= '1.9'
Expand Down
8 changes: 8 additions & 0 deletions test/test_decoder.rb
@@ -0,0 +1,8 @@
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))

class DecoderTestCase < QRToolsTestCase
def test_new
assert decoder = QRTools::Decoder.new
end
end

4 changes: 2 additions & 2 deletions test/test_image.rb
@@ -1,7 +1,7 @@
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))

class ImageTestCase < QRDecodeTestCase
class ImageTestCase < QRToolsTestCase
def test_load
assert img = QRDecode::Image.load(File.join(ASSETS, '01-1.jpg'))
assert img = QRTools::Image.load(File.join(ASSETS, '01-1.jpg'))
end
end

0 comments on commit 581c773

Please sign in to comment.