Merge branch 'master' into astron-master

This commit is contained in:
Harvir 2015-11-13 01:44:16 +00:00
commit 7819257585
481 changed files with 6269 additions and 59296 deletions

View File

@ -96,9 +96,12 @@ files into the appropriate locations on your computer. You may have to run the
Mac OS X
--------
On Mac OS X, all you need to compile Panda3D is a set of precompiled
thirdparty packages, which can be acquired from here:
https://www.panda3d.org/download/panda3d-1.9.0/panda3d-1.9.0-tools-mac.tar.gz
On Mac OS X, you will need to download a set of precompiled thirdparty packages in order to
compile Panda3D, which can be acquired from [here](https://www.panda3d.org/download/panda3d-1.9.0/panda3d-1.9.0-tools-mac.tar.gz).
In order to build the installer on Mac OS X you will need to install PackageMaker.
This can be obtained from the "Auxiliary Tools for Xcode" which can be downloaded
from Apple [here](https://developer.apple.com/downloads/).
After placing the thirdparty directory inside the panda3d source directory,
you may build Panda3D using a command like the following:

View File

@ -1,60 +0,0 @@
//
// Package.pp
//
// This file defines certain configuration variables that are to be
// written into the various make scripts. It is processed by ppremake
// (along with the Sources.pp files in each of the various
// contribories) to generate build scripts appropriate to each
// environment.
//
// This is the package-specific file, which should be at the top of
// every source hierarchy. It generally gets the ball rolling, and is
// responsible for explicitly including all of the relevent Config.pp
// files.
// What is the name and version of this source tree?
#if $[eq $[PACKAGE],]
#define PACKAGE contrib
#define VERSION 0.80
#endif
// Where should we find the PANDA source contribory?
#if $[PANDA_SOURCE]
#define PANDA_SOURCE $[unixfilename $[PANDA_SOURCE]]
#elif $[or $[CTPROJS],$[PANDA]]
// If we are presently attached, use the environment variable.
#define PANDA_SOURCE $[unixfilename $[PANDA]]
#if $[eq $[PANDA],]
#error You seem to be attached to some trees, but not PANDA!
#endif
#else
// Otherwise, if we are not attached, we guess that the source is a
// sibling contribory to this source root.
#define PANDA_SOURCE $[standardize $[TOPDIR]/../panda]
#endif
// Where should we install CONTRIB?
#if $[CONTRIB_INSTALL]
#define CONTRIB_INSTALL $[unixfilename $[CONTRIB_INSTALL]]
#elif $[CTPROJS]
#set CONTRIB $[unixfilename $[CONTRIB]]
#define CONTRIB_INSTALL $[CONTRIB]/built
#if $[eq $[CONTRIB],]
#error You seem to be attached to some trees, but not CONTRIB!
#endif
#else
#defer CONTRIB_INSTALL $[unixfilename $[INSTALL_DIR]]
#endif
// Also get the PANDA Package file and everything that includes.
#if $[not $[isfile $[PANDA_SOURCE]/Package.pp]]
#printvar PANDA_SOURCE
#error PANDA source contribory not found from contrib! Are you attached properly?
#endif
#include $[PANDA_SOURCE]/Package.pp
// Define the inter-tree dependencies.
#define NEEDS_TREES panda $[NEEDS_TREES]
#define DEPENDABLE_HEADER_DIRS $[DEPENDABLE_HEADER_DIRS] $[PANDA_INSTALL]/include

View File

@ -1,10 +0,0 @@
// This is the toplevel directory for a package.
#define DIR_TYPE toplevel
#define REQUIRED_TREES dtool panda
#define EXTRA_DIST \
Sources.pp Config.pp Package.pp
#define PYTHON_PACKAGE 1

View File

@ -1,4 +0,0 @@
// This is a group directory: a directory level above a number of
// source subdirectories.
#define DIR_TYPE group

View File

@ -1,82 +0,0 @@
#define LOCAL_LIBS p3contribbase
#define BUILDING_DLL BUILDING_PANDAAI
#define OTHER_LIBS \
panda:c \
p3express:c p3putil:c p3pandabase:c pandaexpress:m \
p3interrogatedb:c p3prc:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m
#begin lib_target
#define TARGET pandaai
#define COMBINED_SOURCES p3ai_composite1.cxx
#define SOURCES \
aiBehaviors.h \
aiCharacter.h \
aiGlobals.h \
aiNode.h \
aiPathFinder.h \
aiWorld.h \
arrival.h \
config_ai.h \
evade.h \
flee.h \
flock.h \
aiGlobals.h \
meshNode.h \
obstacleAvoidance.h \
pathFind.h \
pathFollow.h \
pursue.h \
seek.h \
wander.h
#define INCLUDED_SOURCES \
aiBehaviors.cxx \
aiCharacter.cxx \
aiNode.cxx \
aiPathFinder.cxx \
aiWorld.cxx \
p3ai_composite.cxx \
p3ai_composite1.cxx \
arrival.cxx \
config_ai.cxx \
evade.cxx \
flee.cxx \
flock.cxx \
meshNode.cxx \
obstacleAvoidance.cxx \
pathFind.cxx \
pathFollow.cxx \
pursue.cxx \
seek.cxx \
wander.cxx
#define INSTALL_HEADERS \
aiBehaviors.h \
aiCharacter.h \
aiGlobals.h \
aiNode.h \
aiPathFinder.h \
aiWorld.h \
arrival.h \
config_ai.h \
evade.h \
flee.h \
flock.h \
aiGlobals.h \
meshNode.h \
obstacleAvoidance.h \
pathFind.h \
pathFollow.h \
pursue.h \
seek.h \
wander.h
#define IGATESCAN all
#end lib_target

View File

@ -1,13 +0,0 @@
#define OTHER_LIBS p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m p3prc:c
#begin lib_target
#define TARGET p3contribbase
#define SOURCES \
contribbase.cxx contribbase.h contribsymbols.h \
#define INSTALL_HEADERS \
contribbase.h contribbase.h
#end lib_target

View File

@ -1,2 +0,0 @@
// For now, since we are not installing Python files, this file can
// remain empty.

View File

@ -1,60 +0,0 @@
//
// Package.pp
//
// This file defines certain configuration variables that are to be
// written into the various make scripts. It is processed by ppremake
// (along with the Sources.pp files in each of the various
// directories) to generate build scripts appropriate to each
// environment.
//
// This is the package-specific file, which should be at the top of
// every source hierarchy. It generally gets the ball rolling, and is
// responsible for explicitly including all of the relevent Config.pp
// files.
// What is the name and version of this source tree?
#if $[eq $[PACKAGE],]
#define PACKAGE direct
#define VERSION 0.80
#endif
// Where should we find the PANDA source directory?
#if $[PANDA_SOURCE]
#define PANDA_SOURCE $[unixfilename $[PANDA_SOURCE]]
#elif $[or $[CTPROJS],$[PANDA]]
// If we are presently attached, use the environment variable.
#define PANDA_SOURCE $[unixfilename $[PANDA]]
#if $[eq $[PANDA],]
#error You seem to be attached to some trees, but not PANDA!
#endif
#else
// Otherwise, if we are not attached, we guess that the source is a
// sibling directory to this source root.
#define PANDA_SOURCE $[standardize $[TOPDIR]/../panda]
#endif
// Where should we install DIRECT?
#if $[DIRECT_INSTALL]
#define DIRECT_INSTALL $[unixfilename $[DIRECT_INSTALL]]
#elif $[CTPROJS]
#set DIRECT $[unixfilename $[DIRECT]]
#define DIRECT_INSTALL $[DIRECT]/built
#if $[eq $[DIRECT],]
#error You seem to be attached to some trees, but not DIRECT!
#endif
#else
#defer DIRECT_INSTALL $[unixfilename $[INSTALL_DIR]]
#endif
// Also get the PANDA Package file and everything that includes.
#if $[not $[isfile $[PANDA_SOURCE]/Package.pp]]
#printvar PANDA_SOURCE
#error PANDA source directory not found from direct! Are you attached properly?
#endif
#include $[PANDA_SOURCE]/Package.pp
// Define the inter-tree dependencies.
#define NEEDS_TREES panda $[NEEDS_TREES]
#define DEPENDABLE_HEADER_DIRS $[DEPENDABLE_HEADER_DIRS] $[PANDA_INSTALL]/include

View File

@ -1,11 +0,0 @@
// This is the toplevel directory for a package.
#define DIR_TYPE toplevel
#define SAMPLE_SOURCE_FILE src/directbase/directbase.cxx
#define REQUIRED_TREES dtool panda
#define EXTRA_DIST \
Sources.pp Config.pp Package.pp
#define PYTHON_PACKAGE 1

View File

@ -1,7 +0,0 @@
// This is a group directory: a directory level above a number of
// source subdirectories.
#define DIR_TYPE group
// The metalibs directory always depends on the src directory.
#define DEPENDS src

View File

@ -1,32 +0,0 @@
// DIR_TYPE "metalib" indicates we are building a shared library that
// consists mostly of references to other shared libraries. Under
// Windows, this directly produces a DLL (as opposed to the regular
// src libraries, which don't produce anything but a pile of OBJ files
// under Windows).
#define DIR_TYPE metalib
#define BUILDING_DLL BUILDING_DIRECT
#define USE_PACKAGES native_net
#define COMPONENT_LIBS \
p3directbase p3dcparser p3showbase p3deadrec p3directd p3interval p3distributed p3motiontrail p3http
#define OTHER_LIBS \
panda:m \
pandaexpress:m \
p3parametrics:c \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3express:c p3pstatclient:c p3prc:c p3pandabase:c p3linmath:c \
p3putil:c p3display:c p3event:c p3pgraph:c p3pgraphnodes:c \
p3gsgbase:c p3gobj:c p3mathutil:c \
p3downloader:c p3pnmimage:c p3chan:c \
p3pipeline:c p3cull:c \
$[if $[HAVE_NET],p3net:c] $[if $[WANT_NATIVE_NET],p3nativenet:c]
#begin metalib_target
#define TARGET p3direct
#define SOURCES direct.cxx
#end metalib_target

View File

@ -1,4 +0,0 @@
// This is a group directory: a directory level above a number of
// source subdirectories.
#define DIR_TYPE group

View File

@ -525,9 +525,8 @@ class Actor(DirectObject, NodePath):
self.__LODNode = None
# remove all its children
if(self.__geomNode):
self.__geomNode.removeChildren()
if self.__geomNode:
self.__geomNode.getChildren().detach()
self.__hasLOD = 0

View File

@ -1,3 +0,0 @@
// For now, since we are not installing Python files, this file can
// remain empty.

View File

@ -1,10 +0,0 @@
#define INSTALL_CONFIG \
40_direct.prc
#if $[CTPROJS]
// These files only matter to ctattach users.
#define INSTALL_CONFIG $[INSTALL_CONFIG] direct.init
#endif
#include $[THISDIRPREFIX]direct.prc.pp

View File

@ -1,32 +0,0 @@
//
// direct.prc.pp
//
// This file defines the script to auto-generate direct.prc at
// ppremake time. This is intended to fill in some of the default
// parameters, in particular the default display types.
//
#output 40_direct.prc notouch
#### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
################################# DO NOT EDIT ###########################
#if $[CTPROJS]
// If we are using the ctattach tools, append "built"--this is a VR
// Studio convention.
model-path $DMODELS/built
sound-path $DMODELS/built
#else
// Most people outside the VR Studio just see this.
model-path $DMODELS
sound-path $DMODELS
#endif
# Define a new egg object type. See the comments in _panda.prc about this.
egg-object-type-direct-widget <Scalar> collide-mask { 0x80000000 } <Collide> { Polyset descend }
# Define a new cull bin that will render on top of everything else.
cull-bin gui-popup 60 unsorted
#end 40_direct.prc

View File

@ -13,13 +13,13 @@ from direct.directnotify import DirectNotifyGlobal
#if __debug__:
# import DevWalker
from direct.task import Task
from panda3d.core import ConfigVariableBool
CollisionHandlerRayStart = 4000.0 # This is a hack, it may be better to use a line instead of a ray.
class ControlManager:
notify = DirectNotifyGlobal.directNotify.newCategory("ControlManager")
wantAvatarPhysicsIndicator = config.GetBool('want-avatar-physics-indicator', 0)
wantAvatarPhysicsDebug = config.GetBool('want-avatar-physics-debug', 0)
wantWASD = config.GetBool('want-WASD', 0)
wantWASD = ConfigVariableBool('want-WASD', True)
def __init__(self, enable=True, passMessagesThrough = False):
assert self.notify.debug("init control manager %s" % (passMessagesThrough))

View File

@ -18,15 +18,17 @@ from direct.showbase import DirectObject
from direct.controls.ControlManager import CollisionHandlerRayStart
from direct.showbase.InputStateGlobal import inputState
from direct.task.Task import Task
from pandac.PandaModules import *
from panda3d.core import *
from direct.extensions_native import VBase3_extensions
from direct.extensions_native import VBase4_extensions
import math
class GravityWalker(DirectObject.DirectObject):
notify = directNotify.newCategory("GravityWalker")
wantDebugIndicator = base.config.GetBool('want-avatar-physics-indicator', 0)
wantFloorSphere = base.config.GetBool('want-floor-sphere', 0)
earlyEventSphere = base.config.GetBool('early-event-sphere', 0)
wantDebugIndicator = ConfigVariableBool('want-avatar-physics-indicator', False)
wantFloorSphere = ConfigVariableBool('want-floor-sphere', False)
earlyEventSphere = ConfigVariableBool('early-event-sphere', False)
DiagonalFactor = math.sqrt(2.) / 2.

View File

@ -19,7 +19,11 @@ from direct.showbase import DirectObject
from direct.controls.ControlManager import CollisionHandlerRayStart
from direct.showbase.InputStateGlobal import inputState
from direct.task.Task import Task
from pandac.PandaModules import *
from panda3d.core import *
from panda3d.physics import *
from direct.extensions_native import Mat3_extensions
from direct.extensions_native import VBase3_extensions
from direct.extensions_native import VBase4_extensions
import math
#import LineStream
@ -27,8 +31,7 @@ import math
class PhysicsWalker(DirectObject.DirectObject):
notify = DirectNotifyGlobal.directNotify.newCategory("PhysicsWalker")
wantDebugIndicator = base.config.GetBool('want-avatar-physics-indicator', 0)
wantAvatarPhysicsIndicator = base.config.GetBool('want-avatar-physics-indicator', 0)
wantDebugIndicator = ConfigVariableBool('want-avatar-physics-indicator', False)
useLifter = 0
useHeightRay = 0

View File

@ -1,23 +0,0 @@
#define LOCAL_LIBS \
p3dcparser
#define OTHER_LIBS \
p3express:c pandaexpress:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3prc:c p3pstatclient:c p3pandabase:c p3linmath:c p3putil:c \
p3pipeline:c p3downloader:c \
$[if $[HAVE_NET],p3net:c] $[if $[WANT_NATIVE_NET],p3nativenet:c] \
panda:m \
p3pystub
#define C++FLAGS -DWITHIN_PANDA
#begin bin_target
#define TARGET dcparse
#define USE_PACKAGES zlib openssl tar
#define SOURCES \
dcparse.cxx
#define WIN_SYS_LIBS shell32.lib
#end bin_target

View File

@ -1,64 +0,0 @@
#define OTHER_LIBS \
p3express:c pandaexpress:m \
p3pstatclient:c p3pipeline:c panda:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m p3prc:c p3pandabase:c \
p3downloader:c $[if $[HAVE_NET],p3net:c] $[if $[WANT_NATIVE_NET],p3nativenet:c] \
p3linmath:c p3putil:c
#define LOCAL_LIBS \
p3directbase
#define YACC_PREFIX dcyy
#define C++FLAGS -DWITHIN_PANDA
#define UNIX_SYS_LIBS m
#define USE_PACKAGES python
#begin lib_target
#define TARGET p3dcparser
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
#define SOURCES \
dcAtomicField.h dcAtomicField.I dcClass.h dcClass.I \
dcDeclaration.h \
dcField.h dcField.I \
dcFile.h dcFile.I \
dcKeyword.h dcKeywordList.h \
dcLexer.lxx \
dcLexerDefs.h dcMolecularField.h dcParser.yxx dcParserDefs.h \
dcSubatomicType.h \
dcPackData.h dcPackData.I \
dcPacker.h dcPacker.I \
dcPackerCatalog.h dcPackerCatalog.I \
dcPackerInterface.h dcPackerInterface.I \
dcParameter.h dcClassParameter.h dcArrayParameter.h \
dcSimpleParameter.h dcSwitchParameter.h \
dcNumericRange.h dcNumericRange.I \
dcSwitch.h \
dcTypedef.h \
dcPython.h \
dcbase.h dcindent.h hashGenerator.h \
primeNumberGenerator.h
#define INCLUDED_SOURCES \
dcAtomicField.cxx dcClass.cxx \
dcDeclaration.cxx \
dcField.cxx dcFile.cxx \
dcKeyword.cxx dcKeywordList.cxx \
dcMolecularField.cxx dcSubatomicType.cxx \
dcPackData.cxx \
dcPacker.cxx \
dcPackerCatalog.cxx \
dcPackerInterface.cxx \
dcParameter.cxx dcClassParameter.cxx dcArrayParameter.cxx \
dcSimpleParameter.cxx dcSwitchParameter.cxx \
dcSwitch.cxx \
dcTypedef.cxx \
dcindent.cxx \
hashGenerator.cxx primeNumberGenerator.cxx
// #define SOURCES $[SOURCES] $[INCLUDED_SOURCES]
// #define COMBINED_SOURCES
#define IGATESCAN all
#end lib_target

View File

@ -1,28 +0,0 @@
#begin lib_target
#define TARGET p3deadrec
#define LOCAL_LIBS \
p3directbase
#define OTHER_LIBS \
p3express:c p3linmath:c \
p3interrogatedb:c p3dconfig:c \
p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3prc:c p3pandabase:c p3putil:c \
p3pipeline:c
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
#define SOURCES \
config_deadrec.h \
smoothMover.h smoothMover.I
#define INCLUDED_SOURCES \
config_deadrec.cxx \
smoothMover.cxx
#define INSTALL_HEADERS \
config_deadrec.h \
smoothMover.h smoothMover.I
#define IGATESCAN \
all
#end lib_target

View File

@ -1,20 +0,0 @@
#define USE_PACKAGES cg // from gobj.
#begin lib_target
#define TARGET p3directbase
#define SOURCES \
directbase.cxx directbase.h directsymbols.h \
#define INSTALL_HEADERS \
directbase.h directsymbols.h
// These libraries and frameworks are used by dtoolutil; we redefine
// them here so they get into the panda build system.
#if $[ne $[PLATFORM], FreeBSD]
#define UNIX_SYS_LIBS dl
#endif
#define WIN_SYS_LIBS shell32.lib
#define OSX_SYS_FRAMEWORKS Foundation $[if $[not $[BUILD_IPHONE]],AppKit]
#end lib_target

View File

@ -1,23 +0,0 @@
// This package presently only builds on Windows.
// We also require the network layer (queuedConnectionManager, etc.)
#define BUILD_DIRECTORY $[and $[WINDOWS_PLATFORM],$[HAVE_NET],$[HAVE_DIRECTD]]
#define LOCAL_LIBS \
p3directbase
#define OTHER_LIBS \
$[if $[HAVE_NET],p3net:c] p3linmath:c p3putil:c p3express:c panda:m pandaexpress:m p3dtoolconfig p3dtool
#define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32.lib //advapi32.lib
#begin lib_target
#define TARGET p3directd
#define SOURCES \
directd.h directd.cxx
#define INSTALL_HEADERS \
directd.h
#define IGATESCAN directd.h
#end lib_target

View File

@ -1,30 +0,0 @@
// This package presently only builds on Windows.
// We also require the network layer (queuedConnectionManager, etc.)
#define BUILD_DIRECTORY $[and $[WINDOWS_PLATFORM],$[HAVE_NET],$[HAVE_DIRECTD]]
//#define LOCAL_LIBS \
// p3directbase
#define OTHER_LIBS \
$[if $[HAVE_NET],p3net:c] p3linmath:c p3putil:c p3express:c panda:m pandaexpress:m p3dtoolconfig p3dtool
#define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32.lib //advapi32.lib
#begin bin_target
#define TARGET p3directdServer
#define LOCAL_LIBS p3directd
#define OTHER_LIBS $[OTHER_LIBS] p3pystub
#define SOURCES \
directdServer.cxx directdServer.h
#end bin_target
#begin test_bin_target
#define TARGET directdClient
#define LOCAL_LIBS p3directd
#define OTHER_LIBS $[OTHER_LIBS] p3pystub
#define SOURCES \
directdClient.cxx directdClient.h
#end test_bin_target

View File

@ -1,8 +0,0 @@
#if $[and $[CTPROJS],$[WINDOWS_PLATFORM]]
// This script is only useful if you're using the ctattach script on
// Windows; therefore, we only bother to install it if you're using
// the cattach scripts.
#define INSTALL_SCRIPTS runPythonEmacs
#endif

View File

@ -227,16 +227,27 @@ class SelectedNodePaths(DirectObject):
selected = self.last
# Toggle visibility of selected node paths
if selected:
selected.toggleVis()
if selected.isHidden():
selected.show()
else:
selected.hide()
def toggleVisAll(self):
# Toggle viz for all selected node paths
self.forEachSelectedNodePathDo(NodePath.toggleVis)
selectedNodePaths = self.getSelectedAsList()
for nodePath in selectedNodePaths:
if nodePath.isHidden():
nodePath.show()
else:
nodePath.hide()
def isolateSelected(self):
selected = self.last
if selected:
selected.isolate()
selected.showAllDescendents()
for sib in selected.getParent().getChildren():
if sib.node() != selected.node():
sib.hide()
def getDirectNodePath(self, nodePath):
# Get this pointer

View File

@ -879,7 +879,9 @@ class DirectSession(DirectObject):
# Yes, show everything in level
self.showAllDescendants(nodePath.getParent())
# Now hide all of this node path's siblings
nodePath.hideSiblings()
for sib in nodePath.getParent().getChildren():
if sib.node() != nodePath.node():
sib.hide()
def toggleVis(self, nodePath = 'None Given'):
""" Toggle visibility of node path """
@ -890,7 +892,10 @@ class DirectSession(DirectObject):
nodePath = self.selected.last
if nodePath:
# Now toggle node path's visibility state
nodePath.toggleVis()
if nodePath.isHidden():
nodePath.show()
else:
nodePath.hide()
def removeNodePath(self, nodePath = 'None Given'):
if nodePath == 'None Given':
@ -904,8 +909,11 @@ class DirectSession(DirectObject):
def showAllDescendants(self, nodePath = render):
""" Show the level and its descendants """
nodePath.showAllDescendants()
nodePath.hideCS()
if not isinstance(nodePath, CollisionNode):
nodePath.show()
for child in nodePath.getChildren():
self.showAllDescendants(child)
def upAncestry(self):
if self.ancestry:

View File

@ -1,25 +0,0 @@
#define C++FLAGS -DWITHIN_PANDA
#begin lib_target
#define BUILD_TARGET $[HAVE_PYTHON]
#define USE_PACKAGES openssl native_net net
#define TARGET p3distributed
#define LOCAL_LIBS \
p3directbase p3dcparser
#define OTHER_LIBS \
p3event:c p3downloader:c panda:m p3express:c pandaexpress:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3prc:c p3pstatclient:c p3pandabase:c p3linmath:c p3putil:c \
p3pipeline:c $[if $[HAVE_NET],p3net:c] $[if $[WANT_NATIVE_NET],p3nativenet:c]
#define SOURCES \
config_distributed.cxx config_distributed.h \
cConnectionRepository.cxx cConnectionRepository.I \
cConnectionRepository.h \
cDistributedSmoothNodeBase.cxx cDistributedSmoothNodeBase.I \
cDistributedSmoothNodeBase.h
#define IGATESCAN all
#end lib_target

View File

@ -1,4 +1,5 @@
from .core import Dtool_funcToMethod
from panda3d.direct import CInterval
from .extension_native_helpers import Dtool_funcToMethod
from direct.directnotify.DirectNotifyGlobal import directNotify
CInterval.DtoolClassDict["notify"] = directNotify.newCategory("Interval")

View File

@ -3,6 +3,9 @@
#del func
#####################################################################
from panda3d.core import HTTPChannel
from .extension_native_helpers import Dtool_funcToMethod
"""
HTTPChannel-extensions module: contains methods to extend functionality
of the HTTPChannel class

2
direct/src/extensions_native/Mat3_extensions.py Executable file → Normal file
View File

@ -8,6 +8,8 @@ Mat3-extensions module: contains methods to extend functionality
of the LMatrix3f class.
"""
from panda3d.core import Mat3
from .extension_native_helpers import Dtool_funcToMethod
def pPrintValues(self):
"""

View File

@ -8,6 +8,9 @@ NodePath-extensions module: contains methods to extend functionality
of the NodePath class
"""
from panda3d.core import NodePath
from .extension_native_helpers import Dtool_funcToMethod
####################################################################
def id(self):
"""Deprecated. Returns a unique id identifying the NodePath instance"""
@ -27,7 +30,8 @@ del getChildrenAsList
#####################################################################
def printChildren(self):
"""Prints out the children of the bottom node of a node path"""
"""Deprecated. Prints out the children of the bottom node of a node path"""
print("Warning: NodePath.printChildren() is deprecated.")
for child in self.getChildren():
print(child.getName())
Dtool_funcToMethod(printChildren, NodePath)
@ -35,14 +39,16 @@ del printChildren
#####################################################################
def removeChildren(self):
"""Deletes the children of the bottom node of a node path"""
"""Deprecated. Deletes the children of the bottom node of a node path"""
print("Warning: NodePath.removeChildren() is deprecated. Use get_children().detach() instead.")
self.getChildren().detach()
Dtool_funcToMethod(removeChildren, NodePath)
del removeChildren
#####################################################################
def toggleVis(self):
"""Toggles visibility of a nodePath"""
"""Deprecated. Toggles visibility of a nodePath"""
print("Warning: NodePath.toggleVis() is deprecated. Use is_hidden(), show() and hide() instead.")
if self.isHidden():
self.show()
return 1
@ -54,7 +60,8 @@ del toggleVis
#####################################################################
def showSiblings(self):
"""Show all the siblings of a node path"""
"""Deprecated. Show all the siblings of a node path"""
print("Warning: NodePath.showSiblings() is deprecated.")
for sib in self.getParent().getChildren():
if sib.node() != self.node():
sib.show()
@ -63,7 +70,8 @@ del showSiblings
#####################################################################
def hideSiblings(self):
"""Hide all the siblings of a node path"""
"""Deprecated. Hide all the siblings of a node path"""
print("Warning: NodePath.hideSiblings() is deprecated.")
for sib in self.getParent().getChildren():
if sib.node() != self.node():
sib.hide()
@ -72,7 +80,8 @@ del hideSiblings
#####################################################################
def showAllDescendants(self):
"""Show the node path and all its children"""
"""Deprecated. Show the node path and all its children"""
print("Warning: NodePath.showAllDescendants() is deprecated.")
self.show()
for child in self.getChildren():
child.showAllDescendants()
@ -81,9 +90,12 @@ del showAllDescendants
#####################################################################
def isolate(self):
"""Show the node path and hide its siblings"""
"""Deprecated. Show the node path and hide its siblings"""
print("Warning: NodePath.isolate() is deprecated.")
self.showAllDescendants()
self.hideSiblings()
for sib in self.getParent().getChildren():
if sib.node() != self.node():
sib.hide()
Dtool_funcToMethod(isolate, NodePath)
del isolate
#####################################################################
@ -101,7 +113,8 @@ del remove
#####################################################################
def lsNames(self):
"""Walk down a tree and print out the path"""
"""Deprecated. Walk down a tree and print out the path"""
print("Warning: NodePath.lsNames() is deprecated.")
if self.isEmpty():
print("(empty)")
else:
@ -114,7 +127,8 @@ Dtool_funcToMethod(lsNames, NodePath)
del lsNames
#####################################################################
def lsNamesRecurse(self, indentString=' '):
"""Walk down a tree and print out the path"""
"""Deprecated. Walk down a tree and print out the path"""
print("Warning: NodePath.lsNamesRecurse() is deprecated.")
for nodePath in self.getChildren():
type = nodePath.node().getType().getName()
name = nodePath.getName()
@ -125,7 +139,8 @@ Dtool_funcToMethod(lsNamesRecurse, NodePath)
del lsNamesRecurse
#####################################################################
def reverseLsNames(self):
"""Walk up a tree and print out the path to the root"""
"""Deprecated. Walk up a tree and print out the path to the root"""
print("Warning: NodePath.reverseLsNames() is deprecated.")
ancestors = list(self.getAncestors())
ancestry = ancestors.reverse()
indentString = ""
@ -139,8 +154,8 @@ Dtool_funcToMethod(reverseLsNames, NodePath)
del reverseLsNames
#####################################################################
def getAncestry(self):
"""Get a list of a node path's ancestors"""
print("NodePath.getAncestry() is deprecated. Use get_ancestors() instead.""")
"""Deprecated. Get a list of a node path's ancestors"""
print("NodePath.getAncestry() is deprecated. Use get_ancestors() instead.")
ancestors = list(self.getAncestors())
ancestors.reverse()
return ancestors
@ -151,8 +166,9 @@ del getAncestry
def pPrintString(self, other = None):
"""
pretty print
Deprecated. pretty print
"""
print("NodePath.pPrintString() is deprecated.")
if __debug__:
# Normally I would have put the if __debug__ around
# the entire funciton, the that doesn't seem to work
@ -183,7 +199,8 @@ del pPrintString
#####################################################################
def printPos(self, other = None, sd = 2):
""" Pretty print a node path's pos """
""" Deprecated. Pretty print a node path's pos """
print("NodePath.printPos() is deprecated.")
formatString = '%0.' + '%d' % sd + 'f'
if other:
pos = self.getPos(other)
@ -201,7 +218,8 @@ del printPos
#####################################################################
def printHpr(self, other = None, sd = 2):
""" Pretty print a node path's hpr """
""" Deprecated. Pretty print a node path's hpr """
print("NodePath.printHpr() is deprecated.")
formatString = '%0.' + '%d' % sd + 'f'
if other:
hpr = self.getHpr(other)
@ -219,7 +237,8 @@ del printHpr
#####################################################################
def printScale(self, other = None, sd = 2):
""" Pretty print a node path's scale """
""" Deprecated. Pretty print a node path's scale """
print("NodePath.printScale() is deprecated.")
formatString = '%0.' + '%d' % sd + 'f'
if other:
scale = self.getScale(other)
@ -237,7 +256,8 @@ Dtool_funcToMethod(printScale, NodePath)
del printScale
#####################################################################
def printPosHpr(self, other = None, sd = 2):
""" Pretty print a node path's pos and, hpr """
""" Deprecated. Pretty print a node path's pos and, hpr """
print("NodePath.printPosHpr() is deprecated.")
formatString = '%0.' + '%d' % sd + 'f'
if other:
pos = self.getPos(other)
@ -260,7 +280,8 @@ Dtool_funcToMethod(printPosHpr, NodePath)
del printPosHpr
#####################################################################
def printPosHprScale(self, other = None, sd = 2):
""" Pretty print a node path's pos, hpr, and scale """
""" Deprecated. Pretty print a node path's pos, hpr, and scale """
print("NodePath.printPosHprScale() is deprecated.")
formatString = '%0.' + '%d' % sd + 'f'
if other:
pos = self.getPos(other)
@ -289,6 +310,8 @@ del printPosHprScale
#####################################################################
def printTransform(self, other = None, sd = 2, fRecursive = 0):
"Deprecated."
print("NodePath.printTransform() is deprecated.")
from panda3d.core import Vec3
fmtStr = '%%0.%df' % sd
name = self.getName()
@ -327,7 +350,8 @@ del printTransform
def iPos(self, other = None):
""" Set node path's pos to 0, 0, 0 """
""" Deprecated. Set node path's pos to 0, 0, 0 """
print("NodePath.iPos() is deprecated.")
if other:
self.setPos(other, 0, 0, 0)
else:
@ -337,7 +361,8 @@ del iPos
#####################################################################
def iHpr(self, other = None):
""" Set node path's hpr to 0, 0, 0 """
""" Deprecated. Set node path's hpr to 0, 0, 0 """
print("NodePath.iHpr() is deprecated.")
if other:
self.setHpr(other, 0, 0, 0)
else:
@ -347,7 +372,8 @@ Dtool_funcToMethod(iHpr, NodePath)
del iHpr
#####################################################################
def iScale(self, other = None):
""" SEt node path's scale to 1, 1, 1 """
""" Deprecated. Set node path's scale to 1, 1, 1 """
print("NodePath.iScale() is deprecated.")
if other:
self.setScale(other, 1, 1, 1)
else:
@ -357,7 +383,8 @@ Dtool_funcToMethod(iScale, NodePath)
del iScale
#####################################################################
def iPosHpr(self, other = None):
""" Set node path's pos and hpr to 0, 0, 0 """
""" Deprecated. Set node path's pos and hpr to 0, 0, 0 """
print("NodePath.iPosHpr() is deprecated.")
if other:
self.setPosHpr(other, 0, 0, 0, 0, 0, 0)
else:
@ -367,7 +394,8 @@ Dtool_funcToMethod(iPosHpr, NodePath)
del iPosHpr
#####################################################################
def iPosHprScale(self, other = None):
""" Set node path's pos and hpr to 0, 0, 0 and scale to 1, 1, 1 """
""" Deprecated. Set node path's pos and hpr to 0, 0, 0 and scale to 1, 1, 1 """
print("NodePath.iPosHprScale() is deprecated.")
if other:
self.setPosHprScale(other, 0, 0, 0, 0, 0, 0, 1, 1, 1)
else:
@ -417,11 +445,13 @@ del deselect
#####################################################################
def showCS(self, mask = None):
"""
Deprecated.
Shows the collision solids at or below this node. If mask is
not None, it is a BitMask32 object (e.g. WallBitmask,
CameraBitmask) that indicates which particular collision
solids should be made visible; otherwise, all of them will be.
"""
print("NodePath.showCS() is deprecated. Use findAllMatches('**/+CollisionNode').show() instead.")
npc = self.findAllMatches('**/+CollisionNode')
for p in range(0, npc.getNumPaths()):
np = npc[p]
@ -433,11 +463,13 @@ del showCS
#####################################################################
def hideCS(self, mask = None):
"""
Deprecated.
Hides the collision solids at or below this node. If mask is
not None, it is a BitMask32 object (e.g. WallBitmask,
CameraBitmask) that indicates which particular collision
solids should be hidden; otherwise, all of them will be.
"""
print("NodePath.hideCS() is deprecated. Use findAllMatches('**/+CollisionNode').hide() instead.")
npc = self.findAllMatches('**/+CollisionNode')
for p in range(0, npc.getNumPaths()):
np = npc[p]
@ -621,6 +653,7 @@ del getNumDescendants
#####################################################################
def removeNonCollisions(self):
# remove anything that is not collision-related
print("NodePath.removeNonCollisions() is deprecated")
stack = [self]
while len(stack):
np = stack.pop()

View File

@ -1,20 +0,0 @@
#if $[OSX_PLATFORM]
#output extensions_darwin.py
#### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
################################# DO NOT EDIT ###########################
# This defines the shared-library filename extension that is built and
# imported on OSX. It's normally .dylib, but in certain Python and
# OSX versions (for instance, Python 2.4 on OSX 10.4), it appears that
# we need to generate and import .so files instead, since Python won't
# import the .dylibs directly. This is controlled via the BUNDLE_EXT
# variable defined in Config.pp.
#if $[BUNDLE_EXT]
dll_ext = "$[BUNDLE_EXT]"
#else
dll_ext = ".dylib"
#endif
#end extensions_darwin.py
#endif // OSX_PLATFORM

3
direct/src/extensions_native/VBase3_extensions.py Executable file → Normal file
View File

@ -2,6 +2,9 @@
Methods to extend functionality of the VBase3 class
"""
from panda3d.core import VBase3
from .extension_native_helpers import Dtool_funcToMethod
def pPrintValues(self):
"""
Pretty print

4
direct/src/extensions_native/VBase4_extensions.py Executable file → Normal file
View File

@ -2,6 +2,9 @@
Methods to extend functionality of the VBase4 class
"""
from panda3d.core import VBase4
from .extension_native_helpers import Dtool_funcToMethod
def pPrintValues(self):
"""
Pretty print
@ -16,6 +19,5 @@ def asTuple(self):
"""
print("Warning: VBase4.asTuple() is no longer needed and deprecated. Use the vector directly instead.")
return tuple(self)
Dtool_funcToMethod(asTuple, VBase4)
del asTuple

View File

@ -1,28 +0,0 @@
import sys
main_dir = Filename()
if sys.argv and sys.argv[0]:
main_dir = Filename.from_os_specific(sys.argv[0])
if main_dir.empty():
# We must be running in the Python interpreter directly, so return the CWD.
main_dir = ExecutionEnvironment.get_cwd()
else:
main_dir.make_absolute()
main_dir = Filename(main_dir.get_dirname())
ExecutionEnvironment.shadow_environment_variable('MAIN_DIR', main_dir.to_os_specific())
del sys, main_dir
def Dtool_funcToMethod(func, cls, method_name=None):
"""Adds func to class so it is an accessible method; use method_name to specify the name to be used for calling the method.
The new method is accessible to any instance immediately."""
#if sys.version_info < (3, 0):
# func.im_class = cls
func.im_func = func
func.im_self = None
if not method_name:
method_name = func.__name__
cls.DtoolClassDict[method_name] = func;

View File

@ -1,122 +1,10 @@
### Tools
__all__ = ["Dtool_ObjectToDict", "Dtool_funcToMethod", "Dtool_PreloadDLL"]
__all__ = ["Dtool_ObjectToDict", "Dtool_funcToMethod"]
import imp, sys, os
# The following code exists to work around a problem that exists
# with Python 2.5 or greater.
# Specifically, Python 2.5 is designed to import files named *.pyd
# only; it will not import files named *.dll (or *.so). We work
# around this problem by explicitly preloading all of the dll's we
# expect to need.
dll_suffix = ''
if sys.platform == "win32":
# On Windows, dynamic libraries end in ".dll".
dll_ext = '.dll'
module_ext = '.pyd'
# We allow the caller to preload dll_suffix into the sys module.
dll_suffix = getattr(sys, 'dll_suffix', None)
if dll_suffix is None:
# Otherwise, we try to determine it from the executable name:
# python_d.exe implies _d across the board.
dll_suffix = ''
if sys.executable.endswith('_d.exe'):
dll_suffix = '_d'
elif sys.platform == "darwin":
# On OSX, the dynamic libraries usually end in .dylib, but
# sometimes we need .so.
try:
from direct.extensions_native.extensions_darwin import dll_ext
except ImportError:
dll_ext = '.dylib'
module_ext = '.so'
else:
# On most other UNIX systems (including linux), .so is used.
dll_ext = '.so'
module_ext = '.so'
if sys.platform == "win32":
# On Windows, we must furthermore ensure that the PATH is modified
# to locate all of the DLL files.
# First, search for the directory that contains all of our compiled
# modules.
target = None
filename = "libpandaexpress%s%s" % (dll_suffix, dll_ext)
for dir in sys.path + [sys.prefix]:
lib = os.path.join(dir, filename)
if (os.path.exists(lib)):
target = dir
if target == None:
message = "Cannot find %s" % (filename)
raise ImportError(message)
# And add that directory to the system path.
path = os.environ["PATH"]
if not path.startswith(target + ";"):
os.environ["PATH"] = target + ";" + path
def Dtool_FindModule(module):
# Finds a .pyd module on the Python path.
filename = module.replace('.', os.path.sep) + module_ext
for dir in sys.path:
lib = os.path.join(dir, filename)
if (os.path.exists(lib)):
return lib
return None
def Dtool_PreloadDLL(module):
if module in sys.modules:
return
# First find it as a .pyd module on the Python path.
if Dtool_FindModule(module):
# OK, we should have no problem importing it as is.
return
# Nope, we'll need to search for a dynamic lib and preload it.
# Search for the appropriate directory.
target = None
filename = module.replace('.', os.path.sep) + dll_suffix + dll_ext
for dir in sys.path + [sys.prefix]:
lib = os.path.join(dir, filename)
if (os.path.exists(lib)):
target = dir
break
if target is None:
message = "DLL loader cannot find %s." % (module)
raise ImportError(message)
# Now import the file explicitly.
pathname = os.path.join(target, filename)
imp.load_dynamic(module, pathname)
# Nowadays, we can compile libpandaexpress with libpanda into a
# .pyd file called panda3d/core.pyd which can be imported without
# any difficulty. Let's see if this is the case.
# In order to support things like py2exe that play games with the
# physical python files on disk, we can't entirely rely on
# Dtool_FindModule to find our panda3d.core module. However, we
# should be able to import it. To differentiate the old-style Panda
# build (with .dll's) from the new-style Panda build (with .pyd's), we
# first try to import panda3d.core directly; if it succeeds we're in a
# new-style build, and if it fails we must be in an old-style build.
try:
from panda3d.core import *
except ImportError:
Dtool_PreloadDLL("libpandaexpress")
from libpandaexpress import *
def Dtool_ObjectToDict(cls, name, obj):
cls.DtoolClassDict[name] = obj;
cls.DtoolClassDict[name] = obj
def Dtool_funcToMethod(func, cls, method_name=None):
"""Adds func to class so it is an accessible method; use method_name to specify the name to be used for calling the method.
@ -127,4 +15,4 @@ def Dtool_funcToMethod(func, cls, method_name=None):
func.im_self = None
if not method_name:
method_name = func.__name__
cls.DtoolClassDict[method_name] = func;
cls.DtoolClassDict[method_name] = func

View File

@ -1,3 +0,0 @@
/genPyCode
/genPyCode.bat
/genPyCode.py

View File

@ -1,344 +0,0 @@
""" This module implements genPyCode, which is itself a generated
script with a few default parameters filled in. This module allows
the user to specify alternate parameters on the command line. """
import getopt
import sys
import os
import time
from direct.ffi import FFIConstants
# Define a help string for the user
helpString ="""
genPyCode -h
genPyCode
genPyCode [opts] -i libdtoolconfig libcode1 libcode2 ...
This script generates Python wrappers to interface with the C++
libraries that have already been run through interrogate. It is
necessary to run this script after building the Panda tools for the
first time, or after any major change in which some of the interface
may have changed.
The default options are baked into genPyCode by ppremake and need not
be specified. However, it is possible to override these on the
command line if you need to fine-tune the behavior of genPyCode for
some reason. Most often, the only needed change will be to add one or
more additional libraries to the list of libraries instrumented by
default.
Options:
-h print this message
-v verbose
-d generate HTML documentation too
-C dir directory to write output code
-H dir directory to write output HTML
-x dir directory to pull extension code from
-i lib interrogate library
-e dir directory to search for *.in files (may be repeated)
-p dir directory to search for Python source files (may be repeated)
-r remove the default library list; instrument only named libraries
-O no C++ comments or assertion statements
-n Don't use squeezeTool to squeeze the result into one .pyz file
-s Don't delete source files after squeezing
Any additional names listed on the command line are taken to be names
of libraries that are to be instrumented.
"""
HTMLHeader = """
<html>
<head>
<title>Panda3D documentation generated %s</title>
</head>
<body>
"""
HTMLFooter = """
</body>
</html>
"""
# Initialize variables
outputCodeDir = ''
outputHTMLDir = ''
directDir = ''
extensionsDir = ''
interrogateLib = ''
codeLibs = []
etcPath = []
pythonSourcePath = []
doSqueeze = True
deleteSourceAfterSqueeze = True
doHTML = False
native = False # This is set by genPyCode.py
def doGetopts():
global outputCodeDir
global outputHTMLDir
global extensionsDir
global interrogateLib
global codeLibs
global doSqueeze
global deleteSourceAfterSqueeze
global doHTML
global etcPath
global pythonSourcePath
# These options are allowed but are flagged as warnings (they are
# deprecated with the new genPyCode script):
# -g adds libgateway
# -t adds libtoontown
# -p adds libpirates
# -o adds libopt
FFIConstants.notify.setDebug(0)
FFIConstants.notify.setInfo(0)
# Extract the args the user passed in
try:
opts, pargs = getopt.getopt(sys.argv[1:], 'hvdOC:H:x:Ni:e:p:rns')
except e:
# User passed in a bad option, print the error and the help, then exit
print(e)
print(helpString)
sys.exit()
# Store the option values into our variables
for opt in opts:
flag, value = opt
if (flag == '-h'):
print(helpString)
sys.exit()
elif (flag == '-v'):
if not FFIConstants.notify.getInfo():
FFIConstants.notify.setInfo(1)
else:
FFIConstants.notify.setDebug(1)
elif (flag == '-d'):
doHTML = True
elif (flag == '-C'):
outputCodeDir = value
elif (flag == '-H'):
outputHTMLDir = value
elif (flag == '-x'):
extensionsDir = value
elif (flag == '-i'):
interrogateLib = value
elif (flag == '-e'):
etcPath.append(value)
elif (flag == '-p'):
pythonSourcePath.append(value)
elif (flag == '-r'):
codeLibs = []
elif (flag == '-O'):
FFIConstants.wantComments = 0
FFIConstants.wantTypeChecking = 0
elif (flag == '-n'):
doSqueeze = False
elif (flag == '-s'):
deleteSourceAfterSqueeze = False
else:
FFIConstants.notify.error('illegal option: ' + flag)
# Check for old, no-longer-used parameter:
invalidParameters = [
'linux', 'win-debug', 'win-release', 'win-publish',
'install', 'release'
]
if pargs and pargs[0] in invalidParameters:
FFIConstants.notify.warning("parameter is deprecated: %s" % (pargs[0]))
del pargs[0]
# Store the program arguments into the codeLibs
for arg in pargs:
arg = arg.strip()
if arg:
codeLibs.append(arg)
# Make sure each name appears on codeLibs exactly once.
newLibs = []
for codeLib in codeLibs:
if codeLib not in newLibs:
newLibs.append(codeLib)
codeLibs = newLibs
def doErrorCheck():
global outputCodeDir
global outputHTMLDir
global extensionsDir
global interrogateLib
global codeLibs
global doSqueeze
global etcPath
# Now do some error checking and verbose output
if (not interrogateLib):
FFIConstants.notify.error('You must specify an interrogate library (-i lib)')
else:
FFIConstants.notify.debug('Setting interrogate library to: ' + interrogateLib)
FFIConstants.InterrogateModuleName = interrogateLib
if (not outputCodeDir):
FFIConstants.notify.info('Setting output code directory to current directory')
outputCodeDir = '.'
elif (not os.path.exists(outputCodeDir)):
FFIConstants.notify.info('Directory does not exist, creating: ' + outputCodeDir)
os.mkdir(outputCodeDir)
FFIConstants.notify.info('Setting output code directory to: ' + outputCodeDir)
else:
FFIConstants.notify.info('Setting output code directory to: ' + outputCodeDir)
if doHTML:
if (not outputHTMLDir):
FFIConstants.notify.info('Setting output HTML directory to current directory')
outputHTMLDir = '.'
elif (not os.path.exists(outputHTMLDir)):
FFIConstants.notify.info('Directory does not exist, creating: ' + outputHTMLDir)
os.makedirs(outputHTMLDir)
FFIConstants.notify.info('Setting output HTML directory to: ' + outputHTMLDir)
else:
FFIConstants.notify.info('Setting output HTML directory to: ' + outputHTMLDir)
if (not extensionsDir):
FFIConstants.notify.debug('Setting extensions directory to current directory')
extensionsDir = '.'
elif (not os.path.exists(extensionsDir)):
FFIConstants.notify.error('Directory does not exist: ' + extensionsDir)
else:
FFIConstants.notify.debug('Setting extensions directory to: ' + extensionsDir)
if (not codeLibs):
FFIConstants.notify.error('You must specify one or more libraries to generate code from')
else:
FFIConstants.notify.debug('Generating code for: ' + repr(codeLibs))
FFIConstants.CodeModuleNameList = codeLibs
def generateNativeWrappers():
from direct.extensions_native.extension_native_helpers import Dtool_PreloadDLL
# Empty out the output directories of unnecessary crud from
# previous runs before we begin.
for file in os.listdir(outputCodeDir):
pathname = os.path.join(outputCodeDir, file)
if not os.path.isdir(pathname):
os.unlink(pathname)
# Generate __init__.py
initFilename = os.path.join(outputCodeDir, '__init__.py')
init = open(initFilename, 'w')
# Generate PandaModules.py
pandaModulesFilename = os.path.join(outputCodeDir, 'PandaModules.py')
pandaModules = open(pandaModulesFilename, 'w')
# Copy in any helper classes from the extensions_native directory
extensionHelperFiles = ['extension_native_helpers.py']
for name in extensionHelperFiles:
inFilename = os.path.join(extensionsDir, name)
outFilename = os.path.join(outputCodeDir, name)
if os.path.exists(inFilename):
inFile = open(inFilename, 'r')
outFile = open(outFilename, 'w')
outFile.write(inFile.read())
# Generate a series of "libpandaModules.py" etc. files, one for
# each named module.
for moduleName in FFIConstants.CodeModuleNameList:
print('Importing code library: ' + moduleName)
Dtool_PreloadDLL(moduleName)
__import__(moduleName)
module = sys.modules[moduleName]
# Make a suitable meta module name
metaModuleName = ""
nextCap = False
for ch in moduleName:
if ch == '.':
nextCap = True
elif nextCap:
metaModuleName += ch.upper()
nextCap = False
else:
metaModuleName += ch
metaModuleName += "Modules"
# Wrap the import in a try..except so that we can continue if
# the library isn't present. This is particularly necessary
# in the runtime (plugin) environment, where all libraries are
# not necessarily downloaded.
if sys.version_info >= (3, 0):
pandaModules.write('try:\n from .%s import *\nexcept ImportError as err:\n if "DLL loader cannot find" not in str(err):\n raise\n' % (metaModuleName))
else:
pandaModules.write('try:\n from %s import *\nexcept ImportError, err:\n if "DLL loader cannot find" not in str(err):\n raise\n' % (metaModuleName))
# Not sure if this message is helpful or annoying.
#pandaModules.write(' print("Failed to import %s")\n' % (moduleName))
pandaModules.write('\n')
moduleModulesFilename = os.path.join(outputCodeDir, '%s.py' % (metaModuleName))
moduleModules = open(moduleModulesFilename, 'w')
if sys.version_info >= (3, 0):
moduleModules.write('from .extension_native_helpers import *\n')
else:
moduleModules.write('from extension_native_helpers import *\n')
moduleModules.write('Dtool_PreloadDLL("%s")\n' % (moduleName))
moduleModules.write('from %s import *\n\n' % (moduleName))
# Now look for extensions
for className, classDef in module.__dict__.items():
if isinstance(classDef, type):
extensionFilename = os.path.join(extensionsDir, '%s_extensions.py' % (className))
if os.path.exists(extensionFilename):
print(' Found extensions for class: %s' % (className))
extension = open(extensionFilename, 'r')
moduleModules.write(extension.read())
moduleModules.write('\n')
def run():
global outputCodeDir
global outputHTMLDir
global directDir
global extensionsDir
global interrogateLib
global codeLibs
global doSqueeze
global deleteSourceAfterSqueeze
global etcPath
global pythonSourcePath
doGetopts()
doErrorCheck()
# Ok, now we can start generating code
if native:
generateNativeWrappers()
else:
from direct.ffi import FFIInterrogateDatabase
db = FFIInterrogateDatabase.FFIInterrogateDatabase(etcPath = etcPath)
db.generateCode(outputCodeDir, extensionsDir)
if doSqueeze:
db.squeezeGeneratedCode(outputCodeDir, deleteSourceAfterSqueeze)
if doHTML:
from direct.directscripts import gendocs
from panda3d.core import PandaSystem
versionString = '%s %s' % (
PandaSystem.getDistributor(), PandaSystem.getVersionString())
gendocs.generate(versionString, etcPath, pythonSourcePath,
outputHTMLDir, HTMLHeader % time.asctime(),
HTMLFooter, '', '.html')

View File

@ -1,24 +0,0 @@
# create a DirectNotify category for FFI modules
from direct.directnotify.DirectNotifyGlobal import *
notify = directNotify.newCategory("FFI")
# This is the name of the file that the importing code will be stored
importModuleName = 'PandaModules'
# A header for all the generated files
generatedHeader = '# This file is automatically generated. It would be unwise to edit.\n\n'
# These modules should come from somewhere outside this program
# Maybe in an environment variable, or by looking at what you are
# attached to?
CodeModuleNameList = []
# This is the module that contains the interrogate functions
InterrogateModuleName = None
# Should FFI output C++ comments with the source code?
wantComments = 1
# Should FFI output type assertions?
wantTypeChecking = 1

View File

@ -1,32 +0,0 @@
import FFIConstants
class FFIEnvironment:
def __init__(self):
self.reset()
def reset(self):
self.types = {}
self.globalFunctions = []
self.downcastFunctions = []
self.globalValues = []
self.manifests = []
def addType(self, typeDescriptor, name):
if name in self.types:
FFIConstants.notify.info('Redefining type named: ' + name)
self.types[name] = typeDescriptor
def getTypeNamed(self, name):
try:
self.types[name]
except KeyError:
raise 'Type not found in FFIEnvironment'
def addGlobalFunction(self, typeDescriptors):
self.globalFunctions.extend(typeDescriptors)
def addDowncastFunction(self, typeDescriptor):
self.downcastFunctions.append(typeDescriptor)
def addGlobalValue(self, typeDescriptor):
self.globalValues.append(typeDescriptor)
def addManifest(self, typeDescriptor):
self.manifests.append(typeDescriptor)

View File

@ -1,268 +0,0 @@
from new import instance
import FFIConstants
WrapperClassMap = {}
DowncastMap = {}
# For testing, you can turn verbose and debug on
# FFIConstants.notify.setInfo(1)
# FFIConstants.notify.setDebug(1)
# Uncomment the notify statements if you need to debug,
# otherwise leave them commented out to prevent runtime
# overhead of calling them
# Register a python class in the type map if it is a typed object
# The type map is used for upcasting and downcasting through
# the panda inheritance chain
def registerInTypeMap(pythonClass):
from pandac import TypedObject
if issubclass(pythonClass, TypedObject.TypedObject):
typeIndex = pythonClass.getClassType().getIndex()
WrapperClassMap[typeIndex] = pythonClass
def funcToMethod(func, clas, method_name=None):
"""Adds func to class so it is an accessible method; use method_name to specify the name to be used for calling the method.
The new method is accessible to any instance immediately."""
func.im_class=clas
func.im_func=func
func.im_self=None
if not method_name:
clas.__dict__[method_name]=func
else:
clas.__dict__[func.__name__]=func
def FFIInstance(classdef, this = 0, userManagesMemory = 0):
answer = instance(classdef)
answer.this = this
answer.userManagesMemory = userManagesMemory
return answer
class FFIExternalObject:
def __init__(self, *_args):
# By default, we do not manage our own memory
self.userManagesMemory = 0
# Start with a null this pointer
self.this = 0
def destructor(self):
# Base destructor in case you do not define one
pass
def getLineage(self, thisClass, targetBaseClass):
# Recursively determine the path in the heirarchy tree from thisClass
# to the targetBaseClass
return self.getLineageInternal(thisClass, targetBaseClass, [thisClass])
def getLineageInternal(self, thisClass, targetBaseClass, chain):
# Recursively determine the path in the heirarchy tree from thisClass
# to the targetBaseClass
#FFIConstants.notify.debug('getLineageInternal: checking %s to %s'
# % (thisClass.__name__, targetBaseClass.__name__))
if (targetBaseClass in thisClass.__bases__):
# Found a link
return chain + [targetBaseClass]
elif (len(thisClass.__bases__) == 0):
# No possible links
return 0
else:
# recurse
for base in thisClass.__bases__:
res = self.getLineageInternal(base, targetBaseClass, chain+[base])
if res:
# FFIConstants.notify.debug('getLineageInternal: found path: ' + repr(res))
return res
# Not found anywhere
return 0
def getDowncastFunctions(self, thisClass, baseClass):
#FFIConstants.notify.debug(
# 'getDowncastFunctions: Looking for downcast function from %s to %s'
# % (baseClass.__name__, thisClass.__name__))
lineage = self.getLineage(thisClass, baseClass)
# Start with an empty list of downcast functions
downcastFunctionList = []
# If it could not find the baseClass anywhere in the lineage,
# return empty
if not lineage:
return []
# Walk along the lineage looking for downcast functions from
# class to class+1. Start at the top and work downwards.
top = len(lineage) - 1
for i in range(top):
toClass = lineage[top - i - 1]
fromClass = lineage[top - i]
downcastFuncName = ('downcastTo' + toClass.__name__
+ 'From' + fromClass.__name__)
# Look over this classes global modules dictionaries
# for the downcast function name
for globmod in toClass.__CModuleDowncasts__:
func = globmod.__dict__.get(downcastFuncName)
if func:
#FFIConstants.notify.debug(
# 'getDowncastFunctions: Found downcast function %s in %s'
# % (downcastFuncName, globmod.__name__))
downcastFunctionList.append(func)
return downcastFunctionList
def lookUpNewType(self, typeHandle, rootType):
# We tried to downcast to an unknown type. Try to figure out
# the lowest type we *do* know, so we can downcast to that
# type instead.
if typeHandle.getNumParentClasses() == 0:
# This type has no parents! That shouldn't happen.
FFIConstants.notify.warning("Unknown class type: %s has no parents!" % (typeHandle.getName()))
return None
parentType = typeHandle.getParentTowards(rootType, self)
parentIndex = parentType.getIndex()
parentWrapperClass = WrapperClassMap.get(parentIndex)
if parentWrapperClass == None:
parentWrapperClass = self.lookUpNewType(parentType, rootType)
if parentWrapperClass != None:
# If the parent class is known, then record that this
# class is a derivation of that parent class.
WrapperClassMap[typeHandle.getIndex()] = parentWrapperClass
return parentWrapperClass
def setPointer(self):
# See what type it really is and downcast to that type (if necessary)
# Look up the TypeHandle in the dict. get() returns None if it is not there
index = self.getTypeIndex()
exactWrapperClass = WrapperClassMap.get(index)
if exactWrapperClass == None:
# This is an unknown class type. Perhaps it derives from
# a class type we know.
exactWrapperClass = self.lookUpNewType(self.getType(), self.getClassType())
# We do not need to downcast if we already have the same class
if (exactWrapperClass and (exactWrapperClass != self.__class__)):
# Create a new wrapper class instance
#exactObject = exactWrapperClass(None)
exactObject = FFIInstance(exactWrapperClass)
# Get the downcast pointer that has had all the downcast
# funcs called
downcastObject = self.downcast(exactWrapperClass)
exactObject.this = downcastObject.this
exactObject.userManagesMemory = downcastObject.userManagesMemory
# Make sure the original downcast object does not get
# garbage collected so that the exactObject will not get
# gc'd thereby transferring ownership of the object to
# this new exactObject
downcastObject.userManagesMemory = 0
return exactObject
else:
return self
def downcast(self, toClass):
fromClass = self.__class__
#FFIConstants.notify.debug('downcast: downcasting from %s to %s' % \
# (fromClass.__name__, toClass.__name__))
# Check the cache to see if we have looked this up before
downcastChain = DowncastMap.get((fromClass, toClass))
if downcastChain == None:
downcastChain = self.getDowncastFunctions(toClass, fromClass)
#FFIConstants.notify.debug('downcast: computed downcast chain: ' + repr(downcastChain))
# Store it for next time
DowncastMap[(fromClass, toClass)] = downcastChain
newObject = self
for downcastFunc in downcastChain:
#FFIConstants.notify.debug('downcast: downcasting %s using %s' % \
# (newObject.__class__.__name__, downcastFunc))
newObject = downcastFunc(newObject)
return newObject
def compareTo(self, other):
# By default, we compare the C++ pointers
# Some classes will override the compareTo operator with their own
# logic in C++ (like vectors and matrices for instance)
try:
if self.this < other.this:
return -1
if self.this > other.this:
return 1
else:
return 0
except:
return 1
def __cmp__(self, other):
# Only use the C++ compareTo if they are the same class
if isinstance(other, self.__class__):
return self.compareTo(other)
# Otherwise, they must not be the same
# Just do a basic python id compare
else:
return cmp(id(self), id(other))
def __repr__(self):
# Lots of Panda classes have an output function defined that takes an Ostream
# We create a LineStream for the output function to write to, then we extract
# the string out of it and return it as our str
try:
from pandac import LineStream
lineStream = LineStream.LineStream()
self.output(lineStream)
baseRepr = lineStream.getLine()
except AssertionError, e:
raise AssertionError, e
except:
baseRepr = ('[' + self.__class__.__name__ + ' at: ' + repr(self.this) + ']')
# In any case, return the baseRepr
return baseRepr
def __str__(self):
# This is a more complete version of printing which shows the object type
# and pointer, plus the output from write() or output() whichever is defined
# Print this info for all objects
baseRepr = ('[' + self.__class__.__name__ + ' at: ' + repr(self.this) + ']')
# Lots of Panda classes have an write or output function defined that takes an Ostream
# We create a LineStream for the write or output function to write to, then we extract
# the string out of it and return it as our repr
from pandac import LineStream
lineStream = LineStream.LineStream()
try:
# First try the write function, that is the better one
self.write(lineStream)
while lineStream.isTextAvailable():
baseRepr = baseRepr + '\n' + lineStream.getLine()
except AssertionError, e:
raise AssertionError, e
except:
try:
# Sometimes write insists on a seconds parameter.
self.write(lineStream, 0)
while lineStream.isTextAvailable():
baseRepr = baseRepr + '\n' + lineStream.getLine()
except AssertionError, e:
raise AssertionError, e
except:
try:
# Ok, no write function, lets try output then
self.output(lineStream)
while lineStream.isTextAvailable():
baseRepr = baseRepr + '\n' + lineStream.getLine()
except AssertionError, e:
raise AssertionError, e
except:
pass
# In any case, return the baseRepr
return baseRepr
def __hash__(self):
return self.this

View File

@ -1,870 +0,0 @@
# Note: do not import this file directly, it is meant to be used as part of
# a Python script (generatePythonCode) that sets up variables that this
# module depends on
import string
import os
import glob
import FFIEnvironment
import FFITypes
import FFISpecs
import FFIRename
import FFIConstants
import FFIOverload
from direct.showbase.PythonUtil import *
FFIConstants.notify.info('Importing interrogate library: ' + FFIConstants.InterrogateModuleName)
# Note: we do a from lib import * here because we do not want
# to be dependent on the name of the interrogate library in this code
exec('from ' + FFIConstants.InterrogateModuleName + ' import *')
def constructGlobalFile(codeDir, CModuleName):
"""
Open a file that will hold the global values and functions code
"""
file = open(os.path.join(codeDir, CModuleName + 'Globals' + '.py'), 'w')
return file
def constructDowncastFile(codeDir, CModuleName):
"""
Open a file that will hold the global values and functions code
"""
file = open(os.path.join(codeDir, CModuleName + 'Downcasts' + '.py'), 'w')
return file
def constructImportFile(codeDir, CModuleName):
"""
Open a file that will hold the global values and functions code
"""
file = open(os.path.join(codeDir, CModuleName + 'Modules' + '.py'), 'w')
return file
def outputGlobalFileImports(file, methodList, CModuleName):
# Print the standard header
file.write(FFIConstants.generatedHeader)
file.write('# CMODULE [' + CModuleName + ']\n')
# Import Python's builtin types
file.write('from types import IntType, LongType, FloatType, NoneType, StringType\n')
file.write('from direct.ffi import FFIExternalObject\n')
# Import the C modules
CModuleList = []
for method in methodList:
if (not (method.typeDescriptor.moduleName in CModuleList)):
CModuleList.append(method.typeDescriptor.moduleName)
for CModuleName in CModuleList:
if CModuleName:
file.write('import ' + CModuleName + '\n')
moduleList = []
for method in methodList:
returnType = method.typeDescriptor.returnType.recursiveTypeDescriptor()
returnTypeName = returnType.foreignTypeName
if (not (returnTypeName in moduleList)):
if (returnType.__class__ == FFITypes.ClassTypeDescriptor):
moduleList.append(returnTypeName)
# Look at all the arguments
argTypes = method.typeDescriptor.argumentTypes
for argType in argTypes:
# Get the real return type (not derived)
argType = argType.typeDescriptor.recursiveTypeDescriptor()
if (not argType.isNested):
argTypeName = argType.foreignTypeName
# Do not put our own module in the import list
# Do not put modules already in the list (like a set)
if (not (argTypeName in moduleList)):
# If this is a class (not a primitive), put it on the list
if (argType.__class__ == FFITypes.ClassTypeDescriptor):
moduleList.append(argTypeName)
for moduleName in moduleList:
if moduleName:
file.write('import ' + moduleName + '\n')
file.write('import ' + moduleName + '1\n')
file.write('\n')
def outputImportFileImports(file, typeList, CModuleName):
"""
This is the file that we will import to get all the panda modules
"""
# Print the standard header
file.write(FFIConstants.generatedHeader)
file.write('# CMODULE [' + CModuleName + ']\n')
file.write('# Import the interrogate module\n')
file.write('import ' + FFIConstants.InterrogateModuleName + '\n')
file.write('\n')
file.write('# Import the C module\n')
file.write('import ' + CModuleName + '\n')
# Filter out only the class and enum type descriptors (not const, pointers, etc)
classTypeList = []
enumTypeList = []
for type in typeList:
if (type.__class__ == FFITypes.ClassTypeDescriptor):
if (not type.isNested):
classTypeList.append(type)
elif (type.__class__ == FFITypes.EnumTypeDescriptor):
if (not type.isNested):
enumTypeList.append(type)
# Sort the types based on inheritance, most generic first
classTypeList.sort(FFIOverload.inheritanceLevelSort)
moduleList = []
for type in classTypeList:
moduleList.append(type.foreignTypeName)
file.write('# Import enums into the global name space\n')
for type in enumTypeList:
file.write('from ' + type.enumName + ' import *\n')
file.write('\n')
file.write('# Import downcast functions\n')
file.write('from ' + CModuleName + 'Downcasts import *\n')
file.write('\n')
file.write('# Import classes\n')
for moduleName in moduleList:
if moduleName:
file.write('import ' + moduleName + '\n')
file.write('\n')
file.write('# Import classes2\n')
for moduleName in moduleList:
if moduleName:
file.write('import ' + moduleName + '1\n')
file.write('\n')
file.write('# Import the global module file into our name space\n')
file.write('from ' + CModuleName + 'Globals import *\n')
file.write('\n')
file.write('# Generate the classes\n')
#for moduleName in moduleList:
# file.write(moduleName + '.generateClass_' + moduleName + '()\n')
file.write('\n')
file.write('# Copy the classes into our own namespace\n')
for moduleName in moduleList:
file.write(moduleName + ' = ' + moduleName + '.' + moduleName + '\n')
file.write('\n')
file.write('# Put the classes in the wrapper class map\n')
file.write('from direct.ffi.FFIExternalObject import registerInTypeMap\n')
file.write('\n')
for moduleName in moduleList:
file.write('registerInTypeMap(' + moduleName + ')\n')
file.write('\n')
def getTypeName(typeIndex, scoped=0):
"""
Return a fully specified type name for this type index
Return the scoped name if asked for it
"""
nameComponents = []
name = ''
if scoped:
typeName = interrogate_type_scoped_name(typeIndex)
else:
typeName = interrogate_type_name(typeIndex)
if typeIndex == 0:
FFIConstants.notify.debug('typeIndex 0: ' + typeName)
if interrogate_type_is_wrapped(typeIndex):
typeName = getTypeName(interrogate_type_wrapped_type(typeIndex))
if interrogate_type_is_const(typeIndex):
nameComponents.append('const')
if interrogate_type_is_pointer(typeIndex):
nameComponents.append('ptr')
if interrogate_type_is_signed(typeIndex):
# signed is now built into the type name
#nameComponents.append('signed')
pass
if interrogate_type_is_unsigned(typeIndex):
# unsigned is now built into the type name
#nameComponents.append('unsigned')
pass
if interrogate_type_is_long(typeIndex):
nameComponents.append('long')
if interrogate_type_is_longlong(typeIndex):
nameComponents.append('longLong')
if interrogate_type_is_short(typeIndex):
nameComponents.append('short')
if (len(nameComponents) > 0):
typeName = string.capitalize(typeName[0]) + typeName[1:]
nameComponents.append(typeName)
for i in range(len(nameComponents)):
if (i == 0):
name = name + nameComponents[i]
else:
name = name + string.capitalize(nameComponents[i][0]) + nameComponents[i][1:]
FFIConstants.notify.debug('typeIndex: ' + repr(typeIndex) + ' typeName: ' + typeName + ' has name: ' + name)
if not name:
FFIConstants.notify.warning('typeIndex: ' + repr(typeIndex) + ' typeName: ' + typeName + ' has no name')
name = "UnnamedType"
return name
class FFIInterrogateDatabase:
def __init__(self, etcPath = []):
for dir in etcPath:
interrogate_add_search_directory(dir)
self.typeIndexMap = {}
self.environment = FFIEnvironment.FFIEnvironment()
def isDefinedType(self, typeIndex):
return typeIndex in self.typeIndexMap
def constructDescriptor(self, typeIndex):
if interrogate_type_is_atomic(typeIndex):
return self.constructPrimitiveTypeDescriptor(typeIndex)
elif interrogate_type_is_enum(typeIndex):
return self.constructEnumTypeDescriptor(typeIndex)
elif interrogate_type_is_wrapped(typeIndex):
if interrogate_type_is_pointer(typeIndex):
return self.constructPointerTypeDescriptor(typeIndex)
elif interrogate_type_is_const(typeIndex):
return self.constructConstTypeDescriptor(typeIndex)
elif (interrogate_type_is_class(typeIndex) or
interrogate_type_is_struct(typeIndex) or
interrogate_type_is_union(typeIndex)):
return self.constructClassTypeDescriptor(typeIndex)
elif (not interrogate_type_is_fully_defined(typeIndex)):
return self.constructClassTypeDescriptor(typeIndex)
else:
raise 'A type in the interrogate database was not recognized: '+ repr(typeIndex)
def constructPrimitiveTypeDescriptor(self, typeIndex):
if self.isDefinedType(typeIndex):
return self.typeIndexMap[typeIndex]
else:
descriptor = FFITypes.PrimitiveTypeDescriptor()
#descriptor.environment = self.environment
descriptor.atomicType = interrogate_type_atomic_token(typeIndex)
if interrogate_type_has_module_name(typeIndex):
descriptor.moduleName = 'lib' + interrogate_type_module_name(typeIndex)
descriptor.foreignTypeName = \
FFIRename.nonClassNameFromCppName(getTypeName(typeIndex))
descriptor.typeIndex = typeIndex
self.typeIndexMap[typeIndex] = descriptor
return descriptor
def constructEnumTypeDescriptor(self, typeIndex):
if self.isDefinedType(typeIndex):
return self.typeIndexMap[typeIndex]
else:
descriptor = FFITypes.EnumTypeDescriptor()
#descriptor.environment = self.environment
descriptor.isNested = interrogate_type_is_nested(typeIndex)
if descriptor.isNested:
outerTypeIndex = interrogate_type_outer_class(typeIndex)
descriptor.outerType = self.constructDescriptor(outerTypeIndex)
if interrogate_type_has_module_name(typeIndex):
descriptor.moduleName = 'lib' + interrogate_type_module_name(typeIndex)
# Enums are ints in C++ but we do not want to redefine the int type
# So we will just call them enums
descriptor.enumName = FFIRename.classNameFromCppName(getTypeName(typeIndex))
descriptor.foreignTypeName = '__enum__' + descriptor.enumName
numValues = interrogate_type_number_of_enum_values(typeIndex)
# Store the names and values of the enum in a dictionary
for i in range(numValues):
value = interrogate_type_enum_value(typeIndex, i)
name = FFIRename.classNameFromCppName(
interrogate_type_enum_value_name(typeIndex, i))
scopedName = FFIRename.classNameFromCppName(
interrogate_type_enum_value_scoped_name(typeIndex, i))
descriptor.values[name] = value
descriptor.typeIndex = typeIndex
self.typeIndexMap[typeIndex] = descriptor
return descriptor
def constructPointerTypeDescriptor(self, typeIndex):
if self.isDefinedType(typeIndex):
return self.typeIndexMap[typeIndex]
descriptor = FFITypes.PointerTypeDescriptor()
#descriptor.environment = self.environment
descriptor.isNested = interrogate_type_is_nested(typeIndex)
if descriptor.isNested:
outerTypeIndex = interrogate_type_outer_class(typeIndex)
descriptor.outerType = self.constructDescriptor(outerTypeIndex)
if interrogate_type_has_module_name(typeIndex):
descriptor.moduleName = 'lib' + interrogate_type_module_name(typeIndex)
descriptor.foreignTypeName = \
FFIRename.nonClassNameFromCppName(getTypeName(typeIndex))
descriptor.typeIndex = typeIndex
wrappedTypeIndex = interrogate_type_wrapped_type(typeIndex)
wrappedTypeDescriptor = self.constructDescriptor(wrappedTypeIndex)
descriptor.typeDescriptor = wrappedTypeDescriptor
self.typeIndexMap[typeIndex] = descriptor
return descriptor
def constructConstTypeDescriptor(self, typeIndex):
if self.isDefinedType(typeIndex):
return self.typeIndexMap[typeIndex]
descriptor = FFITypes.ConstTypeDescriptor()
#descriptor.environment = self.environment
descriptor.isNested = interrogate_type_is_nested(typeIndex)
if descriptor.isNested:
outerTypeIndex = interrogate_type_outer_class(typeIndex)
descriptor.outerType = self.constructDescriptor(outerTypeIndex)
if interrogate_type_has_module_name(typeIndex):
descriptor.moduleName = 'lib' + interrogate_type_module_name(typeIndex)
descriptor.foreignTypeName = \
FFIRename.nonClassNameFromCppName(getTypeName(typeIndex))
descriptor.typeIndex = typeIndex
wrappedTypeIndex = interrogate_type_wrapped_type(typeIndex)
wrappedTypeDescriptor = self.constructDescriptor(wrappedTypeIndex)
descriptor.typeDescriptor = wrappedTypeDescriptor
self.typeIndexMap[typeIndex] = descriptor
return descriptor
def constructParentTypeDescriptors(self, typeIndex):
numParents = interrogate_type_number_of_derivations(typeIndex)
descriptors = []
for i in range(numParents):
parentTypeIndex = interrogate_type_get_derivation(typeIndex, i)
if self.isDefinedType(parentTypeIndex):
parentTypeDescriptor = self.typeIndexMap[parentTypeIndex]
else:
parentTypeDescriptor = self.constructDescriptor(parentTypeIndex)
descriptors.append(parentTypeDescriptor)
return descriptors
def constructNestedTypeDescriptors(self, typeIndex):
nestedTypes = []
numNestedTypes = interrogate_type_number_of_nested_types(typeIndex)
for i in range(numNestedTypes):
nestedTypeIndex = interrogate_type_get_nested_type(typeIndex, i)
descriptor = self.constructDescriptor(nestedTypeIndex)
nestedTypes.append(descriptor)
return nestedTypes
def constructClassTypeDescriptor(self, typeIndex):
if self.isDefinedType(typeIndex):
return self.typeIndexMap[typeIndex]
typeName = FFIRename.classNameFromCppName(getTypeName(typeIndex))
if typeName == "PyObject":
# A special case: the PyObject type is really a native
# Python object, not to be molested--it's not really an
# FFI class object.
descriptor = FFITypes.PyObjectTypeDescriptor()
self.typeIndexMap[typeIndex] = descriptor
return descriptor
descriptor = FFITypes.ClassTypeDescriptor()
self.typeIndexMap[typeIndex] = descriptor
#descriptor.environment = self.environment
descriptor.foreignTypeName = typeName
if (typeName == "TypedObject"):
FFITypes.TypedObjectDescriptor = descriptor
descriptor.isNested = interrogate_type_is_nested(typeIndex)
if descriptor.isNested:
outerTypeIndex = interrogate_type_outer_class(typeIndex)
descriptor.outerType = self.constructDescriptor(outerTypeIndex)
if interrogate_type_has_module_name(typeIndex):
descriptor.moduleName = 'lib' + interrogate_type_module_name(typeIndex)
if FFIConstants.wantComments:
if interrogate_type_has_comment(typeIndex):
descriptor.comment = interrogate_type_comment(typeIndex)
descriptor.typeIndex = typeIndex
descriptor.instanceMethods = self.constructMemberFunctionSpecifications(typeIndex)
descriptor.upcastMethods = self.constructUpcastFunctionSpecifications(typeIndex)
# Constructing downcasts does not return the functions, it just puts them in the class
# See the comment in that function
self.constructDowncastFunctionSpecifications(typeIndex)
descriptor.filterOutStaticMethods()
descriptor.constructors = self.constructConstructorSpecifications(typeIndex)
descriptor.destructor = self.constructDestructorSpecification(typeIndex)
descriptor.parentTypes = self.constructParentTypeDescriptors(typeIndex)
descriptor.nestedTypes = self.constructNestedTypeDescriptors(typeIndex)
return descriptor
def constructFunctionTypeDescriptors(self, functionIndex):
# Store these values because they will be the same for all the wrappers
isVirtual = interrogate_function_is_virtual(functionIndex)
#environment = self.environment
foreignTypeName = interrogate_function_name(functionIndex)
if FFIConstants.wantComments:
prototype = interrogate_function_prototype(functionIndex)
if interrogate_function_has_comment(functionIndex):
comment = interrogate_function_comment(functionIndex)
else:
comment = ''
# Prepend lib to the module name it reports because that will be the name of
# the Python module we import. This is apparently stems from a makefile
# discrepency in the way we build the libraries
if interrogate_function_has_module_name(functionIndex):
moduleName = 'lib' + interrogate_function_module_name(functionIndex)
else:
moduleName = None
typeIndex = functionIndex
# Look at the Python wrappers for this function
numPythonWrappers = interrogate_function_number_of_python_wrappers(functionIndex)
if numPythonWrappers == 0:
# If there are no Python wrappers, it is because interrogate could not handle
# something about the function. Just return an empty list
return []
wrapperDescriptors = []
# Iterate over the wrappers constructing a FunctionTypeDescriptor for each
for i in range(numPythonWrappers):
descriptor = FFITypes.FunctionTypeDescriptor()
descriptor.isVirtual = isVirtual
#descriptor.environment = environment
descriptor.foreignTypeName = foreignTypeName
if FFIConstants.wantComments:
descriptor.comment = comment
descriptor.prototype = prototype
descriptor.moduleName = moduleName
descriptor.typeIndex = typeIndex
pythonFunctionIndex = interrogate_function_python_wrapper(functionIndex, i)
descriptor.wrapperName = interrogate_wrapper_name(pythonFunctionIndex)
# Even if it does not have a return value, it reports void which is better
# for generating code, so I will not even ask here
# if interrogate_wrapper_has_return_value(pythonFunctionIndex):
returnType = interrogate_wrapper_return_type(pythonFunctionIndex)
descriptor.returnType = self.constructDescriptor(returnType)
descriptor.argumentTypes = self.constructFunctionArgumentTypes(pythonFunctionIndex)
descriptor.userManagesMemory = interrogate_wrapper_caller_manages_return_value(pythonFunctionIndex)
descriptor.returnValueDestructor = interrogate_wrapper_return_value_destructor(pythonFunctionIndex)
wrapperDescriptors.append(descriptor)
return wrapperDescriptors
def constructFunctionArgumentTypes(self, functionIndex):
numArgs = interrogate_wrapper_number_of_parameters(functionIndex)
arguments = []
for argIndex in range(numArgs):
if interrogate_wrapper_parameter_has_name(functionIndex, argIndex):
name = FFIRename.nonClassNameFromCppName(
interrogate_wrapper_parameter_name(functionIndex, argIndex))
else:
name = ('parameter' + repr(argIndex))
descriptor = self.constructDescriptor(
interrogate_wrapper_parameter_type(functionIndex, argIndex))
argSpec = FFISpecs.MethodArgumentSpecification()
if interrogate_wrapper_parameter_is_this(functionIndex, argIndex):
argSpec.isThis = 1
argSpec.name = name
argSpec.typeDescriptor = descriptor
arguments.append(argSpec)
return arguments
def constructMemberFunctionSpecifications(self, typeIndex):
funcSpecs = []
numFuncs = interrogate_type_number_of_methods(typeIndex)
for i in range(numFuncs):
funcIndex = interrogate_type_get_method(typeIndex, i)
typeDescs = self.constructFunctionTypeDescriptors(funcIndex)
for typeDesc in typeDescs:
funcSpec = FFISpecs.MethodSpecification()
funcSpec.name = FFIRename.methodNameFromCppName(
interrogate_function_name(funcIndex),
getTypeName(typeIndex))
funcSpec.typeDescriptor = typeDesc
funcSpec.index = funcIndex
funcSpecs.append(funcSpec)
return funcSpecs
def constructUpcastFunctionSpecifications(self, typeIndex):
funcSpecs = []
numFuncs = interrogate_type_number_of_derivations(typeIndex)
for i in range(numFuncs):
if interrogate_type_derivation_has_upcast(typeIndex, i):
funcIndex = interrogate_type_get_upcast(typeIndex, i)
typeDescs = self.constructFunctionTypeDescriptors(funcIndex)
for typeDesc in typeDescs:
funcSpec = FFISpecs.MethodSpecification()
# We synthesize the upcast function name instead
# of using the name supplied by interrogate, to
# allow for possible renaming of types on this
# side.
funcSpec.name = 'upcastTo' + typeDesc.returnType.typeDescriptor.foreignTypeName
#funcSpec.name = FFIRename.methodNameFromCppName(
# interrogate_function_name(funcIndex))
funcSpec.typeDescriptor = typeDesc
funcSpec.index = funcIndex
funcSpecs.append(funcSpec)
return funcSpecs
def constructDowncastFunctionSpecifications(self, typeIndex):
"""
The strange thing about downcast functions is that they appear in the
class they are being downcast TO, not downcast FROM. But they should be
built into the class they are being downcast from. For instance, a method
downcastToNode(ptrBoundedObject) will appear in Node's list of methods
but should be compiled into BoundedObject's class
UPDATE: These are no longer compiled into the from-class. That was
preventing the libraries from being independent since the from class
now had knowledge of the to class which is potentially in a library
downstream. Now these functions are just global functions
"""
numFuncs = interrogate_type_number_of_derivations(typeIndex)
for i in range(numFuncs):
# Make sure this downcast is possible
if (not interrogate_type_derivation_downcast_is_impossible(typeIndex, i)):
if interrogate_type_derivation_has_downcast(typeIndex, i):
funcIndex = interrogate_type_get_downcast(typeIndex, i)
typeDescs = self.constructFunctionTypeDescriptors(funcIndex)
for typeDesc in typeDescs:
funcSpec = FFISpecs.GlobalFunctionSpecification()
funcSpec.name = FFIRename.methodNameFromCppName(
interrogate_function_name(funcIndex),
getTypeName(typeIndex))
funcSpec.typeDescriptor = typeDesc
funcSpec.index = funcIndex
# Here we look for the class in the first argument
fromClass = typeDesc.argumentTypes[0].typeDescriptor.recursiveTypeDescriptor()
# Append the from class name on the method to uniquify it now
# that these are global methods
funcSpec.name = funcSpec.name + 'From' + fromClass.foreignTypeName
# Append this funcSpec to that class's downcast methods
# fromClass.downcastMethods.append(funcSpec)
self.environment.addDowncastFunction(funcSpec)
def constructConstructorSpecifications(self, typeIndex):
funcSpecs = []
numFuncs = interrogate_type_number_of_constructors(typeIndex)
for i in range(numFuncs):
funcIndex = interrogate_type_get_constructor(typeIndex, i)
typeDescs = self.constructFunctionTypeDescriptors(funcIndex)
for typeDesc in typeDescs:
funcSpec = FFISpecs.MethodSpecification()
funcSpec.name = 'constructor'
# funcSpec.name = FFIRename.methodNameFromCppName(
# interrogate_function_name(funcIndex))
funcSpec.typeDescriptor = typeDesc
# Flag this function as being a constructor
funcSpec.constructor = 1
funcSpec.index = funcIndex
funcSpecs.append(funcSpec)
return funcSpecs
def constructDestructorSpecification(self, typeIndex):
if (not interrogate_type_has_destructor(typeIndex)):
return None
funcIndex = interrogate_type_get_destructor(typeIndex)
typeDescs = self.constructFunctionTypeDescriptors(funcIndex)
if (len(typeDescs) == 0):
return None
for typeDesc in typeDescs:
funcSpec = FFISpecs.MethodSpecification()
funcSpec.name = 'destructor'
# funcSpec.name = FFIRename.methodNameFromCppName(
# interrogate_function_name(funcIndex))
funcSpec.typeDescriptor = typeDesc
funcSpec.index = funcIndex
return funcSpec
def addTypes(self, CModuleName):
for i in range(interrogate_number_of_global_types()):
typeIndex = interrogate_get_global_type(i)
if self.typeInCModule(typeIndex, CModuleName):
self.constructDescriptor(typeIndex)
def addEnvironmentTypes(self):
for descriptor in self.typeIndexMap.values():
self.environment.addType(descriptor, descriptor.foreignTypeName)
def functionInCModule(self, funcIndex, CModuleName):
if interrogate_function_has_module_name(funcIndex):
moduleName = 'lib' + interrogate_function_module_name(funcIndex)
return (moduleName == CModuleName)
def typeInCModule(self, typeIndex, CModuleName):
if interrogate_type_has_module_name(typeIndex):
moduleName = 'lib' + interrogate_type_module_name(typeIndex)
return (moduleName == CModuleName)
def constructGlobal(self, globalIndex, CModuleName):
# We really do not need the descriptor for the value, just
# the getter and setter
# typeIndex = interrogate_element_type(globalIndex)
# descriptor = self.constructDescriptor(typeIndex)
if interrogate_element_has_getter(globalIndex):
getterIndex = interrogate_element_getter(globalIndex)
# If this function is not in this Cmodule just return
if not self.functionInCModule(getterIndex, CModuleName):
return None
getter = self.constructGlobalFunction(getterIndex)
else:
getter = None
if interrogate_element_has_setter(globalIndex):
setterIndex = interrogate_element_setter(globalIndex)
# If this function is not in this Cmodule just return
if not self.functionInCModule(setterIndex, CModuleName):
return None
setter = self.constructGlobalFunction(setterIndex)
else:
setter = None
globalSpec = FFISpecs.GlobalValueSpecification()
globalSpec.getter = getter
globalSpec.setter = setter
# globalSpec.typeDescriptor = descriptor
cppName = interrogate_element_name(globalIndex)
globalSpec.name = FFIRename.classNameFromCppName(cppName)
return globalSpec
def constructGlobalFunction(self, globalIndex):
descriptors = self.constructFunctionTypeDescriptors(globalIndex)
if (len(descriptors) == 0):
return None
funcSpecs = []
for descriptor in descriptors:
funcSpec = FFISpecs.GlobalFunctionSpecification()
funcSpec.typeDescriptor = descriptor
funcSpec.name = FFIRename.methodNameFromCppName(
funcSpec.typeDescriptor.foreignTypeName)
funcSpec.index = globalIndex
funcSpecs.append(funcSpec)
return funcSpecs
def addGlobalFunctions(self, CModuleName):
numGlobals = interrogate_number_of_global_functions()
for i in range(numGlobals):
funcIndex = interrogate_get_global_function(i)
if self.functionInCModule(funcIndex, CModuleName):
newGlob = self.constructGlobalFunction(funcIndex)
if newGlob:
self.environment.addGlobalFunction(newGlob)
def addGlobalValues(self, CModuleName):
numGlobals = interrogate_number_of_globals()
for i in range(numGlobals):
globalIndex = interrogate_get_global(i)
newGlob = self.constructGlobal(globalIndex, CModuleName)
if newGlob:
self.environment.addGlobalValue(newGlob)
def constructManifest(self, manifestIndex):
descriptor = None
intValue = None
getter = None
if interrogate_manifest_has_type(manifestIndex):
typeIndex = interrogate_manifest_get_type(manifestIndex)
descriptor = self.constructDescriptor(typeIndex)
definition = interrogate_manifest_definition(manifestIndex)
# See if this manifest is an int. There are shortcuts if it is.
# If it does have an int value, there will be no getter, we will
# just output the value in the generated code
if interrogate_manifest_has_int_value(manifestIndex):
intValue = interrogate_manifest_get_int_value(manifestIndex)
else:
# See if this manifest has a getter
if interrogate_manifest_has_getter(manifestIndex):
getterIndex = interrogate_manifest_getter(manifestIndex)
getter = self.constructGlobalFunction(getterIndex)
manifestSpec = FFISpecs.ManifestSpecification()
manifestSpec.typeDescriptor = descriptor
manifestSpec.definition = definition
manifestSpec.intValue = intValue
manifestSpec.getter = getter
cppName = interrogate_manifest_name(manifestIndex)
manifestSpec.name = FFIRename.classNameFromCppName(cppName)
return manifestSpec
def addManifestSymbols(self):
numManifests = interrogate_number_of_manifests()
for i in range(numManifests):
manifestIndex = interrogate_get_manifest(i)
newManifest = self.constructManifest(manifestIndex)
self.environment.addManifest(newManifest)
def generateCode(self, codeDir, extensionsDir):
# Empty out the codeDir of unnecessary crud from previous runs
# before we begin.
for file in os.listdir(codeDir):
pathname = os.path.join(codeDir, file)
if not os.path.isdir(pathname):
os.unlink(pathname)
# Import all the C++ modules
for CModuleName in FFIConstants.CodeModuleNameList:
self.generateCodeLib(codeDir, extensionsDir, CModuleName)
# For convenience, output a file that imports all the c module files
file = open(os.path.join(codeDir, FFIConstants.importModuleName + '.py'), 'w')
for CModuleName in FFIConstants.CodeModuleNameList:
file.write('from ' + CModuleName + 'Modules import *\n')
file.close()
# Generate an empty __init__.py to make the directory a Python
# package.
init = os.path.join(codeDir, '__init__.py')
file = open(init, 'w')
file.close()
def squeezeGeneratedCode(self, outputDir, deleteSource=True):
# Since we will be squeezing the importModuleName file, rename
# the original to something we can import from within the
# squeezed version.
squeezedName = FFIConstants.importModuleName
unsqueezedName = FFIConstants.importModuleName + 'Unsqueezed'
os.rename(os.path.join(outputDir, squeezedName + '.py'),
os.path.join(outputDir, unsqueezedName + '.py'))
# Get the list of files to squeeze. This is all of the .py
# files in the output directory except for the __init__.py
# file.
files = glob.glob(os.path.join(outputDir, '*.py'))
init = os.path.join(outputDir, '__init__.py')
try:
files.remove(init)
except:
pass
print "Squeezing %s files." % (len(files))
from direct.showbase import pandaSqueezeTool
pandaSqueezeTool.squeeze(squeezedName, unsqueezedName,
files, outputDir)
if deleteSource:
# Remove the now-squeezed source files.
for file in files:
os.remove(file)
def generateCodeLib(self, codeDir, extensionsDir, CModuleName):
# Reset the environment so we are clean from any old modules
self.environment.reset()
FFIConstants.notify.info('='*50)
FFIConstants.notify.warning('Importing code library: ' + CModuleName)
exec('import ' + CModuleName)
if interrogate_error_flag():
FFIConstants.notify.error("Error reading interrogate database; can't continue.")
self.updateBindings(CModuleName)
FFIConstants.notify.info('Generating type code...')
for type in self.environment.types.values():
# Do not generate code for nested types at the top level
if (not type.isNested):
type.generateGlobalCode(codeDir, extensionsDir)
FFIConstants.notify.info('Generating global downcast code...')
downcastFile = constructDowncastFile(codeDir, CModuleName)
# Output all the imports based on this list of functions
outputGlobalFileImports(downcastFile,
self.environment.downcastFunctions,
CModuleName)
for type in self.environment.downcastFunctions:
type.generateGlobalDowncastCode(downcastFile)
FFIConstants.notify.info('Generating global code...')
globalFile = constructGlobalFile(codeDir, CModuleName)
# Make a list of all the global functions. This includes the normal
# global functions as well as the getters and setters on all the
# global values. This list is used to figure out what files to import
# Only include the global functions from the current C module
globalFunctions = self.environment.globalFunctions
for globalValue in self.environment.globalValues:
if globalValue.getter:
globalFunctions.append(globalValue.getter)
if globalValue.setter:
globalFunctions.append(globalValue.setter)
# Output all the imports based on this list of functions
outputGlobalFileImports(globalFile, globalFunctions, CModuleName)
# Generate overloading
overloadedGlobalFunctions = {}
for methodSpec in globalFunctions:
methodList = overloadedGlobalFunctions.setdefault(methodSpec.name, [])
methodList.append(methodSpec)
overloadedGlobalFunctions = FFIOverload.cullOverloadedMethods(overloadedGlobalFunctions)
for methodSpecList in overloadedGlobalFunctions.values():
treeColl = FFIOverload.FFIMethodArgumentTreeCollection(None, methodSpecList)
treeColl.generateCode(globalFile, -1)
FFIConstants.notify.info('Generating global values...')
for type in self.environment.globalValues:
type.generateGlobalCode(globalFile)
FFIConstants.notify.info('Generating global functions...')
for type in self.environment.globalFunctions:
type.generateGlobalCode(globalFile)
FFIConstants.notify.info('Generating manifests...')
for type in self.environment.manifests:
type.generateGlobalCode(globalFile)
globalFile.close()
FFIConstants.notify.info('Generating import code...')
importFile = constructImportFile(codeDir, CModuleName)
outputImportFileImports(importFile, self.environment.types.values(), CModuleName)
def updateBindings(self, CModuleName):
FFIConstants.notify.info('Updating Bindings')
FFIConstants.notify.info('Adding Types...')
self.addTypes(CModuleName)
FFIConstants.notify.info('Adding global values...')
self.addGlobalValues(CModuleName)
FFIConstants.notify.info('Adding global functions...')
self.addGlobalFunctions(CModuleName)
FFIConstants.notify.info('Adding manifests symbols...')
self.addManifestSymbols()
FFIConstants.notify.info('Adding environment types...')
self.addEnvironmentTypes()

View File

@ -1,472 +0,0 @@
from direct.showbase.PythonUtil import *
from types import *
import string
import FFIConstants
import FFISpecs
import FFITypes
"""
Things that are not supported:
- Overloading a function based on an enum being differentiated from an int
- Type names from C++ cannot have __enum__ in their name
- Overloading static and non-static methods with the same name
"""
AT_not_atomic = 0
AT_int = 1
AT_float = 2
AT_double = 3
AT_bool = 4
AT_char = 5
AT_void = 6
AT_string = 7
AT_longlong = 8
def cullOverloadedMethods(fullMethodDict):
"""
Find all the entries that have multiple indexes for the same method name
Get rid of all others.
"""
tmpDict = {}
# For each class
for methodName in fullMethodDict.keys():
methodList = fullMethodDict[methodName]
# See if this method has more than one function index (overloaded)
if (len(methodList) > 1):
tmpDict[methodName] = methodList
# Mark all the method specifications as overloaded
for methodSpec in methodList:
methodSpec.overloaded = 1
return tmpDict
def getTypeName(classTypeDesc, typeDesc):
"""
Map the interrogate primitive type names to python type names.
We assume that the module using this has imported the types module.
It is valid to pass in None for classTypeDesc if we are not in a class
"""
typeName = typeDesc.getFullNestedName()
# Atomic C++ types are type checked against the builtin
# Python types. This code sorts out the mapping
if typeDesc.isAtomic():
# Ints, bools, and chars are treated as ints.
# Enums are special and are not atomic, see below
if ((typeDesc.atomicType == AT_int) or
(typeDesc.atomicType == AT_bool) or
(typeDesc.atomicType == AT_char)):
return 'IntType'
# Floats and doubles are both floats in Python
elif ((typeDesc.atomicType == AT_float) or
(typeDesc.atomicType == AT_double)):
return 'FloatType'
elif ((typeDesc.atomicType == AT_longlong)):
return 'LongType'
# Strings are treated as Python strings
elif ((typeDesc.atomicType == AT_string)):
return 'StringType'
elif (typeDesc.atomicType == AT_void):
# Convert the void type to None type... I guess...
# So far we do not have any code that uses this
return 'NoneType'
else:
FFIConstants.notify.error("Unknown atomicType: %s" % (typeDesc.atomicType))
# If the type is an enum, we really want to treat it like an int
# To handle this, the type will have __enum__ in the name
# Usually it will start the typeName, but some typeNames have the
# surrounding class as part of their name
# like BoundedObject.__enum__BoundingVolumeType
elif (typeName.find('__enum__') >= 0):
return 'IntType'
# If it was not atomic or enum, it must be a class which is a
# bit trickier because we output different things depending on the
# scoping of the type.
else:
# classTypeDesc typeDesc fullNestedName Resulting TypeName
# 1 Outer Other Other Other.Other
# 2 Outer Outer Outer Outer
# 3 Outer Inner Outer.Inner Outer.Inner
# 4 Inner Other Other Other.Other
# 5 Inner Outer Outer Outer
# 6 Inner Inner Outer.Inner Outer.Inner
# 7 None Other Other Other.Other
# CASES 1, 4, and 7 are the only ones that are different from the full
# nested name, returning Other.Other
returnNestedTypeNames = string.split(typeName, '.')
returnModuleName = returnNestedTypeNames[0]
if classTypeDesc:
classTypeName = classTypeDesc.getFullNestedName()
classNestedTypeNames = string.split(classTypeName, '.')
# If there is no nesting, return typeName.typeName
if ((not (classTypeDesc.foreignTypeName in returnNestedTypeNames)) and
(not (typeDesc.foreignTypeName in classNestedTypeNames))):
return (returnModuleName + '.' + typeName)
# All other cases, we just need typeName
else:
return typeName
else:
# If you had no class, you need to specify module plus typename
return (returnModuleName + '.' + typeName)
def inheritsFrom(type1, type2):
"""
Return true if type1 inherits from type2
This works by recursively checking parentTypes for type1
"""
if type1.parentTypes:
if type2 in type1.parentTypes:
return 1
else:
result = 0
for type in type1.parentTypes:
result = (result or inheritsFrom(type, type2))
return result
else:
return 0
def getInheritanceLevel(type, checkNested = 1):
if type.__class__ == FFITypes.PyObjectTypeDescriptor:
# A special case: PyObject * is always the most general
# object. Everything is a PyObject.
return -1
# If this is a nested type, return the inheritance level of the outer type.
if type.isNested:
# Check the level of your outer class
# pass the checkNested flag as 0 to prevent an infinite loop
# between the parent and child
level = getInheritanceLevel(type.outerType, 0)
else:
level = 0
for parentType in type.parentTypes:
# Add 1 because you are one level higher than your parent
level = max(level, 1+getInheritanceLevel(parentType))
if checkNested:
for nestedType in type.nestedTypes:
# Do not add 1 to your nested types
level = max(level, getInheritanceLevel(nestedType))
return level
def inheritanceLevelSort(type1, type2):
level1 = getInheritanceLevel(type1)
level2 = getInheritanceLevel(type2)
if (level1 == level2):
# If they are equal in the inheritance,
# sort them alphabetically by their type name
return cmp(type1.foreignTypeName, type2.foreignTypeName)
elif (level1 < level2):
return -1
elif (level1 > level2):
return 1
def subclass(type1, type2):
"""
Helper funcion used in sorting classes by inheritance
"""
# If the types are the same, return 0
if type1 == type2:
return 0
# If you have no args, sort you first
elif (type1 == 0):
return 1
elif (type2 == 0):
return -1
# If class1 inherits from class2 return -1
elif inheritsFrom(type1, type2):
return -1
# If class2 inherits from class1 return 1
elif inheritsFrom(type2, type1):
return 1
else:
# This is the don't care case. We must specify a sorting
# rule just so it is not arbitrary
if (type1.foreignTypeName > type2.foreignTypeName):
return -1
else:
return 1
class FFIMethodArgumentTreeCollection:
def __init__(self, classTypeDesc, methodSpecList):
self.classTypeDesc = classTypeDesc
self.methodSpecList = methodSpecList
self.methodDict = {}
self.treeDict = {}
def outputOverloadedMethodHeader(self, file, nesting):
# If one is static, we assume they all are.
# The current system does not support overloading static and non-static
# methods with the same name
# Constructors are not treated as static. They are special because
# they are not really constructors, they are instance methods that fill
# in the this pointer.
# Global functions do not need static versions
if (self.methodSpecList[0].isStatic() and
(not self.methodSpecList[0].isConstructor())):
indent(file, nesting, 'def ' +
self.methodSpecList[0].name + '(*_args):\n')
else:
indent(file, nesting, 'def ' +
self.methodSpecList[0].name + '(self, *_args):\n')
self.methodSpecList[0].outputCFunctionComment(file, nesting+2)
indent(file, nesting+2, 'numArgs = len(_args)\n')
def outputOverloadedMethodFooter(self, file, nesting):
# If this is a static method, we need to output a static version
# If one is static, we assume they all are.
# The current system does not support overloading static and non-static
# methods with the same name
# Constructors are not treated as static. They are special because
# they are not really constructors, they are instance methods that fill
# in the this pointer.
methodName = self.methodSpecList[0].name
if (self.methodSpecList[0].isStatic() and
(not self.methodSpecList[0].isConstructor()) and
(not isinstance(self.methodSpecList[0], FFISpecs.GlobalFunctionSpecification))):
self.outputOverloadedStaticFooter(file, nesting)
else:
if self.classTypeDesc:
indent(file, nesting, "FFIExternalObject.funcToMethod("+methodName+','+ self.classTypeDesc.foreignTypeName+ ",'"+methodName+"')\n")
indent(file, nesting, 'del '+methodName+'\n')
indent(file, nesting, ' \n')
indent(file, nesting+1, '\n')
def outputOverloadedStaticFooter(self, file, nesting):
# foo = staticmethod(foo)
methodName = self.methodSpecList[0].name
indent(file, nesting, self.classTypeDesc.foreignTypeName + '.' + methodName + ' = staticmethod(' + methodName + ')\n')
indent(file, nesting,'del ' +methodName+' \n\n')
def setup(self):
for method in self.methodSpecList:
numArgs = len(method.typeDescriptor.thislessArgTypes())
numArgsList = self.methodDict.setdefault(numArgs, [])
numArgsList.append(method)
for numArgs in self.methodDict.keys():
methodList = self.methodDict[numArgs]
tree = FFIMethodArgumentTree(self.classTypeDesc, methodList)
treeList = self.treeDict.setdefault(numArgs, [])
treeList.append(tree)
def generateCode(self, file, nesting):
self.setup()
self.outputOverloadedMethodHeader(file, nesting)
numArgsKeys = self.treeDict.keys()
numArgsKeys.sort()
for i in range(len(numArgsKeys)):
numArgs = numArgsKeys[i]
trees = self.treeDict[numArgs]
for tree in trees:
# If this is the first case, output an if clause
if (i == 0):
indent(file, nesting+2, 'if (numArgs == ' + repr(numArgs) + '):\n')
# If this is a subsequent first case, output an elif clause
else:
indent(file, nesting+2, 'elif (numArgs == ' + repr(numArgs) + '):\n')
tree.setup()
tree.traverse(file, nesting+1, 0)
# If the overloaded function got all the way through the if statements
# it must have had the wrong number or type of arguments
indent(file, nesting+2, "else:\n")
indent(file, nesting+3, "raise TypeError, 'Invalid number of arguments: ' + repr(numArgs) + ', expected one of: ")
for numArgs in numArgsKeys:
indent(file, 0, (repr(numArgs) + ' '))
indent(file, 0, "'\n")
self.outputOverloadedMethodFooter(file, nesting)
class FFIMethodArgumentTree:
"""
Tree is made from nested dictionaries.
The keys are methodNamed.
The values are [tree, methodSpec]
methodSpec may be None at any level
If tree is None, it is a leaf node and methodSpec will be defined
"""
def __init__(self, classTypeDesc, methodSpecList):
self.argSpec = None
self.classTypeDesc = classTypeDesc
self.methodSpecList = methodSpecList
# The actual tree is implemented as nested dictionaries
self.tree = {}
def setup(self):
for methodSpec in self.methodSpecList:
argTypes = methodSpec.typeDescriptor.thislessArgTypes()
self.fillInArgTypes(argTypes, methodSpec)
def fillInArgTypes(self, argTypes, methodSpec):
# If the method takes no arguments, we will assign a type index of 0
if (len(argTypes) == 0):
self.tree[0] = [
FFIMethodArgumentTree(self.classTypeDesc,
self.methodSpecList),
methodSpec]
else:
self.argSpec = argTypes[0]
typeDesc = self.argSpec.typeDescriptor.recursiveTypeDescriptor()
if (len(argTypes) == 1):
# If this is the last parameter, we are a leaf node, so store the
# methodSpec in this dictionary
self.tree[typeDesc] = [None, methodSpec]
else:
if typeDesc in self.tree:
# If there already is a tree here, jump into and pass the
# cdr of the arg list
subTree = self.tree[typeDesc][0]
subTree.fillInArgTypes(argTypes[1:], methodSpec)
else:
# Add a subtree for the rest of the arg list
subTree = FFIMethodArgumentTree(self.classTypeDesc,
self.methodSpecList)
subTree.fillInArgTypes(argTypes[1:], methodSpec)
# This subtree has no method spec
self.tree[typeDesc] = [subTree, None]
def traverse(self, file, nesting, level):
oneTreeHasArgs = 0
typeNameList = []
# First see if this tree branches at all. If it does not there are
# drastic optimizations we can take because we can simply call the
# bottom-most function. We are not checking the types of all the
# arguments for the sake of type checking, we are simply trying to
# figure out which overloaded function to call. If there is only
# one overloaded function with this number of arguements at this
# level, it must be the one. No need to continue checking all the
# arguments.
branches = 0
subTree = self
prevTree = subTree
levelCopy = level
while subTree:
if (len(subTree.tree.keys()) == 0):
# Dead end branch
break
if (len(subTree.tree.keys()) > 1):
# Ok, we branch, it was worth a try though
branches = 1
break
prevTree = subTree
# Must only have one subtree, traverse it
subTree = subTree.tree.values()[0][0]
levelCopy += 1
# If there were no branches, this is easy
# Just output the function and return
# Note this operates on prevTree because subTree went one too far
if not branches:
methodSpec = prevTree.tree.values()[0][1]
indent(file, nesting+2, 'return ')
methodSpec.outputOverloadedCall(file, prevTree.classTypeDesc, levelCopy)
return
# Ok, We must have a branch down here somewhere
# Make a copy of the keys so we can sort them in place
sortedKeys = self.tree.keys()
# Sort the keys based on inheritance hierarchy, most specific classes first
sortedKeys.sort(subclass)
for i in range(len(sortedKeys)):
typeDesc = sortedKeys[i]
# See if this takes no arguments
if (typeDesc == 0):
# Output the function
methodSpec = self.tree[0][1]
indent(file, nesting+2, 'return ')
methodSpec.outputOverloadedCall(file, self.classTypeDesc, 0)
else:
# This is handled at the top of the file now (?)
# Import a file if we need to for this typeDesc
# if ((typeDesc != 0) and
# (not typeDesc.isNested) and
# # Do not put our own module in the import list
# (self.classTypeDesc != typeDesc) and
# # If this is a class (not a primitive), put it on the list
# (typeDesc.__class__ == FFITypes.ClassTypeDescriptor)):
# indent(file, nesting+2, 'import ' + typeDesc.foreignTypeName + '\n')
# Specify that at least one of these trees had arguments
# so we know to output an else clause
oneTreeHasArgs = 1
typeName = getTypeName(self.classTypeDesc, typeDesc)
typeNameList.append(typeName)
if typeDesc.__class__ == FFITypes.PyObjectTypeDescriptor:
# A special case: if one of the parameters is
# PyObject *, that means anything is accepted.
condition = '1'
else:
# Otherwise, we'll check the particular type of
# the object.
condition = '(isinstance(_args[' + repr(level) + '], ' + typeName + '))'
# Legal types for a float parameter include int and long.
if (typeName == 'FloatType'):
condition += (' or (isinstance(_args[' + repr(level) + '], IntType))')
condition += (' or (isinstance(_args[' + repr(level) + '], LongType))')
# Legal types for a long parameter include int.
elif (typeName == 'LongType'):
condition += (' or (isinstance(_args[' + repr(level) + '], IntType))')
# Legal types for an int parameter include long.
elif (typeName == 'IntType'):
condition += (' or (isinstance(_args[' + repr(level) + '], LongType))')
indent(file, nesting+2, 'if ' + condition + ':\n')
if (self.tree[typeDesc][0] is not None):
self.tree[typeDesc][0].traverse(file, nesting+1, level+1)
else:
methodSpec = self.tree[typeDesc][1]
indent(file, nesting+3, 'return ')
numArgs = level+1
methodSpec.outputOverloadedCall(file, self.classTypeDesc, numArgs)
# Output an else clause if one of the trees had arguments
if oneTreeHasArgs:
indent(file, nesting+2, "raise TypeError, 'Invalid argument " + repr(level) + ", expected one of: ")
for name in typeNameList:
indent(file, 0, ('<' + name + '> '))
indent(file, 0, "'\n")
def isSinglePath(self):
if (len(self.tree.keys()) > 1):
# More than one child, return false
return 0
else:
# Only have one child, see if he only has one child
key = self.tree.keys()[0]
tree = self.tree[key][0]
if tree:
return tree.isSinglePath()
else:
return self.tree[key][1]

View File

@ -1,151 +0,0 @@
import FFIConstants
from string import *
pythonKeywords = ['and','del','for','is','raise','assert','elif','from','lambda','return','break','else','global','not','try','class','except','if','or','while','continue','exec','import','pass','def','finally','in','print']
methodRenameDictionary = {
'operator==': '__eq__',
'operator!=': '__ne__',
'operator<<': '__lshift__',
'operator>>': '__rshift__',
'operator<': '__lt__',
'operator>': '__gt__',
'operator<=': '__le__',
'operator>=': '__ge__',
'operator=': 'assign',
'operator()': '__call__',
'operator[]': '__getitem__',
'operator++': 'increment',
'operator--': 'decrement',
'operator^': '__xor__',
'operator%': '__mod__',
'operator!': 'logicalNot',
'operator~': 'bitwiseNot',
'operator&': '__and__',
'operator&&': 'logicalAnd',
'operator|': '__or__',
'operator||': 'logicalOr',
'operator+': '__add__',
'operator-': '__sub__',
'operator*': '__mul__',
'operator/': '__div__',
'operator+=': '__iadd__',
'operator-=': '__isub__',
'operator*=': '__imul__',
'operator/=': '__idiv__',
'operator,': 'concatenate',
'operator|=': '__ior__',
'operator&=': '__iand__',
'operator^=': '__ixor__',
'operator~=': 'bitwiseNotEqual',
'operator->': 'dereference',
'operator<<=': '__ilshift__',
'operator>>=': '__irshift__',
'print': 'Cprint',
'CInterval.setT': '_priv__cSetT',
}
classRenameDictionary = {
'Loader': 'PandaLoader',
'String': 'CString',
'LMatrix4f': 'Mat4',
'LMatrix3f': 'Mat3',
'LVecBase4f': 'VBase4',
'LVector4f': 'Vec4',
'LPoint4f': 'Point4',
'LVecBase3f': 'VBase3',
'LVector3f': 'Vec3',
'LPoint3f': 'Point3',
'LVecBase2f': 'VBase2',
'LVector2f': 'Vec2',
'LPoint2f': 'Point2',
'LQuaternionf': 'Quat',
'LMatrix4d': 'Mat4D',
'LMatrix3d': 'Mat3D',
'LVecBase4d': 'VBase4D',
'LVector4d': 'Vec4D',
'LPoint4d': 'Point4D',
'LVecBase3d': 'VBase3D',
'LVector3d': 'Vec3D',
'LPoint3d': 'Point3D',
'LVecBase2d': 'VBase2D',
'LVector2d': 'Vec2D',
'LPoint2d': 'Point2D',
'LQuaterniond': 'QuatD',
'Plane': 'PlaneBase',
'Planef': 'Plane',
'Planed': 'PlaneD',
'Frustum': 'FrustumBase',
'Frustumf': 'Frustum',
'Frustumd': 'FrustumD'
}
def checkKeyword(cppName):
if cppName in pythonKeywords:
cppName = '_' + cppName
return cppName
# TODO: Make faster - this thing is horribly slow
def classNameFromCppName(cppName):
# initialize to empty string
className = ''
# These are the characters we want to strip out of the name
badChars = '!@#$%^&*()<>,.-=+~{}? '
nextCap = 0
firstChar = 1
for char in cppName:
if (char in badChars):
continue
elif (char == '_'):
nextCap = 1
continue
elif (nextCap or firstChar):
className = className + capitalize(char)
nextCap = 0
firstChar = 0
else:
className = className + char
if className in classRenameDictionary:
className = classRenameDictionary[className]
if (className == ''):
FFIConstants.notify.warning('Renaming class: ' + cppName + ' to empty string')
# FFIConstants.notify.debug('Renaming class: ' + cppName + ' to: ' + className)
# Note we do not have to check for keywords because class name are capitalized
return className
def nonClassNameFromCppName(cppName):
className = classNameFromCppName(cppName)
# Make the first character lowercase
newName = lower(className[0])+className[1:]
# Mangle names that happen to be python keywords so they are not anymore
newName = checkKeyword(newName)
return newName
def methodNameFromCppName(cppName, className = None):
methodName = ''
badChars = ' '
nextCap = 0
for char in cppName:
if (char in badChars):
continue
elif (char == '_'):
nextCap = 1
continue
elif nextCap:
methodName = methodName + capitalize(char)
nextCap = 0
else:
methodName = methodName + char
if className != None:
methodName = methodRenameDictionary.get(className + '.' + methodName, methodName)
methodName = methodRenameDictionary.get(methodName, methodName)
# Mangle names that happen to be python keywords so they are not anymore
methodName = checkKeyword(methodName)
return methodName

View File

@ -1,586 +0,0 @@
import FFIConstants
import FFITypes
import FFIOverload
import string
from direct.showbase.PythonUtil import *
augmentedAssignments = ['__iadd__', '__isub__', '__imul__', '__idiv__',
'__ior__', '__iand__', '__ixor__',
'__ilshift__', '__irshift__']
class FunctionSpecification:
def __init__(self):
self.name = ''
self.typeDescriptor = None
self.index = 0
self.overloaded = 0
# Is this function a constructor
self.constructor = 0
def isConstructor(self):
return self.constructor
def isStatic(self):
for arg in self.typeDescriptor.argumentTypes:
if arg.isThis:
return 0
# No args were this pointers, must be static
return 1
def outputTypeChecking(self, methodClass, args, file, nesting):
"""
Output an assert statement to check the type of each arg in this method
This can be turned off with a command line parameter in generatePythonCode
It is valid to pass in None for methodClass if you are not in any methodClass
"""
if FFIConstants.wantTypeChecking:
for i in range(len(args)):
methodArgSpec = args[i]
typeDesc = methodArgSpec.typeDescriptor.recursiveTypeDescriptor()
typeName = FFIOverload.getTypeName(methodClass, typeDesc)
# We only do type checking on class types. C++ can do
# type checking on the primitive types, and will do a
# better job anyway.
if typeDesc.__class__ == FFITypes.ClassTypeDescriptor:
# Get the real return type (not derived)
if ((not typeDesc.isNested) and
# Do not put our own module in the import list
(methodClass != typeDesc)):
indent(file, nesting, 'import ' + typeDesc.foreignTypeName + '\n')
indent(file, nesting, 'if not isinstance(' +
methodArgSpec.name + ', ' + typeName + '):\n')
indent(file, nesting + 1,
'raise TypeError, "Invalid argument %s, expected <%s>"\n' % (i, typeDesc.foreignTypeName))
def outputCFunctionComment(self, file, nesting):
"""
Output a docstring to the file describing the C++ call with type info
Also output the C++ comment from interrogate.
"""
if FFIConstants.wantComments:
indent(file, nesting, '"""\n')
# Output the function prototype
if self.typeDescriptor.prototype:
indent(file, nesting, self.typeDescriptor.prototype + '\n')
# Output the function comment
if self.typeDescriptor.comment:
# To insert tabs into the comment, replace all newlines with a newline+tabs
comment = string.replace(self.typeDescriptor.comment,
'\n', ('\n' + (' ' * nesting)))
indent(file, nesting, comment)
indent(file, 0, '\n')
indent(file, nesting, '"""\n')
def getFinalName(self):
"""
Return the name of the function given that it might be overloaded
If it is overloaded, prepend "overloaded", then append the types of
each argument to make it unique.
So "getChild(int)" becomes "overloaded_getChild_int(int)"
"""
if self.overloaded:
name = 'private__overloaded_' + self.name
for methodArgSpec in self.typeDescriptor.argumentTypes:
name = name + '_' + methodArgSpec.typeDescriptor.foreignTypeName
return name
else:
return self.name
def outputOverloadedCall(self, file, classTypeDesc, numArgs):
"""
Write the function call to call this overloaded method
For example:
self.overloaded_setPos_ptrNodePath_float_float_float(*_args)
If it is a class (static) method, call the class method
Class.overloaded_setPos_ptrNodePath_float_float_float(*_args)
Constructors are not treated as static. They are special because
they are not really constructors, they are instance methods that fill
in the this pointer.
These do not get indented because they are not the beginning of the line
If classTypeDesc is None, then this is a global function and should
output code as such
"""
if classTypeDesc:
if (self.isStatic() and not self.isConstructor()):
if numArgs:
indent(file, 0, classTypeDesc.foreignTypeName + '.' + self.getFinalName() + '(*_args)\n')
else:
indent(file, 0, classTypeDesc.foreignTypeName + '.' + self.getFinalName() + '()\n')
else:
if numArgs:
indent(file, 0, 'self.' + self.getFinalName() + '(*_args)\n')
else:
indent(file, 0, 'self.' + self.getFinalName() + '()\n')
else:
if numArgs:
indent(file, 0, self.getFinalName() + '(*_args)\n')
else:
indent(file, 0, self.getFinalName() + '()\n')
class GlobalFunctionSpecification(FunctionSpecification):
def __init__(self):
FunctionSpecification.__init__(self)
# Use generateCode when creating a global (non-class) function
def generateGlobalCode(self, file):
self.outputHeader(file)
self.outputBody(file)
self.outputFooter(file)
# Use generateCode when creating a global (non-class) function
def generateGlobalDowncastCode(self, file):
self.outputHeader(file)
self.outputBody(file, 0, 0) # no downcast, no type checking
self.outputFooter(file)
# Use generateMethodCode when creating a global->class function
def generateMethodCode(self, methodClass, file, nesting):
self.outputMethodHeader(methodClass, file, nesting)
self.outputMethodBody(methodClass, file, nesting)
self.outputMethodFooter(methodClass, file, nesting)
##################################################
## Global Function Code Generation
##################################################
def outputHeader(self, file):
argTypes = self.typeDescriptor.argumentTypes
indent(file, 0, 'def ' + self.getFinalName() + '(')
for i in range(len(argTypes)):
file.write(argTypes[i].name)
if (i < (len(argTypes)-1)):
file.write(', ')
file.write('):\n')
def outputBody(self, file, needsDowncast=1, typeChecking=1):
# The method body will look something like
# returnValue = PandaGlobal.method(arg)
# returnObject = NodePath()
# returnObject.this = returnValue
# returnObject.userManagesMemory = 1 (optional)
# return returnObject
self.outputCFunctionComment(file, 1)
argTypes = self.typeDescriptor.argumentTypes
# The global downcast functions do not need type checking, and
# in fact have a problem where they assert you are downcasting
# from the immediate superclass when in fact you may be downcasting
# from a class way up the chain as long as their is single
# inheritance up to it
if typeChecking:
self.outputTypeChecking(None, argTypes, file, 1)
indent(file, 1, 'returnValue = ' + self.typeDescriptor.moduleName
+ '.' + self.typeDescriptor.wrapperName + '(')
for i in range(len(argTypes)):
file.write(argTypes[i].passName())
if (i < (len(argTypes)-1)):
file.write(', ')
file.write(')\n')
#indent(file, 1, 'if returnValue is None:\n')
#indent(file, 2, 'return None\n')
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
returnType.generateReturnValueWrapper(None, file,
self.typeDescriptor.userManagesMemory,
needsDowncast, 1)
def outputFooter(self, file):
indent(file, 0, '\n')
##################################################
## Class Method Code Generation
##################################################
def outputMethodHeader(self, methodClass, file, nesting):
argTypes = self.typeDescriptor.argumentTypes
indent(file, nesting, 'def ' + self.getFinalName() + '(')
for i in range(len(argTypes)):
# Instead of the first argument, put self
if (i == 0):
file.write('self')
else:
file.write(argTypes[i].name)
if (i < (len(argTypes)-1)):
file.write(', ')
file.write('):\n')
def outputMethodBody(self, methodClass, file, nesting):
# The method body will look something like
# returnValue = PandaGlobal.method(self.this, arg)
# returnValue.userManagesMemory = 1 (optional)
# return returnValue
self.outputCFunctionComment(file, nesting+2)
argTypes = self.typeDescriptor.argumentTypes
self.outputTypeChecking(methodClass, argTypes[1:], file, nesting+2)
indent(file, nesting+2, 'returnValue = ' + self.typeDescriptor.moduleName
+ '.' + self.typeDescriptor.wrapperName + '(')
for i in range(len(argTypes)):
# Instead of the first argument, put self.this
if (i == 0):
file.write('self.this')
else:
file.write(argTypes[i].passName())
if (i < (len(argTypes)-1)):
file.write(', ')
file.write(')\n')
indent(file, 1, 'if returnValue is None:\n')
indent(file, 2, 'return None\n')
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
returnType.generateReturnValueWrapper(methodClass, file,
self.typeDescriptor.userManagesMemory,
1, nesting+2)
def outputMethodFooter(self, methodClass, file, nesting):
indent(file, nesting+1, '\n')
class MethodSpecification(FunctionSpecification):
def __init__(self):
FunctionSpecification.__init__(self)
def generateConstructorCode(self, methodClass, file, nesting):
self.outputConstructorHeader(methodClass, file, nesting)
self.outputConstructorBody(methodClass, file, nesting)
self.outputConstructorFooter(methodClass, file, nesting)
def generateDestructorCode(self, methodClass, file, nesting):
self.outputDestructorHeader(methodClass, file, nesting)
self.outputDestructorBody(methodClass, file, nesting)
self.outputDestructorFooter(methodClass, file, nesting)
def generateMethodCode(self, methodClass, file, nesting):
self.outputMethodHeader(methodClass, file, nesting)
self.outputMethodBody(methodClass, file, nesting)
self.outputMethodFooter(methodClass, file, nesting)
def generateStaticCode(self, methodClass, file, nesting):
self.outputStaticHeader(methodClass, file, nesting)
self.outputStaticBody(methodClass, file, nesting)
self.outputStaticFooter(methodClass, file, nesting)
def generateInheritedMethodCode(self, methodClass, parentList, file, nesting, needsDowncast):
self.outputInheritedMethodHeader(methodClass, parentList, file, nesting, needsDowncast)
self.outputInheritedMethodBody(methodClass, parentList, file, nesting, needsDowncast)
self.outputInheritedMethodFooter(methodClass, parentList, file, nesting, needsDowncast)
def generateUpcastMethodCode(self, methodClass, file, nesting):
# The upcast method code is just like regular code, but the
# return value wrapper does not have downcasting instructions
self.outputMethodHeader(methodClass, file, nesting)
self.outputMethodBody(methodClass, file, nesting, 0) # no downcast
self.outputMethodFooter(methodClass, file, nesting)
##################################################
## Constructor Code Generation
##################################################
def outputConstructorHeader(self, methodClass, file, nesting):
argTypes = self.typeDescriptor.argumentTypes
thislessArgTypes = self.typeDescriptor.thislessArgTypes()
indent(file, nesting+1, 'def ' + self.getFinalName() + '(self')
if (len(thislessArgTypes) > 0):
file.write(', ')
for i in range(len(thislessArgTypes)):
file.write(thislessArgTypes[i].name)
if (i < (len(thislessArgTypes)-1)):
file.write(', ')
file.write('):\n')
self.outputCFunctionComment(file, nesting+2)
def outputConstructorBody(self, methodClass, file, nesting):
# The method body will look something like
# self.this = panda.Class_constructor(arg)
# self.userManagesMemory = 1 (optional)
argTypes = self.typeDescriptor.argumentTypes
thislessArgTypes = self.typeDescriptor.thislessArgTypes()
self.outputTypeChecking(methodClass, thislessArgTypes, file, nesting+2)
indent(file, nesting+2, 'self.this = ' + self.typeDescriptor.moduleName + '.'
+ self.typeDescriptor.wrapperName + '(')
# Do not pass self into the constructor
for i in range(len(thislessArgTypes)):
file.write(thislessArgTypes[i].passName())
if (i < (len(thislessArgTypes)-1)):
file.write(', ')
file.write(')\n')
indent(file, nesting+2, 'assert self.this != 0\n')
if self.typeDescriptor.userManagesMemory:
indent(file, nesting+2, 'self.userManagesMemory = 1\n')
def outputConstructorFooter(self, methodClass, file, nesting):
indent(file, nesting+1, '\n')
##################################################
## Destructor Code Generation
##################################################
def outputDestructorHeader(self, methodClass, file, nesting):
argTypes = self.typeDescriptor.argumentTypes
thislessArgTypes = self.typeDescriptor.thislessArgTypes()
indent(file, nesting+1, 'def ' + self.getFinalName() + '(self')
if (len(thislessArgTypes) > 0):
file.write(', ')
for i in range(len(thislessArgTypes)):
file.write(thislessArgTypes[i].name)
if (i < (len(thislessArgTypes)-1)):
file.write(', ')
file.write('):\n')
self.outputCFunctionComment(file, nesting+2)
def outputDestructorBody(self, methodClass, file, nesting):
# The method body will look something like
# panda.Class_destructor(self.this)
functionName = (self.typeDescriptor.moduleName + '.'
+ self.typeDescriptor.wrapperName)
# Make sure the module and function have not been deleted first
# This only happens during shutdown
indent(file, nesting+2, 'if (' + self.typeDescriptor.moduleName + ' and ' +
functionName + '):\n')
indent(file, nesting+3, functionName + '(self.this)\n')
def outputDestructorFooter(self, methodClass, file, nesting):
indent(file, nesting+1, '\n')
##################################################
## Method Code Generation
##################################################
def outputMethodHeader(self, methodClass, file, nesting):
argTypes = self.typeDescriptor.argumentTypes
thislessArgTypes = self.typeDescriptor.thislessArgTypes()
indent(file, nesting, 'def ' + self.getFinalName() + '(self')
if (len(thislessArgTypes) > 0):
file.write(', ')
for i in range(len(thislessArgTypes)):
file.write(thislessArgTypes[i].name)
if (i < (len(thislessArgTypes)-1)):
file.write(', ')
file.write('):\n')
def outputMethodBody(self, methodClass, file, nesting, needsDowncast=1):
# The method body will look something like
# returnValue = panda.Class_method(self.this, arg)
# returnValue.userManagesMemory = 1 (optional)
# return returnValue
self.outputCFunctionComment(file, nesting+2)
argTypes = self.typeDescriptor.argumentTypes
thislessArgTypes = self.typeDescriptor.thislessArgTypes()
self.outputTypeChecking(methodClass, thislessArgTypes, file, nesting+2)
indent(file, nesting+2, 'returnValue = ' + self.typeDescriptor.moduleName + '.'
+ self.typeDescriptor.wrapperName + '(')
file.write('self.this')
if (len(thislessArgTypes) > 0):
file.write(', ')
for i in range(len(thislessArgTypes)):
file.write(thislessArgTypes[i].passName())
if (i < (len(thislessArgTypes)-1)):
file.write(', ')
file.write(')\n')
# If this is an augmented assignment operator like +=, we have special rules
# In this case we simply call the C++ function, make sure we got the same
# return value back, then return self. Otherwise if you let it go through the
# normal system, it actually deletes the old Python object causing the C++ memory
# to be deleted then returns a new Python shadow object with the old C++ pointer... BAD!
if self.getFinalName() in augmentedAssignments:
indent(file, nesting+2, 'assert self.this == returnValue\n')
indent(file, nesting+2, 'return self\n')
else:
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
returnType.generateReturnValueWrapper(methodClass, file,
self.typeDescriptor.userManagesMemory,
needsDowncast, nesting+2)
def outputMethodFooter(self, methodClass, file, nesting):
indent(file, nesting, 'FFIExternalObject.funcToMethod(' +self.getFinalName()+ ',' + methodClass.foreignTypeName + ",'" +self.getFinalName() +"')\n")
indent(file, nesting, 'del ' + self.getFinalName()+' \n')
indent(file, nesting+1,'\n')
#indent(file, nesting, methodClass.foreignTypeName +'.'+ self.getFinalName() + ' = staticmethod(' + self.getFinalName() + ')\n')
#indent(file, nesting,'del ' + self.getFinalName()+' \n')
#indent(file, nesting+1, '\n')
indent(file, nesting+1, '\n')
##################################################
## Static Method Code Generation
##################################################
def outputStaticHeader(self, methodClass, file, nesting):
argTypes = self.typeDescriptor.argumentTypes
indent(file, nesting, 'def ' + self.getFinalName() + '(')
for i in range(len(argTypes)):
file.write(argTypes[i].name)
if (i < (len(argTypes)-1)):
file.write(', ')
file.write('):\n')
def outputStaticBody(self, methodClass, file, nesting):
# The method body will look something like
# returnValue = panda.class_method(self.this, arg)
# returnValue.userManagesMemory = 1 (optional)
# return returnValue
self.outputCFunctionComment(file, nesting+2)
argTypes = self.typeDescriptor.argumentTypes
thislessArgTypes = self.typeDescriptor.thislessArgTypes()
self.outputTypeChecking(methodClass, thislessArgTypes, file, nesting+2)
indent(file, nesting+2, 'returnValue = ' + self.typeDescriptor.moduleName + '.'
+ self.typeDescriptor.wrapperName + '(')
# Static methods do not take the this parameter
if (len(thislessArgTypes) > 0):
for i in range(len(thislessArgTypes)):
file.write(thislessArgTypes[i].passName())
if (i < (len(thislessArgTypes)-1)):
file.write(', ')
file.write(')\n')
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
returnType.generateReturnValueWrapper(methodClass, file,
self.typeDescriptor.userManagesMemory,
1, nesting+2)
def outputStaticFooter(self, methodClass, file, nesting):
indent(file, nesting, methodClass.foreignTypeName +'.'+ self.getFinalName() + ' = staticmethod(' + self.getFinalName() + ')\n')
indent(file, nesting,'del ' + self.getFinalName()+' \n')
indent(file, nesting+1, '\n')
##################################################
## Upcast Method Code Generation
##################################################
def outputInheritedMethodHeader(self, methodClass, parentList, file, nesting, needsDowncast):
argTypes = self.typeDescriptor.argumentTypes
thislessArgTypes = self.typeDescriptor.thislessArgTypes()
indent(file, nesting, 'def ' + self.getFinalName() + '(self')
if (len(thislessArgTypes) > 0):
file.write(', ')
for i in range(len(thislessArgTypes)):
file.write(thislessArgTypes[i].name)
if (i < (len(thislessArgTypes)-1)):
file.write(', ')
file.write('):\n')
def outputInheritedMethodBody(self, methodClass, parentList, file, nesting, needsDowncast):
# The method body will look something like
# upcastSelf = self.upcastToParentClass()
# returnValue = libpanda.method(upcastSelf.this, arg)
# returnValue.userManagesMemory = 1 (optional)
# return returnValue
self.outputCFunctionComment(file, nesting+2)
argTypes = self.typeDescriptor.argumentTypes
thislessArgTypes = self.typeDescriptor.thislessArgTypes()
self.outputTypeChecking(methodClass, thislessArgTypes, file, nesting+2)
indent(file, nesting+2, 'upcastSelf = self\n')
for i in range(len(parentList)):
# Only output the upcast call if that parent class defines it
parentClass = parentList[i]
methodName = 'upcastTo' + parentClass.foreignTypeName
if (i != 0):
childClass = parentList[i-1]
if childClass.hasMethodNamed(methodName):
indent(file, nesting+2, 'upcastSelf = upcastSelf.' + methodName + '()\n')
else:
indent(file, nesting+2, '# upcastSelf = upcastSelf.' + methodName + '()\n')
else:
if methodClass.hasMethodNamed(methodName):
indent(file, nesting+2, 'upcastSelf = upcastSelf.' + methodName + '()\n')
else:
indent(file, nesting+2, '# upcastSelf = upcastSelf.' + methodName + '()\n')
indent(file, nesting+2, 'returnValue = ' + self.typeDescriptor.moduleName
+ '.' + self.typeDescriptor.wrapperName + '(upcastSelf.this')
if (len(thislessArgTypes) > 0):
file.write(', ')
for i in range(len(thislessArgTypes)):
file.write(thislessArgTypes[i].passName())
if (i < (len(thislessArgTypes)-1)):
file.write(', ')
file.write(')\n')
returnType = self.typeDescriptor.returnType.recursiveTypeDescriptor()
# Generate the return value code with no downcast instructions
returnType.generateReturnValueWrapper(methodClass, file,
self.typeDescriptor.userManagesMemory,
needsDowncast, nesting+2)
def outputInheritedMethodFooter(self, methodClass, parentList, file, nesting, needsDowncast):
indent(file, nesting, 'FFIExternalObject.funcToMethod(' +self.getFinalName()+ ',' + methodClass.foreignTypeName + ",'" +self.getFinalName() +"')\n")
indent(file, nesting, 'del ' + self.getFinalName()+' \n')
indent(file, nesting+1,'\n')
class GlobalValueSpecification:
def __init__(self):
self.name = ''
# We really do not need the descriptor for the value, just
# the getter and setter
# self.typeDescriptor = None
# To be filled in with a GlobalFunctionSpecification
self.getter = None
# To be filled in with a GlobalFunctionSpecification
self.setter = None
def generateGlobalCode(self, file):
indent(file, 0, '# Global value: ' + self.name + '\n')
if self.getter:
self.getter.generateGlobalCode(file)
if self.setter:
self.setter.generateGlobalCode(file)
indent(file, 0, '\n')
# Manifest symbols
class ManifestSpecification:
def __init__(self):
self.name = ''
# We are not currently using the type descriptor
self.typeDescriptor = None
# To be filled in with a GlobalFunctionSpecification
# if this manifest has one
self.getter = None
# Manifests that have int values have their int value defined
# instead of having to call a getter (because there are so many of them)
self.intValue = None
# The string definition of this manifest
self.definition = None
def generateGlobalCode(self, file):
# Note, if the manifest has no value and no getter we do not output anything
# even though they may be defined in the C++ sense. Without any values
# they are pretty useless in Python
# If it has an int value, just output that instead of bothering
# with a getter
if (self.intValue != None):
indent(file, 0, '# Manifest: ' + self.name + '\n')
indent(file, 0, (self.name + ' = ' + repr(self.intValue) + '\n'))
indent(file, 0, '\n')
elif self.definition:
indent(file, 0, ('# Manifest: ' + self.name + ' definition: ' +
self.definition + '\n'))
# Out put the getter
if self.getter:
self.getter.generateGlobalCode(file)
indent(file, 0, '\n')
class MethodArgumentSpecification:
def __init__(self):
self.name = ''
self.typeDescriptor = None
# By default it is not the this pointer
self.isThis = 0
def passName(self):
if (self.typeDescriptor.recursiveTypeDescriptor().__class__ == \
FFITypes.ClassTypeDescriptor):
return self.name + '.this'
else:
return self.name

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
#define INSTALL_SCRIPTS genPyCode.py
#define INSTALL_MODULES panda3d.py
// If we're on Win32 without Cygwin, install the genPyCode.bat file;
// for all other platforms, install the genPyCode sh script.
#if $[MAKE_BAT_SCRIPTS]
#define INSTALL_SCRIPTS $[INSTALL_SCRIPTS] genPyCode.bat
#else
#define INSTALL_SCRIPTS $[INSTALL_SCRIPTS] genPyCode
#endif
#include $[THISDIRPREFIX]genPyCode.pp

View File

@ -1,220 +0,0 @@
//
// genPyCode.pp
//
// This file defines the script to auto-generate a sensible genPyCode
// for the user based on the Config.pp variables in effect at the time
// ppremake is run. The generated script will know which directories
// to generate its output to, as well as which source files to read
// for the input.
//
#define install_dir $[$[upcase $[PACKAGE]]_INSTALL]
#define install_lib_dir $[or $[INSTALL_LIB_DIR],$[install_dir]/lib]
#define install_bin_dir $[or $[INSTALL_BIN_DIR],$[install_dir]/bin]
#define install_igatedb_dir $[or $[INSTALL_IGATEDB_DIR],$[install_dir]/etc]
#define python $[PYTHON_COMMAND]
#if $[USE_DEBUG_PYTHON]
#define python $[PYTHON_DEBUG_COMMAND]
#endif
// If we're on Win32 without Cygwin, generate a genPyCode.bat file;
// for all other platforms, generate a genPyCode sh script. Although
// it's true that on non-Win32 platforms we don't need the script
// (since the python file itself could be made directly executable),
// we generate the script anyway to be consistent with Win32, which
// does require it.
#if $[MAKE_BAT_SCRIPTS]
#output genPyCode.bat
@echo off
rem #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
rem ################################# DO NOT EDIT ###########################
$[python] -u $[osfilename $[install_bin_dir]/genPyCode.py] %1 %2 %3 %4 %5 %6 %7 %8 %9
#end genPyCode.bat
#else // MAKE_BAT_SCRIPTS
#output genPyCode $[if $[>= $[PPREMAKE_VERSION],1.21],binary]
#! /bin/sh
#### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
################################# DO NOT EDIT ###########################
#if $[CTPROJS]
# This script was generated while the user was using the ctattach
# tools. That had better still be the case.
#if $[WINDOWS_PLATFORM]
$[python] -u `cygpath -w $DIRECT/built/bin/genPyCode.py` "$@"
#else
$[python] -u $DIRECT/built/bin/genPyCode.py "$@"
#endif
#else
$[python] -u '$[osfilename $[install_bin_dir]/genPyCode.py]' "$@"
#endif
#end genPyCode
#endif // MAKE_BAT_SCRIPTS
#output genPyCode.py
#! /usr/bin/env $[python]
#### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
################################# DO NOT EDIT ###########################
import os
import sys
import glob
#if $[CTPROJS]
# This script was generated while the user was using the ctattach
# tools. That had better still be the case.
def deCygwinify(path):
if os.name in ['nt'] and path[0] == '/':
# On Windows, we may need to convert from a Cygwin-style path
# to a native Windows path.
# Check for a case like /i/ or /p/: this converts
# to i:/ or p:/.
dirs = path.split('/')
if len(dirs) > 2 and len(dirs[1]) == 1:
path = '%s:\%s' % (dirs[1], '\\'.join(dirs[2:]))
else:
# Otherwise, prepend $PANDA_ROOT and flip the slashes.
pandaRoot = os.getenv('PANDA_ROOT')
if pandaRoot:
path = os.path.normpath(pandaRoot + path)
return path
ctprojs = os.getenv('CTPROJS')
if not ctprojs:
print "You are no longer attached to any trees!"
sys.exit(1)
directDir = os.getenv('DIRECT')
if not directDir:
print "You are not attached to DIRECT!"
sys.exit(1)
directDir = deCygwinify(directDir)
# Make sure that direct.showbase.FindCtaPaths gets imported.
parent, base = os.path.split(directDir)
if parent not in sys.path:
sys.path.append(parent)
import direct.showbase.FindCtaPaths
#endif // CTPROJS
from direct.ffi import DoGenPyCode
from direct.ffi import FFIConstants
# The following parameters were baked in to this script at the time
# ppremake was run in Direct.
#define extensions_name $[if $[PYTHON_NATIVE],extensions_native,extensions]
#if $[>= $[OPTIMIZE], 4]
FFIConstants.wantComments = 0
FFIConstants.wantTypeChecking = 0
#endif
DoGenPyCode.interrogateLib = r'libdtoolconfig'
DoGenPyCode.codeLibs = r'$[GENPYCODE_LIBS]'.split()
DoGenPyCode.native = $[if $[PYTHON_NATIVE],1,0]
#if $[not $[CTPROJS]]
// Since the user is not using ctattach, bake these variables in too.
DoGenPyCode.directDir = r'$[osfilename $[TOPDIR]]'
DoGenPyCode.outputCodeDir = r'$[osfilename $[install_lib_dir]/pandac]'
DoGenPyCode.outputHTMLDir = r'$[osfilename $[install_data_dir]/doc]'
DoGenPyCode.extensionsDir = r'$[osfilename $[TOPDIR]/src/$[extensions_name]]'
DoGenPyCode.etcPath = [r'$[osfilename $[install_igatedb_dir]]']
DoGenPyCode.pythonSourcePath = r'$[osfilename $[TOPDIR]]'
#else
# The user is expected to be using ctattach, so don't bake in the
# following four; these instead come from the dynamic settings set by
# ctattach.
DoGenPyCode.directDir = directDir
DoGenPyCode.outputCodeDir = os.path.join(directDir, 'built', 'lib', 'pandac')
DoGenPyCode.outputHTMLDir = os.path.join(directDir, 'built', 'shared', 'doc')
DoGenPyCode.extensionsDir = os.path.join(directDir, 'src', '$[extensions_name]')
DoGenPyCode.etcPath = []
DoGenPyCode.pythonSourcePath = []
#if $[CTA_GENERIC_GENPYCODE]
# Look for additional packages (other than the basic three)
# that the user might be dynamically attached to.
packages = []
for proj in ctprojs.split():
projName = proj.split(':')[0]
packages.append(projName)
packages.reverse()
try:
from direct.extensions_native.extension_native_helpers import Dtool_PreloadDLL
except ImportError:
print "Unable to import Dtool_PreloadDLL, not trying generic libraries."
else:
for package in packages:
packageDir = os.getenv(package)
if packageDir:
packageDir = deCygwinify(packageDir)
etcDir = os.path.join(packageDir, 'etc')
try:
inFiles = glob.glob(os.path.join(etcDir, 'built', '*.in'))
except:
inFiles = []
if inFiles:
DoGenPyCode.etcPath.append(etcDir)
if package not in ['WINTOOLS', 'DTOOL', 'DIRECT', 'PANDA']:
DoGenPyCode.pythonSourcePath.append(packageDir)
libDir = os.path.join(packageDir, 'built', 'lib')
try:
files = os.listdir(libDir)
except:
files = []
for file in files:
if os.path.isfile(os.path.join(libDir, file)):
basename, ext = os.path.splitext(file)
# Try to import the library. If we can import it,
# instrument it.
try:
Dtool_PreloadDLL(basename)
# __import__(basename, globals(), locals())
isModule = 1
except:
isModule = 0
#
# RHH.... hack OPT2 .. py debug libraries...
#
if not isModule:
# debug py library magin naming in windows..
basename = basename.replace('_d','')
try:
Dtool_PreloadDLL(basename)
# __import__(basename, globals(), locals())
isModule = 1
except:
isModule = 0
if isModule:
if basename not in DoGenPyCode.codeLibs:
DoGenPyCode.codeLibs.append(basename)
#endif // CTA_GENERIC_GENPYCODE
#endif // CTPROJS
DoGenPyCode.run()
#end genPyCode.py

View File

@ -1,96 +0,0 @@
##############################################################
#
# This module should be invoked by a shell-script that says:
#
# python -c "import direct.ffi.jGenPyCode" <arguments>
#
# Before invoking python, the shell-script may need to set
# these environment variables, to make sure that everything
# can be located appropriately.
#
# PYTHONPATH
# PATH
# LD_LIBRARY_PATH
#
##############################################################
import sys, os
##############################################################
#
# Locate the 'direct' tree and the 'pandac' tree.
#
##############################################################
DIRECT=None
PANDAC=None
for dir in sys.path:
if (DIRECT is None):
if (dir != "") and os.path.exists(os.path.join(dir,"direct")):
DIRECT=os.path.join(dir,"direct")
if (PANDAC is None):
if (dir != "") and (os.path.exists(os.path.join(dir,"pandac"))):
PANDAC=os.path.join(dir,"pandac")
if (DIRECT is None):
sys.exit("Could not locate the 'direct' python modules")
if (PANDAC is None):
sys.exit("Could not locate the 'pandac' python modules")
##############################################################
#
# Locate direct/src/extensions.
#
# It could be inside the direct tree. It may be underneath
# a 'src' subdirectory. Or, the direct tree may actually be
# a stub that points to the source tree.
#
##############################################################
EXTENSIONS=None
if (EXTENSIONS is None):
if os.path.isdir(os.path.join(DIRECT,"src","extensions_native")):
EXTENSIONS=os.path.join(DIRECT,"src","extensions_native")
if (EXTENSIONS is None):
if os.path.isdir(os.path.join(DIRECT,"extensions_native")):
EXTENSIONS=os.path.join(DIRECT,"extensions_native")
if (EXTENSIONS is None):
if os.path.isdir(os.path.join(DIRECT,"..","..","direct","src","extensions_native")):
EXTENSIONS=os.path.join(DIRECT,"..","..","direct","src","extensions_native")
if (EXTENSIONS is None):
sys.exit("Could not locate direct/src/extensions_native")
##############################################################
#
# Call genpycode with default paths.
#
##############################################################
from direct.ffi import DoGenPyCode
DoGenPyCode.outputCodeDir = PANDAC
DoGenPyCode.outputHTMLDir = os.path.join(PANDAC,"..","doc")
DoGenPyCode.directDir = DIRECT
DoGenPyCode.extensionsDir = EXTENSIONS
DoGenPyCode.interrogateLib = r'libdtoolconfig'
DoGenPyCode.codeLibs = ['libpandaexpress','libpanda','libpandaphysics','libpandafx','libp3direct','libpandaskel','libpandaegg','libpandaode']
DoGenPyCode.etcPath = [os.path.join(PANDAC,"input")]
DoGenPyCode.pythonSourcePath = [DIRECT]
DoGenPyCode.native = 1
#print "outputDir = ", DoGenPyCode.outputDir
#print "directDir = ", DoGenPyCode.directDir
#print "extensionsDir = ", DoGenPyCode.extensionsDir
#print "interrogateLib = ", DoGenPyCode.interrogateLib
#print "codeLibs = ", DoGenPyCode.codeLibs
#print "etcPath = ", DoGenPyCode.etcPath
#print "native = ", DoGenPyCode.native
DoGenPyCode.run()
os._exit(0)

View File

@ -1,275 +0,0 @@
#!/bin/true
import os, sys, imp
panda3d_modules = {
"core" :("libpandaexpress", "libpanda"),
"dtoolconfig" : "libp3dtoolconfig",
"physics" : "libpandaphysics",
"fx" : "libpandafx",
"direct" : "libp3direct",
"egg" : "libpandaegg",
"ode" : "libpandaode",
"bullet" : "libpandabullet",
"vision" : "libp3vision",
"physx" : "libpandaphysx",
"ai" : "libpandaai",
"awesomium" : "libp3awesomium",
"speedtree" : "libpandaspeedtree",
"rocket" :("_rocketcore", "_rocketcontrols", "libp3rocket"),
"vrpn" : "libp3vrpn",
}
class panda3d_import_manager:
# Important: store a reference to the sys and os modules, as
# all references in the global namespace will be reset.
os = os
sys = sys
imp = imp
__libraries__ = {}
# Figure out the dll suffix (commonly, _d for windows debug builds),
# and the dll extension.
dll_suffix = ''
dll_exts = ('.pyd', '.so')
if sys.platform == "win32":
dll_exts = ('.pyd', '.dll')
# We allow the caller to preload dll_suffix into the sys module.
dll_suffix = getattr(sys, 'dll_suffix', None)
if dll_suffix is None:
# Otherwise, we try to determine it from the executable name:
# python_d.exe implies _d across the board.
dll_suffix = ''
if sys.executable.endswith('_d.exe'):
dll_suffix = '_d'
# On OSX, extension modules can be loaded from either .so or .dylib.
if sys.platform == "darwin":
dll_exts = ('.pyd', '.so', '.dylib')
prepared = False
@classmethod
def __prepare(cls):
# This method only needs to be called once.
if cls.prepared:
return
cls.prepared = True
# First, we must ensure that the library path is
# modified to locate all of the dynamic libraries.
target = None
filename = "libpandaexpress" + cls.dll_suffix
for dir in cls.sys.path + [cls.sys.prefix]:
lib = cls.os.path.join(dir, filename)
for dll_ext in cls.dll_exts:
if (cls.os.path.exists(lib + dll_ext)):
target = dir
break
if target == None:
raise ImportError("Cannot find %s" % (filename))
target = cls.os.path.abspath(target)
# And add that directory to the system library path.
if cls.sys.platform == "win32":
cls.__prepend_to_path("PATH", target)
else:
cls.__prepend_to_path("LD_LIBRARY_PATH", target)
if cls.sys.platform == "darwin":
cls.__prepend_to_path("DYLD_LIBRARY_PATH", target)
@classmethod
def __prepend_to_path(cls, varname, target):
""" Prepends the given directory to the
specified search path environment variable. """
# Get the current value
if varname in cls.os.environ:
path = cls.os.environ[varname].strip(cls.os.pathsep)
else:
path = ""
# Prepend our value, if it's not already the first thing
if len(path) == 0:
cls.os.environ[varname] = target
elif not path.startswith(target):
cls.os.environ[varname] = target + cls.os.pathsep + path
@classmethod
def libimport(cls, name):
""" Imports and returns the specified library name. The
provided library name has to be without dll extension. """
if name in cls.__libraries__:
return cls.__libraries__[name]
if not cls.prepared: cls.__prepare()
# Try to import it normally first.
try:
return __import__(name)
except ImportError:
_, err, _ = cls.sys.exc_info()
if str(err) != "No module named " + name and \
str(err) != "No module named '%s'" % name:
raise
# Hm, importing normally didn't work. Let's try imp.load_dynamic.
# But first, locate the desired library.
target = None
filename = name + cls.dll_suffix
for dir in cls.sys.path + [cls.sys.prefix]:
lib = cls.os.path.join(dir, filename)
for dll_ext in cls.dll_exts:
if (cls.os.path.exists(lib + dll_ext)):
target = lib + dll_ext
break
if target:
# Once we find the first match, break all the way
# out--don't keep looking for a second match.
break
if target == None:
message = "DLL loader cannot find %s." % name
raise ImportError(message)
target = cls.os.path.abspath(target)
# Now import the file explicitly.
lib = cls.imp.load_dynamic(name, target)
cls.__libraries__[name] = lib
return lib
class panda3d_submodule(type(sys)):
""" Represents a submodule of 'panda3d' that represents a dynamic
library. This dynamic library is loaded when something is accessed
from the module. """
__manager__ = panda3d_import_manager
def __init__(self, name, library):
type(sys).__init__(self, "panda3d." + name)
self.__library__ = library
self.__libraries__ = [self.__library__]
def __load__(self):
""" Forces the library to be loaded right now. """
self.__manager__.libimport(self.__library__)
def __getattr__(self, name):
mod = self.__manager__.libimport(self.__library__)
if name == "__all__":
everything = []
for obj in mod.__dict__.keys():
if not obj.startswith("__"):
everything.append(obj)
self.__all__ = everything
return everything
elif name == "__library__":
return self.__library__
elif name == "__libraries__":
return self.__libraries__
elif name in mod.__dict__.keys():
value = mod.__dict__[name]
setattr(self, name, value)
return value
# Not found? Raise the error that Python would normally raise.
raise AttributeError("'module' object has no attribute '%s'" % name)
class panda3d_multisubmodule(type(sys)):
""" Represents a submodule of 'panda3d' that represents multiple
dynamic libraries. These are loaded when something is accessed
from the module. """
__manager__ = panda3d_import_manager
def __init__(self, name, libraries):
type(sys).__init__(self, "panda3d." + name)
self.__libraries__ = libraries
def __load__(self):
""" Forces the libraries to be loaded right now. """
err = []
for lib in self.__libraries__:
try:
self.__manager__.libimport(lib)
except ImportError:
_, msg, _ = self.__manager__.sys.exc_info()
err.append(str(msg).rstrip('.'))
if len(err) > 0:
raise ImportError(', '.join(err))
def __getattr__(self, name):
if name == "__all__":
everything = []
for lib in self.__libraries__:
for obj in self.__manager__.libimport(lib).__dict__:
if not obj.startswith("__"):
everything.append(obj)
self.__all__ = everything
return everything
elif name == "__libraries__":
return self.__libraries__
for lib in self.__libraries__:
mod = self.__manager__.libimport(lib)
if name in mod.__dict__:
value = mod.__dict__[name]
setattr(self, name, value)
return value
# Not found? Raise the error that Python would normally raise.
raise AttributeError("'module' object has no attribute '%s'" % name)
class panda3d_module(type(sys)):
""" Represents the main 'panda3d' module. """
__file__ = __file__
modules = panda3d_modules
__manager__ = panda3d_import_manager
def __load__(self):
""" Force all the libraries to be loaded right now. """
err = []
for module in self.modules:
try:
self.__manager__.sys.modules["panda3d.%s" % module].__load__()
except ImportError:
_, msg, _ = self.__manager__.sys.exc_info()
err.append(str(msg).rstrip('.'))
if len(err) > 0:
raise ImportError(', '.join(err))
def __getattr__(self, name):
if name == "__all__":
self.__all__ = name
return self.modules.keys()
elif name == "__file__":
return self.__file__
elif name in self.modules:
value = self.__manager__.sys.modules["panda3d.%s" % name]
setattr(self, name, value)
return value
# Not found? Raise the error that Python would normally raise.
raise AttributeError("'module' object has no attribute '%s'" % name)
# Create the fake module objects and insert them into sys.modules.
this = panda3d_module("panda3d")
# Loop through the module dictionary, create a fake
# module for each of them, and insert them into
# sys.modules and into the 'panda3d' fake module.
for mod, lib in panda3d_modules.items():
if isinstance(lib, tuple):
module = panda3d_multisubmodule(mod, lib)
else:
module = panda3d_submodule(mod, lib)
sys.modules["panda3d." + mod] = module
this.__dict__[mod] = module
# Important: this must be the last thing in this file
sys.modules["panda3d"] = this

View File

@ -1,4 +0,0 @@
#defer install_data_dir $[install_lib_dir]/$[PACKAGE]/$[DIRNAME]
#define INSTALL_DATA filter-bloomi.sha filter-bloomx.sha filter-bloomy.sha filter-blurx.sha filter-blury.sha filter-copy.sha filter-down4.sha

View File

@ -1,38 +0,0 @@
#define BUILD_DIRECTORY $[WANT_NATIVE_NET]
#define USE_PACKAGES native_net
#define OTHER_LIBS \
p3express:c pandaexpress:m \
p3pstatclient:c p3pipeline:c panda:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m p3prc:c p3pandabase:c \
$[if $[HAVE_NET],p3net:c] $[if $[WANT_NATIVE_NET],p3nativenet:c] \
p3linmath:c p3putil:c
#define LOCAL_LIBS \
p3directbase
#define C++FLAGS -DWITHIN_PANDA
#define UNIX_SYS_LIBS m
#define USE_PACKAGES python
#begin lib_target
#define TARGET p3http
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
#define SOURCES \
config_http.h \
http_connection.h \
http_request.h
#define INCLUDED_SOURCES \
config_http.cxx \
http_connection.cxx \
parsedhttprequest.cxx \
http_request.cxx
#define IGATESCAN all
#end lib_target

View File

@ -7,6 +7,8 @@ from direct.showbase.DirectObject import DirectObject
from direct.task.Task import Task, TaskManager
from panda3d.core import *
from panda3d.direct import *
from direct.extensions_native import CInterval_extensions
from direct.extensions_native import NodePath_extensions
import math
class Interval(DirectObject):

View File

@ -1,54 +0,0 @@
#begin lib_target
#define TARGET p3interval
#define LOCAL_LIBS \
p3directbase
#define OTHER_LIBS \
p3downloader:c p3linmath:c \
p3chan:c p3event:c p3gobj:c p3pnmimage:c p3mathutil:c \
p3pgraph:c p3putil:c panda:m p3express:c pandaexpress:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3pandabase:c p3prc:c p3gsgbase:c p3pstatclient:c \
$[if $[HAVE_NET],p3net:c] $[if $[WANT_NATIVE_NET],p3nativenet:c] \
p3pipeline:c
#define SOURCES \
config_interval.cxx config_interval.h \
cInterval.cxx cInterval.I cInterval.h \
cIntervalManager.cxx cIntervalManager.I cIntervalManager.h \
cConstraintInterval.cxx cConstraintInterval.I cConstraintInterval.h \
cConstrainTransformInterval.cxx cConstrainTransformInterval.I cConstrainTransformInterval.h \
cConstrainPosInterval.cxx cConstrainPosInterval.I cConstrainPosInterval.h \
cConstrainHprInterval.cxx cConstrainHprInterval.I cConstrainHprInterval.h \
cConstrainPosHprInterval.cxx cConstrainPosHprInterval.I cConstrainPosHprInterval.h \
cLerpInterval.cxx cLerpInterval.I cLerpInterval.h \
cLerpNodePathInterval.cxx cLerpNodePathInterval.I cLerpNodePathInterval.h \
cLerpAnimEffectInterval.cxx cLerpAnimEffectInterval.I cLerpAnimEffectInterval.h \
cMetaInterval.cxx cMetaInterval.I cMetaInterval.h \
hideInterval.cxx hideInterval.I hideInterval.h \
lerpblend.cxx lerpblend.h \
showInterval.cxx showInterval.I showInterval.h \
waitInterval.cxx waitInterval.I waitInterval.h \
lerp_helpers.h
#define INSTALL_HEADERS \
config_interval.h \
cInterval.I cInterval.h \
cIntervalManager.I cIntervalManager.h \
cConstraintInterval.I cConstraintInterval.h \
cConstrainTransformInterval.I cConstrainTransformInterval.h \
cConstrainPosInterval.I cConstrainPosInterval.h \
cConstrainHprInterval.I cConstrainHprInterval.h \
cConstrainPosHprInterval.I cConstrainPosHprInterval.h \
cLerpInterval.I cLerpInterval.h \
cLerpNodePathInterval.I cLerpNodePathInterval.h \
cLerpAnimEffectInterval.I cLerpAnimEffectInterval.h \
cMetaInterval.I cMetaInterval.h \
hideInterval.I hideInterval.h \
lerpblend.h \
showInterval.I showInterval.h \
waitInterval.I waitInterval.h \
lerp_helpers.h
#define IGATESCAN all
#end lib_target

View File

@ -1,3 +0,0 @@
// Toontown-specific codes have been moved into $TOONTOWN source tree

View File

@ -4,6 +4,7 @@ from panda3d.core import *
from panda3d.direct import *
from direct.task import Task
from direct.showbase.DirectObject import DirectObject
from direct.directnotify.DirectNotifyGlobal import directNotify
def remove_task ( ):

View File

@ -1,42 +0,0 @@
#begin lib_target
#define TARGET p3motiontrail
#define LOCAL_LIBS \
p3directbase
#define OTHER_LIBS \
p3linmath:c \
p3mathutil:c \
p3gobj:c \
p3putil:c \
p3pipeline:c \
p3event:c \
p3pstatclient:c \
p3pnmimage:c \
$[if $[HAVE_NET],p3net:c] $[if $[WANT_NATIVE_NET],p3nativenet:c] \
p3pgraph:c \
panda:m \
p3express:c \
p3downloader:c \
pandaexpress:m \
p3interrogatedb:c \
p3dconfig:c \
p3dtoolconfig:m \
p3dtoolutil:c \
p3dtoolbase:c \
p3dtool:m \
p3pandabase:c \
p3prc:c \
p3gsgbase:c \
p3parametrics:c
#define SOURCES \
config_motiontrail.cxx config_motiontrail.h \
cMotionTrail.cxx cMotionTrail.h
#define INSTALL_HEADERS \
config_motiontrail.h \
cMotionTrail.h
#define IGATESCAN all
#end lib_target

View File

@ -3361,7 +3361,7 @@ class Packager:
self.currentPackage.addExtensionModules()
self.currentPackage.freezer.reset()
self.do_file('panda3d/_core.pyd', newDir='panda3d')
self.do_file('panda3d/core.pyd', newDir='panda3d')
# This is the key Python module that is imported at runtime to
# start an application running.

View File

@ -1,77 +0,0 @@
// This directory contains the Python code necessary to interface with
// the browser plugin system at runtime. It also contains the Python
// scripts to create and manage p3d files, which are the actual
// runtime applications, and packages, which are additional code and
// assets that can be downloaded at runtime by p3d files.
#if $[BUILD_P3D_SCRIPTS]
// If the developer has asked to build the shell script to invoke
// ppackage.py (or some other Python script in this directory), then
// do so now. These convenient scripts aren't built by default,
// because usually ppackage.p3d etc. is a more reliable way to
// invoke these applications. However, there might be development
// environments that don't have a ppackage.p3d available, in which
// case it is convenient to have one or more of these scripts.
#define INSTALL_SCRIPTS $[BUILD_P3D_SCRIPTS:%=%.py]
// On Windows, we generate a batch file; on other platforms
// (including Cygwin), we generate a sh script.
#define install_dir $[$[upcase $[PACKAGE]]_INSTALL]
#define install_bin_dir $[or $[INSTALL_BIN_DIR],$[install_dir]/bin]
#define python $[PYTHON_COMMAND]
#if $[USE_DEBUG_PYTHON]
#define python $[PYTHON_DEBUG_COMMAND]
#endif
#if $[>= $[OPTIMIZE], 4]
#define python $[python] -OO
#endif
#foreach scriptname $[BUILD_P3D_SCRIPTS]
#if $[MAKE_BAT_SCRIPTS]
#set INSTALL_SCRIPTS $[INSTALL_SCRIPTS] $[scriptname].bat
#else
#set INSTALL_SCRIPTS $[INSTALL_SCRIPTS] $[scriptname]
#endif
#if $[MAT_BAT_SCRIPTS]
#output $[scriptname].bat notouch
@echo off
rem #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
rem ################################# DO NOT EDIT ###########################
$[python] -u $[osfilename $[install_bin_dir]/$[scriptname].py] %1 %2 %3 %4 %5 %6 %7 %8 %9
#end $[scriptname].bat
#else // MAKE_BAT_SCRIPTS
#output $[scriptname] binary notouch
#! /bin/sh
#### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
################################# DO NOT EDIT ###########################
#if $[CTPROJS]
# This script was generated while the user was using the ctattach
# tools. That had better still be the case.
#if $[WINDOWS_PLATFORM]
$[python] -u `cygpath -w $DIRECT/built/bin/$[scriptname].py` "$@"
#else
$[python] -u $DIRECT/built/bin/$[scriptname].py "$@"
#endif
#else
$[python] -u '$[osfilename $[install_bin_dir]/$[scriptname].py]' "$@"
#endif
#end $[scriptname]
#endif // MAKE_BAT_SCRIPTS
#end scriptname
#endif // WANT_PACKAGE_SCRIPT

View File

@ -1,369 +0,0 @@
// This directory contains the code for the "Core API" part of the
// Panda3D browser plugin system, which is not built unless you have
// defined HAVE_P3D_PLUGIN in your Config.pp. Most Panda3D developers
// will have no need to build this, unless you are developing the
// plugin system itself.
// This directory also contains the code for p3dpython.exe, which is
// part of the Panda3D rtdist build. It's not strictly part of the
// "Core API"; it is packaged as part of each downloadable version of
// Panda3D. It is only built if you have defined either
// PANDA_PACKAGE_HOST_URL or HAVE_P3D_RTDIST in your Config.pp, which
// indicates an intention to build a downloadable version of Panda3D.
// Developers who are preparing a custom Panda3D package for download
// by the plugin will need to build this.
// If P3D_PLUGIN_MT is defined, then (on Windows) /MT is used to
// compile the core API and the NPAPI and ActiveX plugins, instead of
// /MD. This links the plugin with the static C runtime library,
// instead of the dynamic runtime library, which is much better for
// distributing the plugin with the XPI and CAB interfaces. This
// requires that special /MT versions of OpenSSL and zlib are available.
#define _MT $[if $[P3D_PLUGIN_MT],_mt]
#define COREAPI_SOURCES \
fileSpec.cxx fileSpec.h fileSpec.I \
find_root_dir.cxx find_root_dir.h \
$[if $[IS_OSX],find_root_dir_assist.mm] \
get_tinyxml.h \
binaryXml.cxx binaryXml.h \
fhandle.h \
handleStream.cxx handleStream.h handleStream.I \
handleStreamBuf.cxx handleStreamBuf.h handleStreamBuf.I \
mkdir_complete.cxx mkdir_complete.h \
parse_color.cxx parse_color.h \
wstring_encode.cxx wstring_encode.h \
p3d_lock.h p3d_plugin.h \
p3d_plugin_config.h \
p3d_plugin_common.h \
p3dAuthSession.h p3dAuthSession.I \
p3dBoolObject.h \
p3dConcreteSequence.h \
p3dConcreteStruct.h \
p3dConditionVar.h p3dConditionVar.I \
p3dDownload.h p3dDownload.I \
p3dFileDownload.h p3dFileDownload.I \
p3dFileParams.h p3dFileParams.I \
p3dFloatObject.h \
p3dHost.h p3dHost.I \
p3dInstance.h p3dInstance.I \
p3dInstanceManager.h p3dInstanceManager.I \
p3dIntObject.h \
p3dMainObject.h \
p3dMultifileReader.h p3dMultifileReader.I \
p3dNoneObject.h \
p3dObject.h p3dObject.I \
p3dOsxSplashWindow.h p3dOsxSplashWindow.I \
p3dPackage.h p3dPackage.I \
p3dPatchfileReader.h p3dPatchfileReader.I \
p3dPatchFinder.h p3dPatchFinder.I \
p3dPythonObject.h \
p3dReferenceCount.h p3dReferenceCount.I \
p3dSession.h p3dSession.I \
p3dSplashWindow.h p3dSplashWindow.I \
p3dStringObject.h \
p3dTemporaryFile.h p3dTemporaryFile.I \
p3dUndefinedObject.h \
p3dWinSplashWindow.h p3dWinSplashWindow.I \
p3dX11SplashWindow.h p3dX11SplashWindow.I \
p3dWindowParams.h p3dWindowParams.I \
plugin_get_x11.h \
xml_helpers.h \
run_p3dpython.h
#define COREAPI_INCLUDED_SOURCES \
p3d_plugin.cxx \
p3dAuthSession.cxx \
p3dBoolObject.cxx \
p3dConcreteSequence.cxx \
p3dConcreteStruct.cxx \
p3dConditionVar.cxx \
p3dDownload.cxx \
p3dFileDownload.cxx \
p3dFileParams.cxx \
p3dFloatObject.cxx \
p3dHost.cxx \
p3dInstance.cxx \
p3dInstanceManager.cxx \
p3dIntObject.cxx \
p3dMainObject.cxx \
p3dMultifileReader.cxx \
p3dNoneObject.cxx \
p3dObject.cxx \
p3dOsxSplashWindow.cxx \
p3dPackage.cxx \
p3dPatchfileReader.cxx \
p3dPatchFinder.cxx \
p3dPythonObject.cxx \
p3dReferenceCount.cxx \
p3dSession.cxx \
p3dSplashWindow.cxx \
p3dStringObject.cxx \
p3dTemporaryFile.cxx \
p3dUndefinedObject.cxx \
p3dWinSplashWindow.cxx \
p3dX11SplashWindow.cxx \
p3dWindowParams.cxx \
xml_helpers.cxx
#begin lib_target
//
// p3d_plugin.dll, the main entry point to the Core API.
//
#define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_OPENSSL],$[HAVE_ZLIB]]
#define USE_PACKAGES openssl$[_MT] zlib$[_MT] x11
#define TARGET p3d_plugin
#define LIB_PREFIX
#define BUILDING_DLL BUILDING_P3D_PLUGIN
#define LINK_FORCE_STATIC_RELEASE_C_RUNTIME $[P3D_PLUGIN_MT]
#define OTHER_LIBS \
p3tinyxml$[_MT] $[if $[OSX_PLATFORM],p3subprocbuffer]
#define COMBINED_SOURCES p3d_plugin_composite1.cxx
#define SOURCES $[COREAPI_SOURCES]
#define INCLUDED_SOURCES $[COREAPI_INCLUDED_SOURCES]
#define INSTALL_HEADERS \
p3d_plugin.h
#define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib
#end lib_target
#begin static_lib_target
//
// libp3d_plugin_static.lib, the Core API as a static library (for p3dembed).
//
#define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_OPENSSL],$[HAVE_ZLIB]]
#define USE_PACKAGES openssl zlib x11
#define TARGET p3d_plugin_static
#define BUILDING_DLL BUILDING_P3D_PLUGIN
#define OTHER_LIBS \
p3tinyxml $[if $[OSX_PLATFORM],p3subprocbuffer]
#define COMBINED_SOURCES p3d_plugin_composite1.cxx
#define SOURCES $[COREAPI_SOURCES]
#define INCLUDED_SOURCES $[COREAPI_INCLUDED_SOURCES]
#define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib
#end static_lib_target
#begin bin_target
//
// p3dcert.exe, the authorization GUI invoked when the user clicks the
// red "play" button to approve an unknown certificate. Considered
// part of the Core API, though it is a separate download.
//
#if $[HAVE_FLTK]
#define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_FLTK],$[HAVE_OPENSSL]]
#define USE_PACKAGES fltk openssl
#define SOURCES p3dCert.cxx p3dCert.h
#else
#define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_WX],$[HAVE_OPENSSL]]
#define USE_PACKAGES wx openssl
#define SOURCES p3dCert_wx.cxx p3dCert_wx.h
#endif
#define TARGET p3dcert
#define SOURCES $[SOURCES] \
is_pathsep.h is_pathsep.I \
wstring_encode.cxx wstring_encode.h \
mkdir_complete.cxx mkdir_complete.h
#define OSX_SYS_FRAMEWORKS Carbon
#end bin_target
#define PLUGIN_COMMON_SOURCES \
load_plugin.cxx load_plugin.h \
fileSpec.cxx fileSpec.h fileSpec.I \
find_root_dir.cxx find_root_dir.h \
$[if $[IS_OSX],find_root_dir_assist.mm] \
is_pathsep.h is_pathsep.I \
mkdir_complete.cxx mkdir_complete.h \
get_twirl_data.cxx get_twirl_data.h \
parse_color.cxx parse_color.h \
wstring_encode.cxx wstring_encode.h
#begin static_lib_target
//
// libplugin_common.lib, a repository of code shared between the core
// API and the various plugin implementations.
//
#define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_OPENSSL]]
#define TARGET plugin_common
#define USE_PACKAGES openssl
#define SOURCES $[PLUGIN_COMMON_SOURCES]
#end static_lib_target
#if $[P3D_PLUGIN_MT]
#begin static_lib_target
//
// libplugin_common_mt.lib, the same as above, with /MT compilation.
//
#define BUILD_TARGET $[and $[HAVE_P3D_PLUGIN],$[HAVE_OPENSSL]]
#define TARGET plugin_common_mt
#define USE_PACKAGES openssl_mt
#define LINK_FORCE_STATIC_RELEASE_C_RUNTIME 1
#define SOURCES $[PLUGIN_COMMON_SOURCES]
#end static_lib_target
#endif // $[P3D_PLUGIN_MT]
// The remaining targets build p3dpython.exe and variants.
#begin bin_target
//
// p3dpython.exe, the primary entry point to the downloaded Panda3D
// runtime. This executable is run in a child process by the Core API
// to invoke a particular instance of Panda.
//
#define BUILD_TARGET $[and $[HAVE_P3D_RTDIST],$[HAVE_PYTHON],$[HAVE_OPENSSL]]
#define USE_PACKAGES python openssl cg
#define TARGET p3dpython
#define OTHER_LIBS \
p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3express:c pandaexpress:m p3dxml:c \
p3pgraph:c p3pgraphnodes:c p3cull:c p3gsgbase:c p3gobj:c \
p3mathutil:c p3downloader:c p3pnmimage:c \
p3prc:c p3pstatclient:c p3pandabase:c p3linmath:c p3putil:c \
p3pipeline:c p3event:c p3display:c panda:m \
$[if $[WANT_NATIVE_NET],p3nativenet:c] \
$[if $[HAVE_NET],p3net:c] \
p3tinyxml
#define SOURCES \
binaryXml.cxx binaryXml.h \
fhandle.h \
handleStream.cxx handleStream.h handleStream.I \
handleStreamBuf.cxx handleStreamBuf.h handleStreamBuf.I \
p3d_lock.h p3d_plugin.h \
p3d_plugin_config.h \
p3dCInstance.cxx \
p3dCInstance.h p3dCInstance.I \
p3dPythonRun.cxx p3dPythonRun.h p3dPythonRun.I \
run_p3dpython.h run_p3dpython.cxx
#define SOURCES $[SOURCES] \
p3dPythonMain.cxx
// If you have to link with a static Python library, define it here.
#define EXTRA_LIBS $[EXTRA_P3DPYTHON_LIBS]
#define OSX_SYS_FRAMEWORKS Carbon
#define WIN_SYS_LIBS user32.lib
#end bin_target
#begin bin_target
//
// p3dpythonw.exe, a special variant on p3dpython.exe required by
// Windows (and built only on a Windows platform). This variant is
// compiled as a desktop application, as opposed to p3dpython.exe,
// which is a console application. (Both variants are required,
// because the plugin might be invoked either from a console or from
// the desktop.)
//
#define BUILD_TARGET $[and $[HAVE_P3D_RTDIST],$[HAVE_PYTHON],$[HAVE_OPENSSL],$[WINDOWS_PLATFORM]]
#define USE_PACKAGES python openssl
#define TARGET p3dpythonw
#define EXTRA_CDEFS NON_CONSOLE
#define OTHER_LIBS \
p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3express:c pandaexpress:m p3dxml:c \
p3pgraph:c p3pgraphnodes:c p3cull:c p3gsgbase:c p3gobj:c \
p3mathutil:c p3downloader:c p3pnmimage:c \
p3prc:c p3pstatclient:c p3pandabase:c p3linmath:c p3putil:c \
p3pipeline:c p3event:c p3display:c panda:m \
$[if $[WANT_NATIVE_NET],p3nativenet:c] \
$[if $[HAVE_NET],p3net:c] \
p3tinyxml
#define SOURCES \
binaryXml.cxx binaryXml.h \
fhandle.h \
handleStream.cxx handleStream.h handleStream.I \
handleStreamBuf.cxx handleStreamBuf.h handleStreamBuf.I \
p3d_lock.h p3d_plugin.h \
p3d_plugin_config.h \
p3dCInstance.cxx \
p3dCInstance.h p3dCInstance.I \
p3dPythonRun.cxx p3dPythonRun.h p3dPythonRun.I \
run_p3dpython.h run_p3dpython.cxx
#define SOURCES $[SOURCES] \
p3dPythonMain.cxx
// If you have to link with a static Python library, define it here.
#define EXTRA_LIBS $[EXTRA_P3DPYTHON_LIBS]
#define OSX_SYS_FRAMEWORKS Carbon
#define WIN_SYS_LIBS user32.lib
#end bin_target
#begin lib_target
//
// libp3dpython.dll, a special library used to run P3DPythonRun within
// the parent (browser) process, instead of forking a child, as a
// desparation fallback in case forking fails for some reason.
//
#define BUILD_TARGET $[and $[HAVE_P3D_RTDIST],$[HAVE_PYTHON],$[HAVE_OPENSSL]]
#define USE_PACKAGES python openssl cg
#define TARGET libp3dpython
#define LIB_PREFIX
#define OTHER_LIBS \
p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3express:c pandaexpress:m p3dxml:c \
p3pgraph:c p3pgraphnodes:c p3cull:c p3gsgbase:c p3gobj:c \
p3mathutil:c p3downloader:c p3pnmimage:c \
p3prc:c p3pstatclient:c p3pandabase:c p3linmath:c p3putil:c \
p3pipeline:c p3event:c p3display:c panda:m \
$[if $[WANT_NATIVE_NET],p3nativenet:c] \
$[if $[HAVE_NET],p3net:c] \
p3tinyxml
#define SOURCES \
binaryXml.cxx binaryXml.h \
fhandle.h \
handleStream.cxx handleStream.h handleStream.I \
handleStreamBuf.cxx handleStreamBuf.h handleStreamBuf.I \
p3d_lock.h p3d_plugin.h \
p3d_plugin_config.h \
p3dCInstance.cxx \
p3dCInstance.h p3dCInstance.I \
p3dPythonRun.cxx p3dPythonRun.h p3dPythonRun.I \
run_p3dpython.h run_p3dpython.cxx
#define WIN_SYS_LIBS user32.lib
#end lib_target
#include $[THISDIRPREFIX]p3d_plugin_config.h.pp

View File

@ -193,7 +193,7 @@ run_python() {
return 1;
}
// Set the __path__ such that it can find panda3d/_core.pyd, etc.
// Set the __path__ such that it can find panda3d/core.pyd, etc.
Filename panda3d_dir(dir, "panda3d");
string dir_str = panda3d_dir.to_os_specific();
PyModule_AddObject(panda3d_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length()));

View File

@ -1,38 +0,0 @@
// This file is read and processed by ppremake to generate
// p3d_plugin_config.h.
#output p3d_plugin_config.h notouch
/* p3d_plugin_config.h. Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]]. */
/********************************** DO NOT EDIT ****************************/
/* The URL that is the root of the download server that this plugin
should contact. The contents.xml file that defines this particular
"coreapi" package should be found at this location. */
#$[]define PANDA_PACKAGE_HOST_URL "$[PANDA_PACKAGE_HOST_URL]"
/* The Core API version number. This one also appears in
pandaVersion.h. */
#$[]define P3D_COREAPI_VERSION_STR "$[join .,$[P3D_COREAPI_VERSION]]"
/* As does the plugin version number. */
#$[]define P3D_PLUGIN_VERSION_STR "$[join .,$[P3D_PLUGIN_VERSION]]"
/* The filename(s) to generate output to when the plugin is running.
For debugging purposes only. */
#$[]define P3D_PLUGIN_LOG_DIRECTORY "$[subst \,\\,$[osfilename $[P3D_PLUGIN_LOG_DIRECTORY]]]"
#$[]define P3D_PLUGIN_LOG_BASENAME1 "$[P3D_PLUGIN_LOG_BASENAME1]"
#$[]define P3D_PLUGIN_LOG_BASENAME2 "$[P3D_PLUGIN_LOG_BASENAME2]"
#$[]define P3D_PLUGIN_LOG_BASENAME3 "$[P3D_PLUGIN_LOG_BASENAME3]"
/* For development only: the location at which p3dpython.exe can be
found. Empty string for the default. */
#$[]define P3D_PLUGIN_P3DPYTHON "$[subst \,\\,$[osfilename $[P3D_PLUGIN_P3DPYTHON]]]"
/* For development only: the location at which p3d_plugin.dll/.so can
be found. Empty string for the default. */
#$[]define P3D_PLUGIN_P3D_PLUGIN "$[subst \,\\,$[osfilename $[P3D_PLUGIN_P3D_PLUGIN]]]"
/* We need to know whether GTK is enabled for XEmbed. */
$[cdefine HAVE_GTK]
#end p3d_plugin_config.h

View File

@ -1,175 +0,0 @@
//
// P3DActiveX.rc.pp
//
// This file defines the script to auto-generate P3DActiveX.rc at
// ppremake time. We use this to fill in the DLL version correctly.
//
#output P3DActiveX.rc notouch
/$[]/#### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
/$[]/################################# DO NOT EDIT ###########################
// Microsoft Visual C++ generated resource script.
//
#$[]include "resource.h"
#$[]define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#$[]include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#$[]undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#$[]if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#$[]ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#$[]pragma code_page(1252)
#$[]endif //_WIN32
#$[]ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#$[]include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"1 TYPELIB ""P3DActiveX.tlb""\r\n"
"\0"
END
#$[]endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION $[P3D_PLUGIN_DLL_COMMA_VERSION]
PRODUCTVERSION $[P3D_PLUGIN_DLL_COMMA_VERSION]
FILEFLAGSMASK 0x3fL
#$[]ifdef _DEBUG
FILEFLAGS 0x1L
#$[]else
FILEFLAGS 0x0L
#$[]endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "FileDescription", "Panda3D Game Engine Plug-in $[P3D_PLUGIN_VERSION_STR]\0"
Value "CompanyName", "$[PANDA_DISTRIBUTOR]"
VALUE "FileVersion", "$[P3D_PLUGIN_DLL_DOT_VERSION]"
VALUE "InternalName", "P3DActiveX.ocx"
VALUE "LegalTrademarks", "\0"
VALUE "FileOpenName", "Panda3D applet\0"
VALUE "OLESelfRegister", "\0"
VALUE "OriginalFilename", "P3DActiveX.ocx"
VALUE "ProductName", "Panda3D Game Engine Plug-in $[P3D_PLUGIN_VERSION_STR]\0"
VALUE "ProductVersion", "$[P3D_PLUGIN_DLL_DOT_VERSION]"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_P3DACTIVEX BITMAP "P3DActiveXCtrl.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PROPPAGE_P3DACTIVEX DIALOG 0, 0, 250, 62
STYLE DS_SETFONT | WS_CHILD
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "TODO: Place controls to manipulate properties of P3DActiveX Control on this dialog.",
IDC_STATIC,7,25,229,16
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#$[]ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_PROPPAGE_P3DACTIVEX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 55
END
END
#$[]endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_P3DACTIVEX "P3DActiveX Control"
IDS_P3DACTIVEX_PPG "P3DActiveX Property Page"
END
STRINGTABLE
BEGIN
IDS_P3DACTIVEX_PPG_CAPTION "General"
END
#$[]endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#$[]ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB "P3DActiveX.tlb"
/////////////////////////////////////////////////////////////////////////////
#$[]endif // not APSTUDIO_INVOKED
#end P3DActiveX.rc

View File

@ -1,42 +0,0 @@
// This directory builds the code for the ActiveX (Internet Explorer)
// plugin, part of the Panda3D browser plugin system. Most Panda3D
// developers will have no need to build this, unless you are
// developing the plugin system itself. Define HAVE_P3D_PLUGIN in
// your Config.pp to build this directory.
#define BUILD_DIRECTORY $[and $[HAVE_P3D_PLUGIN],$[WINDOWS_PLATFORM],$[HAVE_ACTIVEX],$[not $[eq $[USE_COMPILER],MSVC9x64]]]
#define _MT $[if $[P3D_PLUGIN_MT],_mt]
#begin lib_target
#define TARGET p3dactivex
#define LIB_PREFIX
#define DYNAMIC_LIB_EXT .ocx
#define LOCAL_LIBS plugin_common$[_MT]
#define LINK_FORCE_STATIC_RELEASE_C_RUNTIME $[P3D_PLUGIN_MT]
#define OTHER_LIBS p3tinyxml$[_MT]
#define COMBINED_SOURCES \
$[TARGET]_composite1.cxx
#define SOURCES \
P3DActiveX.h P3DActiveXCtrl.h P3DActiveXPropPage.h \
PPBrowserObject.h PPDownloadCallback.h PPDownloadRequest.h \
PPInstance.h PPInterface.h PPLogger.h PPPandaObject.h \
resource.h P3DActiveX.idl
#define INCLUDED_SOURCES \
P3DActiveX.cpp P3DActiveXCtrl.cpp P3DActiveXPropPage.cpp \
PPBrowserObject.cpp PPDownloadCallback.cpp PPDownloadRequest.cpp \
PPInstance.cpp PPInterface.cpp PPLogger.cpp PPPandaObject.cpp
#define EXTRA_CDEFS _USRDLL _WINDLL _MBCS $[if $[not $[P3D_PLUGIN_MT]],_AFXDLL]
#define WIN_RESOURCE_FILE P3DActiveX.rc
#define LINKER_DEF_FILE P3DActiveX.def
#define INSTALL_HEADERS
#end lib_target
#include $[THISDIRPREFIX]P3DActiveX.rc.pp

View File

@ -1,62 +0,0 @@
// This directory builds the code for the NPAPI (Mozilla) plugin, part
// of the Panda3D browser plugin system. Most Panda3D developers will
// have no need to build this, unless you are developing the plugin
// system itself. Define HAVE_P3D_PLUGIN in your Config.pp to build
// this directory.
#define BUILD_DIRECTORY $[and $[HAVE_P3D_PLUGIN],$[HAVE_NPAPI]]
#define _MT $[if $[P3D_PLUGIN_MT],_mt]
#define USE_PACKAGES npapi gtk
#begin lib_target
// By Mozilla convention, on Windows at least, the generated DLL
// filename must begin with "np", not "libnp". (Actually, this is
// probably no longer true on recent versions of Mozilla. But why
// take chances?)
#define TARGET nppanda3d
#define LIB_PREFIX
#define LOCAL_LIBS plugin_common$[_MT]
#define LINK_FORCE_STATIC_RELEASE_C_RUNTIME $[P3D_PLUGIN_MT]
#define OTHER_LIBS p3tinyxml$[_MT]
#define COMBINED_SOURCES \
$[TARGET]_composite1.cxx
#define SOURCES \
nppanda3d_common.h \
ppBrowserObject.h ppBrowserObject.I \
ppDownloadRequest.h ppDownloadRequest.I \
ppInstance.h ppInstance.I \
ppPandaObject.h ppPandaObject.I \
ppToplevelObject.h ppToplevelObject.I \
startup.h
#define INCLUDED_SOURCES \
ppBrowserObject.cxx \
ppDownloadRequest.cxx \
ppInstance.cxx \
ppPandaObject.cxx \
ppToplevelObject.cxx \
startup.cxx
// Windows-specific options.
#if $[WINDOWS_PLATFORM]
#define WIN_RESOURCE_FILE nppanda3d.rc
#define LINKER_DEF_FILE nppanda3d.def
#define WIN_SYS_LIBS user32.lib shell32.lib ole32.lib
#endif
// Mac-specific options.
#if $[OSX_PLATFORM]
#define LINK_AS_BUNDLE 1
#define BUNDLE_EXT
#endif
#define INSTALL_HEADERS
#end lib_target
#include $[THISDIRPREFIX]nppanda3d.rc.pp

View File

@ -1,55 +0,0 @@
//
// nppanda3d.rc.pp
//
// This file defines the script to auto-generate nppanda3d.rc at
// ppremake time. We use this to fill in the DLL version correctly.
//
// This resource file is required on Windows to load the appropriate
// text into the DLL, so Mozilla will recognize the DLL as a plugin.
// It also defines the MIME type supported by the plugin.
#output nppanda3d.rc notouch
/$[]/#### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
/$[]/################################# DO NOT EDIT ###########################
#$[]define APSTUDIO_READONLY_SYMBOLS
#$[]include "winresrc.h"
#$[]undef APSTUDIO_READONLY_SYMBOLS
VS_VERSION_INFO VERSIONINFO
FILEVERSION $[P3D_PLUGIN_DLL_COMMA_VERSION]
PRODUCTVERSION $[P3D_PLUGIN_DLL_COMMA_VERSION]
FILEFLAGSMASK 0x3fL
#$[]ifdef _DEBUG
FILEFLAGS 0x1L
#$[]else
FILEFLAGS 0x0L
#$[]endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "FileDescription", "Runs 3-D games and interactive applets\0"
VALUE "FileVersion", "$[P3D_PLUGIN_DLL_DOT_VERSION]"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "application/x-panda3d\0"
VALUE "FileExtents", "p3d\0"
VALUE "FileOpenName", "Panda3D applet\0"
VALUE "OriginalFilename", "nppanda3d.dll\0"
VALUE "ProductName", "Panda3D Game Engine Plug-In $[P3D_PLUGIN_VERSION_STR]\0"
VALUE "ProductVersion", "$[P3D_PLUGIN_DLL_DOT_VERSION]"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#end nppanda3d.rc

View File

@ -1,142 +0,0 @@
// This directory contains the code for the panda3d.exe executable,
// the "standalone" part of the Panda3D plugin/runtime system. Define
// HAVE_P3D_PLUGIN in your Config.pp to build it.
#define BUILD_DIRECTORY $[and $[HAVE_P3D_PLUGIN],$[HAVE_OPENSSL],$[HAVE_ZLIB]]
#begin bin_target
#define USE_PACKAGES openssl zlib
#define TARGET panda3d
#define LOCAL_LIBS plugin_common
#define OTHER_LIBS \
p3prc:c p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3pandabase:c p3downloader:c p3express:c pandaexpress:m \
p3pystub p3tinyxml
#define OSX_SYS_FRAMEWORKS Foundation AppKit Carbon
#define SOURCES \
panda3dBase.cxx panda3dBase.h panda3dBase.I \
panda3d.cxx panda3d.h panda3d.I \
panda3dMain.cxx
#define WIN_RESOURCE_FILE panda3d.rc
#define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib ole32.lib
#end bin_target
#begin bin_target
// On Windows, we also need to build panda3dw.exe, the non-console
// version of panda3d.exe.
#define BUILD_TARGET $[WINDOWS_PLATFORM]
#define USE_PACKAGES openssl zlib
#define TARGET panda3dw
#define LOCAL_LIBS plugin_common
#define OTHER_LIBS \
p3prc:c p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3pandabase:c p3downloader:c p3express:c pandaexpress:m \
p3pystub p3tinyxml
#define OSX_SYS_FRAMEWORKS Foundation AppKit Carbon
#define SOURCES \
panda3dBase.cxx panda3dBase.h panda3dBase.I \
panda3d.cxx panda3d.h panda3d.I \
panda3dWinMain.cxx
#define WIN_RESOURCE_FILE panda3d.rc
#define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib ole32.lib
#end bin_target
#begin bin_target
// On Mac, we'll build panda3d_mac, which is the Carbon-friendly
// application we wrap in a bundle, for picking a p3d file from
// Finder.
#define BUILD_TARGET $[OSX_PLATFORM]
#define USE_PACKAGES openssl zlib
#define TARGET panda3d_mac
#define LOCAL_LIBS plugin_common
#define OTHER_LIBS \
p3prc:c p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3pandabase:c p3downloader:c p3express:c pandaexpress:m \
p3pystub p3tinyxml
#define OSX_SYS_FRAMEWORKS Foundation AppKit Carbon
#define SOURCES \
panda3dBase.cxx panda3dBase.h panda3dBase.I \
panda3d.cxx panda3d.h panda3d.I \
panda3dMac.cxx panda3dMac.h panda3dMac.I
#end bin_target
#begin bin_target
#define USE_PACKAGES openssl zlib
#define TARGET p3dembed
#define LOCAL_LIBS plugin_common p3d_plugin_static
// We need to define this, even though we are not creating a DLL,
// because we need the symbols to be "exported" so we can find them in
// our own address space.
#define EXTRA_CDEFS BUILDING_P3D_PLUGIN
#define OTHER_LIBS \
p3prc:c p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3pandabase:c p3downloader:c p3express:c pandaexpress:m \
p3pystub p3tinyxml \
$[if $[OSX_PLATFORM],p3subprocbuffer]
#define OSX_SYS_FRAMEWORKS Foundation AppKit Carbon
#define SOURCES \
panda3dBase.cxx panda3dBase.h panda3dBase.I \
p3dEmbed.cxx p3dEmbedMain.cxx
#define WIN_RESOURCE_FILE panda3d.rc
#define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib
#end bin_target
#begin bin_target
// On Windows, we also need to build p3dembedw.exe, the non-console
// version of p3dembed.exe.
#define BUILD_TARGET $[WINDOWS_PLATFORM]
#define USE_PACKAGES openssl zlib
#define TARGET p3dembedw
#define LOCAL_LIBS plugin_common p3d_plugin_static
// We need to define this, even though we are not creating a DLL,
// because we need the symbols to be "exported" so we can find them in
// our own address space.
#define EXTRA_CDEFS BUILDING_P3D_PLUGIN P3DEMBEDW
#define OTHER_LIBS \
p3prc:c p3dtoolutil:c p3dtoolbase:c p3dtool:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3pandabase:c p3downloader:c p3express:c pandaexpress:m \
p3pystub p3tinyxml
#define SOURCES \
panda3dBase.cxx panda3dBase.h panda3dBase.I \
p3dEmbed.cxx p3dEmbedMain.cxx
#define WIN_RESOURCE_FILE panda3d.rc
#define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib
#end bin_target
#include $[THISDIRPREFIX]panda3d.rc.pp

View File

@ -1,53 +0,0 @@
//
// panda3d.rc.pp
//
// This file defines the script to auto-generate panda3d.rc at
// ppremake time. We use this to fill in the DLL version correctly.
//
#output panda3d.rc notouch
/$[]/#### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[notdir $[THISFILENAME]].
/$[]/################################# DO NOT EDIT ###########################
#$[]define APSTUDIO_READONLY_SYMBOLS
#$[]include "winresrc.h"
#$[]undef APSTUDIO_READONLY_SYMBOLS
VS_VERSION_INFO VERSIONINFO
FILEVERSION $[P3D_PLUGIN_DLL_COMMA_VERSION]
PRODUCTVERSION $[P3D_PLUGIN_DLL_COMMA_VERSION]
FILEFLAGSMASK 0x3fL
#$[]ifdef _DEBUG
FILEFLAGS 0x1L
#$[]else
FILEFLAGS 0x0L
#$[]endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "FileDescription", "Panda3D Game Engine Runtime $[P3D_PLUGIN_VERSION_STR]\0"
VALUE "FileVersion", "$[P3D_PLUGIN_DLL_DOT_VERSION]"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "application/x-panda3d\0"
VALUE "FileExtents", "p3d\0"
VALUE "FileOpenName", "Panda3D applet\0"
VALUE "ProductName", "Panda3D Game Engine Runtime $[P3D_PLUGIN_VERSION_STR]\0"
VALUE "ProductVersion", "$[P3D_PLUGIN_DLL_DOT_VERSION]"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
ICON_FILE ICON "panda3d.ico"
#end panda3d.rc

View File

@ -1420,17 +1420,14 @@ def printListEnum(l):
pass
# base class for all Panda C++ objects
# libdtoolconfig doesn't seem to have this, grab it off of PandaNode
# libdtoolconfig doesn't seem to have this, grab it off of TypedObject
dtoolSuperBase = None
def _getDtoolSuperBase():
global dtoolSuperBase
from panda3d.core import TypedObject
dtoolSuperBase = TypedObject.__bases__[0]
assert repr(dtoolSuperBase) == "<type 'libdtoolconfig.DTOOL_SUPER_BASE111'>" \
or repr(dtoolSuperBase) == "<type 'libdtoolconfig.DTOOL_SUPPER_BASE111'>" \
or repr(dtoolSuperBase) == "<type 'dtoolconfig.DTOOL_SUPER_BASE111'>" \
or repr(dtoolSuperBase) == "<type 'dtoolconfig.DTOOL_SUPER_BASE'>"
assert dtoolSuperBase.__name__ == 'DTOOL_SUPER_BASE'
safeReprNotify = None

View File

@ -11,6 +11,8 @@ from panda3d.core import *
from panda3d.direct import get_config_showbase, throw_new_frame, init_app_for_gui
from panda3d.direct import storeAccessibilityShortcutKeys, allowAccessibilityShortcutKeys
# Register the extension methods for NodePath.
from direct.extensions_native import NodePath_extensions
# This needs to be available early for DirectGUI imports
import __builtin__ as builtins
@ -2512,6 +2514,8 @@ class ShowBase(DirectObject.DirectObject):
rig.reparentTo(camera)
self.graphicsEngine.openWindows()
self.graphicsEngine.renderFrame()
self.graphicsEngine.renderFrame()
self.graphicsEngine.syncFrame()
tex = buffer.getTexture()
saved = self.screenshot(namePrefix = namePrefix,
@ -2602,6 +2606,7 @@ class ShowBase(DirectObject.DirectObject):
# One more frame for luck.
self.graphicsEngine.renderFrame()
self.graphicsEngine.syncFrame()
saved = self.screenshot(namePrefix = namePrefix,
defaultFilename = defaultFilename,

View File

@ -1,41 +0,0 @@
#begin lib_target
#define TARGET p3showbase
#define LOCAL_LIBS \
p3directbase
#define OTHER_LIBS \
p3pgraph:c p3pgraphnodes:c p3gsgbase:c p3gobj:c p3mathutil:c p3pstatclient:c \
p3downloader:c p3pandabase:c p3pnmimage:c p3prc:c \
p3pipeline:c p3cull:c \
$[if $[HAVE_NET],p3net:c] $[if $[WANT_NATIVE_NET],p3nativenet:c] \
p3display:c p3linmath:c p3event:c p3putil:c panda:m \
p3express:c pandaexpress:m \
p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m
#define WIN_SYS_LIBS \
User32.lib
#define SOURCES \
showBase.cxx showBase.h \
$[if $[IS_OSX],showBase_assist.mm]
#define IGATESCAN all
#end lib_target
// Define a Python extension module for operating on frozen modules.
// This is a pure C module; it involves no Panda code or C++ code.
#begin lib_target
#define BUILD_TARGET $[HAVE_PYTHON]
#define TARGET p3extend_frozen
#define LIB_PREFIX
#if $[OSX_PLATFORM]
#define LINK_AS_BUNDLE 1
#define BUNDLE_EXT .so
#endif
#if $[WINDOWS_PLATFORM]
#define DYNAMIC_LIB_EXT .pyd
#endif
#define SOURCES extend_frozen.c
#end lib_target

View File

@ -1,7 +1,7 @@
__all__ = ['register', 'sharedPackages',
'reloadSharedPackage', 'reloadSharedPackages']
from panda3d._core import Filename, VirtualFileSystem, VirtualFileMountSystem, OFileStream, copyStream
from panda3d.core import Filename, VirtualFileSystem, VirtualFileMountSystem, OFileStream, copyStream
import sys
import marshal
import imp

View File

@ -1,2 +0,0 @@
// For now, since we are not installing Python files, this file can
// remain empty.

View File

@ -10,7 +10,7 @@ __all__ = [
'execfile',
]
import panda3d._core as core
from panda3d import core
import sys
import os
import io

View File

@ -19,6 +19,7 @@ except ImportError:
signal = None
from panda3d.core import *
from direct.extensions_native import HTTPChannel_extensions
def print_exc_plus():
"""

View File

@ -1,3 +0,0 @@
// For now, since we are not installing Python files, this file can
// remain empty.

View File

@ -1,3 +0,0 @@
// For now, since we are not installing Python files, this file can
// remain empty.

View File

@ -1,3 +0,0 @@
// For now, since we are not installing Python files, this file can
// remain empty.

View File

@ -1,63 +0,0 @@
//
// Package.pp
//
// This file defines certain configuration variables that are to be
// written into the various make scripts. It is processed by ppremake
// (along with the Sources.pp files in each of the various
// directories) to generate build scripts appropriate to each
// environment.
//
// This is the package-specific file, which should be at the top of
// every source hierarchy. It generally gets the ball rolling, and is
// responsible for explicitly including all of the relevent Config.pp
// files.
// What is the name and version of this source tree?
#if $[eq $[PACKAGE],]
#define PACKAGE dmodels
#define VERSION 0.80
#endif
// Where should we find the DIRECT source directory?
#if $[or $[CTPROJS],$[DIRECT]]
// If we are presently attached, use the environment variable.
#define DIRECT_SOURCE $[DIRECT]
#if $[eq $[DIRECT],]
#error You seem to be attached to some trees, but not DIRECT!
#endif
#else
// Otherwise, if we are not attached, we guess that the source is a
// sibling directory to this source root.
#define DIRECT_SOURCE $[standardize $[TOPDIR]/../direct]
#endif
// Where should we install DMODELS?
#if $[DMODELS_INSTALL]
#define DMODELS_INSTALL $[unixfilename $[DMODELS_INSTALL]]
#elif $[or $[CTPROJS],$[DMODELS]]
#define DMODELS_INSTALL $[DMODELS]/built
#if $[eq $[DMODELS],]
#error You seem to be attached to some trees, but not DMODELS!
#endif
#else
#defer DMODELS_INSTALL $[INSTALL_DIR]
#endif
// Define the inter-tree dependencies.
#define NEEDS_TREES $[NEEDS_TREES] direct
// Also get the DIRECT Package file and everything that includes.
#if $[not $[isfile $[DIRECT_SOURCE]/Package.pp]]
#printvar DIRECT_SOURCE
#error DIRECT source directory not found from dmodels! Are you attached properly?
#endif
#include $[DIRECT_SOURCE]/Package.pp
// Define some global variables for this tree.
#define FLT2EGG_OPTS -no -uo ft

View File

@ -1,4 +0,0 @@
// This is the toplevel directory for a models tree.
#define DIR_TYPE models_toplevel
#define TEXATTRIB_DIR src/maps

View File

@ -1,4 +0,0 @@
// This is a group directory: a directory level above a number of
// source subdirectories.
#define DIR_TYPE models_group

View File

@ -1,4 +0,0 @@
// This is a group directory: a directory level above a number of
// source subdirectories.
#define DIR_TYPE models_group

View File

@ -1,9 +0,0 @@
#define DIR_TYPE models
#define INSTALL_TO audio/sfx
// General GUI Sounds
#begin install_audio
#define SOURCES \
GUI_rollover.wav GUI_click.wav
#end install_audio

View File

@ -1,8 +0,0 @@
#define DIR_TYPE models
#define INSTALL_TO models/fonts
//#begin install_egg
// #define SOURCES Comic.egg
//#end install_egg

View File

@ -1,14 +0,0 @@
#define DIR_TYPE models
#define INSTALL_TO models/gui
#begin flt_egg
#define SOURCES $[wildcard *.flt]
#end flt_egg
#begin install_egg
#define SOURCES $[patsubst %.flt,%.egg,$[wildcard *.flt]]
#end install_egg
#begin install_egg
#define SOURCES radio_button_gui.egg
#end install_egg

Some files were not shown because too many files have changed in this diff Show More