Types

Scapix generates bindings for functions with supported parameter types and return type. Functions with unsupported types in parameters or return value are ignored.

Portable types:

classes derived from scapix::bridge::object

void
bool
std::int8_t
std::int16_t
std::int32_t
std::int64_t
std::uint8_t
std::uint16_t
std::uint32_t
std::uint64_t
float
double
std::shared_ptr<T>
std::string (always in UTF-8 encoding)
std::vector<T>
std::map<K,V>
std::set<K>
std::unordered_map<K,V>
std::unordered_set<K>
std::function<F>
enum (as underlying integer type)
struct (all non-static data members are public)

Non-portable types:

char
signed char
short
int
long
long long
unsigned char
unsigned short
unsigned int
unsigned long
unsigned long long
  • Supported types may be nested arbitrarily.
  • Classes derived from scapix::bridge::object are bridged by reference and supported in Scapix bindings only when passed as std::shared_ptr<type>.
  • All other types are bridged by copy.
  • Supported type may be passed or returned by value (Type), by const reference (const Type&) or by rvalue reference (Type&&).
  • Non-const lvalue reference (Type&) is intentionally unsupported.
  • struct should be defined in the same header where it is used as a parameter or return value (this limitation will be lifted in a future version).
  • Use callbacks to call bridged language from C++

Type mappings:

C++ Java ObjC C#
void void void void
bool boolean BOOL bool
std::int8_t byte int8_t sbyte
std::int16_t short int16_t short
std::int32_t int int32_t int
std::int64_t long int64_t long
std::uint8_t byte uint8_t byte
std::uint16_t short uint16_t ushort
std::uint32_t int uint32_t uint
std::uint64_t long uint64_t ulong
float float float float
double double double double
std::string java.lang.String NSString* string
std::vector<T> T[] NSArray<T>* T[]
std::map<K,V> java.util.TreeMap<K,V> NSDictionary<K,V>* SortedDictionary<K,V>
std::set<K> java.util.TreeSet<E> NSOrderedSet<K>* SortedSet<K>
std::unordered_map<K,V> java.util.HashMap<K,V> NSDictionary<K,V>* Dictionary<K,V>
std::unordered_set<K> java.util.HashSet<E> NSSet<K>* HashSet<K>
std::function<F> @FunctionalInterface block delegate

Example:

#include <scapix/bridge/object.h>

class test : public scapix::bridge::object<test>
{
public:

    // these functions are bridged: all parameter and return value types are supported

    void func1(const std::vector<std::shared_ptr<test>>&);
    void func2(std::function<void(std::vector<std::shared_ptr<test>)>);
    std::map<std::string, std::shared_ptr<test>> func3();

    // these functions are not bridged: not all parameter and return value types are supported

    void func10(void*);

};