Sha256: 8d55a5b46775f1cc4029bf0c689ba07f0a6ac6cdba77c2954735c75a2b99ee8d

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

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

<% end %>
<% if options[:module] %>
library <%= options[:module] %>;

<% end %>
import 'dart:ffi';
import 'dart:io' as io;
<% for library in @libraries %>
<% if library && @functions[library] %>

final <%= library&.name || :lib %> = DynamicLibrary.open('<%= dlopen_paths_for(library).first %>');
<% end %>
<% for enum in @enums[library] || [] %>

<% if enum.comment %>
/// <%= enum.comment %>
<% end %>
abstract class <%= enum.name %> {
  <%= enum.name %>._();

  <% for name, value in enum.values || {} %>
  static const <%= name %> = <%= value %>;
  <% end %>
}
<% end %>
<% for struct in @structs[library] || [] %>

<% if struct.comment %>
/// <%= struct.comment %>
<% end %>
<% if struct.opaque? %>
class <%= struct.name %> extends Struct {
    Int8 _opaque;
<% else %>
class <%= struct.name %> extends Struct {
  <% for (name, type), i in (struct.fields || {}).each_with_index %>
<%= i.zero? ? '' : "\n" -%>
    <% unless type.pointer? %>
    @<%= ffi_struct_type(type) %>() // <%= type %>
    <% else %>
    // <%= type %>
    <% end %>
    <%= dart_struct_type(type) %> <%= name %>;
  <% end %>
<% end %>
}
<% end %>
<% for function in @functions[library] || [] %>

<% if function.comment %>
/// <%= function.comment %>
<% end %>
final <%= dart_param_type(function.type) %> Function(<%=
      function.parameters.each_value.map { |p| dart_param_type(p.type) }.join(', ')
    %>) <%= function.name %> = <%= library&.name || :lib %>
    .lookup<NativeFunction<<%= ffi_param_type(function.type) %> Function(<%=
      function.parameters.each_value.map { |p| ffi_param_type(p.type) }.join(', ')
    %>)>>('<%= function.name %>')
    .asFunction();
<% end %>
<% end %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffidb-0.12.0 etc/templates/dart.erb