| 1586 | } |
| 1587 | |
| 1588 | EMSCRIPTEN_BINDINGS(interface_tests) { |
| 1589 | class_<AbstractClass>("AbstractClass") |
| 1590 | .smart_ptr<std::shared_ptr<AbstractClass>>("shared_ptr<AbstractClass>") |
| 1591 | .allow_subclass<AbstractClassWrapper>("AbstractClassWrapper") |
| 1592 | .function("abstractMethod", &AbstractClass::abstractMethod, pure_virtual()) |
| 1593 | // The optional_override is necessary because, otherwise, the C++ compiler |
| 1594 | // cannot deduce the signature of the lambda function. |
| 1595 | .function("optionalMethod", optional_override( |
| 1596 | [](AbstractClass& this_, const std::string& s) { |
| 1597 | return this_.AbstractClass::optionalMethod(s); |
| 1598 | } |
| 1599 | )) |
| 1600 | .function("concreteMethod", &AbstractClass::concreteMethod) |
| 1601 | .function("passShared", select_overload<void(AbstractClass&, const std::shared_ptr<Derived>&)>([](AbstractClass& self, const std::shared_ptr<Derived>& derived) { |
| 1602 | self.AbstractClass::passShared(derived); |
| 1603 | })) |
| 1604 | .function("passVal", select_overload<void(AbstractClass&, const val&)>([](AbstractClass& self, const val& v) { |
| 1605 | self.AbstractClass::passVal(v); |
| 1606 | })) |
| 1607 | ; |
| 1608 | |
| 1609 | function("getAbstractClass", &getAbstractClass); |
| 1610 | function("callAbstractMethod", &callAbstractMethod); |
| 1611 | function("callOptionalMethod", &callOptionalMethod); |
| 1612 | function("callReturnsSharedPtrMethod", &callReturnsSharedPtrMethod); |
| 1613 | function("callDifferentArguments", &callDifferentArguments); |
| 1614 | function("passShared", &passShared); |
| 1615 | function("passVal", &passVal); |
| 1616 | |
| 1617 | class_<AbstractClassWithConstructor>("AbstractClassWithConstructor") |
| 1618 | .allow_subclass<AbstractClassWithConstructorWrapper>("AbstractClassWithConstructorWrapper", constructor<std::string>()) |
| 1619 | .function("abstractMethod", &AbstractClassWithConstructor::abstractMethod, pure_virtual()) |
| 1620 | .function("concreteMethod", &AbstractClassWithConstructor::concreteMethod) |
| 1621 | ; |
| 1622 | function("callAbstractMethod2", &callAbstractMethod2); |
| 1623 | |
| 1624 | class_<HeldAbstractClass, base<PolySecondBase>>("HeldAbstractClass") |
| 1625 | .smart_ptr<std::shared_ptr<HeldAbstractClass>>("shared_ptr<HeldAbstractClass>") |
| 1626 | .allow_subclass<HeldAbstractClassWrapper, std::shared_ptr<HeldAbstractClassWrapper>>("HeldAbstractClassWrapper", "HeldAbstractClassWrapperPtr") |
| 1627 | .function("method", &HeldAbstractClass::method, pure_virtual()) |
| 1628 | ; |
| 1629 | function("passHeldAbstractClass", &passHeldAbstractClass); |
| 1630 | } |
| 1631 | |
| 1632 | template<typename T, size_t sizeOfArray> |
| 1633 | constexpr size_t getElementCount(T (&)[sizeOfArray]) { |
nothing calls this directly
no test coverage detected