[pypy-svn] r18657 - in pypy/dist/pypy: module/_socket/rpython module/_socket/rpython/test translator/c/src
dialtone at codespeak.net
dialtone at codespeak.net
Sat Oct 15 19:43:22 CEST 2005
Author: dialtone
Date: Sat Oct 15 19:43:19 2005
New Revision: 18657
Added:
pypy/dist/pypy/module/_socket/rpython/
pypy/dist/pypy/module/_socket/rpython/__init__.py
pypy/dist/pypy/module/_socket/rpython/exttable.py
pypy/dist/pypy/module/_socket/rpython/ll__socket.py
pypy/dist/pypy/module/_socket/rpython/test/
pypy/dist/pypy/module/_socket/rpython/test/__init__.py
pypy/dist/pypy/module/_socket/rpython/test/test_ll__socket.py
pypy/dist/pypy/translator/c/src/ll__socket.h
Log:
starting translation work on socket module
Added: pypy/dist/pypy/module/_socket/rpython/__init__.py
==============================================================================
Added: pypy/dist/pypy/module/_socket/rpython/exttable.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/_socket/rpython/exttable.py Sat Oct 15 19:43:19 2005
@@ -0,0 +1,13 @@
+"""
+Annotation support for interp-level socket objects.
+"""
+
+import _socket
+from pypy.rpython.extfunctable import declare
+
+module = 'pypy.module._socket.rpython.ll__socket'
+
+# ____________________________________________________________
+# Built-in functions needed in the rtyper
+
+declare(_socket.ntohs, int, '%s/ntohs' % module)
Added: pypy/dist/pypy/module/_socket/rpython/ll__socket.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/_socket/rpython/ll__socket.py Sat Oct 15 19:43:19 2005
@@ -0,0 +1,5 @@
+import _socket
+
+def ll__socket_ntohs(htons):
+ return _socket.ntohs(htons)
+ll__socket_ntohs.suggested_primitive = True
Added: pypy/dist/pypy/module/_socket/rpython/test/__init__.py
==============================================================================
Added: pypy/dist/pypy/module/_socket/rpython/test/test_ll__socket.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/_socket/rpython/test/test_ll__socket.py Sat Oct 15 19:43:19 2005
@@ -0,0 +1,13 @@
+
+import _socket
+import pypy.module._socket.rpython.exttable
+from pypy.module._socket.rpython.ll__socket import *
+from pypy.translator.annrpython import RPythonAnnotator
+from pypy.rpython.test.test_llinterp import interpret
+
+def test_ntohs():
+ def fn():
+ return _socket.ntohs(1)
+ a = RPythonAnnotator()
+ res = interpret(fn, [])
+ assert res == _socket.ntohs(1)
Added: pypy/dist/pypy/translator/c/src/ll__socket.h
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/c/src/ll__socket.h Sat Oct 15 19:43:19 2005
@@ -0,0 +1,21 @@
+
+#ifdef MS_WINDOWS
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+#else
+ #include <arpa/inet.h>
+#endif
+
+int LL__socket_ntohs(int htons);
+
+
+#ifndef PYPY_NOT_MAIN_FILE
+
+int LL__socket_ntohs(int htons)
+{
+
+ return (int)ntohs((short) htons);
+
+}
+
+#endif
More information about the Pypy-commit
mailing list