Leave a comment about the limitation of Primitive

and adjust some code styling from that PR.
This commit is contained in:
Takashi Kokubun 2024-01-23 14:37:22 -08:00
Родитель 7ac74f5c77
Коммит 996776e936
2 изменённых файлов: 13 добавлений и 6 удалений

Просмотреть файл

@ -1541,13 +1541,17 @@ module RubyVM::RJIT # :nodoc: all
end
def C.VALUE
@VALUE ||= CType::Immediate.find(Primitive.cexpr!("SIZEOF(VALUE)"),
Primitive.cexpr!("SIGNED_TYPE_P(VALUE)"))
@VALUE ||= CType::Immediate.find(
Primitive.cexpr!("SIZEOF(VALUE)"),
Primitive.cexpr!("SIGNED_TYPE_P(VALUE)"),
)
end
def C.shape_id_t
@shape_id_t ||= CType::Immediate.find(Primitive.cexpr!("SIZEOF(shape_id_t)"),
Primitive.cexpr!("SIGNED_TYPE_P(shape_id_t)"))
@shape_id_t ||= CType::Immediate.find(
Primitive.cexpr!("SIZEOF(shape_id_t)"),
Primitive.cexpr!("SIGNED_TYPE_P(shape_id_t)"),
)
end
def C.rb_id_table

Просмотреть файл

@ -182,9 +182,12 @@ class BindingGenerator
unless generate_node(nodes_index[type])&.start_with?('CType::Immediate')
raise "Non-immediate type is given to dynamic_types: #{type}"
end
# Only one Primitive.cexpr! is allowed for each line: https://github.com/ruby/ruby/pull/9612
println " def C.#{type}"
println " @#{type} ||= CType::Immediate.find(Primitive.cexpr!(\"SIZEOF(#{type})\"),"
println " Primitive.cexpr!(\"SIGNED_TYPE_P(#{type})\"))"
println " @#{type} ||= CType::Immediate.find("
println " Primitive.cexpr!(\"SIZEOF(#{type})\"),"
println " Primitive.cexpr!(\"SIGNED_TYPE_P(#{type})\"),"
println " )"
println " end"
println
end