]> git.saurik.com Git - cycript.git/blobdiff - Exception.hpp
Wedge way to link against Python 2.7 to configure.
[cycript.git] / Exception.hpp
index ff63b8c8e55eea230ec51710497a848ed07a976b..4b97f83ba44e876590f28a0788344d65d7cd54d2 100644 (file)
 
 class CYPool;
 
-struct CYException {
+struct _visible CYException {
     virtual ~CYException() {
     }
 
     virtual const char *PoolCString(CYPool &pool) const = 0;
 #ifdef CY_EXECUTE
-    virtual JSValueRef CastJSValue(JSContextRef context) const = 0;
+    virtual JSValueRef CastJSValue(JSContextRef context, const char *name) const = 0;
 #endif
 };
 
@@ -53,14 +53,16 @@ void CYThrow(JSContextRef context, JSValueRef value);
 
 #define CYTry \
     try
-#define CYCatch(value) \
+#define CYCatch_(value, name) \
     catch (const CYException &error) { \
-        *exception = error.CastJSValue(context); \
+        *exception = error.CastJSValue(context, name); \
         return value; \
     } catch (...) { \
         *exception = CYCastJSValue(context, "catch(...)"); \
         return value; \
     }
+#define CYCatch(value) \
+    CYCatch_(value, "Error")
 
 #define _assert_(mode, test, code, format, ...) do \
     if (!(test)) \
@@ -105,9 +107,10 @@ static _finline bool CYContains(int value, size_t many, const int *okay) {
 
 #define _sqlcall(expr) ({ \
     __typeof__(expr) _value = (expr); \
-    _assert_("sqlcall", _value == 0 || _value >= 100 && _value < 200, #expr, " %u:%s", _value sqlite3_errmsg(database_)); \
-})
+    _assert_("sqlcall", _value == 0 || _value >= 100 && _value < 200, #expr, " %u:%s", _value, sqlite3_errmsg(database_)); \
+_value; })
 
+#ifdef CY_EXECUTE
 struct CYJSException {
     JSContextRef context_;
     JSValueRef value_;
@@ -131,5 +134,6 @@ struct CYJSException {
     CYJSException _error(context); \
     (code)(args, _error); \
 })
+#endif
 
 #endif/*CYCRIPT_ERROR_HPP*/