hacks 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f13cdcb072c1740305781547e1ec9fb8d325fc7f13c906b366ce5698457b8d0d
4
- data.tar.gz: ce2d9afff0fad70ee8cf2e27f6cd2ba65fec40b610a45b0f145598f9cb9113ad
3
+ metadata.gz: ba3476e1fe18d372391bc6a122ef0d45744f784c135d40faa8cb264e2df3e905
4
+ data.tar.gz: 4c9e1c6d2ed0b1c60a13fe75e03b75774fe1f517c73f5aa2c3e5710f230f9602
5
5
  SHA512:
6
- metadata.gz: 88934330f21446db9a806ce0f65be1cd60361c18a1f38180c0c0425b20b6d34333771d1c3efb607921cebdef7fc652bb1b5fbaec6dc35fbb315cdf7be7c0701f
7
- data.tar.gz: 4b335678b0e31af5018b4781d2057cb2193a6a66f179127ee8956e632a8b561a83255423e92f086bb7c856c5206335d12b42e0dfde19aee253e601d382f183cf
6
+ metadata.gz: 7666b5394fecf21bbc25a3e8d9bfdc1356d5a25f41e8b40984820d29d8b71bde04fb0c3b82d5d9031fd9245b6b440f11400b1e491e66e4834a3ec562f622c4f0
7
+ data.tar.gz: 9cd8b84ee5133710d2cd1328238d2adb046698105dd2cf5e444108e4f3671e66a68c872cd8c4bd268c2e4988d94f97ae92c948e7e85a2c03a2f1046eed9a322f
data/ext/hacks/extconf.rb CHANGED
@@ -3,8 +3,9 @@ require "erb"
3
3
 
4
4
  require File.join File.dirname(__FILE__), "constants.rb"
5
5
  require File.join File.dirname(__FILE__), "structs.rb"
6
+ require File.join File.dirname(__FILE__), "function_pointers.rb"
6
7
 
7
- def make_c constants, structs
8
+ def make_c constants, structs, fps
8
9
  erb_file = File.join File.dirname(__FILE__), "hacks.c.erb"
9
10
  erb = ERB.new(File.binread(erb_file), trim_mode: "-")
10
11
  c = erb.result(binding)
@@ -12,6 +13,12 @@ def make_c constants, structs
12
13
  File.binwrite c_file, c
13
14
  end
14
15
 
15
- make_c Hacks::CONSTANTS.find_all { have_const(_1) }.map { [_1.sub(/^RUBY_/, ''), _1] }, Hacks::STRUCTS
16
+ constants = Hacks::CONSTANTS.find_all {
17
+ have_const(_1)
18
+ }.map {
19
+ [_1.sub(/^RUBY_/, ''), _1]
20
+ }
21
+
22
+ make_c constants, Hacks::STRUCTS, Hacks::FPs
16
23
 
17
24
  create_makefile "hacks"
@@ -0,0 +1,6 @@
1
+ module Hacks
2
+ FPs = %w{
3
+ rb_funcallv
4
+ rb_ary_new
5
+ }
6
+ end
@@ -31,6 +31,14 @@ hacks_rb_id2sym(VALUE mod, VALUE x)
31
31
  return rb_id2sym((ID)NUM2INT(x));
32
32
  }
33
33
 
34
+ <%- fps.each do |name| -%>
35
+ static VALUE
36
+ hacks_fp_<%= name %>(VALUE mod)
37
+ {
38
+ return SIZET2NUM((size_t)<%= name %>);
39
+ }
40
+ <%- end -%>
41
+
34
42
  void Init_hacks(void)
35
43
  {
36
44
  VALUE rb_mHacks = rb_define_module("Hacks");
@@ -60,4 +68,9 @@ void Init_hacks(void)
60
68
  rb_define_singleton_method(rb_mHacks, "rb_obj_class", hacks_rb_obj_class, 1);
61
69
  rb_define_singleton_method(rb_mHacks, "rb_gc_writebarrier", hacks_rb_gc_writebarrier, 2);
62
70
  rb_define_singleton_method(rb_mHacks, "rb_intern_str", hacks_rb_intern_str, 1);
71
+
72
+ VALUE rb_mFPs = rb_define_module_under(rb_mHacks, "FunctionPointers");
73
+ <%- fps.each do |name| -%>
74
+ rb_define_singleton_method(rb_mFPs, "<%= name %>", hacks_fp_<%= name %>, 0);
75
+ <%- end -%>
63
76
  }
data/hacks.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "hacks"
5
- s.version = "0.0.4"
5
+ s.version = "0.0.5"
6
6
  s.summary = "Ruby C internals exposed as Ruby"
7
7
  s.description = "These are some hacks I use. This gem exposes some Ruby C internals as Ruby functions and constants"
8
8
  s.authors = ["Aaron Patterson"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hacks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-02 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -52,6 +52,7 @@ files:
52
52
  - Rakefile
53
53
  - ext/hacks/constants.rb
54
54
  - ext/hacks/extconf.rb
55
+ - ext/hacks/function_pointers.rb
55
56
  - ext/hacks/hacks.c.erb
56
57
  - ext/hacks/structs.rb
57
58
  - hacks.gemspec
@@ -60,7 +61,7 @@ homepage: https://github.com/tenderlove/hacks
60
61
  licenses:
61
62
  - Apache-2.0
62
63
  metadata: {}
63
- post_install_message:
64
+ post_install_message:
64
65
  rdoc_options: []
65
66
  require_paths:
66
67
  - lib
@@ -75,8 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
78
  requirements: []
78
- rubygems_version: 3.5.0.dev
79
- signing_key:
79
+ rubygems_version: 3.0.3.1
80
+ signing_key:
80
81
  specification_version: 4
81
82
  summary: Ruby C internals exposed as Ruby
82
83
  test_files: []