Sha256: 263fb31363b4d6cd8bd06df803ca32b1c0fd5ae4956f5a0998b995989835488a

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

<% if header? %>
; <%= FFIDB.header %>

<% end %>
(asdf:load-system :cffi)
<% for library in @libraries %>
<% if library && @functions[library] %>

(cffi:define-foreign-library <%= library&.name || :lib %>
  (t (:default "<%= dlopen_paths_for(library).first %>")))

(cffi:use-foreign-library <%= library&.name || :lib %>)
<% end %>
<% for enum in @enums[library] || [] %>

<% if enum.comment %>
<%= format_comment(enum.comment, ';;') %>
<% end %>
(cffi:defcenum <%= enum.name %>
<% for name, value in enum.values || {} %>
  (:<%= name %> <%= value %>)
<% end %>
)
<% end %>
<% for struct in @structs[library] || [] %>

<% if struct.comment %>
<%= format_comment(struct.comment, ';;') %>
<% end %>
<% if struct.opaque? %>
(cffi:defctype <%= struct.name %> :pointer)
<% else %>
(cffi:defcstruct <%= struct.name %>
<% for name, type in struct.fields || {} %>
  (<%= name %> <%= struct_type(type) %>)
<% end %>
)
<% end %>
<% end %>
<% for function in @functions[library] || [] %>

<% if function.comment %>
<%= format_comment(function.comment, ';;') %>
<% end %>
(cffi:defcfun "<%= function.name %>" <%= param_type(function.type) %><%=
  function.parameters.each_value.map { |p| " (#{p.name} #{param_type(p.type)})" }.join
%>)
<% end %>
<% end %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffidb-0.13.0 etc/templates/lisp.erb