Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 1f12318a8fd8eb5e6098c6984c3d788dc45a6201 @NicolasT committed Jul 19, 2008
Showing with 84 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +38 −0 jscore/jscore.pyx
  3. +31 −0 setup.py
  4. +7 −0 test/test_context.py
8 .gitignore
@@ -0,0 +1,8 @@
+build
+dist
+*.bak
+*.swp
+jscore/jscore.c
+*.pyc
+python_jscore.egg-info
+jscore.so
38 jscore/jscore.pyx
@@ -0,0 +1,38 @@
+cdef extern from "JavaScriptCore/JavaScript.h":
+ ctypedef JSValueRef
+ ctypedef JSObjectRef
+ ctypedef JSContextRef
+ ctypedef JSGlobalContextRef
+ ctypedef JSStringRef
+ ctypedef JSClassRef
+
+cdef class Value:
+ cdef JSValueRef _obj
+
+cdef class Object:
+ cdef JSObjectRef _obj
+
+cdef class String:
+ cdef JSStringRef _obj
+
+cdef class Class:
+ cdef JSClassRef _obj
+
+cdef class Context:
+ cdef JSContextRef _obj
+
+cdef class GlobalContext(Context):
+ cdef JSGlobalContextRef _obj
+
+ def __new__(self, Class globalObjectClass=None):
+ print globalObjectClass
+ if globalObjectClass:
+ cls = globalObjectClass._obj
+ else:
+ cls = None
+ print cls
+ self._obj = JSGlobalContextCreate(cls)
+ print self._obj
+
+cdef extern from "JavaScriptCore/JSContextRef.h":
+ JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
31 setup.py
@@ -0,0 +1,31 @@
+from setuptools import setup, Extension, find_packages
+from Cython.Distutils import build_ext
+
+jscore_module = [
+ Extension('jscore',
+ ['jscore/jscore.pyx', ],
+ language='c',
+ include_dirs=['/home/nicolas/Projects/jhbuild/webkit/inst/include/webkit-1.0', ],
+ library_dirs=['/home/nicolas/Projects/jhbuild/webkit/inst/lib', ],
+ libraries=['webkit-1.0', ],
+ )
+]
+
+setup(name='python-jscore',
+ version='0.1',
+ packages=find_packages(exclude=['test', ]),
+
+ author='Nicolas Trangez',
+ author_email='ikke@nicolast.be',
+ description='Python bindings to the JavaScriptCore library',
+ keywords='javascript javascriptcore jscore webkit',
+
+ ext_modules=jscore_module,
+ package_data={
+ '': ['*.pyx', ],
+ },
+ cmdclass={
+ 'build_ext': build_ext,
+ },
+ test_suite='nose.collector',
+)
7 test/test_context.py
@@ -0,0 +1,7 @@
+import unittest
+
+import jscore
+
+class TestJSContext(unittest.TestCase):
+ def test_instanciation(self):
+ ctx = jscore.JSGlobalContext()

0 comments on commit 1f12318

Please sign in to comment.