[Python-checkins] CVS: python/dist/src/Include Python.h,2.34,2.35 ceval.h,2.42,2.43 compile.h,2.32,2.33 pythonrun.h,2.41,2.42
Tim Peters
tim_one@users.sourceforge.net
Sun, 15 Jul 2001 19:29:47 -0700
Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv30317/python/dist/src/Include
Modified Files:
Python.h ceval.h compile.h pythonrun.h
Log Message:
Part way to allowing "from __future__ import generators" to communicate
that info to code dynamically compiled *by* code compiled with generators
enabled. Doesn't yet work because there's still no way to tell the parser
that "yield" is OK (unlike nested_scopes, the parser has its fingers in
this too).
Replaced PyEval_GetNestedScopes by a more-general
PyEval_MergeCompilerFlags. Perhaps I should not have? I doubted it was
*intended* to be part of the public API, so just did.
Index: Python.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v
retrieving revision 2.34
retrieving revision 2.35
diff -C2 -r2.34 -r2.35
*** Python.h 2001/07/15 18:38:46 2.34
--- Python.h 2001/07/16 02:29:45 2.35
***************
*** 97,102 ****
#include "modsupport.h"
- #include "ceval.h"
#include "pythonrun.h"
#include "sysmodule.h"
#include "intrcheck.h"
--- 97,102 ----
#include "modsupport.h"
#include "pythonrun.h"
+ #include "ceval.h"
#include "sysmodule.h"
#include "intrcheck.h"
Index: ceval.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/ceval.h,v
retrieving revision 2.42
retrieving revision 2.43
diff -C2 -r2.42 -r2.43
*** ceval.h 2001/06/27 19:18:03 2.42
--- ceval.h 2001/07/16 02:29:45 2.43
***************
*** 32,36 ****
DL_IMPORT(PyObject *) PyEval_GetFrame(void);
DL_IMPORT(int) PyEval_GetRestricted(void);
! DL_IMPORT(int) PyEval_GetNestedScopes(void);
DL_IMPORT(int) Py_FlushLine(void);
--- 32,40 ----
DL_IMPORT(PyObject *) PyEval_GetFrame(void);
DL_IMPORT(int) PyEval_GetRestricted(void);
!
! /* Look at the current frame's (if any) code's co_flags, and turn on
! the corresponding compiler flags in cf->cf_flags. Return 1 if any
! flag was set, else return 0. */
! DL_IMPORT(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
DL_IMPORT(int) Py_FlushLine(void);
Index: compile.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/compile.h,v
retrieving revision 2.32
retrieving revision 2.33
diff -C2 -r2.32 -r2.33
*** compile.h 2001/07/15 21:08:29 2.32
--- compile.h 2001/07/16 02:29:45 2.33
***************
*** 35,38 ****
--- 35,45 ----
#define CO_NESTED 0x0010
#define CO_GENERATOR 0x0020
+ /* XXX Temporary hack. Until generators are a permanent part of the
+ language, we need a way for a code object to record that generators
+ were *possible* when it was compiled. This is so code dynamically
+ compiled *by* a code object knows whether to allow yield stmts. In
+ effect, this passes on the "from __future__ import generators" state
+ in effect when the code block was compiled. */
+ #define CO_GENERATOR_ALLOWED 0x1000
extern DL_IMPORT(PyTypeObject) PyCode_Type;
***************
*** 57,60 ****
--- 64,68 ----
int ff_last_lineno;
int ff_nested_scopes;
+ int ff_generators;
} PyFutureFeatures;
Index: pythonrun.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v
retrieving revision 2.41
retrieving revision 2.42
diff -C2 -r2.41 -r2.42
*** pythonrun.h 2001/03/23 02:46:52 2.41
--- pythonrun.h 2001/07/16 02:29:45 2.42
***************
*** 8,13 ****
#endif
typedef struct {
! int cf_nested_scopes;
} PyCompilerFlags;
--- 8,18 ----
#endif
+ /* These flags are named after the __future__ statements that introduced
+ them. May not remain true for later additions, so fiddle this comment
+ accordingly then. */
+ #define PyCF_NESTED_SCOPES (0x00000001UL)
+ #define PyCF_GENERATORS (0x00000002UL)
typedef struct {
! unsigned long cf_flags; /* bitmask of PyCF_xxx flags */
} PyCompilerFlags;