Skip to content

Commit bcbcf7f

Browse files
committed
Force function signatures to initialize on Emscripten target.
1 parent 2279be8 commit bcbcf7f

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

include/nbind/signature/BaseSignature.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ class BaseSignature {
1515

1616
// Type of the signature.
1717
// Determines the actual signature class of each instance.
18-
// These must match JavaScript enum SignatureType in enums.ts
18+
// These must match JavaScript enum SignatureType in common.ts
1919

2020
enum class SignatureType: unsigned int {
21-
func = 0,
21+
none = 0,
22+
func,
2223
method,
2324
getter,
2425
setter,
@@ -92,6 +93,10 @@ class TemplatedBaseSignature : public BaseSignature {
9293
static Signature &getInstance() {
9394
// Linkage for a singleton instance of each templated class.
9495
static Signature instance;
96+
97+
// The constructor should have been called, but sometimes it wasn't!
98+
if(instance.getType() == SignatureType :: none) new (&instance) Signature();
99+
95100
return(instance);
96101
}
97102

src/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// These must match C++ enum SignatureType in BaseSignature.h
55

66
export const enum SignatureType {
7-
func = 0,
7+
none = 0,
8+
func,
89
method,
910
getter,
1011
setter,

src/em/Binding.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ static void initModule() {
223223
}
224224

225225
switch(signature->getType()) {
226+
case SignatureType :: none:
227+
228+
// Impossible!
229+
abort();
230+
226231
case SignatureType :: method:
227232
case SignatureType :: getter:
228233
case SignatureType :: setter:

0 commit comments

Comments
 (0)