malloc 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,10 +3,11 @@ require 'date'
3
3
  require 'rake/clean'
4
4
  require 'rake/testtask'
5
5
  require 'rake/packagetask'
6
+ require 'rake/loaders/makefile'
6
7
  require 'rbconfig'
7
8
 
8
9
  PKG_NAME = 'malloc'
9
- PKG_VERSION = '1.1.1'
10
+ PKG_VERSION = '1.1.2'
10
11
  CXX = ENV[ 'CXX' ] || 'g++'
11
12
  STRIP = ENV[ 'STRIP' ] || 'strip'
12
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
@@ -27,16 +28,16 @@ HOMEPAGE = %q{http://wedesoft.github.com/malloc/}
27
28
 
28
29
  OBJ = CC_FILES.ext 'o'
29
30
  $CXXFLAGS = ENV[ 'CXXFLAGS' ] || ''
30
- $CXXFLAGS = "#{$CXXFLAGS} -fPIC"
31
- if Config::CONFIG[ 'rubyhdrdir' ]
32
- $CXXFLAGS += "#{$CXXFLAGS} -I#{Config::CONFIG[ 'rubyhdrdir' ]} " +
33
- "-I#{Config::CONFIG[ 'rubyhdrdir' ]}/#{Config::CONFIG[ 'arch' ]}"
31
+ $CXXFLAGS = "#{$CXXFLAGS} -fPIC -DNDEBUG"
32
+ if RbConfig::CONFIG[ 'rubyhdrdir' ]
33
+ $CXXFLAGS = "#{$CXXFLAGS} -I#{RbConfig::CONFIG[ 'rubyhdrdir' ]} " +
34
+ "-I#{RbConfig::CONFIG[ 'rubyhdrdir' ]}/#{RbConfig::CONFIG[ 'arch' ]}"
34
35
  else
35
- $CXXFLAGS += "#{$CXXFLAGS} -I#{Config::CONFIG[ 'archdir' ]}"
36
+ $CXXFLAGS = "#{$CXXFLAGS} -I#{RbConfig::CONFIG[ 'archdir' ]}"
36
37
  end
37
- $LIBRUBYARG = Config::CONFIG[ 'LIBRUBYARG' ]
38
- $SITELIBDIR = Config::CONFIG[ 'sitelibdir' ]
39
- $SITEARCHDIR = Config::CONFIG[ 'sitearchdir' ]
38
+ $LIBRUBYARG = RbConfig::CONFIG[ 'LIBRUBYARG' ]
39
+ $SITELIBDIR = RbConfig::CONFIG[ 'sitelibdir' ]
40
+ $SITEARCHDIR = RbConfig::CONFIG[ 'sitearchdir' ]
40
41
 
41
42
  task :default => :all
42
43
 
@@ -93,6 +94,7 @@ Rake::PackageTask.new PKG_NAME, PKG_VERSION do |p|
93
94
  end
94
95
 
95
96
  begin
97
+ require 'rubygems'
96
98
  require 'rubygems/builder'
97
99
  $SPEC = Gem::Specification.new do |s|
98
100
  s.name = PKG_NAME
@@ -162,7 +164,13 @@ rule '.o' => '.cc' do |t|
162
164
  sh "#{CXX} #{$CXXFLAGS} -c -o #{t.name} #{t.source}"
163
165
  end
164
166
 
165
- file 'ext/malloc.o' => [ 'ext/malloc.cc', 'ext/malloc.hh', 'ext/error.hh' ]
167
+ file ".depends.mf" do |t|
168
+ sh "makedepend -f- -- #{$CXXFLAGS} -- #{CC_FILES.join ' '} > #{t.name}"
169
+ end
170
+ CC_FILES.each do |t|
171
+ file t.ext(".o") => t
172
+ end
173
+ import ".depends.mf"
166
174
 
167
175
  CLEAN.include 'ext/*.o'
168
- CLOBBER.include SO_FILE, 'doc', '.yardoc'
176
+ CLOBBER.include SO_FILE, 'doc', '.yardoc', '.depends.mf'
data/ext/error.hh CHANGED
@@ -1,5 +1,5 @@
1
1
  /* HornetsEye - Computer Vision with Ruby
2
- Copyright (C) 2006, 2007, 2008, 2009 Jan Wedekind
2
+ Copyright (C) 2006, 2007, 2008, 2009, 2010 Jan Wedekind
3
3
 
4
4
  This program is free software: you can redistribute it and/or modify
5
5
  it under the terms of the GNU General Public License as published by
@@ -18,20 +18,19 @@
18
18
 
19
19
  #include <exception>
20
20
  #include <sstream>
21
- #include <string>
22
21
 
23
22
  class Error: public std::exception
24
23
  {
25
24
  public:
26
25
  Error(void) {}
27
26
  Error( Error &e ): std::exception( e )
28
- { m_message << e.m_message.str(); }
27
+ { m_message << e.m_message.str(); }
29
28
  virtual ~Error(void) throw() {}
30
29
  template< typename T >
31
30
  std::ostream &operator<<( const T &t )
32
- { m_message << t; return m_message; }
33
- std::ostream &operator<<( std::ostream& (*__pf)( std::ostream&) )
34
- { (*__pf)( m_message ); return m_message; }
31
+ { m_message << t; return m_message; }
32
+ std::ostream &operator<<( std::ostream& (*__pf)(std::ostream&) )
33
+ { (*__pf)( m_message ); return m_message; }
35
34
  virtual const char* what(void) const throw() {
36
35
  temp = m_message.str();
37
36
  return temp.c_str();
data/ext/malloc.hh CHANGED
@@ -16,7 +16,7 @@
16
16
  #ifndef MALLOC_HH
17
17
  #define MALLOC_HH
18
18
 
19
- #include <ruby.h>
19
+ #include "rubyinc.hh"
20
20
 
21
21
  class Malloc
22
22
  {
data/ext/rubyinc.hh ADDED
@@ -0,0 +1,54 @@
1
+ /* HornetsEye - Computer Vision with Ruby
2
+ Copyright (C) 2006, 2007 Jan Wedekind
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ #ifndef HORNETSEYE_RUBYINC_HH
17
+ #define HORNETSEYE_RUBYINC_HH
18
+
19
+ #ifdef RSHIFT
20
+ #undef RSHIFT
21
+ #endif
22
+
23
+ #define gettimeofday rubygettimeofday
24
+ #define timezone rubygettimezone
25
+ #include <ruby.h>
26
+ // #include <version.h>
27
+ #undef timezone
28
+ #undef gettimeofday
29
+ #ifdef read
30
+ #undef read
31
+ #endif
32
+ #ifdef write
33
+ #undef write
34
+ #endif
35
+ #ifdef RGB
36
+ #undef RGB
37
+ #endif
38
+
39
+ #ifndef RUBY_VERSION_NUMBER
40
+ #define RUBY_VERSION_NUMBER ( RUBY_VERSION_MAJOR * 10000 + \
41
+ RUBY_VERSION_MINOR * 100 + \
42
+ RUBY_VERSION_TEENY )
43
+ #endif
44
+
45
+ #ifndef RUBY_METHOD_FUNC
46
+ #define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))func)
47
+ #endif
48
+
49
+ #ifndef xfree
50
+ #define xfree free
51
+ #endif
52
+
53
+ #endif
54
+
data/lib/malloc_ext.rb CHANGED
@@ -90,21 +90,16 @@ module Hornetseye
90
90
  "Malloc(#{@size})"
91
91
  end
92
92
 
93
- # Read data from memory
93
+ # Display information about this object
94
94
  #
95
- # @example Convert data of Malloc object to string
95
+ # @example Displaying information about a Malloc object
96
96
  # require 'malloc'
97
- # include Hornetseye
98
- # m = Malloc.new 5
99
- # m.write 'abcde'
100
- # m.to_s
101
- # "abcde"
102
- #
103
- # @return [String] A string containing the data.
97
+ # Hornetseye::Malloc.new( 8 ).to_s
98
+ # "Malloc(8)"
104
99
  #
105
- # @see #read
100
+ # @return [String] A string with information about this object.
106
101
  def to_s
107
- read @size
102
+ inspect
108
103
  end
109
104
 
110
105
  # Operator for doing pointer arithmetic
data/test/tc_malloc.rb CHANGED
@@ -30,9 +30,7 @@ class TC_Malloc < Test::Unit::TestCase
30
30
  end
31
31
 
32
32
  def test_to_s
33
- m = Hornetseye::Malloc.new 3
34
- m.write 'abc'
35
- assert_equal 'abc', m.to_s
33
+ assert_equal 'Malloc(32)', Hornetseye::Malloc.new( 32 ).to_s
36
34
  end
37
35
 
38
36
  def test_read_write
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 1
9
- version: 1.1.1
8
+ - 2
9
+ version: 1.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-25 00:00:00 +01:00
17
+ date: 2010-10-05 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,7 @@ files:
47
47
  - ext/malloc.cc
48
48
  - ext/init.cc
49
49
  - ext/malloc.hh
50
+ - ext/rubyinc.hh
50
51
  - ext/error.hh
51
52
  - test/ts_malloc.rb
52
53
  - test/tc_malloc.rb