rqrencoder 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -2,5 +2,6 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  *.swp
5
- lib/rqrencoder/CQREncoder.bundle
5
+ lib/rqrencoder/RQREncoder.bundle
6
+ Gemfile.lock
6
7
  tmp/*
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source "http://rubygems.org"
2
-
3
2
  # Specify your gem's dependencies in rqrencoder.gemspec
4
3
  gemspec
data/Rakefile CHANGED
@@ -5,3 +5,11 @@ require 'rake/extensiontask'
5
5
  Rake::ExtensionTask.new("RQREncoder") do |extension|
6
6
  extension.lib_dir = "lib/rqrencoder"
7
7
  end
8
+
9
+ desc "clean and compile"
10
+ task :recompile => [:clean, :swig, :compile]
11
+
12
+ desc "remake swig wrapper"
13
+ task :swig do
14
+ `swig -ruby ext/rqrencoder/RQREncoder.i`
15
+ end
@@ -1,24 +1,25 @@
1
- %module RQREncoder
1
+ %module "RQREncoder"
2
2
  %{
3
- #include "win2ansi.h"
4
- #include "QR_Encode.h"
3
+ #include <qrencode.h>
5
4
  %}
6
- %include win2ansi.h
7
- %include QR_Encode.h
5
+ %include qrencode.h
8
6
 
9
- %extend CQR_Encode {
10
- VALUE results()
11
- {
12
- VALUE result = rb_ary_new2($self->m_nSymbleSize);
13
- size_t ii = 0;
14
- for (; ii < (size_t)$self->m_nSymbleSize; ++ii) {
15
- VALUE innerAry = rb_ary_new2($self->m_nSymbleSize);
16
- rb_ary_push(result, innerAry);
17
- size_t jj = 0;
18
- for (; jj < (size_t)$self->m_nSymbleSize; ++jj) {
19
- rb_ary_push(innerAry, $self->m_byModuleData[ii][jj] ? Qtrue : Qfalse);
7
+ %extend QRcode {
8
+ VALUE modules() {
9
+ VALUE result, row;
10
+ unsigned char *p;
11
+ int x, y, bit;
12
+ result = rb_ary_new2($self->width);
13
+ p = $self->data;
14
+ for(y=0; y < $self->width; y++) {
15
+ row = rb_ary_new2($self->width);
16
+ for(x=0; x < $self->width; x++) {
17
+ bit = *p & 1;
18
+ rb_ary_push(row, bit == 0 ? Qfalse : Qtrue);
19
+ p++;
20
+ }
21
+ rb_ary_push(result, row);
20
22
  }
23
+ return result;
21
24
  }
22
- return result;
23
- }
24
- }
25
+ }