Module interoptopus::patterns[][src]

Expand description

Optional types that translate to binding with better semantics in languages supporting them.

Patterns are purely optional. If you want to use a certain pattern in your bindings you generally define one or more functions that use some of the types contained in this module.

Backends which support a pattern will then generate additional language-specific helpers and bindings for it. In any case, regardless whether a pattern is supported by a backend or not, fallback bindings will be available.

Pattern Support

Patterns are exclusively designed on top of existing, C-compatible functions and types. That means a backend will handle a pattern in one of three ways:

  • The pattern is supported and the backend will generate the raw, underlying type and / or a language-specific abstraction that safely and conveniently handles it. Examples include converting an AsciiPointer to a C# string, or a class to a Python class.

  • The pattern is not supported and will be omitted if the pattern was merely an aggregate of existing items. Examples include the class pattern in C which will not be emitted. However, this will not pose a problem as all constituent types and methods (functions) are still available as raw bindings.

  • The pattern is not supported and will be replaced with a fallback type. Examples include the AsciiPointer which will become a regular *const u8 in C.

In other words, regardless of which pattern was used, the involved methods and types will always be accessible from any language.

Modules

ascii_pointer

Raw *const char pointer on C-level but ASCII string like in languages that support it.

callbacks

Useful when extern "C" fn() delegate types give compile errors.

class

Bundles function with common receiver into a class in object oriented languages.

option

Like a regular Option but FFI safe.

slice

Like a regular &[T] but FFI safe.

success_enum

For return enums with defined Ok variants, translating to exceptions if not met.

Enums

LibraryPattern

A pattern on a library level, usually involving both methods and types.

TypePattern

A pattern on a type level.