Skip to content

Commit

Permalink
Define missing types in omp library.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk committed Sep 21, 2023
1 parent 0e49366 commit 49d51aa
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions omp/gen_omp_library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def print_enum(name, enum)
require 'ffi'
module FFI
class OMPStruct < Struct
class OMPTStruct < Struct
def to_h
members.zip(values).to_h
end
Expand All @@ -117,7 +117,10 @@ def to_s
class OMPEnum < Enum
end
class OMPUnion < Union
class OMPTUnion < Union
def self.find_type(name, type_map = nil)
OMP.find_type(name)
end
end
class OMPBitmask < Bitmask
Expand Down Expand Up @@ -166,6 +169,7 @@ def to_s
module OMP
extend FFI::Library
typedef :uint, :"unsigned int"
EOF

Expand All @@ -181,7 +185,7 @@ def print_union(name, union)
s
}
puts <<EOF
class #{to_class_name(name)} < FFI::OMPUnion
class #{to_class_name(name)} < FFI::OMPTUnion
layout #{members.collect(&print_lambda).join(",\n"+" "*11)}
EOF
if name == "ompt_data_t"
Expand Down Expand Up @@ -210,7 +214,7 @@ def print_struct(name, struct)
s
}
puts <<EOF
class #{to_class_name(name)} < FFI::OMPStruct
class #{to_class_name(name)} < FFI::OMPTStruct
EOF
puts <<EOF
layout #{members.collect(&print_lambda).join(",\n"+" "*11)}
Expand All @@ -222,6 +226,19 @@ class #{to_class_name(name)} < FFI::OMPStruct
EOF
end

def print_function_pointer(name, type)
puts <<EOF
typedef :pointer, #{to_ffi_name(name)}
EOF
end

$int_scalars.each { |k, v|
puts <<EOF
typedef #{to_ffi_name(v)}, #{to_ffi_name(k)}
EOF
}

$all_types.each { |t|
if t.type.kind_of? YAMLCAst::Enum
enum = $all_enums.find { |e| t.type.name == e.name }
Expand All @@ -238,6 +255,8 @@ class #{to_class_name(name)} < FFI::OMPStruct
union = $all_unions.find { |s| t.type.name == s.name }
next unless union
print_union(t.name, union)
elsif t.type.kind_of?(YAMLCAst::Pointer) && t.type.type.kind_of?(YAMLCAst::Function)
print_function_pointer(t.name, t.type)
end
}

Expand Down

0 comments on commit 49d51aa

Please sign in to comment.