[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19081] trunk/blender: BGE Py API

Campbell Barton ideasman42 at gmail.com
Sun Feb 22 11:22:52 CET 2009


Revision: 19081
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19081
Author:   campbellbarton
Date:     2009-02-22 11:22:49 +0100 (Sun, 22 Feb 2009)

Log Message:
-----------
BGE Py API
print filename:line with ShowDeprecationWarning().
Typo in scripttemplate_gamelogic.py
removed 2 unneeded typedefs

Modified Paths:
--------------
    trunk/blender/intern/SoundSystem/openal/SND_OpenALDevice.h
    trunk/blender/intern/SoundSystem/sdl/SND_SDLCDDevice.h
    trunk/blender/release/scripts/scripttemplate_gamelogic.py
    trunk/blender/source/gameengine/Expressions/Value.cpp

Modified: trunk/blender/intern/SoundSystem/openal/SND_OpenALDevice.h
===================================================================
--- trunk/blender/intern/SoundSystem/openal/SND_OpenALDevice.h	2009-02-22 09:30:18 UTC (rev 19080)
+++ trunk/blender/intern/SoundSystem/openal/SND_OpenALDevice.h	2009-02-22 10:22:49 UTC (rev 19081)
@@ -32,7 +32,7 @@
 #include "SND_AudioDevice.h"
 #include "SoundDefines.h"
 
-typedef struct SDL_CD;
+struct SDL_CD;
 
 class SND_OpenALDevice : public SND_AudioDevice
 {

Modified: trunk/blender/intern/SoundSystem/sdl/SND_SDLCDDevice.h
===================================================================
--- trunk/blender/intern/SoundSystem/sdl/SND_SDLCDDevice.h	2009-02-22 09:30:18 UTC (rev 19080)
+++ trunk/blender/intern/SoundSystem/sdl/SND_SDLCDDevice.h	2009-02-22 10:22:49 UTC (rev 19081)
@@ -29,7 +29,7 @@
 #ifndef SND_SDLCDDEVICE
 #define SND_SDLCDDEVICE
 
-typedef struct SDL_CD;
+struct SDL_CD;
 
 class SND_SDLCDDevice
 {

Modified: trunk/blender/release/scripts/scripttemplate_gamelogic.py
===================================================================
--- trunk/blender/release/scripts/scripttemplate_gamelogic.py	2009-02-22 09:30:18 UTC (rev 19080)
+++ trunk/blender/release/scripts/scripttemplate_gamelogic.py	2009-02-22 10:22:49 UTC (rev 19081)
@@ -11,6 +11,9 @@
 
 script_data = \
 '''
+# This script must be assigned to a python controller
+# where it can access the object that owns it and the sensors/actuators that it connects to.
+
 # GameLogic has been added to the global namespace no need to import
 
 # for keyboard event comparison
@@ -50,7 +53,7 @@
 	for actu in cont.getActuators():
 		# The actuator can be on another object, we may want to use it
 		own_actu = actu.getOwner()
-		print '    actuator:', sens.getName()
+		print '    actuator:', actu.getName()
 		
 		# This runs the actuator or turns it off
 		# note that actuators will continue to run unless explicitly turned off.

Modified: trunk/blender/source/gameengine/Expressions/Value.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/Value.cpp	2009-02-22 09:30:18 UTC (rev 19080)
+++ trunk/blender/source/gameengine/Expressions/Value.cpp	2009-02-22 10:22:49 UTC (rev 19081)
@@ -859,7 +859,42 @@
 
 void CValue::ShowDeprecationWarning(const char* old_way,const char* new_way)
 {
-	if (!m_ignore_deprecation_warnings)
+	if (!m_ignore_deprecation_warnings) {
 		printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way);
+		
+		// import sys; print '\t%s:%d' % (sys._getframe(0).f_code.co_filename, sys._getframe(0).f_lineno)
+		
+		PyObject *getframe, *frame;
+		PyObject *f_lineno, *f_code, *co_filename;
+		
+		getframe = PySys_GetObject("_getframe"); // borrowed
+		if (getframe) {
+			frame = PyObject_CallObject(getframe, NULL);
+			if (frame) {
+				f_lineno= PyObject_GetAttrString(frame, "f_lineno");
+				f_code= PyObject_GetAttrString(frame, "f_code");
+				if (f_lineno && f_code) {
+					co_filename= PyObject_GetAttrString(f_code, "co_filename");
+					if (co_filename) {
+						
+						printf("\t%s:%d\n", PyString_AsString(co_filename), (int)PyInt_AsLong(f_lineno));
+						
+						Py_DECREF(f_lineno);
+						Py_DECREF(f_code);
+						Py_DECREF(co_filename);
+						Py_DECREF(frame);
+						return;
+					}
+				}
+				
+				Py_XDECREF(f_lineno);
+				Py_XDECREF(f_code);
+				Py_DECREF(frame);
+			}
+			
+		}
+		PyErr_Clear();
+		printf("\tERROR - Could not access sys._getframe(0).f_lineno or sys._getframe().f_code.co_filename\n");
+	}
 }
 





More information about the Bf-blender-cvs mailing list