Skip to content

Commit

Permalink
Import shape constants with mjit-bindgen
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Nov 14, 2022
1 parent 80bab6c commit a8537aa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 34 deletions.
68 changes: 34 additions & 34 deletions mjit_c.rb
Expand Up @@ -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
Expand Down Expand Up @@ -198,6 +166,38 @@ def C.VM_METHOD_TYPE_ISEQ
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
Expand Down
10 changes: 10 additions & 0 deletions tool/mjit/bindgen.rb
Expand Up @@ -341,6 +341,16 @@ def push_target(target)
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
Expand Down

0 comments on commit a8537aa

Please sign in to comment.