summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-14 00:29:28 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2022-11-14 00:29:28 -0800
commita8537aa6a5ec6da5261e727943ba267bc422e594 (patch)
tree593f4eb7dda35cc11c4321ee23d545c553055f3b
parent80bab6c8eddbb225c88155f2eb456a4d937294c7 (diff)
Import shape constants with mjit-bindgen
-rw-r--r--mjit_c.rb68
-rwxr-xr-xtool/mjit/bindgen.rb10
2 files changed, 44 insertions, 34 deletions
diff --git a/mjit_c.rb b/mjit_c.rb
index 41f22f5682..16c73fc220 100644
--- a/mjit_c.rb
+++ b/mjit_c.rb
@@ -4,41 +4,9 @@
module RubyVM::MJIT
C = Object.new
- # This `class << C` section is for calling C functions.
- # For variables/macros, please consider using tool/mjit/bindgen.rb instead.
+ # This `class << C` section is for calling C functions. For importing variables
+ # or macros as is, please consider using tool/mjit/bindgen.rb instead.
class << C
- def SHAPE_BITS
- Primitive.cexpr! 'UINT2NUM(SHAPE_BITS)'
- end
-
- def SHAPE_FLAG_SHIFT
- Primitive.cexpr! 'UINT2NUM(SHAPE_FLAG_SHIFT)'
- end
-
- def SHAPE_ROOT
- Primitive.cexpr! 'UINT2NUM(SHAPE_ROOT)'
- end
-
- def SHAPE_IVAR
- Primitive.cexpr! 'UINT2NUM(SHAPE_IVAR)'
- end
-
- def SHAPE_FROZEN
- Primitive.cexpr! 'UINT2NUM(SHAPE_FROZEN)'
- end
-
- def SHAPE_CAPACITY_CHANGE
- Primitive.cexpr! 'UINT2NUM(SHAPE_CAPACITY_CHANGE)'
- end
-
- def SHAPE_IVAR_UNDEF
- Primitive.cexpr! 'UINT2NUM(SHAPE_IVAR_UNDEF)'
- end
-
- def SHAPE_INITIAL_CAPACITY
- Primitive.cexpr! 'UINT2NUM(SHAPE_INITIAL_CAPACITY)'
- end
-
def ROBJECT_EMBED_LEN_MAX
Primitive.cexpr! 'INT2NUM(RBIMPL_EMBED_LEN_MAX_OF(VALUE))'
end
@@ -198,6 +166,38 @@ module RubyVM::MJIT
Primitive.cexpr! %q{ INT2NUM(VM_METHOD_TYPE_ISEQ) }
end
+ def C.SHAPE_BITS
+ Primitive.cexpr! %q{ UINT2NUM(SHAPE_BITS) }
+ end
+
+ def C.SHAPE_CAPACITY_CHANGE
+ Primitive.cexpr! %q{ UINT2NUM(SHAPE_CAPACITY_CHANGE) }
+ end
+
+ def C.SHAPE_FLAG_SHIFT
+ Primitive.cexpr! %q{ UINT2NUM(SHAPE_FLAG_SHIFT) }
+ end
+
+ def C.SHAPE_FROZEN
+ Primitive.cexpr! %q{ UINT2NUM(SHAPE_FROZEN) }
+ end
+
+ def C.SHAPE_INITIAL_CAPACITY
+ Primitive.cexpr! %q{ UINT2NUM(SHAPE_INITIAL_CAPACITY) }
+ end
+
+ def C.SHAPE_IVAR
+ Primitive.cexpr! %q{ UINT2NUM(SHAPE_IVAR) }
+ end
+
+ def C.SHAPE_IVAR_UNDEF
+ Primitive.cexpr! %q{ UINT2NUM(SHAPE_IVAR_UNDEF) }
+ end
+
+ def C.SHAPE_ROOT
+ Primitive.cexpr! %q{ UINT2NUM(SHAPE_ROOT) }
+ end
+
def C.INVALID_SHAPE_ID
Primitive.cexpr! %q{ ULONG2NUM(INVALID_SHAPE_ID) }
end
diff --git a/tool/mjit/bindgen.rb b/tool/mjit/bindgen.rb
index 70800b7dcb..64ac3eb7d2 100755
--- a/tool/mjit/bindgen.rb
+++ b/tool/mjit/bindgen.rb
@@ -341,6 +341,16 @@ generator = BindingGenerator.new(
VM_METHOD_TYPE_CFUNC
VM_METHOD_TYPE_ISEQ
],
+ UINT: %w[
+ SHAPE_BITS
+ SHAPE_CAPACITY_CHANGE
+ SHAPE_FLAG_SHIFT
+ SHAPE_FROZEN
+ SHAPE_INITIAL_CAPACITY
+ SHAPE_IVAR
+ SHAPE_IVAR_UNDEF
+ SHAPE_ROOT
+ ],
ULONG: %w[
INVALID_SHAPE_ID
SHAPE_MASK