[Python-checkins] commit of r41575 - in python/branches/ast-objects: Include Python

neal.norwitz python-checkins at python.org
Thu Dec 1 07:25:47 CET 2005


Author: neal.norwitz
Date: Thu Dec  1 07:25:42 2005
New Revision: 41575

Modified:
   python/branches/ast-objects/Include/ast.h
   python/branches/ast-objects/Include/compile.h
   python/branches/ast-objects/Include/pythonrun.h
   python/branches/ast-objects/Include/symtable.h
   python/branches/ast-objects/Python/future.c
   python/branches/ast-objects/Python/import.c
   python/branches/ast-objects/Python/pythonrun.c
   python/branches/ast-objects/Python/symtable.c
Log:
Start using PyObjects (and PyTypeObjects) instead of _mod or mod_ty.  gets a few more modules compiling

Modified: python/branches/ast-objects/Include/ast.h
==============================================================================
--- python/branches/ast-objects/Include/ast.h	(original)
+++ python/branches/ast-objects/Include/ast.h	Thu Dec  1 07:25:42 2005
@@ -4,7 +4,7 @@
 extern "C" {
 #endif
 
-PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags,
+PyAPI_FUNC(PyTypeObject*) PyAST_FromNode(const node *, PyCompilerFlags *flags,
 				  const char *);
 
 #ifdef __cplusplus

Modified: python/branches/ast-objects/Include/compile.h
==============================================================================
--- python/branches/ast-objects/Include/compile.h	(original)
+++ python/branches/ast-objects/Include/compile.h	Thu Dec  1 07:25:42 2005
@@ -23,10 +23,9 @@
 #define FUTURE_GENERATORS "generators"
 #define FUTURE_DIVISION "division"
 
-struct _mod; /* Declare the existence of this type */
-PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
+PyAPI_FUNC(PyCodeObject *) PyAST_Compile(PyTypeObject *, const char *,
 					PyCompilerFlags *);
-PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
+PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(PyTypeObject *, const char *);
 
 #define ERR_LATE_FUTURE \
 "from __future__ imports must occur at the beginning of the file"

Modified: python/branches/ast-objects/Include/pythonrun.h
==============================================================================
--- python/branches/ast-objects/Include/pythonrun.h	(original)
+++ python/branches/ast-objects/Include/pythonrun.h	Thu Dec  1 07:25:42 2005
@@ -36,9 +36,9 @@
 PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
 PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
 
-PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *, 
+PyAPI_FUNC(PyTypeObject *) PyParser_ASTFromString(const char *, const char *, 
 						 int, PyCompilerFlags *flags);
-PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, int, 
+PyAPI_FUNC(PyTypeObject *) PyParser_ASTFromFile(FILE *, const char *, int, 
 					       char *, char *,
                                                PyCompilerFlags *, int *);
 #define PyParser_SimpleParseString(S, B) \

Modified: python/branches/ast-objects/Include/symtable.h
==============================================================================
--- python/branches/ast-objects/Include/symtable.h	(original)
+++ python/branches/ast-objects/Include/symtable.h	Thu Dec  1 07:25:42 2005
@@ -49,10 +49,10 @@
 #define PySTEntry_Check(op) ((op)->ob_type == &PySTEntry_Type)
 
 PyAPI_FUNC(PySTEntryObject *) \
-	PySTEntry_New(struct symtable *, identifier, _Py_block_ty, void *, int);
+	PySTEntry_New(struct symtable *, PyObject *name, _Py_block_ty, void *, int);
 PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
 
-PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *, 
+PyAPI_FUNC(struct symtable *) PySymtable_Build(PyTypeObject *, const char *, 
 					      PyFutureFeatures *);
 PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
 

Modified: python/branches/ast-objects/Python/future.c
==============================================================================
--- python/branches/ast-objects/Python/future.c	(original)
+++ python/branches/ast-objects/Python/future.c	Thu Dec  1 07:25:42 2005
@@ -47,7 +47,7 @@
 }
 
 static int
-future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
+future_parse(PyFutureFeatures *ff, PyTypeObject *mod, const char *filename)
 {
 	int i, found_docstring = 0, done = 0, prev_line = 0;
 
@@ -114,7 +114,7 @@
 
 
 PyFutureFeatures *
-PyFuture_FromAST(mod_ty mod, const char *filename)
+PyFuture_FromAST(PyTypeObject *mod, const char *filename)
 {
 	PyFutureFeatures *ff;
 

Modified: python/branches/ast-objects/Python/import.c
==============================================================================
--- python/branches/ast-objects/Python/import.c	(original)
+++ python/branches/ast-objects/Python/import.c	Thu Dec  1 07:25:42 2005
@@ -772,13 +772,13 @@
 parse_source_module(const char *pathname, FILE *fp)
 {
 	PyCodeObject *co = NULL;
-	mod_ty mod;
+	PyTypeObject *mod;
 
 	mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0, 
 				   NULL);
 	if (mod) {
 		co = PyAST_Compile(mod, pathname, NULL);
-		free_mod(mod);
+		Py_DECREF(mod);
 	}
 	return co;
 }

Modified: python/branches/ast-objects/Python/pythonrun.c
==============================================================================
--- python/branches/ast-objects/Python/pythonrun.c	(original)
+++ python/branches/ast-objects/Python/pythonrun.c	Thu Dec  1 07:25:42 2005
@@ -35,9 +35,9 @@
 /* Forward */
 static void initmain(void);
 static void initsite(void);
-static PyObject *run_err_mod(mod_ty, const char *, PyObject *, PyObject *,
+static PyObject *run_err_mod(PyTypeObject*, const char *, PyObject *, PyObject *,
 			      PyCompilerFlags *);
-static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *,
+static PyObject *run_mod(PyTypeObject*, const char *, PyObject *, PyObject *,
 			  PyCompilerFlags *);
 static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *,
 			      PyCompilerFlags *);
@@ -696,7 +696,7 @@
 PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
 {
 	PyObject *m, *d, *v, *w;
-	mod_ty mod;
+	PyTypeObject *mod;
 	char *ps1 = "", *ps2 = "";
 	int errcode = 0;
 
@@ -734,7 +734,7 @@
 		return -1;
 	d = PyModule_GetDict(m);
 	v = run_mod(mod, filename, d, d, flags);
-	free_mod(mod);
+	Py_DECREF(mod);
 	if (v == NULL) {
 		PyErr_Print();
 		return -1;
@@ -1155,9 +1155,9 @@
 		  PyObject *locals, PyCompilerFlags *flags)
 {
 	PyObject *ret;
-	mod_ty mod = PyParser_ASTFromString(str, "<string>", start, flags);
+	PyTypeObject *mod = PyParser_ASTFromString(str, "<string>", start, flags);
 	ret = run_err_mod(mod, "<string>", globals, locals, flags);
-	free_mod(mod);
+	Py_DECREF(mod);
 	return ret;
 }
 
@@ -1166,19 +1166,19 @@
 		  PyObject *locals, int closeit, PyCompilerFlags *flags)
 {
 	PyObject *ret;
-	mod_ty mod = PyParser_ASTFromFile(fp, filename, start, 0, 0,
+	PyTypeObject *mod = PyParser_ASTFromFile(fp, filename, start, 0, 0,
 					  flags, NULL);
 	if (mod == NULL)
 		return NULL;
 	if (closeit)
 		fclose(fp);
 	ret = run_err_mod(mod, filename, globals, locals, flags);
-	free_mod(mod);
+	Py_DECREF(mod);
 	return ret;
 }
 
 static PyObject *
-run_err_mod(mod_ty mod, const char *filename, PyObject *globals, 
+run_err_mod(PyTypeObject *mod, const char *filename, PyObject *globals, 
 	    PyObject *locals, PyCompilerFlags *flags)
 {
 	if (mod == NULL)
@@ -1187,7 +1187,7 @@
 }
 
 static PyObject *
-run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals,
+run_mod(PyTypeObject *mod, const char *filename, PyObject *globals, PyObject *locals,
 	 PyCompilerFlags *flags)
 {
 	PyCodeObject *co;
@@ -1236,37 +1236,37 @@
 Py_CompileStringFlags(const char *str, const char *filename, int start,
 		      PyCompilerFlags *flags)
 {
-	mod_ty mod;
+	PyTypeObject *mod;
 	PyCodeObject *co;
 	mod = PyParser_ASTFromString(str, filename, start, flags);
 	if (mod == NULL)
 		return NULL;
 	co = PyAST_Compile(mod, filename, flags);
-	free_mod(mod);
+	Py_DECREF(mod);
 	return (PyObject *)co;
 }
 
 struct symtable *
 Py_SymtableString(const char *str, const char *filename, int start)
 {
-	mod_ty mod;
+	PyTypeObject *mod;
 	struct symtable *st;
 
 	mod = PyParser_ASTFromString(str, filename, start, NULL);
 	if (mod == NULL)
 		return NULL;
 	st = PySymtable_Build(mod, filename, 0);
-	free_mod(mod);
+	Py_DECREF(mod);
 	return st;
 }
 
 /* Preferred access to parser is through AST. */
-mod_ty
+PyTypeObject *
 PyParser_ASTFromString(const char *s, const char *filename, int start, 
 		       PyCompilerFlags *flags)
 {
 	node *n;
-	mod_ty mod;
+	PyTypeObject *mod;
 	perrdetail err;
 	n = PyParser_ParseStringFlagsFilename(s, filename, &_PyParser_Grammar,
 					      start, &err, 
@@ -1282,12 +1282,12 @@
 	}
 }
 
-mod_ty
+PyTypeObject *
 PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1, 
 		     char *ps2, PyCompilerFlags *flags, int *errcode)
 {
 	node *n;
-	mod_ty mod;
+	PyTypeObject *mod;
 	perrdetail err;
 	n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, start, 
 				    ps1, ps2, &err, PARSER_FLAGS(flags));

Modified: python/branches/ast-objects/Python/symtable.c
==============================================================================
--- python/branches/ast-objects/Python/symtable.c	(original)
+++ python/branches/ast-objects/Python/symtable.c	Thu Dec  1 07:25:42 2005
@@ -12,7 +12,7 @@
 "name '%.400s' is used prior to global declaration"
 
 PySTEntryObject *
-PySTEntry_New(struct symtable *st, identifier name, _Py_block_ty block,
+PySTEntry_New(struct symtable *st, PyObject *name, _Py_block_ty block,
 	      void *key, int lineno)
 {
 	PySTEntryObject *ste = NULL;
@@ -204,7 +204,7 @@
 }
 
 struct symtable *
-PySymtable_Build(mod_ty mod, const char *filename, PyFutureFeatures *future)
+PySymtable_Build(PyTypeObject *mod, const char *filename, PyFutureFeatures *future)
 {
 	struct symtable *st = symtable_new();
 	asdl_seq *seq;


More information about the Python-checkins mailing list