From 858e1aba676bda554a6d72de9863186e7b1ca0d1 Mon Sep 17 00:00:00 2001 From: Bruno da Silva de Oliveira Date: Fri, 23 May 2003 20:37:35 +0000 Subject: [PATCH] - Support for global variables - Bug fixes in ClassExporter [SVN r18518] --- pyste/NEWS | 4 +++ pyste/doc/global_variables.html | 49 +++++++++++++++++++++++++++++++++ pyste/doc/introduction.html | 2 +- pyste/doc/pyste.txt | 12 ++++++++ pyste/doc/smart_pointers.html | 5 ++-- pyste/example/vars.h | 19 +++++++++++++ pyste/example/vars.pyste | 1 + pyste/index.html | 5 ++++ pyste/src/ClassExporter.py | 2 +- pyste/src/HeaderExporter.py | 2 ++ pyste/src/VarExporter.py | 31 +++++++++++++++++++++ pyste/src/declarations.py | 4 +-- pyste/src/exporterutils.py | 10 +++---- pyste/src/infos.py | 16 ++++++++++- pyste/src/pyste.py | 14 +++++++--- pyste/tests/example_varsUT.py | 17 ++++++++++++ pyste/tests/nt_build_all.bat | 1 + 17 files changed, 178 insertions(+), 16 deletions(-) create mode 100644 pyste/doc/global_variables.html create mode 100644 pyste/example/vars.h create mode 100644 pyste/example/vars.pyste create mode 100644 pyste/src/VarExporter.py create mode 100644 pyste/tests/example_varsUT.py diff --git a/pyste/NEWS b/pyste/NEWS index 28bcbbfe..3505706d 100644 --- a/pyste/NEWS +++ b/pyste/NEWS @@ -1,3 +1,7 @@ +23 May 2003 +Support for global variables added. +Various bug fixes. + 08 May 2003 Fixed bug where in a certain cases the GCCXMLParser would end up with multiple declarations of the same class diff --git a/pyste/doc/global_variables.html b/pyste/doc/global_variables.html new file mode 100644 index 00000000..84b3b9d3 --- /dev/null +++ b/pyste/doc/global_variables.html @@ -0,0 +1,49 @@ + + + +Global Variables + + + + + + + + + +
+ + Global Variables +
+
+ + + + + + +
+

+To export global variables, use the Var construct:

+
+    Var("myglobal", "foo.h")
+
+

+Beware of non-const global variables: changes in Python won't reflect in C++! +If you really must change them in Python, you will have to write some accessor +functions, and export those.

+ + + + + + +
+
+
+ + diff --git a/pyste/doc/introduction.html b/pyste/doc/introduction.html index d86179e2..ccbbda4d 100644 --- a/pyste/doc/introduction.html +++ b/pyste/doc/introduction.html @@ -57,7 +57,7 @@ this will create a file "hello.cpp" in the directory where th run.

Pyste supports the following features:

- +
diff --git a/pyste/doc/pyste.txt b/pyste/doc/pyste.txt index 945b2364..b37c6833 100644 --- a/pyste/doc/pyste.txt +++ b/pyste/doc/pyste.txt @@ -48,6 +48,7 @@ Pyste supports the following features: * Enums (both "free" enums and class enums) * Nested Classes * Support for [^boost::shared_ptr] and [^std::auto_ptr] +* Global Variables [page Running Pyste] @@ -465,3 +466,14 @@ For [^std::auto_ptr]'s, use the function [^use_auto_ptr]. This system is temporary, and in the future the converters will automatically be exported if needed, without the need to tell Pyste about them explicitly. + +[page:1 Global Variables] + +To export global variables, use the [^Var] construct: + + Var("myglobal", "foo.h") + +Beware of non-const global variables: changes in Python won't reflect in C++! +If you really must change them in Python, you will have to write some accessor +functions, and export those. + diff --git a/pyste/doc/smart_pointers.html b/pyste/doc/smart_pointers.html index e63b49ff..d3ff5923 100644 --- a/pyste/doc/smart_pointers.html +++ b/pyste/doc/smart_pointers.html @@ -4,6 +4,7 @@ Smart Pointers +
@@ -20,7 +21,7 @@ - +

@@ -61,7 +62,7 @@ exported if needed, without the need to tell Pyste about them explicitly.

- +
diff --git a/pyste/example/vars.h b/pyste/example/vars.h new file mode 100644 index 00000000..23de92b5 --- /dev/null +++ b/pyste/example/vars.h @@ -0,0 +1,19 @@ + +struct Color +{ + Color(int r_ = 0, int g_ = 0, int b_ = 0): + r(r_), g(g_), b(b_) + {} + Color( const Color &c): + r(c.r), g(c.g), b(c.b) + {} + int r; + int g; + int b; +}; + +const Color black = Color(0, 0, 0); +const Color red = Color(255, 0, 0); +const Color green = Color(0, 255, 0); +const Color blue = Color(0, 0, 255); +Color in_use = black; diff --git a/pyste/example/vars.pyste b/pyste/example/vars.pyste new file mode 100644 index 00000000..3fd9d689 --- /dev/null +++ b/pyste/example/vars.pyste @@ -0,0 +1 @@ +AllFromHeader('vars.h') diff --git a/pyste/index.html b/pyste/index.html index 0abccae0..b9c21920 100644 --- a/pyste/index.html +++ b/pyste/index.html @@ -65,6 +65,11 @@ Smart Pointers + + + Global Variables + +