class FFI::Struct

def enclosing_module

def enclosing_module
  begin
    mod = self.name.split("::")[0..-2].inject(Object) { |obj, c| obj.const_get(c) }
    mod.respond_to?(:find_type) ? mod : nil
  rescue Exception
    nil
  end
end