1. Stephen Tu
  2. mino-pypy

Commits

Amaury Forgeot d'Arc  committed 3eea4e0

Split rtyper.h: header and implementation.

  • Participants
  • Parent commits 6c06474
  • Branches remove-PYPY_NOT_MAIN_FILE

Comments (0)

Files changed (4)

File pypy/translator/c/genc.py

View file
         srcdir / 'allocator.c',
         srcdir / 'mem.c',
         srcdir / 'exception.c',
+        srcdir / 'rtyper.c',
         srcdir / 'support.c',
         srcdir / 'profiling.c',
         srcdir / 'debug_print.c',

File pypy/translator/c/src/mem.h

View file
 /************************************************************/
 /***  C header subsection: operations on LowLevelTypes    ***/
 
+#include <string.h>
+
 /* used by pypy.rlib.rstack, but also by asmgcc */
 #define OP_STACK_CURRENT(r)  r = (Signed)&r
 

File pypy/translator/c/src/rtyper.c

View file
+/************************************************************/
+/***  C header subsection: tools for RTyper-aware code    ***/
+#include "common_header.h"
+#include "structdef.h"
+#include "forwarddecl.h"
+#include "preimpl.h"
+#include <src/rtyper.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+struct _RPyString_dump_t {
+	struct _RPyString_dump_t *next;
+	char data[1];
+} *_RPyString_dump = NULL;
+
+char *RPyString_AsCharP(RPyString *rps)
+{
+	Signed len = RPyString_Size(rps);
+	struct _RPyString_dump_t *dump = \
+			malloc(sizeof(struct _RPyString_dump_t) + len);
+	if (!dump)
+		return "(out of memory!)";
+	dump->next = _RPyString_dump;
+	_RPyString_dump = dump;
+	memcpy(dump->data, rps->rs_chars.items, len);
+	dump->data[len] = 0;
+	return dump->data;
+}
+
+void RPyString_FreeCache(void)
+{
+	while (_RPyString_dump) {
+		struct _RPyString_dump_t *dump = _RPyString_dump;
+		_RPyString_dump = dump->next;
+		free(dump);
+	}
+}
+
+RPyString *RPyString_FromString(char *buf)
+{
+	int length = strlen(buf);
+	RPyString *rps = RPyString_New(length);
+	memcpy(rps->rs_chars.items, buf, length);
+	return rps;
+}

File pypy/translator/c/src/rtyper.h

View file
 /************************************************************/
- /***  C header subsection: tools for RTyper-aware code    ***/
-
-#include <string.h>
-
+/***  C header subsection: tools for RTyper-aware code    ***/
 
 /* Note that RPython strings are not 0-terminated!  For debugging,
    use PyString_FromRPyString or RPyString_AsCharP */
 #define RPyUnicode_Size(rpu)		((rpu)->ru_chars.length)
 #define _RPyUnicode_AsUnicode(rpu)	((rpu)->ru_chars.items)
 
-/* prototypes */
-
 char *RPyString_AsCharP(RPyString *rps);
 void RPyString_FreeCache(void);
 RPyString *RPyString_FromString(char *buf);
-
-
-/* implementations */
-
-#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
-
-struct _RPyString_dump_t {
-	struct _RPyString_dump_t *next;
-	char data[1];
-} *_RPyString_dump = NULL;
-
-char *RPyString_AsCharP(RPyString *rps)
-{
-	Signed len = RPyString_Size(rps);
-	struct _RPyString_dump_t *dump = \
-			malloc(sizeof(struct _RPyString_dump_t) + len);
-	if (!dump)
-		return "(out of memory!)";
-	dump->next = _RPyString_dump;
-	_RPyString_dump = dump;
-	memcpy(dump->data, rps->rs_chars.items, len);
-	dump->data[len] = 0;
-	return dump->data;
-}
-
-void RPyString_FreeCache(void)
-{
-	while (_RPyString_dump) {
-		struct _RPyString_dump_t *dump = _RPyString_dump;
-		_RPyString_dump = dump->next;
-		free(dump);
-	}
-}
-
-RPyString *RPyString_FromString(char *buf)
-{
-	int length = strlen(buf);
-	RPyString *rps = RPyString_New(length);
-	memcpy(rps->rs_chars.items, buf, length);
-	return rps;
-}
-
-#endif /* PYPY_MAIN_IMPLEMENTATION_FILE */