aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/embind/embind.js11
-rwxr-xr-xsystem/include/emscripten/bind.h5
2 files changed, 15 insertions, 1 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index ace6e7fc..b52f9ff7 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -472,12 +472,13 @@ function __embind_register_struct_field(
});
}
-function RegisteredPointer(name, rawType, registeredClass, pointeeType, Handle, isSmartPointer, rawGetPointee, rawConstructor, rawDestructor) {
+function RegisteredPointer(name, rawType, registeredClass, pointeeType, Handle, isConst, isSmartPointer, rawGetPointee, rawConstructor, rawDestructor) {
this.name = name;
this.rawType = rawType;
this.registeredClass = registeredClass;
this.pointeeType = pointeeType;
this.Handle = Handle; // <-- I think I can kill this
+ this.isConst = isConst;
this.isSmartPointer = isSmartPointer;
this.rawGetPointee = rawGetPointee;
this.rawConstructor = rawConstructor;
@@ -712,6 +713,7 @@ function __embind_register_class(
registeredClass,
undefined,
Handle,
+ false,
false);
type.pointeeType = type; // :(
registerType(rawType, type);
@@ -722,6 +724,7 @@ function __embind_register_class(
registeredClass,
type,
Handle,
+ false,
false));
// todo: implement const pointers (no modification Javascript side)
@@ -731,6 +734,7 @@ function __embind_register_class(
registeredClass,
type,
Handle,
+ true,
false));
type.constructor = createNamedFunction(name, function() {
@@ -813,6 +817,7 @@ function __embind_register_class_function(
methodName,
argCount,
rawArgTypesAddr,
+ isConst,
rawInvoker,
memberFunctionSize,
memberFunction
@@ -832,6 +837,9 @@ function __embind_register_class_function(
}
var ptr = validateThis(this, classType, humanName);
+ if (!isConst && this.$$.registeredPointer.isConst) {
+ throwBindingError('Cannot call non-const method ' + humanName + ' on const reference');
+ }
var destructors = [];
var args = new Array(argCount + 1);
@@ -973,6 +981,7 @@ function __embind_register_smart_ptr(
pointeeType.registeredClass,
pointeeType,
Handle,
+ false,
true,
rawGetPointee,
rawConstructor,
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index 1923013f..bdcde625 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -124,6 +124,7 @@ namespace emscripten {
const char* methodName,
unsigned argCount,
TYPEID argTypes[],
+ bool isConst,
GenericFunction invoker,
size_t memberFunctionSize,
void* memberFunction);
@@ -744,6 +745,7 @@ namespace emscripten {
methodName,
args.count,
args.types,
+ false,
reinterpret_cast<GenericFunction>(&MethodInvoker<ClassType, ReturnType, Args...>::invoke),
sizeof(memberFunction),
&memberFunction);
@@ -760,6 +762,7 @@ namespace emscripten {
methodName,
args.count,
args.types,
+ true,
reinterpret_cast<GenericFunction>(&ConstMethodInvoker<ClassType, ReturnType, Args...>::invoke),
sizeof(memberFunction),
&memberFunction);
@@ -776,6 +779,7 @@ namespace emscripten {
methodName,
args.count,
args.types,
+ false,
reinterpret_cast<GenericFunction>(&FunctionInvoker<ClassType, ReturnType, Args...>::invoke),
sizeof(function),
&function);
@@ -792,6 +796,7 @@ namespace emscripten {
methodName,
args.count,
args.types,
+ true,
reinterpret_cast<GenericFunction>(&FunctionInvoker<ClassType, ReturnType, Args...>::invoke),
sizeof(function),
&function);