@@ -341,7 +341,7 @@ class SharedPtrHolder {
341
341
std::shared_ptr<StringHolder> get () const {
342
342
return ptr_;
343
343
}
344
-
344
+
345
345
void set (std::shared_ptr<StringHolder> p) {
346
346
ptr_ = p;
347
347
}
@@ -988,11 +988,11 @@ class UniquePtrToConstructor {
988
988
UniquePtrToConstructor (std::unique_ptr<int > p)
989
989
: value(*p)
990
990
{}
991
-
991
+
992
992
int getValue () const {
993
993
return value;
994
994
}
995
-
995
+
996
996
private:
997
997
int value;
998
998
};
@@ -1412,7 +1412,7 @@ EMSCRIPTEN_BINDINGS(interface_tests) {
1412
1412
self.AbstractClass ::passVal (v);
1413
1413
}))
1414
1414
;
1415
-
1415
+
1416
1416
function (" getAbstractClass" , &getAbstractClass);
1417
1417
function (" callAbstractMethod" , &callAbstractMethod);
1418
1418
function (" callOptionalMethod" , &callOptionalMethod);
@@ -1500,7 +1500,7 @@ class CustomSmartPtr {
1500
1500
~CustomSmartPtr () {
1501
1501
verify ();
1502
1502
std::fill (d_, d_ + N_, Deleted);
1503
-
1503
+
1504
1504
if (ptr_ && --ptr_->refcount == 0 ) {
1505
1505
delete ptr_;
1506
1506
}
@@ -1751,6 +1751,16 @@ ConstructFromFunctor<I> construct_from_functor_mixin(const val& v, int i)
1751
1751
return {v, i};
1752
1752
}
1753
1753
1754
+ struct ConstructFromFunction {
1755
+ bool optionA;
1756
+ ConstructFromFunction (bool optionA_): optionA{optionA_} {};
1757
+ };
1758
+
1759
+ auto ConstructFromFunctionConstructor (emscripten::val value) {
1760
+ bool optionA = (value.as <bool >() && value[" optionA" ].as <bool >());
1761
+ return new ConstructFromFunction (optionA);
1762
+ }
1763
+
1754
1764
EMSCRIPTEN_BINDINGS (tests) {
1755
1765
register_vector<int >(" IntegerVector" );
1756
1766
register_vector<char >(" CharVector" );
@@ -1873,6 +1883,10 @@ EMSCRIPTEN_BINDINGS(tests) {
1873
1883
.function (" getA" , &ConstructFromFunctor<2 >::getA)
1874
1884
;
1875
1885
1886
+ class_<ConstructFromFunction>(" ConstructFromFunction" )
1887
+ .constructor <emscripten::val>(&ConstructFromFunctionConstructor)
1888
+ ;
1889
+
1876
1890
class_<ValHolder>(" ValHolder" )
1877
1891
.smart_ptr <std::shared_ptr<ValHolder>>(" std::shared_ptr<ValHolder>" )
1878
1892
.constructor <val>()
@@ -1929,7 +1943,7 @@ EMSCRIPTEN_BINDINGS(tests) {
1929
1943
.function (" get" , &StringHolder::get)
1930
1944
.function (" get_const_ref" , &StringHolder::get_const_ref)
1931
1945
;
1932
-
1946
+
1933
1947
class_<SharedPtrHolder>(" SharedPtrHolder" )
1934
1948
.constructor <>()
1935
1949
.function (" get" , &SharedPtrHolder::get)
@@ -2002,7 +2016,7 @@ EMSCRIPTEN_BINDINGS(tests) {
2002
2016
.property (" member" , &SecondBase::member)
2003
2017
.property (" secondBaseMember" , &SecondBase::secondBaseMember)
2004
2018
;
2005
-
2019
+
2006
2020
2007
2021
class_<DerivedHolder>(" DerivedHolder" )
2008
2022
.constructor <>()
@@ -2017,7 +2031,7 @@ EMSCRIPTEN_BINDINGS(tests) {
2017
2031
.constructor <>()
2018
2032
.function (" getClassName" , &SiblingDerived::getClassName)
2019
2033
;
2020
-
2034
+
2021
2035
class_<MultiplyDerived, base<Base>>(" MultiplyDerived" )
2022
2036
.smart_ptr <std::shared_ptr<MultiplyDerived>>(" shared_ptr<MultiplyDerived>" )
2023
2037
.constructor <>()
@@ -2094,7 +2108,7 @@ EMSCRIPTEN_BINDINGS(tests) {
2094
2108
.constructor <>()
2095
2109
.function (" getClassName" , &PolyDiamondBase::getClassName)
2096
2110
;
2097
-
2111
+
2098
2112
class_<PolyDiamondDerived>(" PolyDiamondDerived" )
2099
2113
.smart_ptr <std::shared_ptr<PolyDiamondDerived>>(" shared_ptr<PolyDiamondDerived>" )
2100
2114
.constructor <>()
@@ -2339,10 +2353,10 @@ class MultipleSmartCtors {
2339
2353
class MultipleOverloads {
2340
2354
public:
2341
2355
MultipleOverloads () {}
2342
-
2356
+
2343
2357
int value;
2344
2358
static int staticValue;
2345
-
2359
+
2346
2360
int Func (int i) {
2347
2361
assert (i == 10 );
2348
2362
value = 1 ;
@@ -2358,7 +2372,7 @@ class MultipleOverloads {
2358
2372
int WhichFuncCalled () const {
2359
2373
return value;
2360
2374
}
2361
-
2375
+
2362
2376
static int StaticFunc (int i) {
2363
2377
assert (i == 10 );
2364
2378
staticValue = 1 ;
@@ -2381,7 +2395,7 @@ int MultipleOverloads::staticValue = 0;
2381
2395
class MultipleOverloadsDerived : public MultipleOverloads {
2382
2396
public:
2383
2397
MultipleOverloadsDerived () {}
2384
-
2398
+
2385
2399
int Func (int i, int j, int k) {
2386
2400
assert (i == 30 );
2387
2401
assert (j == 30 );
@@ -2397,7 +2411,7 @@ class MultipleOverloadsDerived : public MultipleOverloads {
2397
2411
value = 4 ;
2398
2412
return 4 ;
2399
2413
}
2400
-
2414
+
2401
2415
static int StaticFunc (int i, int j, int k) {
2402
2416
assert (i == 30 );
2403
2417
assert (j == 30 );
@@ -2476,14 +2490,14 @@ EMSCRIPTEN_BINDINGS(overloads) {
2476
2490
.constructor <int , int , int >()
2477
2491
.function (" WhichCtorCalled" , &MultipleCtors::WhichCtorCalled)
2478
2492
;
2479
-
2493
+
2480
2494
class_<MultipleSmartCtors>(" MultipleSmartCtors" )
2481
2495
.smart_ptr <std::shared_ptr<MultipleSmartCtors>>(" shared_ptr<MultipleSmartCtors>" )
2482
2496
.constructor (&std::make_shared<MultipleSmartCtors, int >)
2483
2497
.constructor (&std::make_shared<MultipleSmartCtors, int , int >)
2484
2498
.function (" WhichCtorCalled" , &MultipleSmartCtors::WhichCtorCalled)
2485
2499
;
2486
-
2500
+
2487
2501
class_<MultipleOverloads>(" MultipleOverloads" )
2488
2502
.constructor <>()
2489
2503
.function (" Func" , select_overload<int (int )>(&MultipleOverloads::Func))
@@ -2560,7 +2574,7 @@ EMSCRIPTEN_BINDINGS(order) {
2560
2574
.field (" first" , &OrderedStruct::first)
2561
2575
.field (" second" , &OrderedStruct::second)
2562
2576
;
2563
-
2577
+
2564
2578
class_<SecondElement>(" SecondElement" )
2565
2579
;
2566
2580
@@ -2644,7 +2658,7 @@ EMSCRIPTEN_BINDINGS(incomplete) {
2644
2658
class Noncopyable {
2645
2659
Noncopyable (const Noncopyable&) = delete ;
2646
2660
Noncopyable& operator =(const Noncopyable&) = delete ;
2647
-
2661
+
2648
2662
public:
2649
2663
Noncopyable () {}
2650
2664
Noncopyable (Noncopyable&& other) {
@@ -2709,7 +2723,7 @@ EMSCRIPTEN_BINDINGS(constants) {
2709
2723
constant (" VALUE_OBJECT_CONSTANT" , sv);
2710
2724
}
2711
2725
2712
- class DerivedWithOffset : public DummyDataToTestPointerAdjustment , public Base {
2726
+ class DerivedWithOffset : public DummyDataToTestPointerAdjustment , public Base {
2713
2727
};
2714
2728
2715
2729
std::shared_ptr<Base> return_Base_from_DerivedWithOffset (std::shared_ptr<DerivedWithOffset> ptr) {
0 commit comments