changeset 10:29eaa1fceff1

Moved definition of undefined type into a separate module.
author Atul Varma <varmaa@toolness.com>
date Sun, 28 Jun 2009 17:10:40 -0700
parents 032cfc448079
children 551ba05fe6ad
files pavement.py pymonkey.c undefined.c undefined.h
diffstat 4 files changed, 48 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/pavement.py	Sun Jun 28 17:07:15 2009 -0700
+++ b/pavement.py	Sun Jun 28 17:10:40 2009 -0700
@@ -22,7 +22,8 @@
          "-lmozjs",
          "-o", "pymonkey.so",
          "-dynamiclib",
-         "pymonkey.c"]
+         "pymonkey.c",
+         "undefined.c"]
         )
 
     if result:
--- a/pymonkey.c	Sun Jun 28 17:07:15 2009 -0700
+++ b/pymonkey.c	Sun Jun 28 17:10:40 2009 -0700
@@ -1,43 +1,6 @@
-#include "jsapi.h"
-#include <Python/Python.h>
-
-#define Py_RETURN_UNDEFINED  { Py_INCREF(PYM_undefined);        \
-                               return PYM_undefined; }
-
-typedef struct {
-  PyObject_HEAD
-} PYM_undefinedObject;
+#include "undefined.h"
 
-// TODO: We should make this behave as much like JavaScript's
-// "undefined" value as possible; e.g., its string value should
-// be "undefined", the singleton should be falsy, etc.
-static PyTypeObject PYM_undefinedType = {
-  PyObject_HEAD_INIT(NULL)
-  0,                           /*ob_size*/
-  "pymonkey.undefined",        /*tp_name*/
-  sizeof(PYM_undefinedObject), /*tp_basicsize*/
-  0,                           /*tp_itemsize*/
-  0,                           /*tp_dealloc*/
-  0,                           /*tp_print*/
-  0,                           /*tp_getattr*/
-  0,                           /*tp_setattr*/
-  0,                           /*tp_compare*/
-  0,                           /*tp_repr*/
-  0,                           /*tp_as_number*/
-  0,                           /*tp_as_sequence*/
-  0,                           /*tp_as_mapping*/
-  0,                           /*tp_hash */
-  0,                           /*tp_call*/
-  0,                           /*tp_str*/
-  0,                           /*tp_getattro*/
-  0,                           /*tp_setattro*/
-  0,                           /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT,          /*tp_flags*/
-  /* tp_doc */
-  "Pythonic equivalent of JavaScript's 'undefined' value",
-};
-
-static PyObject *PYM_undefined = (PyObject *) &PYM_undefinedType;
+#include "jsapi.h"
 
 static JSClass PYM_jsGlobalClass = {
   "PymonkeyGlobal", JSCLASS_GLOBAL_FLAGS,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/undefined.c	Sun Jun 28 17:10:40 2009 -0700
@@ -0,0 +1,32 @@
+#include "undefined.h"
+
+// TODO: We should make this behave as much like JavaScript's
+// "undefined" value as possible; e.g., its string value should
+// be "undefined", the singleton should be falsy, etc.
+PyTypeObject PYM_undefinedType = {
+  PyObject_HEAD_INIT(NULL)
+  0,                           /*ob_size*/
+  "pymonkey.undefined",        /*tp_name*/
+  sizeof(PYM_undefinedObject), /*tp_basicsize*/
+  0,                           /*tp_itemsize*/
+  0,                           /*tp_dealloc*/
+  0,                           /*tp_print*/
+  0,                           /*tp_getattr*/
+  0,                           /*tp_setattr*/
+  0,                           /*tp_compare*/
+  0,                           /*tp_repr*/
+  0,                           /*tp_as_number*/
+  0,                           /*tp_as_sequence*/
+  0,                           /*tp_as_mapping*/
+  0,                           /*tp_hash */
+  0,                           /*tp_call*/
+  0,                           /*tp_str*/
+  0,                           /*tp_getattro*/
+  0,                           /*tp_setattro*/
+  0,                           /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT,          /*tp_flags*/
+  /* tp_doc */
+  "Pythonic equivalent of JavaScript's 'undefined' value",
+};
+
+PyObject *PYM_undefined = (PyObject *) &PYM_undefinedType;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/undefined.h	Sun Jun 28 17:10:40 2009 -0700
@@ -0,0 +1,12 @@
+#include <Python/Python.h>
+
+#define Py_RETURN_UNDEFINED  { Py_INCREF(PYM_undefined);        \
+                               return PYM_undefined; }
+
+typedef struct {
+  PyObject_HEAD
+} PYM_undefinedObject;
+
+extern PyTypeObject PYM_undefinedType;
+
+extern PyObject *PYM_undefined;