aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-04-16 02:13:41 -0700
committerJukka Jylänki <jujjyl@gmail.com>2013-04-18 20:08:17 +0300
commitd990cb17d8c43913a733c28601f4319fce90c27a (patch)
tree1f390315942770b08df008899032d053ccd58f67
parentc2bc8d4f1ed4fe5e7477e4dc5d3f32ca5f1e6a56 (diff)
Finally! JSInterface is dead
-rwxr-xr-xsrc/embind/embind.js23
-rwxr-xr-xsystem/include/emscripten/bind.h74
-rwxr-xr-xsystem/lib/embind/bind.cpp8
-rwxr-xr-xtests/embind/embind.test.js18
-rw-r--r--tests/embind/embind_test.cpp22
5 files changed, 0 insertions, 145 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index bd13087d..440fa267 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -1379,29 +1379,6 @@ function __embind_register_enum_value(
Enum[name] = Value;
}
-function __embind_register_interface(
- rawType,
- name,
- rawConstructor,
- rawDestructor
-) {
- name = readLatin1String(name);
- rawConstructor = FUNCTION_TABLE[rawConstructor];
- rawDestructor = FUNCTION_TABLE[rawDestructor];
-
- registerType(rawType, {
- name: name,
- rawConstructor: rawConstructor,
- rawDestructor: rawDestructor,
- toWireType: function(destructors, o) {
- var handle = __emval_register(o);
- var ptr = this.rawConstructor(handle);
- destructors.push(this.rawDestructor, ptr);
- return ptr;
- },
- });
-}
-
function __embind_register_constant(name, type, value) {
name = readLatin1String(name);
whenDependentTypesAreResolved([], [type], function(type) {
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index b17488b9..894586a6 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -1249,80 +1249,6 @@ namespace emscripten {
typename std::aligned_storage<sizeof(T)>::type data;
};
}
-
- ////////////////////////////////////////////////////////////////////////////////
- // NEW INTERFACE
- ////////////////////////////////////////////////////////////////////////////////
-
- class JSInterface {
- public:
- JSInterface(internal::EM_VAL handle) {
- initialize(handle);
- }
-
- JSInterface(const JSInterface& obj)
- : jsobj(obj.jsobj)
- {}
-
- template<typename ReturnType, typename... Args>
- ReturnType call(const char* name, Args... args) {
- assertInitialized();
- return Caller<ReturnType, Args...>::call(*jsobj, name, args...);
- }
-
- static std::shared_ptr<JSInterface> cloneToSharedPtr(const JSInterface& i) {
- return std::make_shared<JSInterface>(i);
- }
-
- private:
- void initialize(internal::EM_VAL handle) {
- if (jsobj) {
- internal::_embind_fatal_error(
- "Cannot initialize interface wrapper twice",
- "JSInterface");
- }
- jsobj = val::take_ownership(handle);
- }
-
- // this class only exists because you can't partially specialize function templates
- template<typename ReturnType, typename... Args>
- struct Caller {
- static ReturnType call(val& v, const char* name, Args... args) {
- return v.call(name, args...).template as<ReturnType>();
- }
- };
-
- template<typename... Args>
- struct Caller<void, Args...> {
- static void call(val& v, const char* name, Args... args) {
- v.call_void(name, args...);
- }
- };
-
- void assertInitialized() {
- if (!jsobj) {
- internal::_embind_fatal_error(
- "Cannot invoke call on uninitialized Javascript interface wrapper.", "JSInterface");
- }
- }
-
- internal::optional<val> jsobj;
- };
-
- namespace internal {
- extern JSInterface* create_js_interface(EM_VAL e);
- }
-
- class register_js_interface {
- public:
- register_js_interface() {
- _embind_register_interface(
- internal::TypeID<JSInterface>::get(),
- "JSInterface",
- reinterpret_cast<internal::GenericFunction>(&internal::create_js_interface),
- reinterpret_cast<internal::GenericFunction>(&internal::raw_destructor<JSInterface>));
- }
- };
}
namespace emscripten {
diff --git a/system/lib/embind/bind.cpp b/system/lib/embind/bind.cpp
index 6cacf1e2..35d99dad 100755
--- a/system/lib/embind/bind.cpp
+++ b/system/lib/embind/bind.cpp
@@ -36,14 +36,6 @@ extern "C" {
}
}
-namespace emscripten {
- namespace internal {
- JSInterface* create_js_interface(EM_VAL e) {
- return new JSInterface(e);
- }
- }
-}
-
// TODO: fix in library.js or a proper emscripten libc
extern "C" wchar_t *wmemset(wchar_t *dest, wchar_t c, size_t count) {
wchar_t *o = dest;
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js
index 82029de4..5af15be9 100755
--- a/tests/embind/embind.test.js
+++ b/tests/embind/embind.test.js
@@ -1478,24 +1478,6 @@ module({
});
});
- BaseFixture.extend("JavaScript interface", function() {
- this.setUp(function() {
- this.testobj = {
- "method1": function() { return 111; },
- "method2": function() { return 222; }
- };
- });
-
- test("pass js object to c++ and call its method", function() {
- var obj = new cm.JSInterfaceHolder(this.testobj);
- assert.equal(111, obj.callMethod("method1"));
- assert.equal(222, obj.callMethod("method2"));
- assert.equal(111, obj.callMethodUsingSharedPtr("method1"));
- assert.equal(222, obj.callMethodUsingSharedPtr("method2"));
- obj.delete();
- });
- });
-
BaseFixture.extend("abstract methods", function() {
test("can call abstract methods", function() {
var obj = cm.getAbstractClass();
diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp
index ce133112..5733c08f 100644
--- a/tests/embind/embind_test.cpp
+++ b/tests/embind/embind_test.cpp
@@ -1065,20 +1065,6 @@ std::vector<std::shared_ptr<StringHolder>> emval_test_return_shared_ptr_vector()
return sharedStrVector;
}
-class JSInterfaceHolder {
-public:
- JSInterfaceHolder(JSInterface &jsobj) : jsobj_(jsobj) {
- ptr_ = JSInterface::cloneToSharedPtr(jsobj_);
- }
-
- int callMethod(std::string method) { return jsobj_.call<int>(method.c_str()); }
- int callMethodUsingSharedPtr(std::string method) { return ptr_->call<int>(method.c_str()); }
-
-private:
- JSInterface jsobj_;
- std::shared_ptr<JSInterface> ptr_;
-};
-
void test_string_with_vec(const std::string& p1, std::vector<std::string>& v1) {
// THIS DOES NOT WORK -- need to get as val and then call vecFromJSArray
printf("%s\n", p1.c_str());
@@ -1488,8 +1474,6 @@ EMSCRIPTEN_BINDINGS(constants) {
}
EMSCRIPTEN_BINDINGS(tests) {
- register_js_interface();
-
register_vector<int>("IntegerVector");
register_vector<char>("CharVector");
register_vector<unsigned>("VectorUnsigned");
@@ -1883,12 +1867,6 @@ EMSCRIPTEN_BINDINGS(tests) {
register_map<std::string, int>("StringIntMap");
function("embind_test_get_string_int_map", embind_test_get_string_int_map);
- class_<JSInterfaceHolder>("JSInterfaceHolder")
- .constructor<JSInterface&>()
- .function("callMethod", &JSInterfaceHolder::callMethod)
- .function("callMethodUsingSharedPtr", &JSInterfaceHolder::callMethodUsingSharedPtr)
- ;
-
function("embind_test_new_Object", &embind_test_new_Object);
function("embind_test_new_factory", &embind_test_new_factory);