]> git.saurik.com Git - cycript.git/blobdiff - Exception.hpp
Hide all symbols of embedded developer framework.
[cycript.git] / Exception.hpp
index 598548fd0358d51731185eb258c8acf7669f96c5..0410fd151398755ab8593cab38bf68e1b1b373f8 100644 (file)
@@ -26,6 +26,9 @@
 #include <JavaScriptCore/JSBase.h>
 #endif
 
+// XXX: does _assert really need this?
+#include <errno.h>
+
 #include "Standard.hpp"
 
 class CYPool;
@@ -100,4 +103,28 @@ void CYThrow(JSContextRef context, JSValueRef value);
     _value; \
 })
 
+struct CYJSException {
+    JSContextRef context_;
+    JSValueRef value_;
+
+    CYJSException(JSContextRef context) :
+        context_(context),
+        value_(NULL)
+    {
+    }
+
+    ~CYJSException() {
+        CYThrow(context_, value_);
+    }
+
+    operator JSValueRef *() {
+        return &value_;
+    }
+};
+
+#define _jsccall(code, args...) ({ \
+    CYJSException _error(context); \
+    (code)(args, _error); \
+})
+
 #endif/*CYCRIPT_ERROR_HPP*/