[pypy-svn] r18667 - pypy/dist/pypy/translator/c/src

arigo at codespeak.net arigo at codespeak.net
Sun Oct 16 10:32:49 CEST 2005


Author: arigo
Date: Sun Oct 16 10:32:48 2005
New Revision: 18667

Modified:
   pypy/dist/pypy/translator/c/src/exception.h
   pypy/dist/pypy/translator/c/src/g_include.h
Log:
Raise simple exceptions via a function instead of a macro
(convenient place to set a breakpoint in the debugger).


Modified: pypy/dist/pypy/translator/c/src/exception.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/exception.h	(original)
+++ pypy/dist/pypy/translator/c/src/exception.h	Sun Oct 16 10:32:48 2005
@@ -34,19 +34,37 @@
 #define RPyMatchException(etype)	RPYTHON_EXCEPTION_MATCH(rpython_exc_type,  \
 					(RPYTHON_EXCEPTION_VTABLE) etype)
 
-#ifndef PYPY_STANDALONE
-
 
 /* prototypes */
 
+#define RPyRaiseSimpleException(exc, msg)   _RPyRaiseSimpleException(R##exc)
+void _RPyRaiseSimpleException(RPYTHON_EXCEPTION rexc);
+
+#ifndef PYPY_STANDALONE
 void RPyConvertExceptionFromCPython(void);
 void _RPyConvertExceptionToCPython(void);
+#define RPyConvertExceptionToCPython(vanishing)    \
+	_RPyConvertExceptionToCPython();		\
+	vanishing = rpython_exc_value;		\
+	rpython_exc_type = NULL;		\
+	rpython_exc_value = NULL
+#endif
 
 
 /* implementations */
 
 #ifndef PYPY_NOT_MAIN_FILE
 
+void _RPyRaiseSimpleException(RPYTHON_EXCEPTION rexc)
+{
+	/* XXX 1. uses officially bad fishing */
+	/* XXX 2. msg is ignored */
+	rpython_exc_type = rexc->o_typeptr;
+	rpython_exc_value = rexc;
+	PUSH_ALIVE(rpython_exc_value);
+}
+
+#ifndef PYPY_STANDALONE
 void RPyConvertExceptionFromCPython(void)
 {
 	/* convert the CPython exception to an RPython one */
@@ -77,24 +95,11 @@
 		PyErr_SetString(RPythonError, clsname);
 	}
 }
+#endif   /* !PYPY_STANDALONE */
 
 #endif /* PYPY_NOT_MAIN_FILE */
 
-#define RPyConvertExceptionToCPython(vanishing)    \
-	_RPyConvertExceptionToCPython();		\
-	vanishing = rpython_exc_value;		\
-	rpython_exc_type = NULL;		\
-	rpython_exc_value = NULL
-
-#endif   /* !PYPY_STANDALONE */
-
 
-#define RPyRaiseSimpleException(exc, msg)		        \
-	/* XXX 1. uses officially bad fishing */		\
-	/* XXX 2. msg is ignored */				\
-	rpython_exc_type = (R##exc)->o_typeptr;			\
-	rpython_exc_value = (R##exc);				\
-	PUSH_ALIVE(rpython_exc_value)
 
 /******************************************************************/
 #else    /* non-RPython version of exceptions, using CPython only */

Modified: pypy/dist/pypy/translator/c/src/g_include.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/g_include.h	(original)
+++ pypy/dist/pypy/translator/c/src/g_include.h	Sun Oct 16 10:32:48 2005
@@ -14,6 +14,7 @@
 #  include "src/standalone.h"
 #endif
 
+#include "src/mem.h"
 #include "src/exception.h"
 #include "src/trace.h"
 #include "src/support.h"
@@ -22,7 +23,6 @@
 #  include "src/module.h"
 #endif
 
-#include "src/mem.h"
 #include "src/int.h"
 #include "src/char.h"
 #include "src/unichar.h"



More information about the Pypy-commit mailing list