extpp 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f49c10b6867050e901d6a62c1603edf59a043a1bd00adaa0406ec617ad6433c1
4
- data.tar.gz: 30b74d3f1d398329f5e46a8c26e37af6a136b894e7baacadc4a721d3a762fff5
3
+ metadata.gz: 6c22f302ed4a23deab1073040600c6b5fa9983718a9edf01e6fef951a899800a
4
+ data.tar.gz: 7d112b2629ce251b7c27eaa3035181ef67943379f835def732b42042beaeed1b
5
5
  SHA512:
6
- metadata.gz: 3a765bf63c05366b94f3002f3a29e03fd837db823af45205975f32d45ca0aaa1c536f5d278c22b4da61aa7b87e964966bcacb6d5c484dd52c14937af77553748
7
- data.tar.gz: 4f36f5793d58b0e501f4b93ee5e35011d35c5cfb9d1abde899e746df1c959a2a4b6ca6872f79d85eccdd6a998c3c23ea36bfe258a64f65a4925643695587f0d7
6
+ metadata.gz: ea4a26e4e6b0ba28549c79bd3dab29da154fea5456399f6b13c754362f8616a73b14eedb252b53fac76f0c1fcd3f9ee09a5b37ad2ed1683e4be7921a7d4c8d3d
7
+ data.tar.gz: a609c6419db657678c4e2166d68a3d079d3f7d257a0323826a048ab9f592ae0aae02d6c46317c1ea7a1d6b18b170d5e1cfa934c355fd49fcf77c2f4bab5fc2e4
data/README.md CHANGED
@@ -90,12 +90,12 @@ Build this extension:
90
90
  Now, you can use this extension:
91
91
 
92
92
  ```console
93
- % ruby -r ./hello -e 'p Hello.new("me").greet'
93
+ % ruby -r extpp/setup -r ./hello -e 'p Hello.new("me").greet'
94
94
  "Hello me"
95
95
  ```
96
96
 
97
97
  ## License
98
98
 
99
- Copyright (C) 2017-2018 Kouhei Sutou
99
+ Copyright (C) 2017-2019 Kouhei Sutou
100
100
 
101
101
  The 2-Clause BSD License. See [LICENSE.txt](LICENSE.txt) for details.
@@ -1,5 +1,11 @@
1
1
  # News
2
2
 
3
+ ## 0.0.7 - 2019-03-021
4
+
5
+ ### Improvements
6
+
7
+ * Added support for Windows.
8
+
3
9
  ## 0.0.6 - 2019-02-25
4
10
 
5
11
  ### Improvements
@@ -75,7 +75,7 @@ INCLUDEFLAGS = \
75
75
  -I$(INCLUDE_DIR) \
76
76
  -I$(RUBY_HEADER_DIR) \
77
77
  -I$(RUBY_ARCH_HEADER_DIR)
78
- CPPFLAGS = #{RbConfig::CONFIG["CPPFLAGS"]}
78
+ CPPFLAGS = #{RbConfig::CONFIG["CPPFLAGS"]} -DRB_EXTPP_COMPILATION
79
79
  CXXFLAGS = $(CCDLFLAGS) #{cxxflags}
80
80
 
81
81
  all: $(LIBRARY)
@@ -1,4 +1,4 @@
1
- #include <ruby/object.hpp>
1
+ #include <ruby.hpp>
2
2
 
3
3
  namespace {
4
4
  VALUE call_block(RB_BLOCK_CALL_FUNC_ARGLIST(rb_data, rb_block)) {
@@ -1,4 +1,4 @@
1
- #include <ruby/protect.hpp>
1
+ #include <ruby.hpp>
2
2
 
3
3
  namespace rb {
4
4
  VALUE protect(RawCallback callback, VALUE callback_data) {
@@ -5,6 +5,16 @@
5
5
  #define RB_BEGIN_DECLS extern "C" {
6
6
  #define RB_END_DECLS }
7
7
 
8
+ #ifdef _WIN32
9
+ # ifdef RB_EXTPP_COMPILATION
10
+ # define RB_EXTPP_EXPORT __declspec(dllexport)
11
+ # else
12
+ # define RB_EXTPP_EXPORT __declspec(dllimport)
13
+ # endif
14
+ #else
15
+ # define RB_EXTPP_EXPORT __attribute__((visibility("default")))
16
+ #endif
17
+
8
18
  #include <ruby/cast.hpp>
9
19
  #include <ruby/class.hpp>
10
20
  #include <ruby/object.hpp>
@@ -36,12 +36,12 @@ namespace rb {
36
36
 
37
37
  template <>
38
38
  inline int64_t cast<int64_t, Object>(const Object& rb_object) {
39
- return NUM2LONG(rb_object);
39
+ return NUM2LL(rb_object);
40
40
  }
41
41
 
42
42
  template <>
43
43
  inline Object cast<Object, int64_t>(const int64_t& n) {
44
- return Object(LONG2NUM(n));
44
+ return Object(LL2NUM(n));
45
45
  }
46
46
 
47
47
 
@@ -58,12 +58,12 @@ namespace rb {
58
58
 
59
59
  template <>
60
60
  inline uint64_t cast<uint64_t, Object>(const Object& rb_object) {
61
- return NUM2ULONG(rb_object);
61
+ return NUM2ULL(rb_object);
62
62
  }
63
63
 
64
64
  template <>
65
65
  inline Object cast<Object, uint64_t>(const uint64_t& n) {
66
- return Object(ULONG2NUM(n));
66
+ return Object(ULL2NUM(n));
67
67
  }
68
68
 
69
69
 
@@ -3,7 +3,7 @@
3
3
  #include <ruby/object.hpp>
4
4
 
5
5
  namespace rb {
6
- class Class: public Object {
6
+ class RB_EXTPP_EXPORT Class: public Object {
7
7
  public:
8
8
  Class(const char *name);
9
9
  Class(const char *name, VALUE parent);
@@ -5,7 +5,7 @@
5
5
  #include <initializer_list>
6
6
 
7
7
  namespace rb {
8
- class Object {
8
+ class RB_EXTPP_EXPORT Object {
9
9
  public:
10
10
  explicit Object(VALUE rb_object=Qnil) :
11
11
  rb_object_(rb_object),
@@ -3,7 +3,7 @@
3
3
  #include <ruby/type.hpp>
4
4
 
5
5
  namespace rb {
6
- class State {
6
+ class RB_EXTPP_EXPORT State {
7
7
  public:
8
8
  explicit State(int state) :
9
9
  state_(state) {
@@ -17,15 +17,15 @@ namespace rb {
17
17
  int state_;
18
18
  };
19
19
 
20
- VALUE protect(RawCallback callback, VALUE callback_data);
20
+ RB_EXTPP_EXPORT VALUE protect(RawCallback callback, VALUE callback_data);
21
21
 
22
- template <typename CALLBACK>
23
- VALUE protect(const CALLBACK& callback) {
22
+ template <typename NoArgumentCallback>
23
+ VALUE protect(const NoArgumentCallback& callback) {
24
24
  struct Data {
25
- Data(const CALLBACK& callback) :
25
+ Data(const NoArgumentCallback& callback) :
26
26
  callback_(callback) {
27
27
  }
28
- const CALLBACK& callback_;
28
+ const NoArgumentCallback& callback_;
29
29
  } data(callback);
30
30
  auto callback_data = reinterpret_cast<VALUE>(&data);
31
31
  return protect([](VALUE callback_data) -> VALUE {
@@ -60,12 +60,14 @@ module ExtPP
60
60
  std = nil
61
61
 
62
62
  case `#{RbConfig.expand("$(CXX) --version")}`
63
- when /\Ag\+\+ .+ (\d\.\d)\.\d/
63
+ when /g\+\+.+ (\d\.\d)\.\d/
64
64
  version = Float($1)
65
65
  if version < 5.1
66
66
  std = "gnu++11"
67
67
  elsif version < 6.1
68
68
  std = "gnu++14"
69
+ else
70
+ std = "gnu++17"
69
71
  end
70
72
  when /\A.+ clang version (\d\.\d)\.\d/
71
73
  version = Float($1)
@@ -135,7 +137,12 @@ module ExtPP
135
137
  flags << warning_flag
136
138
  end
137
139
  end
138
- @cxx_flags = Shellwords.join(flags)
140
+ case RUBY_PLATFORM
141
+ when /windows/, /mingw/
142
+ @cxx_flags = flags.join(" ")
143
+ else
144
+ @cxx_flags = Shellwords.join(flags)
145
+ end
139
146
  end
140
147
  end
141
148
  end
@@ -0,0 +1,4 @@
1
+ if Object.const_defined?(:RubyInstaller)
2
+ ext_dir = File.expand_path(File.join(__dir__, "..", "..", "ext", "extpp"))
3
+ RubyInstaller::Runtime.add_dll_directory(ext_dir)
4
+ end
@@ -1,3 +1,3 @@
1
1
  module ExtPP
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -1,4 +1,9 @@
1
- task :default => :build
1
+ task :default => :run
2
+
3
+ desc "Run"
4
+ task :run => :build do
5
+ ruby("hello.rb")
6
+ end
2
7
 
3
8
  desc "Build"
4
9
  task :build => "hello.so"
Binary file
Binary file
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
2
2
 
3
3
  --------------------
4
4
 
5
- check_version: checking g++ version... -------------------- 8.2
5
+ check_cxx: checking C++ compiler... -------------------- g++
6
+
7
+ --------------------
8
+
9
+ check_version: checking g++ version... -------------------- 8.3
6
10
 
7
11
  --------------------
8
12
 
Binary file
Binary file
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
2
2
 
3
3
  --------------------
4
4
 
5
- check_version: checking g++ version... -------------------- 8.2
5
+ check_cxx: checking C++ compiler... -------------------- g++
6
+
7
+ --------------------
8
+
9
+ check_version: checking g++ version... -------------------- 8.3
6
10
 
7
11
  --------------------
8
12
 
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
2
2
 
3
3
  --------------------
4
4
 
5
- check_version: checking g++ version... -------------------- 8.2
5
+ check_cxx: checking C++ compiler... -------------------- g++
6
+
7
+ --------------------
8
+
9
+ check_version: checking g++ version... -------------------- 8.3
6
10
 
7
11
  --------------------
8
12
 
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
2
2
 
3
3
  --------------------
4
4
 
5
- check_version: checking g++ version... -------------------- 8.2
5
+ check_cxx: checking C++ compiler... -------------------- g++
6
+
7
+ --------------------
8
+
9
+ check_version: checking g++ version... -------------------- 8.3
6
10
 
7
11
  --------------------
8
12
 
@@ -1,5 +1,7 @@
1
1
  require "test-unit"
2
2
 
3
+ require "extpp/setup"
4
+
3
5
  module Helper
4
6
  module Fixture
5
7
  def fixture_path(*components)
@@ -10,9 +10,17 @@ ext_dir = base_dir + "ext" + "extpp"
10
10
  lib_dir = base_dir + "lib"
11
11
  test_dir = base_dir + "test"
12
12
 
13
- Dir.chdir(ext_dir.to_s) do
14
- if File.exist?("Makefile")
15
- system("make > /dev/null") or exit(false)
13
+ make = nil
14
+ if system("which gmake > #{File::NULL} 2>&1")
15
+ make = "gmake"
16
+ elsif system("which make > #{File::NULL} 2>&1")
17
+ make = "make"
18
+ end
19
+ if make
20
+ Dir.chdir(ext_dir.to_s) do
21
+ if File.exist?("Makefile")
22
+ system("#{make} > #{File::NULL}") or exit(false)
23
+ end
16
24
  end
17
25
  end
18
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extpp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-25 00:00:00.000000000 Z
11
+ date: 2019-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,7 @@ files:
81
81
  - lib/extpp.rb
82
82
  - lib/extpp/compiler.rb
83
83
  - lib/extpp/platform.rb
84
+ - lib/extpp/setup.rb
84
85
  - lib/extpp/version.rb
85
86
  - sample/hello/Rakefile
86
87
  - sample/hello/extconf.rb