diff --git a/.travis.yml b/.travis.yml index 92732bb929..bb0b07dd51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ compiler: - clang before_script: - sudo apt-get install python-dev libpng-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libjpeg-dev libopenal-dev libode-dev nvidia-cg-toolkit -script: python makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT --installer +script: python makepanda/makepanda.py --everything --verbose --git-commit $TRAVIS_COMMIT --installer --threads 2 notifications: irc: channels: diff --git a/README.md b/README.md index bc02c69c6f..615074193e 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,17 @@ After acquiring these dependencies, you may simply build Panda3D from the command prompt using the following command: ```bash -makepanda\makepanda.bat --everything --installer +makepanda\makepanda.bat --everything --installer --no-eigen ``` When the build succeeds, it will produce an .exe file that you can use to install Panda3D on your system. +Note: you may choose to remove --no-eigen and build with Eigen support in +order to improve runtime performance. However, this will cause the build to +take hours to complete, as Eigen is a heavily template-based library, and the +the MSVC compiler does not perform well under these circumstances. + Linux ----- diff --git a/contrib/.gitignore b/contrib/.gitignore index 33fa81ab6b..aa93cd250a 100644 --- a/contrib/.gitignore +++ b/contrib/.gitignore @@ -1,4 +1,9 @@ +*.pyc +*.pyo /__init__.py -/built/ +# These are files that are generated within the source tree by the +# ppremake system. Makefile pp.dep +/built/ +Opt?-* diff --git a/contrib/src/contribbase/contribsymbols.h b/contrib/src/contribbase/contribsymbols.h index e55c535331..5d57d20ea6 100644 --- a/contrib/src/contribbase/contribsymbols.h +++ b/contrib/src/contribbase/contribsymbols.h @@ -22,21 +22,12 @@ C++-style comments, since this file is occasionally included by a C file. */ -#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) - #ifdef BUILDING_PANDAAI - #define EXPCL_PANDAAI __declspec(dllexport) - #define EXPTP_PANDAAI + #define EXPCL_PANDAAI EXPORT_CLASS + #define EXPTP_PANDAAI EXPORT_TEMPL #else - #define EXPCL_PANDAAI __declspec(dllimport) - #define EXPTP_PANDAAI extern + #define EXPCL_PANDAAI IMPORT_CLASS + #define EXPTP_PANDAAI IMPORT_TEMPL #endif -#else /* !WIN32_VC */ - -#define EXPCL_PANDAAI -#define EXPTP_PANDAAI - -#endif /* WIN32_VC */ - #endif diff --git a/direct/.gitignore b/direct/.gitignore index 97b7fbcf49..aa93cd250a 100644 --- a/direct/.gitignore +++ b/direct/.gitignore @@ -1,4 +1,5 @@ *.pyc +*.pyo /__init__.py # These are files that are generated within the source tree by the # ppremake system. diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index 7802ebc3eb..ae55e76d33 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -2,11 +2,10 @@ __all__ = ['Actor'] -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.DirectObject import DirectObject from direct.directnotify import DirectNotifyGlobal -from pandac.PandaModules import LODNode -import types, copy +import types class Actor(DirectObject, NodePath): """ diff --git a/direct/src/cluster/ClusterClient.py b/direct/src/cluster/ClusterClient.py index adb7f8744e..4dca3a1379 100644 --- a/direct/src/cluster/ClusterClient.py +++ b/direct/src/cluster/ClusterClient.py @@ -1,6 +1,6 @@ """ClusterClient: Master for mutli-piping or PC clusters. """ -from pandac.PandaModules import * +from panda3d.core import * from ClusterMsgs import * from ClusterConfig import * from direct.directnotify import DirectNotifyGlobal diff --git a/direct/src/cluster/ClusterConfig.py b/direct/src/cluster/ClusterConfig.py index 74313afc41..6cf71dcaab 100644 --- a/direct/src/cluster/ClusterConfig.py +++ b/direct/src/cluster/ClusterConfig.py @@ -1,6 +1,5 @@ from ClusterClient import * -import string # A dictionary of information for various cluster configurations. # Dictionary is keyed on cluster-config string diff --git a/direct/src/cluster/ClusterMsgs.py b/direct/src/cluster/ClusterMsgs.py index 1533884eb2..e06deeb132 100644 --- a/direct/src/cluster/ClusterMsgs.py +++ b/direct/src/cluster/ClusterMsgs.py @@ -3,7 +3,7 @@ # This module is intended to supply routines and dataformats common to # both ClusterClient and ClusterServer. -from pandac.PandaModules import * +from panda3d.core import * from direct.distributed.PyDatagram import PyDatagram from direct.distributed.PyDatagramIterator import PyDatagramIterator import time diff --git a/direct/src/cluster/ClusterServer.py b/direct/src/cluster/ClusterServer.py index a4a8177a9d..0e5cea0e0d 100644 --- a/direct/src/cluster/ClusterServer.py +++ b/direct/src/cluster/ClusterServer.py @@ -1,4 +1,4 @@ -from pandac.PandaModules import * +from panda3d.core import * from ClusterMsgs import * from direct.distributed.MsgTypes import * from direct.directnotify import DirectNotifyGlobal diff --git a/direct/src/directbase/TestStart.py b/direct/src/directbase/TestStart.py index 7439c691fa..7cb8ae37c7 100755 --- a/direct/src/directbase/TestStart.py +++ b/direct/src/directbase/TestStart.py @@ -1,10 +1,10 @@ -print 'TestStart: Starting up test environment.' +print('TestStart: Starting up test environment.') -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.PythonUtil import * from direct.showbase import ShowBase -ShowBase.ShowBase() +base = ShowBase.ShowBase() # Put an axis in the world: loader.loadModel("models/misc/xyzAxis").reparentTo(render) diff --git a/direct/src/directbase/directsymbols.h b/direct/src/directbase/directsymbols.h index 6692aca23d..26a34e7156 100644 --- a/direct/src/directbase/directsymbols.h +++ b/direct/src/directbase/directsymbols.h @@ -17,21 +17,12 @@ /* See dtoolsymbols.h for a rant on the purpose of this file. */ -#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) - #ifdef BUILDING_DIRECT - #define EXPCL_DIRECT __declspec(dllexport) - #define EXPTP_DIRECT + #define EXPCL_DIRECT EXPORT_CLASS + #define EXPTP_DIRECT EXPORT_TEMPL #else - #define EXPCL_DIRECT __declspec(dllimport) - #define EXPTP_DIRECT extern + #define EXPCL_DIRECT IMPORT_CLASS + #define EXPTP_DIRECT IMPORT_TEMPL #endif -#else /* !WIN32_VC */ - -#define EXPCL_DIRECT -#define EXPTP_DIRECT - -#endif /* WIN32_VC */ - #endif diff --git a/direct/src/directdevices/DirectDeviceManager.py b/direct/src/directdevices/DirectDeviceManager.py index 0c435849f1..1c0c89ca88 100644 --- a/direct/src/directdevices/DirectDeviceManager.py +++ b/direct/src/directdevices/DirectDeviceManager.py @@ -1,7 +1,8 @@ """ Class used to create and control vrpn devices """ from direct.showbase.DirectObject import DirectObject -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.vrpn import * ANALOG_MIN = -0.95 ANALOG_MAX = 0.95 @@ -294,18 +295,3 @@ class DirectTimecodeReader(AnalogNode, DirectObject): def __repr__(self): str = ('%s: %d:%d:%d:%d' % ((self.name,) + self.getTime()[:-1])) return str - - - - - - - - - - - - - - - diff --git a/direct/src/directnotify/Logger.py b/direct/src/directnotify/Logger.py index 8c7f6b6f3b..844dead3d5 100644 --- a/direct/src/directnotify/Logger.py +++ b/direct/src/directnotify/Logger.py @@ -1,7 +1,6 @@ """Logger module: contains the logger class which creates and writes data to log files on disk""" -import sys import time import math diff --git a/direct/src/directnotify/Notifier.py b/direct/src/directnotify/Notifier.py index 2d59c5bf70..816ab8c0df 100644 --- a/direct/src/directnotify/Notifier.py +++ b/direct/src/directnotify/Notifier.py @@ -6,7 +6,6 @@ from LoggerGlobal import defaultLogger from direct.showbase import PythonUtil from panda3d.core import ConfigVariableBool, NotifyCategory, StreamWriter, Notify import time -import types import sys class Notifier: diff --git a/direct/src/directscripts/doxygen_filter.py b/direct/src/directscripts/doxygen_filter.py index f69d2fa07f..43e8fc7aec 100644 --- a/direct/src/directscripts/doxygen_filter.py +++ b/direct/src/directscripts/doxygen_filter.py @@ -2,7 +2,7 @@ doxygen can understand and process. It can be used as an INPUT_FILTER in doxygen. """ -import sys, re, os +import sys, os # Explicitly include these files. Besides these, all # files ending in _src will be explicitly included too. diff --git a/direct/src/directscripts/extract_docs.py b/direct/src/directscripts/extract_docs.py index a248fa83ae..a0033ff5fe 100644 --- a/direct/src/directscripts/extract_docs.py +++ b/direct/src/directscripts/extract_docs.py @@ -7,7 +7,7 @@ files in the lib/pandac/input directory. """ __all__ = [] -import os, re +import os import panda3d, pandac from panda3d.dtoolconfig import * @@ -135,6 +135,8 @@ def translated_type_name(type, scoped=True): typename = interrogate_type_name(type) if typename in ("PyObject", "_object"): return "object" + elif typename == "PN_stdfloat": + return "float" if interrogate_type_is_atomic(type): token = interrogate_type_atomic_token(type) @@ -143,7 +145,9 @@ def translated_type_name(type, scoped=True): else: return typename - typename = translateTypeName(typename) + if not typename.endswith('_t'): + # Hack: don't mangle size_t etc. + typename = translateTypeName(typename) if scoped and interrogate_type_is_nested(type): return translated_type_name(interrogate_type_outer_class(type)) + '::' + typename diff --git a/direct/src/directtools/DirectCameraControl.py b/direct/src/directtools/DirectCameraControl.py index b2333c2ff2..2ec27e8a5a 100644 --- a/direct/src/directtools/DirectCameraControl.py +++ b/direct/src/directtools/DirectCameraControl.py @@ -222,7 +222,7 @@ class DirectCameraControl(DirectObject): skipFlags |= SKIP_CAMERA * (1 - base.getControl()) self.computeCOA(base.direct.iRay.pickGeom(skipFlags = skipFlags)) # Record reference point - self.coaMarkerRef.iPosHprScale(base.cam) + self.coaMarkerRef.setPosHprScale(base.cam, 0, 0, 0, 0, 0, 0, 1, 1, 1) # Record entries self.cqEntries = [] for i in range(base.direct.iRay.getNumEntries()): diff --git a/direct/src/directtools/DirectGeometry.py b/direct/src/directtools/DirectGeometry.py index 437f09e448..9c748e57b3 100644 --- a/direct/src/directtools/DirectGeometry.py +++ b/direct/src/directtools/DirectGeometry.py @@ -1,5 +1,5 @@ -from pandac.PandaModules import * +from panda3d.core import * from DirectGlobals import * from DirectUtil import * import math diff --git a/direct/src/directtools/DirectGlobals.py b/direct/src/directtools/DirectGlobals.py index 11c500e622..2a70697598 100644 --- a/direct/src/directtools/DirectGlobals.py +++ b/direct/src/directtools/DirectGlobals.py @@ -1,4 +1,4 @@ -from pandac.PandaModules import Vec3, Point3, BitMask32 +from panda3d.core import Vec3, Point3, BitMask32 UNPICKABLE = ['x-disc-visible', 'y-disc-visible', 'z-disc-visible', 'GridBack', 'unpickable'] diff --git a/direct/src/directtools/DirectGrid.py b/direct/src/directtools/DirectGrid.py index d02195a2c1..71fedf52c1 100644 --- a/direct/src/directtools/DirectGrid.py +++ b/direct/src/directtools/DirectGrid.py @@ -1,5 +1,5 @@ -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.DirectObject import DirectObject from DirectUtil import * from DirectGeometry import * diff --git a/direct/src/directtools/DirectLights.py b/direct/src/directtools/DirectLights.py index 5e5a5eb5e2..1c4ffef230 100644 --- a/direct/src/directtools/DirectLights.py +++ b/direct/src/directtools/DirectLights.py @@ -1,5 +1,5 @@ -from pandac.PandaModules import * +from panda3d.core import * from string import lower class DirectLight(NodePath): diff --git a/direct/src/directtools/DirectSession.py b/direct/src/directtools/DirectSession.py index a68012c2d8..124799c6cb 100644 --- a/direct/src/directtools/DirectSession.py +++ b/direct/src/directtools/DirectSession.py @@ -2,7 +2,7 @@ import math import types import string -from pandac.PandaModules import * +from panda3d.core import * from DirectUtil import * from direct.showbase.DirectObject import DirectObject @@ -304,6 +304,7 @@ class DirectSession(DirectObject): except NameError: # Has the clusterMode been set via a config variable? self.clusterMode = base.config.GetString("cluster-mode", '') + if self.clusterMode == 'client': self.cluster = createClusterClient() elif self.clusterMode == 'server': @@ -400,7 +401,7 @@ class DirectSession(DirectObject): if self.oobeMode: # Position a target point to lerp the oobe camera to - base.direct.cameraControl.camManipRef.iPosHpr(self.trueCamera) + base.direct.cameraControl.camManipRef.setPosHpr(self.trueCamera, 0, 0, 0, 0, 0, 0) ival = self.oobeCamera.posHprInterval( 2.0, pos = Point3(0), hpr = Vec3(0), other = base.direct.cameraControl.camManipRef, @@ -416,7 +417,7 @@ class DirectSession(DirectObject): cameraParent = self.camera.getParent() # Prepare oobe camera self.oobeCamera.reparentTo(cameraParent) - self.oobeCamera.iPosHpr(self.trueCamera) + self.oobeCamera.setPosHpr(self.trueCamera, 0, 0, 0, 0, 0, 0) # Put camera under new oobe camera self.cam.reparentTo(self.oobeCamera) # Position a target point to lerp the oobe camera to @@ -432,13 +433,13 @@ class DirectSession(DirectObject): def beginOOBE(self): # Make sure we've reached our final destination - self.oobeCamera.iPosHpr(base.direct.cameraControl.camManipRef) + self.oobeCamera.setPosHpr(base.direct.cameraControl.camManipRef, 0, 0, 0, 0, 0, 0) base.direct.camera = self.oobeCamera self.oobeMode = 1 def endOOBE(self): # Make sure we've reached our final destination - self.oobeCamera.iPosHpr(self.trueCamera) + self.oobeCamera.setPosHpr(self.trueCamera, 0, 0, 0, 0, 0, 0) # Disable OOBE mode. self.cam.reparentTo(self.trueCamera) base.direct.camera = self.trueCamera @@ -806,7 +807,7 @@ class DirectSession(DirectObject): [nodePath, oldParent, self.activeParent, fWrt]) def isNotCycle(self, nodePath, parent): - if nodePath.id() == parent.id(): + if nodePath == parent: print 'DIRECT.reparent: Invalid parent' return 0 elif parent.hasParent(): @@ -1308,6 +1309,3 @@ class DisplayRegionList(DirectObject): if drc.cam == cam: self.displayRegionList.remove(drc) break - -# Create one -__builtins__['direct'] = base.direct = DirectSession() diff --git a/direct/src/distributed/PyDatagram.py b/direct/src/distributed/PyDatagram.py index 3699407b73..f5db501b72 100755 --- a/direct/src/distributed/PyDatagram.py +++ b/direct/src/distributed/PyDatagram.py @@ -3,7 +3,8 @@ # class variable FuncDict and so we can import DCSubatomicType at the top # of the file rather than every time we call the putArg function. -from pandac.PandaModules import * +from panda3d.core import Datagram +from panda3d.direct import * # Import the type numbers #from otp.ai.AIMsgTypes import * diff --git a/direct/src/distributed/PyDatagramIterator.py b/direct/src/distributed/PyDatagramIterator.py index ea3cd0ea02..88ebf4021b 100755 --- a/direct/src/distributed/PyDatagramIterator.py +++ b/direct/src/distributed/PyDatagramIterator.py @@ -3,7 +3,8 @@ # class variable FuncDict and so we can import DCSubatomicType at the top # of the file rather than every time we call the putArg function. -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * # Import the type numbers class PyDatagramIterator(DatagramIterator): diff --git a/direct/src/extensions_native/CInterval_extensions.py b/direct/src/extensions_native/CInterval_extensions.py index 34c7a781cc..f20232e2cb 100644 --- a/direct/src/extensions_native/CInterval_extensions.py +++ b/direct/src/extensions_native/CInterval_extensions.py @@ -1,7 +1,8 @@ +from .core import Dtool_funcToMethod from direct.directnotify.DirectNotifyGlobal import directNotify -notify = directNotify.newCategory("Interval") -Dtool_ObjectToDict(CInterval,"notify", notify) -del notify + +CInterval.DtoolClassDict["notify"] = directNotify.newCategory("Interval") + ##################################################################### def setT(self, t): # Overridden from the C++ function to call privPostEvent @@ -10,7 +11,7 @@ def setT(self, t): self.setT_Old(t) self.privPostEvent() -Dtool_ObjectToDict(CInterval, "setT_Old", CInterval.setT) +CInterval.DtoolClassDict["setT_Old"] = CInterval.setT Dtool_funcToMethod(setT, CInterval) del setT ##################################################################### diff --git a/direct/src/extensions_native/NodePath_extensions.py b/direct/src/extensions_native/NodePath_extensions.py index 7b17dc34f6..33c530180c 100644 --- a/direct/src/extensions_native/NodePath_extensions.py +++ b/direct/src/extensions_native/NodePath_extensions.py @@ -10,22 +10,16 @@ of the NodePath class #################################################################### def id(self): - """Returns a unique id identifying the NodePath instance""" - print "Warning: NodePath.id() is deprecated. Use hash(NodePath) or NodePath.get_key() instead." + """Deprecated. Returns a unique id identifying the NodePath instance""" + print("Warning: NodePath.id() is deprecated. Use hash(NodePath) or NodePath.get_key() instead.") return self.getKey() Dtool_funcToMethod(id, NodePath) del id ##################################################################### - -## def __hash__(self): // inside c code -## return self.getKey() -##################################################################### - - # For iterating over children def getChildrenAsList(self): - """Converts a node path's child NodePathCollection into a list""" - print "Warning: NodePath.getChildrenAsList() is deprecated. Use get_children() instead." + """Deprecated. Converts a node path's child NodePathCollection into a list""" + print("Warning: NodePath.getChildrenAsList() is deprecated. Use get_children() instead.") return list(self.getChildren()) Dtool_funcToMethod(getChildrenAsList, NodePath) @@ -35,7 +29,7 @@ del getChildrenAsList def printChildren(self): """Prints out the children of the bottom node of a node path""" for child in self.getChildren(): - print child.getName() + print(child.getName()) Dtool_funcToMethod(printChildren, NodePath) del printChildren ##################################################################### @@ -95,8 +89,8 @@ del isolate ##################################################################### def remove(self): - """Remove a node path from the scene graph""" - print "Warning: NodePath.remove() is deprecated. Use remove_node() instead." + """Deprecated. Remove a node path from the scene graph""" + print("Warning: NodePath.remove() is deprecated. Use remove_node() instead.") # Send message in case anyone needs to do something # before node is deleted messenger.send('preRemoveNodePath', [self]) @@ -109,11 +103,11 @@ del remove def lsNames(self): """Walk down a tree and print out the path""" if self.isEmpty(): - print "(empty)" + print("(empty)") else: type = self.node().getType().getName() name = self.getName() - print type + " " + name + print(type + " " + name) self.lsNamesRecurse() Dtool_funcToMethod(lsNames, NodePath) @@ -124,7 +118,7 @@ def lsNamesRecurse(self, indentString=' '): for nodePath in self.getChildren(): type = nodePath.node().getType().getName() name = nodePath.getName() - print indentString + type + " " + name + print(indentString + type + " " + name) nodePath.lsNamesRecurse(indentString + " ") Dtool_funcToMethod(lsNamesRecurse, NodePath) @@ -138,7 +132,7 @@ def reverseLsNames(self): for nodePath in ancestry: type = nodePath.node().getType().getName() name = nodePath.getName() - print indentString + type + " " + name + print(indentString + type + " " + name) indentString = indentString + " " Dtool_funcToMethod(reverseLsNames, NodePath) @@ -146,7 +140,7 @@ del reverseLsNames ##################################################################### def getAncestry(self): """Get a list of a node path's ancestors""" - print "NodePath.getAncestry() is deprecated. Use get_ancestors() instead.""" + print("NodePath.getAncestry() is deprecated. Use get_ancestors() instead.""") ancestors = list(self.getAncestors()) ancestors.reverse() return ancestors @@ -197,11 +191,11 @@ def printPos(self, other = None, sd = 2): else: pos = self.getPos() otherString = '' - print (self.getName() + '.setPos(' + otherString + + print((self.getName() + '.setPos(' + otherString + formatString % pos[0] + ', ' + formatString % pos[1] + ', ' + formatString % pos[2] + - ')\n') + ')\n')) Dtool_funcToMethod(printPos, NodePath) del printPos ##################################################################### @@ -215,11 +209,11 @@ def printHpr(self, other = None, sd = 2): else: hpr = self.getHpr() otherString = '' - print (self.getName() + '.setHpr(' + otherString + + print((self.getName() + '.setHpr(' + otherString + formatString % hpr[0] + ', ' + formatString % hpr[1] + ', ' + formatString % hpr[2] + - ')\n') + ')\n')) Dtool_funcToMethod(printHpr, NodePath) del printHpr ##################################################################### @@ -233,11 +227,11 @@ def printScale(self, other = None, sd = 2): else: scale = self.getScale() otherString = '' - print (self.getName() + '.setScale(' + otherString + + print((self.getName() + '.setScale(' + otherString + formatString % scale[0] + ', ' + formatString % scale[1] + ', ' + formatString % scale[2] + - ')\n') + ')\n')) Dtool_funcToMethod(printScale, NodePath) del printScale @@ -253,14 +247,14 @@ def printPosHpr(self, other = None, sd = 2): pos = self.getPos() hpr = self.getHpr() otherString = '' - print (self.getName() + '.setPosHpr(' + otherString + + print((self.getName() + '.setPosHpr(' + otherString + formatString % pos[0] + ', ' + formatString % pos[1] + ', ' + formatString % pos[2] + ', ' + formatString % hpr[0] + ', ' + formatString % hpr[1] + ', ' + formatString % hpr[2] + - ')\n') + ')\n')) Dtool_funcToMethod(printPosHpr, NodePath) del printPosHpr @@ -278,7 +272,7 @@ def printPosHprScale(self, other = None, sd = 2): hpr = self.getHpr() scale = self.getScale() otherString = '' - print (self.getName() + '.setPosHprScale(' + otherString + + print((self.getName() + '.setPosHprScale(' + otherString + formatString % pos[0] + ', ' + formatString % pos[1] + ', ' + formatString % pos[2] + ', ' + @@ -288,14 +282,14 @@ def printPosHprScale(self, other = None, sd = 2): formatString % scale[0] + ', ' + formatString % scale[1] + ', ' + formatString % scale[2] + - ')\n') + ')\n')) Dtool_funcToMethod(printPosHprScale, NodePath) del printPosHprScale ##################################################################### def printTransform(self, other = None, sd = 2, fRecursive = 0): - from pandac.PandaModules import Vec3 + from panda3d.core import Vec3 fmtStr = '%%0.%df' % sd name = self.getName() if other == None: @@ -306,23 +300,23 @@ def printTransform(self, other = None, sd = 2, fRecursive = 0): pos = transform.getPos() if not pos.almostEqual(Vec3(0)): outputString = '%s.setPos(%s, %s, %s)' % (name, fmtStr, fmtStr, fmtStr) - print outputString % (pos[0], pos[1], pos[2]) + print(outputString % (pos[0], pos[1], pos[2])) if transform.hasHpr(): hpr = transform.getHpr() if not hpr.almostEqual(Vec3(0)): outputString = '%s.setHpr(%s, %s, %s)' % (name, fmtStr, fmtStr, fmtStr) - print outputString % (hpr[0], hpr[1], hpr[2]) + print(outputString % (hpr[0], hpr[1], hpr[2])) if transform.hasScale(): if transform.hasUniformScale(): scale = transform.getUniformScale() if scale != 1.0: outputString = '%s.setScale(%s)' % (name, fmtStr) - print outputString % scale + print(outputString % scale) else: scale = transform.getScale() if not scale.almostEqual(Vec3(1)): outputString = '%s.setScale(%s, %s, %s)' % (name, fmtStr, fmtStr, fmtStr) - print outputString % (scale[0], scale[1], scale[2]) + print(outputString % (scale[0], scale[1], scale[2])) if fRecursive: for child in self.getChildren(): child.printTransform(other, sd, fRecursive) @@ -383,700 +377,6 @@ def iPosHprScale(self, other = None): Dtool_funcToMethod(iPosHprScale, NodePath) del iPosHprScale ##################################################################### - -def __lerp(self, functorFunc, duration, blendType, taskName=None): - """ - __lerp(self, functorFunc, float, string, string) - Basic lerp functionality used by other lerps. - Fire off a lerp. Make it a task if taskName given. - """ - # functorFunc is a function which can be called to create a functor. - # functor creation is defered so initial state (sampled in functorFunc) - # will be appropriate for the time the lerp is spawned - from direct.task import Task - from direct.interval import LerpBlendHelpers - from direct.task.TaskManagerGlobal import taskMgr - - # make the task function - def lerpTaskFunc(task): - from pandac.PandaModules import Lerp - from pandac.PandaModules import ClockObject - from direct.task.Task import Task, cont, done - if task.init == 1: - # make the lerp - functor = task.functorFunc() - task.lerp = Lerp(functor, task.duration, task.blendType) - task.init = 0 - dt = globalClock.getDt() - task.lerp.setStepSize(dt) - task.lerp.step() - if (task.lerp.isDone()): - # Reset the init flag, in case the task gets re-used - task.init = 1 - return(done) - else: - return(cont) - - # make the lerp task - lerpTask = Task.Task(lerpTaskFunc) - lerpTask.init = 1 - lerpTask.functorFunc = functorFunc - lerpTask.duration = duration - lerpTask.blendType = LerpBlendHelpers.getBlend(blendType) - - if (taskName == None): - # don't spawn a task, return one instead - return lerpTask - else: - # spawn the lerp task - taskMgr.add(lerpTask, taskName) - return lerpTask - -Dtool_funcToMethod(__lerp, NodePath) -del __lerp -##################################################################### -def __autoLerp(self, functorFunc, time, blendType, taskName): - """_autoLerp(self, functor, float, string, string) - This lerp uses C++ to handle the stepping. Bonus is - its more efficient, trade-off is there is less control""" - from pandac.PandaModules import AutonomousLerp - from direct.interval import LerpBlendHelpers - # make a lerp that lives in C++ land - functor = functorFunc() - lerp = AutonomousLerp(functor, time, - LerpBlendHelpers.getBlend(blendType), - base.eventHandler) - lerp.start() - return lerp - -Dtool_funcToMethod(__autoLerp, NodePath) -del __autoLerp -##################################################################### - -# user callable lerp methods -def lerpColor(self, *posArgs, **keyArgs): - """lerpColor(self, *positionArgs, **keywordArgs) - determine which lerpColor* to call based on arguments - """ - if (len(posArgs) == 2): - return apply(self.lerpColorVBase4, posArgs, keyArgs) - elif (len(posArgs) == 3): - return apply(self.lerpColorVBase4VBase4, posArgs, keyArgs) - elif (len(posArgs) == 5): - return apply(self.lerpColorRGBA, posArgs, keyArgs) - elif (len(posArgs) == 9): - return apply(self.lerpColorRGBARGBA, posArgs, keyArgs) - else: - # bad args - raise Exception("Error: NodePath.lerpColor: bad number of args") - -Dtool_funcToMethod(lerpColor, NodePath) -del lerpColor -##################################################################### - -def lerpColorRGBA(self, r, g, b, a, time, - blendType="noBlend", auto=None, task=None): - """lerpColorRGBA(self, float, float, float, float, float, - string="noBlend", string=none, string=none) - """ - def functorFunc(self = self, r = r, g = g, b = b, a = a): - from pandac.PandaModules import ColorLerpFunctor - # just end rgba values, use current color rgba values for start - startColor = self.getColor() - functor = ColorLerpFunctor( - self, - startColor[0], startColor[1], - startColor[2], startColor[3], - r, g, b, a) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpColorRGBA, NodePath) -del lerpColorRGBA -##################################################################### -def lerpColorRGBARGBA(self, sr, sg, sb, sa, er, eg, eb, ea, time, - blendType="noBlend", auto=None, task=None): - """lerpColorRGBARGBA(self, float, float, float, float, float, - float, float, float, float, string="noBlend", string=none, string=none) - """ - def functorFunc(self = self, sr = sr, sg = sg, sb = sb, sa = sa, - er = er, eg = eg, eb = eb, ea = ea): - from pandac.PandaModules import ColorLerpFunctor - # start and end rgba values - functor = ColorLerpFunctor(self, sr, sg, sb, sa, - er, eg, eb, ea) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpColorRGBARGBA, NodePath) -del lerpColorRGBARGBA -##################################################################### -def lerpColorVBase4(self, endColor, time, - blendType="noBlend", auto=None, task=None): - """lerpColorVBase4(self, VBase4, float, string="noBlend", string=none, - string=none) - """ - def functorFunc(self = self, endColor = endColor): - from pandac.PandaModules import ColorLerpFunctor - # just end vec4, use current color for start - startColor = self.getColor() - functor = ColorLerpFunctor( - self, startColor, endColor) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpColorVBase4, NodePath) -del lerpColorVBase4 -##################################################################### -def lerpColorVBase4VBase4(self, startColor, endColor, time, - blendType="noBlend", auto=None, task=None): - """lerpColorVBase4VBase4(self, VBase4, VBase4, float, string="noBlend", - string=none, string=none) - """ - def functorFunc(self = self, startColor = startColor, - endColor = endColor): - from pandac.PandaModules import ColorLerpFunctor - # start color and end vec - functor = ColorLerpFunctor( - self, startColor, endColor) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - - - -Dtool_funcToMethod(lerpColorVBase4VBase4, NodePath) -del lerpColorVBase4VBase4 -##################################################################### - # user callable lerp methods -def lerpColorScale(self, *posArgs, **keyArgs): - """lerpColorScale(self, *positionArgs, **keywordArgs) - determine which lerpColorScale* to call based on arguments - """ - if (len(posArgs) == 2): - return apply(self.lerpColorScaleVBase4, posArgs, keyArgs) - elif (len(posArgs) == 3): - return apply(self.lerpColorScaleVBase4VBase4, posArgs, keyArgs) - elif (len(posArgs) == 5): - return apply(self.lerpColorScaleRGBA, posArgs, keyArgs) - elif (len(posArgs) == 9): - return apply(self.lerpColorScaleRGBARGBA, posArgs, keyArgs) - else: - # bad args - raise Exception("Error: NodePath.lerpColorScale: bad number of args") - - -Dtool_funcToMethod(lerpColorScale, NodePath) -del lerpColorScale -##################################################################### -def lerpColorScaleRGBA(self, r, g, b, a, time, - blendType="noBlend", auto=None, task=None): - """lerpColorScaleRGBA(self, float, float, float, float, float, - string="noBlend", string=none, string=none) - """ - def functorFunc(self = self, r = r, g = g, b = b, a = a): - from pandac.PandaModules import ColorScaleLerpFunctor - # just end rgba values, use current color rgba values for start - startColor = self.getColor() - functor = ColorScaleLerpFunctor( - self, - startColor[0], startColor[1], - startColor[2], startColor[3], - r, g, b, a) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpColorScaleRGBA, NodePath) -del lerpColorScaleRGBA -##################################################################### -def lerpColorScaleRGBARGBA(self, sr, sg, sb, sa, er, eg, eb, ea, time, - blendType="noBlend", auto=None, task=None): - """lerpColorScaleRGBARGBA(self, float, float, float, float, float, - float, float, float, float, string="noBlend", string=none, string=none) - """ - def functorFunc(self = self, sr = sr, sg = sg, sb = sb, sa = sa, - er = er, eg = eg, eb = eb, ea = ea): - from pandac.PandaModules import ColorScaleLerpFunctor - # start and end rgba values - functor = ColorScaleLerpFunctor(self, sr, sg, sb, sa, - er, eg, eb, ea) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpColorScaleRGBARGBA, NodePath) -del lerpColorScaleRGBARGBA -##################################################################### -def lerpColorScaleVBase4(self, endColor, time, - blendType="noBlend", auto=None, task=None): - """lerpColorScaleVBase4(self, VBase4, float, string="noBlend", string=none, - string=none) - """ - def functorFunc(self = self, endColor = endColor): - from pandac.PandaModules import ColorScaleLerpFunctor - # just end vec4, use current color for start - startColor = self.getColor() - functor = ColorScaleLerpFunctor( - self, startColor, endColor) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpColorScaleVBase4, NodePath) -del lerpColorScaleVBase4 -##################################################################### -def lerpColorScaleVBase4VBase4(self, startColor, endColor, time, - blendType="noBlend", auto=None, task=None): - """lerpColorScaleVBase4VBase4(self, VBase4, VBase4, float, string="noBlend", - string=none, string=none) - """ - def functorFunc(self = self, startColor = startColor, - endColor = endColor): - from pandac.PandaModules import ColorScaleLerpFunctor - # start color and end vec - functor = ColorScaleLerpFunctor( - self, startColor, endColor) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - - - -Dtool_funcToMethod(lerpColorScaleVBase4VBase4, NodePath) -del lerpColorScaleVBase4VBase4 -##################################################################### -def lerpHpr(self, *posArgs, **keyArgs): - """lerpHpr(self, *positionArgs, **keywordArgs) - Determine whether to call lerpHprHPR or lerpHprVBase3 - based on first argument - """ - # check to see if lerping with - # three floats or a VBase3 - if (len(posArgs) == 4): - return apply(self.lerpHprHPR, posArgs, keyArgs) - elif(len(posArgs) == 2): - return apply(self.lerpHprVBase3, posArgs, keyArgs) - else: - # bad args - raise Exception("Error: NodePath.lerpHpr: bad number of args") - -Dtool_funcToMethod(lerpHpr, NodePath) -del lerpHpr -##################################################################### -def lerpHprHPR(self, h, p, r, time, other=None, - blendType="noBlend", auto=None, task=None, shortest=1): - """lerpHprHPR(self, float, float, float, float, string="noBlend", - string=none, string=none, NodePath=none) - Perform a hpr lerp with three floats as the end point - """ - def functorFunc(self = self, h = h, p = p, r = r, - other = other, shortest=shortest): - from pandac.PandaModules import HprLerpFunctor - # it's individual hpr components - if (other != None): - # lerp wrt other - startHpr = self.getHpr(other) - functor = HprLerpFunctor( - self, - startHpr[0], startHpr[1], startHpr[2], - h, p, r, other) - if shortest: - functor.takeShortest() - else: - startHpr = self.getHpr() - functor = HprLerpFunctor( - self, - startHpr[0], startHpr[1], startHpr[2], - h, p, r) - if shortest: - functor.takeShortest() - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpHprHPR, NodePath) -del lerpHprHPR -##################################################################### -def lerpHprVBase3(self, hpr, time, other=None, - blendType="noBlend", auto=None, task=None, shortest=1): - """lerpHprVBase3(self, VBase3, float, string="noBlend", string=none, - string=none, NodePath=None) - Perform a hpr lerp with a VBase3 as the end point - """ - def functorFunc(self = self, hpr = hpr, - other = other, shortest=shortest): - from pandac.PandaModules import HprLerpFunctor - # it's a vbase3 hpr - if (other != None): - # lerp wrt other - functor = HprLerpFunctor( - self, (self.getHpr(other)), hpr, other) - if shortest: - functor.takeShortest() - else: - functor = HprLerpFunctor( - self, (self.getHpr()), hpr) - if shortest: - functor.takeShortest() - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - - -Dtool_funcToMethod(lerpHprVBase3, NodePath) -del lerpHprVBase3 -##################################################################### -def lerpPos(self, *posArgs, **keyArgs): - """lerpPos(self, *positionArgs, **keywordArgs) - Determine whether to call lerpPosXYZ or lerpPosPoint3 - based on the first argument - """ - # check to see if lerping with three - # floats or a Point3 - if (len(posArgs) == 4): - return apply(self.lerpPosXYZ, posArgs, keyArgs) - elif(len(posArgs) == 2): - return apply(self.lerpPosPoint3, posArgs, keyArgs) - else: - # bad number off args - raise Exception("Error: NodePath.lerpPos: bad number of args") - -Dtool_funcToMethod(lerpPos, NodePath) -del lerpPos -##################################################################### -def lerpPosXYZ(self, x, y, z, time, other=None, - blendType="noBlend", auto=None, task=None): - """lerpPosXYZ(self, float, float, float, float, string="noBlend", - string=None, NodePath=None) - Perform a pos lerp with three floats as the end point - """ - def functorFunc(self = self, x = x, y = y, z = z, other = other): - from pandac.PandaModules import PosLerpFunctor - if (other != None): - # lerp wrt other - startPos = self.getPos(other) - functor = PosLerpFunctor(self, - startPos[0], startPos[1], startPos[2], - x, y, z, other) - else: - startPos = self.getPos() - functor = PosLerpFunctor(self, startPos[0], - startPos[1], startPos[2], x, y, z) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpPosXYZ, NodePath) -del lerpPosXYZ -##################################################################### -def lerpPosPoint3(self, pos, time, other=None, - blendType="noBlend", auto=None, task=None): - """lerpPosPoint3(self, Point3, float, string="noBlend", string=None, - string=None, NodePath=None) - Perform a pos lerp with a Point3 as the end point - """ - def functorFunc(self = self, pos = pos, other = other): - from pandac.PandaModules import PosLerpFunctor - if (other != None): - #lerp wrt other - functor = PosLerpFunctor( - self, (self.getPos(other)), pos, other) - else: - functor = PosLerpFunctor( - self, (self.getPos()), pos) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - - -Dtool_funcToMethod(lerpPosPoint3, NodePath) -del lerpPosPoint3 -##################################################################### -def lerpPosHpr(self, *posArgs, **keyArgs): - """lerpPosHpr(self, *positionArgs, **keywordArgs) - Determine whether to call lerpPosHprXYZHPR or lerpHprPoint3VBase3 - based on first argument - """ - # check to see if lerping with - # six floats or a Point3 and a VBase3 - if (len(posArgs) == 7): - return apply(self.lerpPosHprXYZHPR, posArgs, keyArgs) - elif(len(posArgs) == 3): - return apply(self.lerpPosHprPoint3VBase3, posArgs, keyArgs) - else: - # bad number off args - raise Exception("Error: NodePath.lerpPosHpr: bad number of args") - -Dtool_funcToMethod(lerpPosHpr, NodePath) -del lerpPosHpr -##################################################################### -def lerpPosHprPoint3VBase3(self, pos, hpr, time, other=None, - blendType="noBlend", auto=None, task=None, shortest=1): - """lerpPosHprPoint3VBase3(self, Point3, VBase3, string="noBlend", - string=none, string=none, NodePath=None) - """ - def functorFunc(self = self, pos = pos, hpr = hpr, - other = other, shortest=shortest): - from pandac.PandaModules import PosHprLerpFunctor - if (other != None): - # lerp wrt other - startPos = self.getPos(other) - startHpr = self.getHpr(other) - functor = PosHprLerpFunctor( - self, startPos, pos, - startHpr, hpr, other) - if shortest: - functor.takeShortest() - else: - startPos = self.getPos() - startHpr = self.getHpr() - functor = PosHprLerpFunctor( - self, startPos, pos, - startHpr, hpr) - if shortest: - functor.takeShortest() - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpPosHprPoint3VBase3, NodePath) -del lerpPosHprPoint3VBase3 -##################################################################### -def lerpPosHprXYZHPR(self, x, y, z, h, p, r, time, other=None, - blendType="noBlend", auto=None, task=None, shortest=1): - """lerpPosHpr(self, float, string="noBlend", string=none, - string=none, NodePath=None) - """ - def functorFunc(self = self, x = x, y = y, z = z, - h = h, p = p, r = r, other = other, shortest=shortest): - from pandac.PandaModules import PosHprLerpFunctor - if (other != None): - # lerp wrt other - startPos = self.getPos(other) - startHpr = self.getHpr(other) - functor = PosHprLerpFunctor(self, - startPos[0], startPos[1], - startPos[2], x, y, z, - startHpr[0], startHpr[1], - startHpr[2], h, p, r, - other) - if shortest: - functor.takeShortest() - else: - startPos = self.getPos() - startHpr = self.getHpr() - functor = PosHprLerpFunctor(self, - startPos[0], startPos[1], - startPos[2], x, y, z, - startHpr[0], startHpr[1], - startHpr[2], h, p, r) - if shortest: - functor.takeShortest() - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - - -Dtool_funcToMethod(lerpPosHprXYZHPR, NodePath) -del lerpPosHprXYZHPR -##################################################################### -def lerpPosHprScale(self, pos, hpr, scale, time, other=None, - blendType="noBlend", auto=None, task=None, shortest=1): - """lerpPosHpr(self, Point3, VBase3, float, float, string="noBlend", - string=none, string=none, NodePath=None) - Only one case, no need for extra args. Call the appropriate lerp - (auto, spawned, or blocking) based on how(if) a task name is given - """ - def functorFunc(self = self, pos = pos, hpr = hpr, - scale = scale, other = other, shortest=shortest): - from pandac.PandaModules import PosHprScaleLerpFunctor - if (other != None): - # lerp wrt other - startPos = self.getPos(other) - startHpr = self.getHpr(other) - startScale = self.getScale(other) - functor = PosHprScaleLerpFunctor(self, - startPos, pos, - startHpr, hpr, - startScale, scale, other) - if shortest: - functor.takeShortest() - else: - startPos = self.getPos() - startHpr = self.getHpr() - startScale = self.getScale() - functor = PosHprScaleLerpFunctor(self, - startPos, pos, - startHpr, hpr, - startScale, scale) - if shortest: - functor.takeShortest() - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - - -Dtool_funcToMethod(lerpPosHprScale, NodePath) -del lerpPosHprScale -##################################################################### -def lerpScale(self, *posArgs, **keyArgs): - """lerpSclae(self, *positionArgs, **keywordArgs) - Determine whether to call lerpScaleXYZ or lerpScaleaseV3 - based on the first argument - """ - # check to see if lerping with three - # floats or a Point3 - if (len(posArgs) == 4): - return apply(self.lerpScaleXYZ, posArgs, keyArgs) - elif(len(posArgs) == 2): - return apply(self.lerpScaleVBase3, posArgs, keyArgs) - else: - # bad number off args - raise Exception("Error: NodePath.lerpScale: bad number of args") - -Dtool_funcToMethod(lerpScale, NodePath) -del lerpScale -##################################################################### -def lerpScaleVBase3(self, scale, time, other=None, - blendType="noBlend", auto=None, task=None): - """lerpPos(self, VBase3, float, string="noBlend", string=none, - string=none, NodePath=None) - """ - def functorFunc(self = self, scale = scale, other = other): - from pandac.PandaModules import ScaleLerpFunctor - if (other != None): - # lerp wrt other - functor = ScaleLerpFunctor(self, - (self.getScale(other)), - scale, other) - else: - functor = ScaleLerpFunctor(self, - (self.getScale()), scale) - - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - -Dtool_funcToMethod(lerpScaleVBase3, NodePath) -del lerpScaleVBase3 -##################################################################### -def lerpScaleXYZ(self, sx, sy, sz, time, other=None, - blendType="noBlend", auto=None, task=None): - """lerpPos(self, float, float, float, float, string="noBlend", - string=none, string=none, NodePath=None) - """ - def functorFunc(self = self, sx = sx, sy = sy, sz = sz, other = other): - from pandac.PandaModules import ScaleLerpFunctor - if (other != None): - # lerp wrt other - startScale = self.getScale(other) - functor = ScaleLerpFunctor(self, - startScale[0], startScale[1], - startScale[2], sx, sy, sz, other) - else: - startScale = self.getScale() - functor = ScaleLerpFunctor(self, - startScale[0], startScale[1], - startScale[2], sx, sy, sz) - return functor - #determine whether to use auto, spawned, or blocking lerp - if (auto != None): - return self.__autoLerp(functorFunc, time, blendType, auto) - elif (task != None): - return self.__lerp(functorFunc, time, blendType, task) - else: - return self.__lerp(functorFunc, time, blendType) - - - - -Dtool_funcToMethod(lerpScaleXYZ, NodePath) -del lerpScaleXYZ -##################################################################### def place(self): base.startDirect(fWantTk = 1) from direct.tkpanels import Placer @@ -1253,8 +553,8 @@ Dtool_funcToMethod(colorScaleInterval, NodePath) del colorScaleInterval ##################################################################### def attachCollisionSphere(self, name, cx, cy, cz, r, fromCollide, intoCollide): - from pandac.PandaModules import CollisionSphere - from pandac.PandaModules import CollisionNode + from panda3d.core import CollisionSphere + from panda3d.core import CollisionNode coll = CollisionSphere(cx, cy, cz, r) collNode = CollisionNode(name) collNode.addSolid(coll) @@ -1267,8 +567,8 @@ Dtool_funcToMethod(attachCollisionSphere, NodePath) del attachCollisionSphere ##################################################################### def attachCollisionSegment(self, name, ax, ay, az, bx, by, bz, fromCollide, intoCollide): - from pandac.PandaModules import CollisionSegment - from pandac.PandaModules import CollisionNode + from panda3d.core import CollisionSegment + from panda3d.core import CollisionNode coll = CollisionSegment(ax, ay, az, bx, by, bz) collNode = CollisionNode(name) collNode.addSolid(coll) @@ -1281,8 +581,8 @@ Dtool_funcToMethod(attachCollisionSegment, NodePath) del attachCollisionSegment ##################################################################### def attachCollisionRay(self, name, ox, oy, oz, dx, dy, dz, fromCollide, intoCollide): - from pandac.PandaModules import CollisionRay - from pandac.PandaModules import CollisionNode + from panda3d.core import CollisionRay + from panda3d.core import CollisionNode coll = CollisionRay(ox, oy, oz, dx, dy, dz) collNode = CollisionNode(name) collNode.addSolid(coll) @@ -1296,7 +596,7 @@ del attachCollisionRay ##################################################################### def flattenMultitex(self, stateFrom = None, target = None, useGeom = 0, allowTexMat = 0, win = None): - from pandac.PandaModules import MultitexReducer + from panda3d.core import MultitexReducer mr = MultitexReducer() if target != None: mr.setTarget(target) @@ -1466,26 +766,31 @@ del r_constructCollisionTree ##################################################################### def analyze(self): - from pandac.PandaModules import SceneGraphAnalyzer + """ + Analyzes the geometry below this node and reports the + number of vertices, triangles, etc. This is the same + information reported by the bam-info program. + """ + from panda3d.core import SceneGraphAnalyzer sga = SceneGraphAnalyzer() sga.addNode(self.node()) if sga.getNumLodNodes() == 0: - print sga + print(sga) else: - print "At highest LOD:" + print("At highest LOD:") sga2 = SceneGraphAnalyzer() sga2.setLodMode(sga2.LMHighest) sga2.addNode(self.node()) - print sga2 + print(sga2) - print "\nAt lowest LOD:" + print("\nAt lowest LOD:") sga2.clear() sga2.setLodMode(sga2.LMLowest) sga2.addNode(self.node()) - print sga2 + print(sga2) - print "\nAll nodes:" - print sga + print("\nAll nodes:") + print(sga) Dtool_funcToMethod(analyze, NodePath) del analyze diff --git a/direct/src/extensions_native/VBase3_extensions.py b/direct/src/extensions_native/VBase3_extensions.py index 331bafdd4e..29fbb3dc00 100755 --- a/direct/src/extensions_native/VBase3_extensions.py +++ b/direct/src/extensions_native/VBase3_extensions.py @@ -14,7 +14,7 @@ def asTuple(self): """ Returns the vector as a tuple. """ - print "Warning: VBase3.asTuple() is no longer needed and deprecated. Use the vector directly instead." + print("Warning: VBase3.asTuple() is no longer needed and deprecated. Use the vector directly instead.") return tuple(self) Dtool_funcToMethod(asTuple, VBase3) del asTuple diff --git a/direct/src/extensions_native/VBase4_extensions.py b/direct/src/extensions_native/VBase4_extensions.py index 8b7c022593..cf5c790e51 100755 --- a/direct/src/extensions_native/VBase4_extensions.py +++ b/direct/src/extensions_native/VBase4_extensions.py @@ -14,7 +14,7 @@ def asTuple(self): """ Returns the vector as a tuple. """ - print "Warning: VBase4.asTuple() is no longer needed and deprecated. Use the vector directly instead." + print("Warning: VBase4.asTuple() is no longer needed and deprecated. Use the vector directly instead.") return tuple(self) Dtool_funcToMethod(asTuple, VBase4) diff --git a/direct/src/extensions_native/core_extensions.py b/direct/src/extensions_native/core_extensions.py new file mode 100644 index 0000000000..3380dc3cf3 --- /dev/null +++ b/direct/src/extensions_native/core_extensions.py @@ -0,0 +1,28 @@ +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; + diff --git a/direct/src/ffi/DoGenPyCode.py b/direct/src/ffi/DoGenPyCode.py index 5bb7cb56e7..9bfb627ab1 100644 --- a/direct/src/ffi/DoGenPyCode.py +++ b/direct/src/ffi/DoGenPyCode.py @@ -5,8 +5,6 @@ the user to specify alternate parameters on the command line. """ import getopt import sys import os -import glob -import types import time from direct.ffi import FFIConstants @@ -224,7 +222,7 @@ def doErrorCheck(): FFIConstants.CodeModuleNameList = codeLibs def generateNativeWrappers(): - from direct.extensions_native.extension_native_helpers import Dtool_FindModule, Dtool_PreloadDLL + from direct.extensions_native.extension_native_helpers import Dtool_PreloadDLL # Empty out the output directories of unnecessary crud from # previous runs before we begin. @@ -337,7 +335,7 @@ def run(): if doHTML: from direct.directscripts import gendocs - from pandac.PandaModules import PandaSystem + from panda3d.core import PandaSystem versionString = '%s %s' % ( PandaSystem.getDistributor(), PandaSystem.getVersionString()) diff --git a/direct/src/ffi/FFITypes.py b/direct/src/ffi/FFITypes.py index 8669d2ec85..da20acb499 100644 --- a/direct/src/ffi/FFITypes.py +++ b/direct/src/ffi/FFITypes.py @@ -8,7 +8,6 @@ They get constructed by and stored in FFIInterrogateDatabase. """ -import sys import os import string import FFIConstants diff --git a/direct/src/ffi/jGenPyCode.py b/direct/src/ffi/jGenPyCode.py index cc7440bd42..3c8ee77bee 100755 --- a/direct/src/ffi/jGenPyCode.py +++ b/direct/src/ffi/jGenPyCode.py @@ -72,7 +72,6 @@ if (EXTENSIONS is None): ############################################################## from direct.ffi import DoGenPyCode -from direct.ffi import FFIConstants DoGenPyCode.outputCodeDir = PANDAC DoGenPyCode.outputHTMLDir = os.path.join(PANDAC,"..","doc") DoGenPyCode.directDir = DIRECT diff --git a/direct/src/filter/CommonFilters.py b/direct/src/filter/CommonFilters.py index 42b06d740b..a6f9e43520 100644 --- a/direct/src/filter/CommonFilters.py +++ b/direct/src/filter/CommonFilters.py @@ -19,8 +19,8 @@ from FilterManager import FilterManager from panda3d.core import LVecBase4, LPoint2 from panda3d.core import Filename from panda3d.core import AuxBitplaneAttrib -from panda3d.core import RenderState, Texture, Shader, ATSNone -import sys,os +from panda3d.core import Texture, Shader, ATSNone +import os CARTOON_BODY=""" float4 cartoondelta = k_cartoonseparation * texpix_txaux.xwyw; diff --git a/direct/src/filter/FilterManager.py b/direct/src/filter/FilterManager.py index c03afe4bc0..432ae6fe93 100644 --- a/direct/src/filter/FilterManager.py +++ b/direct/src/filter/FilterManager.py @@ -14,13 +14,12 @@ Still need to implement: """ -from panda3d.core import NodePath, PandaNode -from panda3d.core import RenderState, Texture, Shader +from panda3d.core import NodePath +from panda3d.core import Texture from panda3d.core import CardMaker -from panda3d.core import TextureStage from panda3d.core import GraphicsPipe, GraphicsOutput from panda3d.core import WindowProperties, FrameBufferProperties -from panda3d.core import Camera, DisplayRegion +from panda3d.core import Camera from panda3d.core import OrthographicLens from panda3d.core import AuxBitplaneAttrib from direct.directnotify.DirectNotifyGlobal import * diff --git a/direct/src/fsm/FourState.py b/direct/src/fsm/FourState.py index 6f42046cef..52c9549d85 100755 --- a/direct/src/fsm/FourState.py +++ b/direct/src/fsm/FourState.py @@ -8,7 +8,6 @@ from direct.directnotify import DirectNotifyGlobal #import DistributedObject import ClassicFSM import State -from direct.task import Task class FourState: diff --git a/direct/src/fsm/SampleFSM.py b/direct/src/fsm/SampleFSM.py index e12c847a4b..ba2c1de138 100644 --- a/direct/src/fsm/SampleFSM.py +++ b/direct/src/fsm/SampleFSM.py @@ -3,7 +3,6 @@ __all__ = ['ClassicStyle', 'NewStyle', 'ToonEyes'] import FSM -from pandac.PandaModules import * from direct.task import Task import string diff --git a/direct/src/fsm/State.py b/direct/src/fsm/State.py index 0af9f45851..75e8269f11 100644 --- a/direct/src/fsm/State.py +++ b/direct/src/fsm/State.py @@ -4,7 +4,6 @@ __all__ = ['State'] from direct.directnotify.DirectNotifyGlobal import directNotify from direct.showbase.DirectObject import DirectObject -import types class State(DirectObject): diff --git a/direct/src/fsm/StatePush.py b/direct/src/fsm/StatePush.py index 49a6667fbb..10820b175b 100755 --- a/direct/src/fsm/StatePush.py +++ b/direct/src/fsm/StatePush.py @@ -5,7 +5,7 @@ __all__ = ['StateVar', 'FunctionCall', 'EnterExit', 'Pulse', 'EventPulse', 'EventArgument', ] from direct.showbase.DirectObject import DirectObject -import types + class PushesStateChanges: # base class for objects that broadcast state changes to a set of subscriber objects diff --git a/direct/src/gui/DirectButton.py b/direct/src/gui/DirectButton.py index 110b4e5a38..a40dfda94b 100644 --- a/direct/src/gui/DirectButton.py +++ b/direct/src/gui/DirectButton.py @@ -2,7 +2,7 @@ __all__ = ['DirectButton'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectFrame import * diff --git a/direct/src/gui/DirectCheckBox.py b/direct/src/gui/DirectCheckBox.py index cf2a371fec..6091f8bc31 100755 --- a/direct/src/gui/DirectCheckBox.py +++ b/direct/src/gui/DirectCheckBox.py @@ -1,5 +1,5 @@ from direct.gui.DirectGui import * -from pandac.PandaModules import * +from panda3d.core import * class DirectCheckBox(DirectButton): diff --git a/direct/src/gui/DirectCheckButton.py b/direct/src/gui/DirectCheckButton.py index 77244b185f..5212031600 100644 --- a/direct/src/gui/DirectCheckButton.py +++ b/direct/src/gui/DirectCheckButton.py @@ -2,8 +2,7 @@ __all__ = ['DirectCheckButton'] -from pandac.PandaModules import * -import DirectGuiGlobals as DGG +from panda3d.core import * from DirectButton import * from DirectLabel import * diff --git a/direct/src/gui/DirectDialog.py b/direct/src/gui/DirectDialog.py index 44cb182ab0..1aa75332d0 100644 --- a/direct/src/gui/DirectDialog.py +++ b/direct/src/gui/DirectDialog.py @@ -2,7 +2,7 @@ __all__ = ['findDialog', 'cleanupDialog', 'DirectDialog', 'OkDialog', 'OkCancelDialog', 'YesNoDialog', 'YesNoCancelDialog', 'RetryCancelDialog'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectFrame import * from DirectButton import * diff --git a/direct/src/gui/DirectEntry.py b/direct/src/gui/DirectEntry.py index e2b306af06..5fa8920328 100644 --- a/direct/src/gui/DirectEntry.py +++ b/direct/src/gui/DirectEntry.py @@ -2,7 +2,7 @@ __all__ = ['DirectEntry'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectFrame import * from OnscreenText import OnscreenText diff --git a/direct/src/gui/DirectEntryScroll.py b/direct/src/gui/DirectEntryScroll.py index bf829bed63..7341671d6a 100644 --- a/direct/src/gui/DirectEntryScroll.py +++ b/direct/src/gui/DirectEntryScroll.py @@ -1,6 +1,6 @@ __all__ = ['DirectEntryScroll'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectScrolledFrame import * from DirectFrame import * @@ -114,6 +114,4 @@ class DirectEntryScroll(DirectFrame): def resetCanvas(self): self.canvas.setPos(0,0,0) - - - \ No newline at end of file + diff --git a/direct/src/gui/DirectFrame.py b/direct/src/gui/DirectFrame.py index 4603f9356c..ed67b84c25 100644 --- a/direct/src/gui/DirectFrame.py +++ b/direct/src/gui/DirectFrame.py @@ -2,12 +2,12 @@ __all__ = ['DirectFrame'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectGuiBase import * from OnscreenImage import OnscreenImage from OnscreenGeom import OnscreenGeom -import string, types +import types class DirectFrame(DirectGuiWidget): DefDynGroups = ('text', 'geom', 'image') diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index 2d8c8241e7..bb959a1601 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/direct/src/gui/DirectGuiBase.py @@ -3,7 +3,8 @@ __all__ = ['DirectGuiBase', 'DirectGuiWidget'] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import get_config_showbase import DirectGuiGlobals as DGG from OnscreenText import * from OnscreenGeom import * @@ -11,9 +12,7 @@ from OnscreenImage import * from direct.directtools.DirectUtil import ROUND_TO from direct.showbase import DirectObject from direct.task import Task -from direct.showbase import ShowBase from direct.showbase.PythonUtil import recordCreationStackStr -from pandac.PandaModules import PStatCollector import types guiObjectCollector = PStatCollector("Client::GuiObjects") @@ -632,7 +631,7 @@ class DirectGuiBase(DirectObject.DirectObject): """ # Need to tack on gui item specific id gEvent = event + self.guiId - if base.config.GetBool('debug-directgui-msgs', False): + if get_config_showbase().GetBool('debug-directgui-msgs', False): from direct.showbase.PythonUtil import StackTrace print gEvent print StackTrace() @@ -655,7 +654,7 @@ def setGuiGridSpacing(spacing): # this should trigger off of __dev__, but it's not available at this point. # __debug__ works because the production client is not __debug__ and the # production AI doesn't create any GUI. -if config.GetBool('record-gui-creation-stack', __debug__): +if get_config_showbase().GetBool('record-gui-creation-stack', __debug__): # this will help track down the code that created DirectGui objects # call obj.printCreationStackTrace() to figure out what code created it DirectGuiBase = recordCreationStackStr(DirectGuiBase) @@ -668,8 +667,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath): # Determine the default initial state for inactive (or # unclickable) components. If we are in edit mode, these are # actually clickable by default. - #guiEdit = base.config.GetBool('direct-gui-edit', 0) - guiEdit = config.GetBool('direct-gui-edit', 0) + guiEdit = get_config_showbase().GetBool('direct-gui-edit', 0) if guiEdit: inactiveInitState = DGG.NORMAL else: @@ -1069,8 +1067,8 @@ class DirectGuiWidget(DirectGuiBase, NodePath): def printConfig(self, indent = 0): space = ' ' * indent print space + self.guiId, '-', self.__class__.__name__ - print space + 'Pos: ' + self.getPos().pPrintValues() - print space + 'Scale: ' + self.getScale().pPrintValues() + print space + 'Pos: %s' % tuple(self.getPos()) + print space + 'Scale: %s' % tuple(self.getScale()) # Print out children info for child in self.getChildren(): messenger.send(DGG.PRINT + child.getName(), [indent + 2]) diff --git a/direct/src/gui/DirectGuiGlobals.py b/direct/src/gui/DirectGuiGlobals.py index 167d2a99b4..0602f9cfc0 100644 --- a/direct/src/gui/DirectGuiGlobals.py +++ b/direct/src/gui/DirectGuiGlobals.py @@ -7,7 +7,7 @@ __all__ = [] Global definitions used by Direct Gui Classes and handy constants that can be used during widget construction """ -from pandac.PandaModules import * +from panda3d.core import * defaultFont = None defaultFontFunc = TextNode.getDefaultFont diff --git a/direct/src/gui/DirectGuiTest.py b/direct/src/gui/DirectGuiTest.py index 2b076eed00..46edc3dd09 100644 --- a/direct/src/gui/DirectGuiTest.py +++ b/direct/src/gui/DirectGuiTest.py @@ -4,11 +4,13 @@ __all__ = [] if __name__ == "__main__": - from direct.directbase import DirectStart + from direct.showbase.ShowBase import ShowBase from DirectGui import * #from whrandom import * from random import * + base = ShowBase() + # EXAMPLE CODE # Load a model smiley = loader.loadModel('models/misc/smiley') diff --git a/direct/src/gui/DirectLabel.py b/direct/src/gui/DirectLabel.py index babd6d53c4..1728fdcb13 100644 --- a/direct/src/gui/DirectLabel.py +++ b/direct/src/gui/DirectLabel.py @@ -2,8 +2,7 @@ __all__ = ['DirectLabel'] -from pandac.PandaModules import * -import DirectGuiGlobals as DGG +from panda3d.core import * from DirectFrame import * class DirectLabel(DirectFrame): diff --git a/direct/src/gui/DirectOptionMenu.py b/direct/src/gui/DirectOptionMenu.py index b37436b5c7..bd2e45fffc 100644 --- a/direct/src/gui/DirectOptionMenu.py +++ b/direct/src/gui/DirectOptionMenu.py @@ -4,7 +4,7 @@ __all__ = ['DirectOptionMenu'] import types -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectButton import * from DirectLabel import * diff --git a/direct/src/gui/DirectRadioButton.py b/direct/src/gui/DirectRadioButton.py index c2cb423f0d..775ccf5648 100755 --- a/direct/src/gui/DirectRadioButton.py +++ b/direct/src/gui/DirectRadioButton.py @@ -2,7 +2,7 @@ __all__ = ['DirectRadioButton'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectButton import * from DirectLabel import * diff --git a/direct/src/gui/DirectScrollBar.py b/direct/src/gui/DirectScrollBar.py index f69896568b..a2a6f70ab2 100644 --- a/direct/src/gui/DirectScrollBar.py +++ b/direct/src/gui/DirectScrollBar.py @@ -2,7 +2,7 @@ __all__ = ['DirectScrollBar'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectFrame import * from DirectButton import * diff --git a/direct/src/gui/DirectScrolledFrame.py b/direct/src/gui/DirectScrolledFrame.py index e3efa164c7..325582ef52 100644 --- a/direct/src/gui/DirectScrolledFrame.py +++ b/direct/src/gui/DirectScrolledFrame.py @@ -2,7 +2,7 @@ __all__ = ['DirectScrolledFrame'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectFrame import * from DirectScrollBar import * diff --git a/direct/src/gui/DirectScrolledList.py b/direct/src/gui/DirectScrolledList.py index aa0293ae5e..d2ac37dfef 100644 --- a/direct/src/gui/DirectScrolledList.py +++ b/direct/src/gui/DirectScrolledList.py @@ -2,13 +2,13 @@ __all__ = ['DirectScrolledListItem', 'DirectScrolledList'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from direct.directnotify import DirectNotifyGlobal from direct.task.Task import Task from DirectFrame import * from DirectButton import * -import string, types +import types class DirectScrolledListItem(DirectButton): diff --git a/direct/src/gui/DirectSlider.py b/direct/src/gui/DirectSlider.py index d2066c3b68..40737e6c9f 100644 --- a/direct/src/gui/DirectSlider.py +++ b/direct/src/gui/DirectSlider.py @@ -2,7 +2,7 @@ __all__ = ['DirectSlider'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectFrame import * from DirectButton import * diff --git a/direct/src/gui/DirectWaitBar.py b/direct/src/gui/DirectWaitBar.py index c1e7bee0c9..2fe9567941 100644 --- a/direct/src/gui/DirectWaitBar.py +++ b/direct/src/gui/DirectWaitBar.py @@ -2,7 +2,7 @@ __all__ = ['DirectWaitBar'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from DirectFrame import * import types diff --git a/direct/src/gui/OnscreenGeom.py b/direct/src/gui/OnscreenGeom.py index d9ef571aa6..faf020a2d1 100644 --- a/direct/src/gui/OnscreenGeom.py +++ b/direct/src/gui/OnscreenGeom.py @@ -2,10 +2,9 @@ __all__ = ['OnscreenGeom'] -from pandac.PandaModules import * -import DirectGuiGlobals as DGG +from panda3d.core import * from direct.showbase.DirectObject import DirectObject -import string,types +import types class OnscreenGeom(DirectObject, NodePath): def __init__(self, geom = None, diff --git a/direct/src/gui/OnscreenImage.py b/direct/src/gui/OnscreenImage.py index 50923eec19..7f4579886d 100644 --- a/direct/src/gui/OnscreenImage.py +++ b/direct/src/gui/OnscreenImage.py @@ -2,10 +2,9 @@ __all__ = ['OnscreenImage'] -from pandac.PandaModules import * -import DirectGuiGlobals as DGG +from panda3d.core import * from direct.showbase.DirectObject import DirectObject -import string,types +import types class OnscreenImage(DirectObject, NodePath): def __init__(self, image = None, diff --git a/direct/src/gui/OnscreenText.py b/direct/src/gui/OnscreenText.py index ed212d2643..9e0f2cb18b 100644 --- a/direct/src/gui/OnscreenText.py +++ b/direct/src/gui/OnscreenText.py @@ -2,10 +2,10 @@ __all__ = ['OnscreenText', 'Plain', 'ScreenTitle', 'ScreenPrompt', 'NameConfirm', 'BlackOnWhite'] -from pandac.PandaModules import * +from panda3d.core import * import DirectGuiGlobals as DGG from direct.showbase.DirectObject import DirectObject -import string,types +import types ## These are the styles of text we might commonly see. They set the ## overall appearance of the text according to one of a number of diff --git a/direct/src/http/baseincomingset.i b/direct/src/http/baseincomingset.i index 32cdf8eaee..75d931f538 100644 --- a/direct/src/http/baseincomingset.i +++ b/direct/src/http/baseincomingset.i @@ -70,7 +70,7 @@ inline int BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READE template inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::AddAConection(_INCLASS1 * newt) { - push_back(newt); + this->push_back(newt); } //////////////////////////////////////////////////////////////////// // Function name : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::BaseIncomingSet diff --git a/direct/src/interval/ActorInterval.py b/direct/src/interval/ActorInterval.py index 98e82bc605..2e884fcc15 100644 --- a/direct/src/interval/ActorInterval.py +++ b/direct/src/interval/ActorInterval.py @@ -2,7 +2,8 @@ __all__ = ['ActorInterval', 'LerpAnimInterval'] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * import Interval import math diff --git a/direct/src/interval/AnimControlInterval.py b/direct/src/interval/AnimControlInterval.py index 3e1d1259d1..bd2acc17ff 100755 --- a/direct/src/interval/AnimControlInterval.py +++ b/direct/src/interval/AnimControlInterval.py @@ -2,7 +2,8 @@ __all__ = ['AnimControlInterval'] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * import Interval import math diff --git a/direct/src/interval/FunctionInterval.py b/direct/src/interval/FunctionInterval.py index fd46bad994..815fd8b090 100644 --- a/direct/src/interval/FunctionInterval.py +++ b/direct/src/interval/FunctionInterval.py @@ -2,11 +2,11 @@ __all__ = ['FunctionInterval', 'EventInterval', 'AcceptInterval', 'IgnoreInterval', 'ParentInterval', 'WrtParentInterval', 'PosInterval', 'HprInterval', 'ScaleInterval', 'PosHprInterval', 'HprScaleInterval', 'PosHprScaleInterval', 'Func', 'Wait'] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.showbase.MessengerGlobal import * from direct.directnotify.DirectNotifyGlobal import directNotify import Interval -import types ############################################################# diff --git a/direct/src/interval/IndirectInterval.py b/direct/src/interval/IndirectInterval.py index 9039064d24..c435dbc76a 100644 --- a/direct/src/interval/IndirectInterval.py +++ b/direct/src/interval/IndirectInterval.py @@ -2,7 +2,8 @@ __all__ = ['IndirectInterval'] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * import Interval import LerpBlendHelpers diff --git a/direct/src/interval/Interval.py b/direct/src/interval/Interval.py index 0907c6d6a0..0ce940a261 100644 --- a/direct/src/interval/Interval.py +++ b/direct/src/interval/Interval.py @@ -4,10 +4,9 @@ __all__ = ['Interval'] from direct.directnotify.DirectNotifyGlobal import directNotify from direct.showbase.DirectObject import DirectObject -from pandac.PandaModules import * from direct.task.Task import Task, TaskManager -from direct.showbase import PythonUtil -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * import math class Interval(DirectObject): diff --git a/direct/src/interval/IntervalGlobal.py b/direct/src/interval/IntervalGlobal.py index ecc9abb6ad..d1589d268d 100644 --- a/direct/src/interval/IntervalGlobal.py +++ b/direct/src/interval/IntervalGlobal.py @@ -10,15 +10,17 @@ from FunctionInterval import * from LerpInterval import * from IndirectInterval import * from MopathInterval import * -import pandac.PandaModules -##Some people may have the particle system compiled out -if hasattr( pandac.PandaModules, 'ParticleSystem' ): - from ParticleInterval import * +try: + import panda3d.physics + ##Some people may have the particle system compiled out + if hasattr( panda3d.physics, 'ParticleSystem' ): + from ParticleInterval import * + if __debug__: + from TestInterval import * +except ImportError: + pass from SoundInterval import * from ProjectileInterval import * from MetaInterval import * from IntervalManager import * -if __debug__: - if hasattr( pandac.PandaModules, 'ParticleSystem' ): - from TestInterval import * -from pandac.PandaModules import WaitInterval +from panda3d.direct import WaitInterval diff --git a/direct/src/interval/IntervalManager.py b/direct/src/interval/IntervalManager.py index 95a0c754a9..3fa556f30c 100644 --- a/direct/src/interval/IntervalManager.py +++ b/direct/src/interval/IntervalManager.py @@ -2,12 +2,10 @@ __all__ = ['IntervalManager', 'ivalMgr'] -from pandac.PandaModules import * -from pandac import PandaModules +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * from direct.showbase import EventManager -import Interval -import types import fnmatch class IntervalManager(CIntervalManager): diff --git a/direct/src/interval/IntervalTest.py b/direct/src/interval/IntervalTest.py index 7a4954a154..4bbfc9db57 100644 --- a/direct/src/interval/IntervalTest.py +++ b/direct/src/interval/IntervalTest.py @@ -4,13 +4,15 @@ __all__ = [] if __name__ == "__main__": - from direct.directbase import DirectStart - from pandac.PandaModules import * + from direct.showbase.ShowBase import ShowBase + from panda3d.core import * from IntervalGlobal import * from direct.actor.Actor import * from direct.directutil import Mopath + base = ShowBase() + boat = loader.loadModel('models/misc/smiley') boat.reparentTo(render) @@ -205,4 +207,4 @@ if __name__ == "__main__": # return mt test(5) - run() + base.run() diff --git a/direct/src/interval/LerpInterval.py b/direct/src/interval/LerpInterval.py index bba040494f..51e9a7e61e 100644 --- a/direct/src/interval/LerpInterval.py +++ b/direct/src/interval/LerpInterval.py @@ -12,7 +12,8 @@ __all__ = [ 'LerpFunctionInterval', 'LerpFunc','LerpFunctionNoStateInterval','LerpFuncNS' ] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * import Interval import LerpBlendHelpers diff --git a/direct/src/interval/MetaInterval.py b/direct/src/interval/MetaInterval.py index f521414593..067414aea1 100644 --- a/direct/src/interval/MetaInterval.py +++ b/direct/src/interval/MetaInterval.py @@ -2,14 +2,15 @@ __all__ = ['MetaInterval', 'Sequence', 'Parallel', 'ParallelEndTogether', 'Track'] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * from IntervalManager import ivalMgr import Interval -from direct.task.Task import Task, TaskManager +from direct.task.Task import TaskManager import types -if __debug__: - import direct.showbase.PythonUtil as PythonUtil +#if __debug__: +# import direct.showbase.PythonUtil as PythonUtil PREVIOUS_END = CMetaInterval.RSPreviousEnd PREVIOUS_START = CMetaInterval.RSPreviousBegin diff --git a/direct/src/interval/MopathInterval.py b/direct/src/interval/MopathInterval.py index fe16700fc9..4a479896f1 100644 --- a/direct/src/interval/MopathInterval.py +++ b/direct/src/interval/MopathInterval.py @@ -3,7 +3,8 @@ __all__ = ['MopathInterval'] import LerpInterval -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * # import Mopath diff --git a/direct/src/interval/ParticleInterval.py b/direct/src/interval/ParticleInterval.py index 1456654330..fec166b6ec 100644 --- a/direct/src/interval/ParticleInterval.py +++ b/direct/src/interval/ParticleInterval.py @@ -6,11 +6,11 @@ __all__ = ['ParticleInterval'] Contains the ParticleInterval class """ -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import directNotify from Interval import Interval -from direct.particles import ParticleEffect class ParticleInterval(Interval): """ diff --git a/direct/src/interval/ProjectileInterval.py b/direct/src/interval/ProjectileInterval.py index 7118c36f4d..3372b415af 100755 --- a/direct/src/interval/ProjectileInterval.py +++ b/direct/src/interval/ProjectileInterval.py @@ -2,10 +2,10 @@ __all__ = ['ProjectileInterval'] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * from Interval import Interval -from direct.showbase.PythonUtil import lerp from direct.showbase import PythonUtil class ProjectileInterval(Interval): diff --git a/direct/src/interval/ProjectileIntervalTest.py b/direct/src/interval/ProjectileIntervalTest.py index 4a5dc0907a..7e0b080d5a 100755 --- a/direct/src/interval/ProjectileIntervalTest.py +++ b/direct/src/interval/ProjectileIntervalTest.py @@ -2,8 +2,8 @@ __all__ = ['doTest'] -from pandac.PandaModules import * -from direct.directbase.DirectStart import * +from panda3d.core import * +from panda3d.direct import * from IntervalGlobal import * def doTest(): diff --git a/direct/src/interval/SoundInterval.py b/direct/src/interval/SoundInterval.py index fab99973e0..5326f105e6 100644 --- a/direct/src/interval/SoundInterval.py +++ b/direct/src/interval/SoundInterval.py @@ -2,7 +2,8 @@ __all__ = ['SoundInterval'] -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import * import Interval import random diff --git a/direct/src/interval/TestInterval.py b/direct/src/interval/TestInterval.py index 7066bac0d5..b7a56d1698 100755 --- a/direct/src/interval/TestInterval.py +++ b/direct/src/interval/TestInterval.py @@ -6,11 +6,11 @@ __all__ = ['TestInterval'] Contains the ParticleInterval class """ -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import directNotify from Interval import Interval -from direct.particles import ParticleEffect class TestInterval(Interval): # Name counter diff --git a/direct/src/motiontrail/MotionTrail.py b/direct/src/motiontrail/MotionTrail.py index ffcdbe5781..531deef003 100644 --- a/direct/src/motiontrail/MotionTrail.py +++ b/direct/src/motiontrail/MotionTrail.py @@ -1,6 +1,7 @@ -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.direct import * from direct.task import Task from direct.showbase.DirectObject import DirectObject diff --git a/direct/src/p3d/AppRunner.py b/direct/src/p3d/AppRunner.py index b9a1f17572..4b331ba272 100644 --- a/direct/src/p3d/AppRunner.py +++ b/direct/src/p3d/AppRunner.py @@ -9,9 +9,10 @@ runp3d.py for a command-line tool to invoke this module. """ +__all__ = ["AppRunner", "dummyAppRunner", "ArgumentError"] + import sys import os -import types import __builtin__ if 'VFSImporter' in sys.modules: @@ -29,7 +30,7 @@ else: from direct.showbase import VFSImporter from direct.showbase.DirectObject import DirectObject -from panda3d.core import VirtualFileSystem, Filename, Multifile, loadPrcFileData, unloadPrcFile, getModelPath, Thread, WindowProperties, ExecutionEnvironment, PandaSystem, Notify, StreamWriter, ConfigVariableString, ConfigPageManager +from panda3d.core import VirtualFileSystem, Filename, Multifile, loadPrcFileData, unloadPrcFile, getModelPath, WindowProperties, ExecutionEnvironment, PandaSystem, Notify, StreamWriter, ConfigVariableString, ConfigPageManager from panda3d.direct import init_app_for_gui from panda3d import core from direct.stdpy import file, glob @@ -43,7 +44,7 @@ from direct.p3d.InstalledHostData import InstalledHostData from direct.p3d.InstalledPackageData import InstalledPackageData # These imports are read by the C++ wrapper in p3dPythonRun.cxx. -from direct.p3d.JavaScript import UndefinedObject, Undefined, ConcreteStruct, BrowserObject +from direct.p3d.JavaScript import Undefined, ConcreteStruct class ArgumentError(AttributeError): pass diff --git a/direct/src/p3d/DWBPackageInstaller.py b/direct/src/p3d/DWBPackageInstaller.py index 43ee9fb71d..4d32e4d503 100644 --- a/direct/src/p3d/DWBPackageInstaller.py +++ b/direct/src/p3d/DWBPackageInstaller.py @@ -1,3 +1,5 @@ +__all__ = ["DWBPackageInstaller"] + from direct.p3d.PackageInstaller import PackageInstaller from direct.gui.DirectWaitBar import DirectWaitBar from direct.gui import DirectGuiGlobals as DGG diff --git a/direct/src/p3d/DeploymentTools.py b/direct/src/p3d/DeploymentTools.py index b0e348f245..5f316e35c7 100644 --- a/direct/src/p3d/DeploymentTools.py +++ b/direct/src/p3d/DeploymentTools.py @@ -4,7 +4,7 @@ to build for as many platforms as possible. """ __all__ = ["Standalone", "Installer"] -import os, sys, subprocess, tarfile, shutil, time, zipfile, glob, socket, getpass, struct +import os, sys, subprocess, tarfile, shutil, time, zipfile, socket, getpass, struct from cStringIO import StringIO from direct.directnotify.DirectNotifyGlobal import * from direct.showbase.AppRunnerGlobal import appRunner @@ -73,7 +73,7 @@ class Standalone: self.tempDir = Filename.temporary("", self.basename, "") + "/" self.tempDir.makeDir() - self.host = HostInfo(PandaSystem.getPackageHostUrl(), appRunner = appRunner, hostDir = self.tempDir, asMirror = False, perPlatform = True) + self.host = HostInfo(PandaSystem.getPackageHostUrl(), appRunner = appRunner, hostDir = self.tempDir, asMirror = False) self.http = HTTPClient.getGlobalPtr() if not self.host.hasContentsFile: @@ -233,7 +233,7 @@ class PackageTree: if hostUrl in self.hosts: return self.hosts[hostUrl] - host = HostInfo(hostUrl, appRunner = appRunner, hostDir = self.hostDir, asMirror = False, perPlatform = False) + host = HostInfo(hostUrl, appRunner = appRunner, hostDir = self.hostDir, asMirror = False) if not host.hasContentsFile: if not host.readContentsFile(): if not host.downloadContentsFile(self.http): @@ -587,15 +587,22 @@ class Installer: for package in pkgTree.packages.values(): xpackage = TiXmlElement('package') xpackage.SetAttribute('name', package.packageName) + + filename = package.packageName + "/" + + if package.packageVersion: + xpackage.SetAttribute('version', package.packageVersion) + filename += package.packageVersion + "/" + if package.platform: xpackage.SetAttribute('platform', package.platform) + filename += package.platform + "/" assert package.platform == platform - xpackage.SetAttribute('per_platform', '0') - if package.packageVersion: - xpackage.SetAttribute('version', version) - xpackage.SetAttribute('filename', package.packageName + "/" + package.packageVersion + "/" + package.descFileBasename) - else: - xpackage.SetAttribute('filename', package.packageName + "/" + package.descFileBasename) + + xpackage.SetAttribute('per_platform', '1') + + filename += package.descFileBasename + xpackage.SetAttribute('filename', filename) xcontents.InsertEndChild(xpackage) doc.InsertEndChild(xcontents) diff --git a/direct/src/p3d/FileSpec.py b/direct/src/p3d/FileSpec.py index 291149ad77..f6ca6b93d0 100644 --- a/direct/src/p3d/FileSpec.py +++ b/direct/src/p3d/FileSpec.py @@ -1,3 +1,5 @@ +__all__ = ["FileSpec"] + import os import time from panda3d.core import Filename, HashVal, VirtualFileSystem diff --git a/direct/src/p3d/HostInfo.py b/direct/src/p3d/HostInfo.py index f22e47cf82..82fa5001cd 100644 --- a/direct/src/p3d/HostInfo.py +++ b/direct/src/p3d/HostInfo.py @@ -1,3 +1,5 @@ +__all__ = ["HostInfo"] + from panda3d.core import HashVal, Filename, PandaSystem, DocumentSpec, Ramfile from panda3d.core import HTTPChannel, ConfigVariableInt from panda3d import core diff --git a/direct/src/p3d/InstalledHostData.py b/direct/src/p3d/InstalledHostData.py index e8c9e5d5d2..d98abb6d18 100644 --- a/direct/src/p3d/InstalledHostData.py +++ b/direct/src/p3d/InstalledHostData.py @@ -1,3 +1,5 @@ +__all__ = ["InstalledHostData"] + from panda3d.core import URLSpec class InstalledHostData: diff --git a/direct/src/p3d/InstalledPackageData.py b/direct/src/p3d/InstalledPackageData.py index 6d0675ac36..c6ebed3ec1 100644 --- a/direct/src/p3d/InstalledPackageData.py +++ b/direct/src/p3d/InstalledPackageData.py @@ -1,3 +1,5 @@ +__all__ = ["InstalledPackageData"] + class InstalledPackageData: """ A list of instances of this class is maintained by InstalledHostData (which is in turn returned by diff --git a/direct/src/p3d/JavaScript.py b/direct/src/p3d/JavaScript.py index 6c08d0ed29..f10ad28d1d 100644 --- a/direct/src/p3d/JavaScript.py +++ b/direct/src/p3d/JavaScript.py @@ -2,6 +2,8 @@ useful when writing code that integrates with JavaScript, especially code that runs in a browser via the web plugin. """ +__all__ = ["UndefinedObject", "Undefined", "ConcreteStruct", "BrowserObject", "MethodWrapper"] + import types class UndefinedObject: diff --git a/direct/src/p3d/PackageInfo.py b/direct/src/p3d/PackageInfo.py index 3e1767b91f..cceb2164c6 100644 --- a/direct/src/p3d/PackageInfo.py +++ b/direct/src/p3d/PackageInfo.py @@ -1,4 +1,6 @@ -from panda3d.core import Filename, URLSpec, DocumentSpec, Ramfile, Multifile, Decompressor, EUOk, EUSuccess, VirtualFileSystem, Thread, getModelPath, ExecutionEnvironment, PStatCollector, TiXmlDocument, TiXmlDeclaration, TiXmlElement +__all__ = ["PackageInfo"] + +from panda3d.core import Filename, DocumentSpec, Multifile, Decompressor, EUOk, EUSuccess, VirtualFileSystem, Thread, getModelPath, ExecutionEnvironment, PStatCollector, TiXmlDocument, TiXmlDeclaration, TiXmlElement import panda3d.core as core from direct.p3d.FileSpec import FileSpec from direct.p3d.ScanDirectoryNode import ScanDirectoryNode diff --git a/direct/src/p3d/PackageInstaller.py b/direct/src/p3d/PackageInstaller.py index 3f920b8bd3..33527ef94e 100644 --- a/direct/src/p3d/PackageInstaller.py +++ b/direct/src/p3d/PackageInstaller.py @@ -1,3 +1,5 @@ +__all__ = ["PackageInstaller"] + from direct.showbase.DirectObject import DirectObject from direct.stdpy.threading import Lock, RLock from direct.showbase.MessengerGlobal import messenger diff --git a/direct/src/p3d/PackageMerger.py b/direct/src/p3d/PackageMerger.py index e5b90705e3..a00a3f7d35 100644 --- a/direct/src/p3d/PackageMerger.py +++ b/direct/src/p3d/PackageMerger.py @@ -1,8 +1,9 @@ +__all__ = ["PackageMerger", "PackageMergerError"] + from direct.p3d.FileSpec import FileSpec from direct.p3d.SeqValue import SeqValue from direct.directnotify.DirectNotifyGlobal import * from panda3d.core import * -import copy import shutil import os diff --git a/direct/src/p3d/Packager.py b/direct/src/p3d/Packager.py index 9614e96d59..5386bb8d71 100644 --- a/direct/src/p3d/Packager.py +++ b/direct/src/p3d/Packager.py @@ -3,17 +3,17 @@ within a Panda3D Multifile, which can be easily be downloaded and/or patched onto a client machine, for the purpose of running a large application. """ +__all__ = ["Packager", "PackagerError", "OutsideOfPackageError", "ArgumentError"] + # Important to import panda3d first, to avoid naming conflicts with # Python's "string" and "Loader" names that are imported later. from panda3d.core import * import sys import os import glob -import marshal import string import types import getpass -import platform import struct import subprocess from direct.p3d.FileSpec import FileSpec diff --git a/direct/src/p3d/PatchMaker.py b/direct/src/p3d/PatchMaker.py index e8fbf80274..7055f5eb3e 100644 --- a/direct/src/p3d/PatchMaker.py +++ b/direct/src/p3d/PatchMaker.py @@ -1,3 +1,5 @@ +__all__ = ["PatchMaker"] + from direct.p3d.FileSpec import FileSpec from direct.p3d.SeqValue import SeqValue from panda3d.core import * diff --git a/direct/src/p3d/ScanDirectoryNode.py b/direct/src/p3d/ScanDirectoryNode.py index 94f323551e..429b8f0fd2 100644 --- a/direct/src/p3d/ScanDirectoryNode.py +++ b/direct/src/p3d/ScanDirectoryNode.py @@ -1,3 +1,5 @@ +__all__ = ["ScanDirectoryNode"] + from panda3d.core import VirtualFileSystem, VirtualFileMountSystem, Filename, TiXmlDocument vfs = VirtualFileSystem.getGlobalPtr() diff --git a/direct/src/p3d/SeqValue.py b/direct/src/p3d/SeqValue.py index 493098f4e6..6ae527578d 100644 --- a/direct/src/p3d/SeqValue.py +++ b/direct/src/p3d/SeqValue.py @@ -1,3 +1,5 @@ +__all__ = ["SeqValue"] + import types class SeqValue: diff --git a/direct/src/particles/ForceGroup.py b/direct/src/particles/ForceGroup.py index 8c04052232..9cd451f5ec 100644 --- a/direct/src/particles/ForceGroup.py +++ b/direct/src/particles/ForceGroup.py @@ -1,4 +1,5 @@ -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.physics import * from direct.showbase.DirectObject import DirectObject from direct.showbase.PhysicsManagerGlobal import * diff --git a/direct/src/particles/ParticleEffect.py b/direct/src/particles/ParticleEffect.py index 914630f19c..bfd4e0c7c9 100644 --- a/direct/src/particles/ParticleEffect.py +++ b/direct/src/particles/ParticleEffect.py @@ -1,7 +1,11 @@ -from pandac.PandaModules import * -import Particles -import ForceGroup +from panda3d.core import * + +# Leave these imports in, they may be used by ptf files. +from panda3d.physics import * +from . import Particles +from . import ForceGroup + from direct.directnotify import DirectNotifyGlobal class ParticleEffect(NodePath): diff --git a/direct/src/particles/ParticleFloorTest.py b/direct/src/particles/ParticleFloorTest.py index 39126fd080..8bb021eed0 100755 --- a/direct/src/particles/ParticleFloorTest.py +++ b/direct/src/particles/ParticleFloorTest.py @@ -1,5 +1,6 @@ -from pandac.PandaModules import * +from panda3d.core import NodePath +from panda3d.physics import LinearVectorForce from direct.particles import ParticleEffect from direct.particles import Particles from direct.particles import ForceGroup @@ -48,8 +49,8 @@ class ParticleFloorTest(NodePath): if __name__ == "__main__": from direct.directbase.TestStart import * - pt=ParticleFloorTest() + pt = ParticleFloorTest() pt.reparentTo(render) pt.start() - camera.setY(-10.0) - run() + base.camera.setY(-10.0) + base.run() diff --git a/direct/src/particles/Particles.py b/direct/src/particles/Particles.py index 826b004b80..ee82ffc81b 100644 --- a/direct/src/particles/Particles.py +++ b/direct/src/particles/Particles.py @@ -1,7 +1,7 @@ -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.physics import PhysicalNode from panda3d.physics import ParticleSystem -from panda3d.physics import BaseParticleFactory from panda3d.physics import PointParticleFactory from panda3d.physics import ZSpinParticleFactory #from panda3d.physics import OrientedParticleFactory @@ -25,8 +25,6 @@ from panda3d.physics import TangentRingEmitter import SpriteParticleRendererExt -import string -import os from direct.directnotify.DirectNotifyGlobal import directNotify import sys diff --git a/direct/src/showbase/Audio3DManager.py b/direct/src/showbase/Audio3DManager.py index 84c572d815..28dffc4bd7 100644 --- a/direct/src/showbase/Audio3DManager.py +++ b/direct/src/showbase/Audio3DManager.py @@ -2,7 +2,7 @@ __all__ = ['Audio3DManager'] -from pandac.PandaModules import Vec3, VBase3 +from panda3d.core import Vec3, VBase3 from direct.task import Task # class Audio3DManager: diff --git a/direct/src/showbase/ContainerLeakDetector.py b/direct/src/showbase/ContainerLeakDetector.py index bc85db1fda..7180ffe543 100755 --- a/direct/src/showbase/ContainerLeakDetector.py +++ b/direct/src/showbase/ContainerLeakDetector.py @@ -1,6 +1,5 @@ -from pandac.PandaModules import PStatCollector from direct.directnotify.DirectNotifyGlobal import directNotify -from direct.showbase.PythonUtil import Queue, invertDictLossless, makeFlywheelGen +from direct.showbase.PythonUtil import makeFlywheelGen from direct.showbase.PythonUtil import itype, serialNum, safeRepr, fastRepr from direct.showbase.Job import Job import types, weakref, random, __builtin__ diff --git a/direct/src/showbase/ContainerReport.py b/direct/src/showbase/ContainerReport.py index d12f42285f..fb5b1a4de1 100755 --- a/direct/src/showbase/ContainerReport.py +++ b/direct/src/showbase/ContainerReport.py @@ -1,6 +1,6 @@ from direct.directnotify.DirectNotifyGlobal import directNotify -from direct.showbase.PythonUtil import Queue, fastRepr, invertDictLossless -from direct.showbase.PythonUtil import itype, safeRepr +from direct.showbase.PythonUtil import Queue, invertDictLossless +from direct.showbase.PythonUtil import safeRepr from direct.showbase.Job import Job import types diff --git a/direct/src/showbase/DistancePhasedNode.py b/direct/src/showbase/DistancePhasedNode.py index 3f8be4306d..02b3fd7a24 100755 --- a/direct/src/showbase/DistancePhasedNode.py +++ b/direct/src/showbase/DistancePhasedNode.py @@ -1,6 +1,5 @@ from direct.showbase.DirectObject import DirectObject -from direct.directnotify import DirectNotifyGlobal -from pandac.PandaModules import * +from panda3d.core import * from PhasedObject import PhasedObject class DistancePhasedNode(PhasedObject, DirectObject, NodePath): diff --git a/direct/src/showbase/ExcelHandler.py b/direct/src/showbase/ExcelHandler.py index d1c6a89d92..01f932b1de 100755 --- a/direct/src/showbase/ExcelHandler.py +++ b/direct/src/showbase/ExcelHandler.py @@ -13,7 +13,6 @@ print e.tables """ from xml.sax import saxutils -from xml.sax import parse class ExcelHandler(saxutils.DefaultHandler): def __init__(self): diff --git a/direct/src/showbase/Finder.py b/direct/src/showbase/Finder.py index f209ef9b14..4c81b64b99 100644 --- a/direct/src/showbase/Finder.py +++ b/direct/src/showbase/Finder.py @@ -2,7 +2,6 @@ __all__ = ['findClass', 'rebindClass', 'copyFuncs', 'replaceMessengerFunc', 'replaceTaskMgrFunc', 'replaceStateFunc', 'replaceCRFunc', 'replaceAIRFunc', 'replaceIvalFunc'] -import time import types import os import sys diff --git a/direct/src/showbase/GarbageReport.py b/direct/src/showbase/GarbageReport.py index 6d6eacea0d..c04fb42367 100755 --- a/direct/src/showbase/GarbageReport.py +++ b/direct/src/showbase/GarbageReport.py @@ -3,7 +3,7 @@ __all__ = ['FakeObject', '_createGarbage', 'GarbageReport', 'GarbageLogger'] from direct.directnotify.DirectNotifyGlobal import directNotify -from direct.showbase.PythonUtil import safeRepr, fastRepr, printListEnumGen, printNumberedTypesGen +from direct.showbase.PythonUtil import fastRepr from direct.showbase.PythonUtil import AlphabetCounter from direct.showbase.Job import Job import gc diff --git a/direct/src/showbase/LazySort.py b/direct/src/showbase/LazySort.py index 90f33559a1..85ac166c00 100755 --- a/direct/src/showbase/LazySort.py +++ b/direct/src/showbase/LazySort.py @@ -109,7 +109,6 @@ if __debug__: print x def test(): - import random from itertools import islice control = sorted(data, key = lambda x: x[0]) diff --git a/direct/src/showbase/Messenger.py b/direct/src/showbase/Messenger.py index 3d901d219d..aba83d7d3a 100644 --- a/direct/src/showbase/Messenger.py +++ b/direct/src/showbase/Messenger.py @@ -7,7 +7,6 @@ from PythonUtil import * from direct.directnotify import DirectNotifyGlobal import types -from panda3d.core import ConfigVariableBool, Thread, Mutex from direct.stdpy.threading import Lock class Messenger: diff --git a/direct/src/showbase/ObjectPool.py b/direct/src/showbase/ObjectPool.py index acfd99696c..80109226ce 100755 --- a/direct/src/showbase/ObjectPool.py +++ b/direct/src/showbase/ObjectPool.py @@ -6,7 +6,6 @@ from direct.directnotify.DirectNotifyGlobal import directNotify from direct.showbase.PythonUtil import invertDictLossless, makeList, safeRepr from direct.showbase.PythonUtil import getNumberedTypedString, getNumberedTypedSortedString from direct.showbase.PythonUtil import getNumberedTypedSortedStringWithReferrersGen -import types import gc class Diff: diff --git a/direct/src/showbase/OnScreenDebug.py b/direct/src/showbase/OnScreenDebug.py index e193996cea..addd59f3ad 100755 --- a/direct/src/showbase/OnScreenDebug.py +++ b/direct/src/showbase/OnScreenDebug.py @@ -2,9 +2,7 @@ __all__ = ['OnScreenDebug'] - - -from pandac.PandaModules import * +from panda3d.core import * import types from direct.gui import OnscreenText diff --git a/direct/src/showbase/ProfileSession.py b/direct/src/showbase/ProfileSession.py index c2cd4f7b67..828272be8c 100755 --- a/direct/src/showbase/ProfileSession.py +++ b/direct/src/showbase/ProfileSession.py @@ -2,13 +2,10 @@ from panda3d.core import TrueClock from direct.directnotify.DirectNotifyGlobal import directNotify from direct.showbase.PythonUtil import ( StdoutCapture, _installProfileCustomFuncs,_removeProfileCustomFuncs, - _profileWithoutGarbageLeak, _getProfileResultFileInfo, _setProfileResultsFileInfo, - _clearProfileResultFileInfo, ) + _getProfileResultFileInfo, _setProfileResultsFileInfo) import __builtin__ import profile import pstats -from StringIO import StringIO -import marshal class PercentStats(pstats.Stats): # prints more useful output when sampled durations are shorter than a millisecond diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 7f335e7a94..8b8d59394d 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -35,7 +35,6 @@ __all__ = ['indent', import types import string -import re import math import operator import inspect @@ -49,12 +48,9 @@ import traceback import __builtin__ from StringIO import StringIO import marshal -import unicodedata -import bisect __report_indent = 3 -from direct.directutil import Verify from panda3d.core import ConfigVariableBool ScalarTypes = (types.FloatType, types.IntType, types.LongType) diff --git a/direct/src/showbase/RandomNumGen.py b/direct/src/showbase/RandomNumGen.py index 685fffa8fa..0b6df19d2b 100644 --- a/direct/src/showbase/RandomNumGen.py +++ b/direct/src/showbase/RandomNumGen.py @@ -3,7 +3,7 @@ __all__ = ['randHash', 'RandomNumGen'] from direct.directnotify import DirectNotifyGlobal -from pandac.PandaModules import Mersenne +from panda3d.core import Mersenne def randHash(num): """ this returns a random 16-bit integer, given a seed integer. diff --git a/direct/src/showbase/SfxPlayer.py b/direct/src/showbase/SfxPlayer.py index 9579ada442..496481e6a4 100644 --- a/direct/src/showbase/SfxPlayer.py +++ b/direct/src/showbase/SfxPlayer.py @@ -2,9 +2,8 @@ __all__ = ['SfxPlayer'] - import math -from pandac.PandaModules import * +from panda3d.core import * class SfxPlayer: """ diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 35b60ce271..2ab17b9ae4 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -24,18 +24,14 @@ from PythonUtil import * from direct.showbase import PythonUtil #from direct.interval.IntervalManager import ivalMgr from direct.interval import IntervalManager -from InputStateGlobal import inputState from direct.showbase.BufferViewer import BufferViewer from direct.task import Task from direct.directutil import Verify from direct.showbase import GarbageReport -import math,sys,os +import sys import Loader import time -import gc import atexit -from direct.fsm import ClassicFSM -from direct.fsm import State from direct.showbase import ExceptionVarDump import DirectObject import SfxPlayer @@ -61,15 +57,16 @@ def exitfunc(): # *seem* to cause anyone any problems. class ShowBase(DirectObject.DirectObject): + config = get_config_showbase() notify = directNotify.newCategory("ShowBase") def __init__(self, fStartDirect = True, windowType = None): - self.__dev__ = config.GetBool('want-dev', __debug__) + self.__dev__ = self.config.GetBool('want-dev', __debug__) builtins.__dev__ = self.__dev__ - logStackDump = (config.GetBool('log-stack-dump', False) or - config.GetBool('client-log-stack-dump', False)) - uploadStackDump = config.GetBool('upload-stack-dump', False) + logStackDump = (self.config.GetBool('log-stack-dump', False) or + self.config.GetBool('client-log-stack-dump', False)) + uploadStackDump = self.config.GetBool('upload-stack-dump', False) if logStackDump or uploadStackDump: ExceptionVarDump.install(logStackDump, uploadStackDump) @@ -84,8 +81,6 @@ class ShowBase(DirectObject.DirectObject): #debug running multiplier self.debugRunningMultiplier = 4 - # Get the dconfig object - self.config = config # Setup wantVerifyPdb as soon as reasonable: Verify.wantVerifyPdb = self.config.GetBool('want-verify-pdb', 0) @@ -367,7 +362,7 @@ class ShowBase(DirectObject.DirectObject): builtins.cpMgr = ConfigPageManager.getGlobalPtr() builtins.cvMgr = ConfigVariableManager.getGlobalPtr() builtins.pandaSystem = PandaSystem.getGlobalPtr() - builtins.wantUberdog = base.config.GetBool('want-uberdog', 1) + builtins.wantUberdog = self.config.GetBool('want-uberdog', 1) if __debug__: builtins.deltaProfiler = DeltaProfiler.DeltaProfiler("ShowBase") builtins.onScreenDebug = OnScreenDebug.OnScreenDebug() @@ -419,7 +414,7 @@ class ShowBase(DirectObject.DirectObject): # adds a sleep right after the main render in igloop # tends to even out the frame rate and keeps it from going # to zero in the out of focus windows - if base.config.GetBool('multi-sleep', 0): + if self.config.GetBool('multi-sleep', 0): self.multiClientSleep = 1 else: self.multiClientSleep = 0 @@ -464,8 +459,8 @@ class ShowBase(DirectObject.DirectObject): profile.Profile.bias = float(self.config.GetString("profile-bias","0")) def f8(x): - return ("%"+"8.%df"%base.config.GetInt("profile-decimals",3)) % x - pstats.f8=f8 + return ("%" + "8.%df" % self.config.GetInt("profile-decimals", 3)) % x + pstats.f8 = f8 # temp; see ToonBase.py def getExitErrorCode(self): @@ -807,7 +802,7 @@ class ShowBase(DirectObject.DirectObject): # Set up a 3-d camera for the window by default. if keepCamera: self.makeCamera(win, scene = scene, aspectRatio = aspectRatio, - stereo = stereo, useCamera = base.cam) + stereo = stereo, useCamera = self.cam) elif makeCamera: self.makeCamera(win, scene = scene, aspectRatio = aspectRatio, stereo = stereo) @@ -832,10 +827,10 @@ class ShowBase(DirectObject.DirectObject): for i in range(numRegions): dr = win.getDisplayRegion(i) # [gjeon] remove drc in base.direct.drList - if base.direct is not None: - for drc in base.direct.drList: + if self.direct is not None: + for drc in self.direct.drList: if drc.cam == dr.getCamera(): - base.direct.drList.displayRegionList.remove(drc) + self.direct.drList.displayRegionList.remove(drc) break cam = NodePath(dr.getCamera()) @@ -888,7 +883,7 @@ class ShowBase(DirectObject.DirectObject): if not self.winList: # Give the window(s) a chance to actually close before we # continue. - base.graphicsEngine.renderFrame() + self.graphicsEngine.renderFrame() def openDefaultWindow(self, *args, **kw): # Creates the main window for the first time, without being @@ -2121,7 +2116,7 @@ class ShowBase(DirectObject.DirectObject): """ if self.__deadInputs: self.eventMgr.doEvents() - self.dgTrav.traverse(base.dataRootNode) + self.dgTrav.traverse(self.dataRootNode) self.eventMgr.eventQueue.clear() self.taskMgr.add(self.__dataLoop, 'dataLoop', sort = -50) self.__deadInputs = 0 @@ -2182,15 +2177,15 @@ class ShowBase(DirectObject.DirectObject): # Clean up the old mode. self.showVertices.node().setActive(0) dr = self.showVertices.node().getDisplayRegion(0) - base.win.removeDisplayRegion(dr) + self.win.removeDisplayRegion(dr) self.showVertices.removeNode() self.showVertices = None return - dr = base.win.makeDisplayRegion() + dr = self.win.makeDisplayRegion() dr.setSort(1000) cam = Camera('showVertices') - cam.setLens(base.camLens) + cam.setLens(self.camLens) # Set up a funny state to render only vertices. override = 100000 @@ -2381,7 +2376,7 @@ class ShowBase(DirectObject.DirectObject): # Tell the camera to cull from here instead of its own # origin. - for c in base.camList: + for c in self.camList: c.node().setCullCenter(self.oobeCullFrustum) if cam.node().isOfType(Camera): cam.node().setCullCenter(self.oobeCullFrustum) @@ -2390,7 +2385,7 @@ class ShowBase(DirectObject.DirectObject): else: # Disable OOBE culling. - for c in base.camList: + for c in self.camList: c.node().setCullCenter(NodePath()) if cam.node().isOfType(Camera): cam.node().setCullCenter(self.oobeCullFrustum) @@ -2466,7 +2461,8 @@ class ShowBase(DirectObject.DirectObject): def saveCubeMap(self, namePrefix = 'cube_map_#.png', defaultFilename = 0, source = None, camera = None, size = 128, - cameraMask = PandaNode.getAllCameraMask()): + cameraMask = PandaNode.getAllCameraMask(), + sourceLens = None): """ Similar to screenshot(), this sets up a temporary cube map @@ -2486,13 +2482,16 @@ class ShowBase(DirectObject.DirectObject): """ if source == None: - source = base.win + source = self.win if camera == None: if hasattr(source, "getCamera"): camera = source.getCamera() if camera == None: - camera = base.camera + camera = self.camera + + if sourceLens == None: + sourceLens = self.camLens if hasattr(source, "getWindow"): source = source.getWindow() @@ -2504,19 +2503,20 @@ class ShowBase(DirectObject.DirectObject): # Set the near and far planes from the default lens. lens = rig.find('**/+Camera').node().getLens() - lens.setNearFar(base.camLens.getNear(), base.camLens.getFar()) + + lens.setNearFar(sourceLens.getNear(), sourceLens.getFar()) # Now render a frame to fill up the texture. rig.reparentTo(camera) - base.graphicsEngine.openWindows() - base.graphicsEngine.renderFrame() + self.graphicsEngine.openWindows() + self.graphicsEngine.renderFrame() tex = buffer.getTexture() saved = self.screenshot(namePrefix = namePrefix, defaultFilename = defaultFilename, source = tex) - base.graphicsEngine.removeWindow(buffer) + self.graphicsEngine.removeWindow(buffer) rig.removeNode() return saved @@ -2525,7 +2525,7 @@ class ShowBase(DirectObject.DirectObject): defaultFilename = 0, source = None, camera = None, size = 256, cameraMask = PandaNode.getAllCameraMask(), - numVertices = 1000): + numVertices = 1000, sourceLens = None): """ This works much like saveCubeMap(), and uses the graphics API's hardware cube-mapping ability to get a 360-degree view @@ -2542,13 +2542,16 @@ class ShowBase(DirectObject.DirectObject): there is a problem. """ if source == None: - source = base.win + source = self.win if camera == None: if hasattr(source, "getCamera"): camera = source.getCamera() if camera == None: - camera = base.camera + camera = self.camera + + if sourceLens == None: + sourceLens = self.camLens if hasattr(source, "getWindow"): source = source.getWindow() @@ -2563,12 +2566,12 @@ class ShowBase(DirectObject.DirectObject): rig = NodePath(namePrefix) buffer = toSphere.makeCubeMap(namePrefix, size, rig, cameraMask, 0) if buffer == None: - base.graphicsEngine.removeWindow(toSphere) + self.graphicsEngine.removeWindow(toSphere) raise StandardError, "Could not make cube map." # Set the near and far planes from the default lens. lens = rig.find('**/+Camera').node().getLens() - lens.setNearFar(base.camLens.getNear(), base.camLens.getFar()) + lens.setNearFar(sourceLens.getNear(), sourceLens.getFar()) # Set up the scene to convert the cube map. It's just a # simple scene, with only the FisheyeMaker object in it. @@ -2592,18 +2595,18 @@ class ShowBase(DirectObject.DirectObject): # Now render a frame. This will render out the cube map and # then apply it to the the card in the toSphere buffer. rig.reparentTo(camera) - base.graphicsEngine.openWindows() - base.graphicsEngine.renderFrame() + self.graphicsEngine.openWindows() + self.graphicsEngine.renderFrame() # One more frame for luck. - base.graphicsEngine.renderFrame() + self.graphicsEngine.renderFrame() saved = self.screenshot(namePrefix = namePrefix, defaultFilename = defaultFilename, source = toSphere.getTexture()) - base.graphicsEngine.removeWindow(buffer) - base.graphicsEngine.removeWindow(toSphere) + self.graphicsEngine.removeWindow(buffer) + self.graphicsEngine.removeWindow(toSphere) rig.removeNode() return saved @@ -2824,11 +2827,11 @@ class ShowBase(DirectObject.DirectObject): def wxLoop(task): # First we need to ensure that the OS message queue is # processed. - base.wxApp.Yield() + self.wxApp.Yield() # Now do all the wxPython events waiting on this frame. - while base.wxApp.Pending(): - base.wxApp.Dispatch() + while self.wxApp.Pending(): + self.wxApp.Dispatch() return task.again @@ -2935,8 +2938,10 @@ class ShowBase(DirectObject.DirectObject): self.startWx(fWantWx) self.wantDirect = fWantDirect if self.wantDirect: - from direct.directtools import DirectSession - base.direct.enable() + from direct.directtools.DirectSession import DirectSession + self.direct = DirectSession() + self.direct.enable() + builtins.direct = self.direct else: builtins.direct = self.direct = None diff --git a/direct/src/showbase/Transitions.py b/direct/src/showbase/Transitions.py index ca4919a48f..86f5ee70fd 100644 --- a/direct/src/showbase/Transitions.py +++ b/direct/src/showbase/Transitions.py @@ -2,10 +2,8 @@ __all__ = ['Transitions'] - -from pandac.PandaModules import * +from panda3d.core import * from direct.gui.DirectGui import * -from direct.task import Task from direct.interval.LerpInterval import LerpColorScaleInterval, LerpColorInterval, LerpScaleInterval, LerpPosInterval from direct.interval.MetaInterval import Sequence, Parallel from direct.interval.FunctionInterval import Func diff --git a/direct/src/showbase/pandaSqueezeTool.py b/direct/src/showbase/pandaSqueezeTool.py index 0899689926..fd87135930 100755 --- a/direct/src/showbase/pandaSqueezeTool.py +++ b/direct/src/showbase/pandaSqueezeTool.py @@ -52,7 +52,7 @@ __all__ = ['usage', 'Squeezer', 'Loader', 'boot', 'open', 'explode', 'getloader' VERSION = "1.6/98-05-04" MAGIC = "[PANDASQUEEZE]" -import base64, imp, marshal, os, string, sys, md5 +import base64, imp, marshal, os, string, sys # -------------------------------------------------------------------- # usage @@ -246,7 +246,7 @@ def getloader(data, package): # # parse options -import getopt, glob, sys +import sys import zlib embed = 0 @@ -340,23 +340,23 @@ exec "import %(start)s" #%(localMagic)s %(archiveid)s import ihooks, zlib, marshal, os, sys -import pandac - def searchPath(filename): - # Look along pandac.__path__ for the indicated filename. Returns + # Look along panda3d.__path__ for the indicated filename. Returns # the located pathname, or None if the filename is not found. - for dir in pandac.__path__: + import panda3d + + for dir in panda3d.__path__: pathname = os.path.join(dir, filename) if os.path.exists(pathname): return pathname return None -# Look for %(archiveBase)s along pandac.__path__. +# Look for %(archiveBase)s along panda3d.__path__. archiveName = "%(archiveBase)s" archivePath = searchPath(archiveName) if archivePath == None: - raise ImportError, "Could not locate pandac.%%s." %% (archiveName) + raise ImportError, "Could not locate panda3d.%%s." %% (archiveName) f=open(archivePath,"rb") exec marshal.loads(%(zbegin)sf.read(%(loaderlen)d)%(zend)s) diff --git a/direct/src/showbase/showBase.h b/direct/src/showbase/showBase.h index 8b9c24f40a..5ffea8cbee 100644 --- a/direct/src/showbase/showBase.h +++ b/direct/src/showbase/showBase.h @@ -52,13 +52,12 @@ EXPCL_DIRECT void store_accessibility_shortcut_keys(); EXPCL_DIRECT void allow_accessibility_shortcut_keys(bool allowKeys); #ifdef IS_OSX -void activate_osx_application(); +EXPCL_DIRECT void activate_osx_application(); #endif END_PUBLISH - #if 0 class TempGridZoneManager { PUBLISHED: diff --git a/direct/src/showutil/BuildGeometry.py b/direct/src/showutil/BuildGeometry.py index 5dfec621e2..7a7ff73b49 100644 --- a/direct/src/showutil/BuildGeometry.py +++ b/direct/src/showutil/BuildGeometry.py @@ -1,8 +1,5 @@ -from direct.distributed import DistributedObject -from direct.directnotify import DirectNotifyGlobal -from pandac.PandaModules import * +from panda3d.core import * from math import * -import math GEO_ID = 0 @@ -385,4 +382,4 @@ def addArrowGeom(rootNode, sizeX, sizeY, color = Vec4(1.0, 1.0, 1.0, 1.0), layer GEO_ID += 1 NodePathGeom = rootNode.attachNewNode(GN) geo = addArrow(GN, sizeX, sizeY, color, layer) - return NodePathGeom, GN, geo \ No newline at end of file + return NodePathGeom, GN, geo diff --git a/direct/src/showutil/Effects.py b/direct/src/showutil/Effects.py index f2847d188d..19f9b40515 100644 --- a/direct/src/showutil/Effects.py +++ b/direct/src/showutil/Effects.py @@ -1,6 +1,6 @@ """ Showutil Effects module: contains code for useful showcode effects. """ -from pandac.PandaModules import * +from panda3d.core import * from direct.interval.IntervalGlobal import * # bounce types diff --git a/direct/src/showutil/FreezeTool.py b/direct/src/showutil/FreezeTool.py index 28c622a9be..df845b0c26 100644 --- a/direct/src/showutil/FreezeTool.py +++ b/direct/src/showutil/FreezeTool.py @@ -16,7 +16,6 @@ try: except ImportError: p3extend_frozen = None -import direct from panda3d.core import * from pandac.extension_native_helpers import dll_suffix, dll_ext diff --git a/direct/src/showutil/Rope.py b/direct/src/showutil/Rope.py index 9f4a3b1c90..5bbda785ed 100644 --- a/direct/src/showutil/Rope.py +++ b/direct/src/showutil/Rope.py @@ -1,4 +1,4 @@ -from pandac.PandaModules import * +from panda3d.core import * import types class Rope(NodePath): diff --git a/direct/src/showutil/TexMemWatcher.py b/direct/src/showutil/TexMemWatcher.py index 5368b49e2e..5de8ecb138 100644 --- a/direct/src/showutil/TexMemWatcher.py +++ b/direct/src/showutil/TexMemWatcher.py @@ -1,4 +1,4 @@ -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.DirectObject import DirectObject import math import copy diff --git a/direct/src/showutil/TexViewer.py b/direct/src/showutil/TexViewer.py index c645ca6403..7d325afdfc 100644 --- a/direct/src/showutil/TexViewer.py +++ b/direct/src/showutil/TexViewer.py @@ -1,4 +1,4 @@ -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.DirectObject import DirectObject class TexViewer(DirectObject): diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index f75ebca9ce..5374c135d2 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -10,11 +10,13 @@ from direct.directnotify.DirectNotifyGlobal import * from direct.showbase import ExceptionVarDump from direct.showbase.PythonUtil import * from direct.showbase.MessengerGlobal import messenger -import signal import types -import time import random -import string + +try: + import signal +except ImportError: + signal = None from panda3d.core import * @@ -149,7 +151,8 @@ class TaskManager: def invokeDefaultHandler(self, signalNumber, stackFrame): print '*** allowing mid-frame keyboard interrupt.' # Restore default interrupt handler - signal.signal(signal.SIGINT, signal.default_int_handler) + if signal: + signal.signal(signal.SIGINT, signal.default_int_handler) # and invoke it raise KeyboardInterrupt @@ -454,7 +457,8 @@ class TaskManager: # after task list processing is complete. self.fKeyboardInterrupt = 0 self.interruptCount = 0 - signal.signal(signal.SIGINT, self.keyboardInterruptHandler) + if signal: + signal.signal(signal.SIGINT, self.keyboardInterruptHandler) startFrameTime = self.globalClock.getRealTime() @@ -465,7 +469,8 @@ class TaskManager: self.doYield(startFrameTime, nextTaskTime) # Restore default interrupt handler - signal.signal(signal.SIGINT, signal.default_int_handler) + if signal: + signal.signal(signal.SIGINT, signal.default_int_handler) if self.fKeyboardInterrupt: raise KeyboardInterrupt diff --git a/direct/src/task/Timer.py b/direct/src/task/Timer.py index ddb188a24a..7474deb652 100644 --- a/direct/src/task/Timer.py +++ b/direct/src/task/Timer.py @@ -2,7 +2,6 @@ __all__ = ['Timer'] -from pandac.PandaModules import * import Task class Timer: diff --git a/direct/src/tkpanels/AnimPanel.py b/direct/src/tkpanels/AnimPanel.py index adb7a0f89b..e68f52fced 100644 --- a/direct/src/tkpanels/AnimPanel.py +++ b/direct/src/tkpanels/AnimPanel.py @@ -11,7 +11,7 @@ from direct.tkwidgets.AppShell import * from direct.showbase.TkGlobal import * from tkSimpleDialog import askfloat from Tkinter import * -import Pmw, string, math, types +import Pmw, string, types from direct.task import Task FRAMES = 0 diff --git a/direct/src/tkpanels/DirectSessionPanel.py b/direct/src/tkpanels/DirectSessionPanel.py index e10c0d91bb..a197cd385f 100644 --- a/direct/src/tkpanels/DirectSessionPanel.py +++ b/direct/src/tkpanels/DirectSessionPanel.py @@ -6,7 +6,7 @@ __all__ = ['DirectSessionPanel'] from direct.showbase.TkGlobal import * from direct.tkwidgets.AppShell import * from Tkinter import * -from pandac.PandaModules import * +from panda3d.core import * import Pmw, string from direct.tkwidgets import Dial from direct.tkwidgets import Floater @@ -724,7 +724,7 @@ class DirectSessionPanel(AppShell): dictName = name else: # Generate a unique name for the dict - dictName = name + '-' + repr(nodePath.id()) + dictName = name + '-' + repr(hash(nodePath)) if dictName not in dict: # Update combo box to include new item names.append(dictName) diff --git a/direct/src/tkpanels/Inspector.py b/direct/src/tkpanels/Inspector.py index ed0e3989cd..2ffa1a5249 100644 --- a/direct/src/tkpanels/Inspector.py +++ b/direct/src/tkpanels/Inspector.py @@ -7,7 +7,6 @@ so that I can just type: inspect(anObject) any time.""" __all__ = ['inspect', 'inspectorFor', 'Inspector', 'ModuleInspector', 'ClassInspector', 'InstanceInspector', 'FunctionInspector', 'InstanceMethodInspector', 'CodeInspector', 'ComplexInspector', 'DictionaryInspector', 'SequenceInspector', 'SliceInspector', 'InspectorWindow'] -import string from direct.showbase.TkGlobal import * from Tkinter import * import Pmw @@ -23,11 +22,11 @@ def inspect(anObject): ### private def inspectorFor(anObject): - typeName = string.capitalize(type(anObject).__name__) + 'Type' + typeName = type(anObject).__name__.capitalize() + 'Type' if typeName in _InspectorMap: inspectorName = _InspectorMap[typeName] else: - print "Can't find an inspector for " + typeName + print("Can't find an inspector for " + typeName) inspectorName = 'Inspector' inspector = globals()[inspectorName](anObject) return inspector @@ -96,7 +95,7 @@ class Inspector: def title(self): "Subclasses may override." - return string.capitalize(self.objectType().__name__) + return self.objectType().__name__.capitalize() def getLastPartNumber(self): return self.lastPartNumber @@ -406,14 +405,14 @@ class InspectorWindow: return self.topInspector().inspectorFor(part) def popupMenu(self, event): - print event + print(event) partNumber = self.selectedIndex() - print partNumber + print(partNumber) if partNumber == None: return part = self.topInspector().partNumber(partNumber) - print part - from pandac.PandaModules import NodePath + print(part) + from panda3d.core import NodePath from direct.fsm import ClassicFSM popupMenu = None if isinstance(part, NodePath): @@ -427,7 +426,7 @@ class InspectorWindow: popupMenu = self.createPopupMenu( part, [('Inspect ClassicFSM', FSMInspector.FSMInspector)]) - print popupMenu + print(popupMenu) if popupMenu: popupMenu.post(event.widget.winfo_pointerx(), event.widget.winfo_pointery()) diff --git a/direct/src/tkpanels/MopathRecorder.py b/direct/src/tkpanels/MopathRecorder.py index 929c166315..3e7bc3e0c5 100644 --- a/direct/src/tkpanels/MopathRecorder.py +++ b/direct/src/tkpanels/MopathRecorder.py @@ -3,7 +3,7 @@ __all__ = ['MopathRecorder'] # Import Tkinter, Pmw, and the dial code from this directory tree. -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.DirectObject import DirectObject from direct.showbase.TkGlobal import * from direct.tkwidgets.AppShell import * diff --git a/direct/src/tkpanels/NotifyPanel.py b/direct/src/tkpanels/NotifyPanel.py index b6156b31fe..76d139daad 100644 --- a/direct/src/tkpanels/NotifyPanel.py +++ b/direct/src/tkpanels/NotifyPanel.py @@ -16,8 +16,7 @@ class NotifyPanel: from direct.showbase.TkGlobal import Pmw, Toplevel, Frame, Label, Radiobutton from direct.showbase.TkGlobal import HORIZONTAL, X, W, NW, BOTH, LEFT, RIGHT, IntVar # To get severity levels - from pandac.PandaModules import NSFatal, NSError, NSWarning, NSInfo - from pandac.PandaModules import NSDebug, NSSpam + from panda3d.core import NSFatal, NSError, NSWarning, NSInfo, NSDebug, NSSpam if tl == None: tl = Toplevel() @@ -125,7 +124,7 @@ class NotifyPanel: return categories def getPandaCategories(self): - from pandac.PandaModules import Notify + from panda3d.core import Notify topCategory = Notify.ptr().getTopCategory() return self._getPandaCategories(topCategory) diff --git a/direct/src/tkpanels/ParticlePanel.py b/direct/src/tkpanels/ParticlePanel.py index 2d89609903..ccc622bdc6 100644 --- a/direct/src/tkpanels/ParticlePanel.py +++ b/direct/src/tkpanels/ParticlePanel.py @@ -17,7 +17,8 @@ from direct.particles import ParticleEffect from Tkinter import * import Pmw, os,Placer -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.physics import * class ParticlePanel(AppShell): # Override class variables @@ -2778,7 +2779,8 @@ if __name__ == '__main__': try: base except: - from direct.directbase import DirectStart + from direct.showbase.ShowBase import ShowBase + base = ShowBase() root = Pmw.initialise() pp = ParticlePanel() diff --git a/direct/src/tkpanels/Placer.py b/direct/src/tkpanels/Placer.py index e762725bd5..9b52343bf7 100644 --- a/direct/src/tkpanels/Placer.py +++ b/direct/src/tkpanels/Placer.py @@ -3,7 +3,7 @@ __all__ = ['Placer', 'place'] # Import Tkinter, Pmw, and the dial code from this directory tree. -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.TkGlobal import * from direct.tkwidgets.AppShell import * from direct.tkwidgets import Dial @@ -429,7 +429,7 @@ class Placer(AppShell): background = self.nodePathMenuBG) # Check to see if node path and ref node path are the same if ((self.refCS != None) and - (self.refCS.id() == self['nodePath'].id())): + (self.refCS == self['nodePath'])): # Yes they are, use temp CS as ref # This calls updatePlacer self.setReferenceNodePath(self.tempCS) @@ -474,7 +474,7 @@ class Placer(AppShell): listbox = self.refNodePathMenu.component('scrolledlist') listbox.setlist(self.refNodePathNames) # Check to see if node path and ref node path are the same - if (nodePath != None) and (nodePath.id() == self['nodePath'].id()): + if (nodePath != None) and (nodePath == self['nodePath']): # Yes they are, use temp CS and update listbox accordingly nodePath = self.tempCS self.refNodePathMenu.selectitem('parent') @@ -509,7 +509,7 @@ class Placer(AppShell): dictName = name else: # Generate a unique name for the dict - dictName = name + '-' + repr(nodePath.id()) + dictName = name + '-' + repr(hash(nodePath)) if dictName not in dict: # Update combo box to include new item names.append(dictName) diff --git a/direct/src/tkwidgets/AppShell.py b/direct/src/tkwidgets/AppShell.py index 3f024c58e5..67a7e6b794 100644 --- a/direct/src/tkwidgets/AppShell.py +++ b/direct/src/tkwidgets/AppShell.py @@ -17,7 +17,6 @@ import Floater import Slider import EntryScale import VectorWidgets -import sys, string import ProgressBar """ diff --git a/direct/src/tkwidgets/Dial.py b/direct/src/tkwidgets/Dial.py index f4216ce844..13a3cc8472 100644 --- a/direct/src/tkwidgets/Dial.py +++ b/direct/src/tkwidgets/Dial.py @@ -10,7 +10,6 @@ from Tkinter import * from Valuator import Valuator, VALUATOR_MINI, VALUATOR_FULL from direct.task import Task import math, string, operator, Pmw -from pandac.PandaModules import ClockObject TWO_PI = 2.0 * math.pi ONEPOINTFIVE_PI = 1.5 * math.pi diff --git a/direct/src/tkwidgets/EntryScale.py b/direct/src/tkwidgets/EntryScale.py index f79afe00aa..e4c8a96a60 100644 --- a/direct/src/tkwidgets/EntryScale.py +++ b/direct/src/tkwidgets/EntryScale.py @@ -4,7 +4,6 @@ EntryScale Class: Scale with a label, and a linked and validated entry __all__ = ['EntryScale', 'EntryScaleGroup'] -from direct.showbase.DirectObject import DirectObject from direct.showbase.TkGlobal import * from Tkinter import * import string, Pmw diff --git a/direct/src/tkwidgets/Floater.py b/direct/src/tkwidgets/Floater.py index 799d6c7b8e..655b7728be 100644 --- a/direct/src/tkwidgets/Floater.py +++ b/direct/src/tkwidgets/Floater.py @@ -9,7 +9,7 @@ from direct.showbase.TkGlobal import * from Tkinter import * from Valuator import Valuator, VALUATOR_MINI, VALUATOR_FULL from direct.task import Task -import math, sys, string, Pmw +import math, Pmw FLOATER_WIDTH = 22 FLOATER_HEIGHT = 18 diff --git a/direct/src/tkwidgets/SceneGraphExplorer.py b/direct/src/tkwidgets/SceneGraphExplorer.py index 9faf76e5e0..f07b24b496 100644 --- a/direct/src/tkwidgets/SceneGraphExplorer.py +++ b/direct/src/tkwidgets/SceneGraphExplorer.py @@ -155,7 +155,7 @@ class SceneGraphExplorerItem(TreeItem): return type + " " + name def GetKey(self): - return self.nodePath.id() + return hash(self.nodePath) def IsEditable(self): # All nodes' names can be edited nowadays. diff --git a/direct/src/tkwidgets/Slider.py b/direct/src/tkwidgets/Slider.py index 2a28107d8d..f2d9bb1246 100644 --- a/direct/src/tkwidgets/Slider.py +++ b/direct/src/tkwidgets/Slider.py @@ -8,10 +8,8 @@ __all__ = ['Slider', 'SliderWidget', 'rgbPanel'] from direct.showbase.TkGlobal import * from Tkinter import * from Valuator import Valuator, rgbPanel, VALUATOR_MINI, VALUATOR_FULL -from direct.task import Task -import math, sys, string -import operator, Pmw -from pandac.PandaModules import ClockObject +import string +import Pmw class Slider(Valuator): """ diff --git a/direct/src/tkwidgets/Tree.py b/direct/src/tkwidgets/Tree.py index b8c8100940..45857934b8 100644 --- a/direct/src/tkwidgets/Tree.py +++ b/direct/src/tkwidgets/Tree.py @@ -20,12 +20,9 @@ __all__ = ['TreeNode', 'TreeItem'] # - optimize tree redraw after expand of subnode import os -import sys -import string from direct.showbase.TkGlobal import * from Tkinter import * -import Pmw -from pandac.PandaModules import * +from panda3d.core import * # Initialize icon directory ICONDIR = ConfigVariableSearchPath('model-path').findFile(Filename('icons')).toOsSpecific() diff --git a/direct/src/wxwidgets/ViewPort.py b/direct/src/wxwidgets/ViewPort.py index 494c3ab845..2fd21a7a41 100755 --- a/direct/src/wxwidgets/ViewPort.py +++ b/direct/src/wxwidgets/ViewPort.py @@ -13,7 +13,7 @@ from direct.directtools.DirectGrid import DirectGrid from direct.showbase.ShowBase import WindowControls from direct.directtools.DirectGlobals import * from WxPandaWindow import WxPandaWindow -from pandac.PandaModules import WindowProperties, OrthographicLens, Point3, Plane, CollisionPlane, CollisionNode, NodePath +from panda3d.core import OrthographicLens, Point3, Plane, CollisionPlane, CollisionNode, NodePath import wx HORIZONTAL = wx.SPLIT_HORIZONTAL diff --git a/direct/src/wxwidgets/WxPandaShell.py b/direct/src/wxwidgets/WxPandaShell.py index 00b2483276..76420489c7 100755 --- a/direct/src/wxwidgets/WxPandaShell.py +++ b/direct/src/wxwidgets/WxPandaShell.py @@ -1,8 +1,7 @@ import wx -import os from wx.lib.agw import fourwaysplitter as FWS -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.ShowBase import * from direct.directtools.DirectGlobals import * diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 64513c39d3..3bb5d7f829 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -1,3 +1,34 @@ +------------------------ RELEASE 1.9.1 ------------------------ + +This minor release fixes some important regressions and bugs found +in 1.9.0, but also introduces a few minor features. + +It also reintroduces the deployment pipeline that was absent from +the previous release. + +* Textures were not being scaled to power-of-2 in some cases +* Fix various issues with shader inputs +* Bullet step function accidentally defaulted to step size of 0 +* Use model-path for finding libRocket assets +* Fix inconsistent behavior with non-power-of-2 textures in rocket +* Fix regression with memoryviews +* Fix symbol error when loading libp3ffmpeg on Mac OS X +* Fix issues running maya2egg on Mac OS X +* PStats now tracks memory residency of graphics buffers +* Support wireframe and point rendering modes in OpenGL ES +* Add missing keys to libRocket keymap +* Fix incorrect parsing of numbers with exponents in Config.prc +* Various performance optimizations +* Fix for reading URLs mounted via the virtual file system +* Improve GLSL error reporting +* Fix issue with model disappearing in rare cases with GLSL +* Fix shader generator memory leaks and runtime performance +* Add M_confined mouse mode that keeps cursor in window +* Expose _NET_WM_PID to window managers in X11 +* bam2egg supports collision sphere and plane solids +* Add sample program demonstrating mouse modes +* Add -L (lighting) and -P (graphics pipe) pview options + ------------------------ RELEASE 1.9.0 ------------------------ This is a major release with many exciting new features! diff --git a/doc/man/interrogate_module.1 b/doc/man/interrogate_module.1 index 289c65d691..039266094d 100644 --- a/doc/man/interrogate_module.1 +++ b/doc/man/interrogate_module.1 @@ -1,4 +1,4 @@ -.TH INTERROGATE_MODULE 1 "26 December 2014" "" Panda3D +.TH INTERROGATE_MODULE 1 "02 June 2015" "" Panda3D .SH NAME interrogate_module \- generate module-level code for interrogate .SH SYNOPSIS @@ -64,6 +64,9 @@ may be specified. If all are omitted, the default is \fB\-c\fP. Generate code within each wrapper function to adjust the global variable "in_interpreter" to indicated whether code is running within the Panda C++ environment or within the high-level language. +.TP +.BI "\-import " module_name +Used to import an external dependency module. .SH "SEE ALSO" .BR interrogate (1), .BR test_interrogate (1) diff --git a/doc/man/pview.1 b/doc/man/pview.1 index a45fb8110f..7b5a5520c0 100644 --- a/doc/man/pview.1 +++ b/doc/man/pview.1 @@ -1,4 +1,4 @@ -.TH PVIEW 1 "27 December 2014" "" Panda3D +.TH PVIEW 1 "1 May 2015" "" Panda3D .SH NAME pview \- quickly view a Panda model and/or animation .SH SYNOPSIS @@ -43,6 +43,15 @@ exit. Delete the model files after loading them (presumably this option will only be used when loading a temporary model file). .TP +.B \-L +Enable lighting in the scene. This can also be achieved with +the 'l' hotkey at runtime. +.TP +.BI "\-P " pipename +Select the given graphics pipe for the window, rather than using +the platform default. The allowed values for are those +from the Config.prc variables 'load-display' and 'aux-display'. +.TP .B \-V Report the current version of Panda, and exit. .TP diff --git a/dtool/PandaVersion.pp b/dtool/PandaVersion.pp index 277912e546..85d2181d87 100644 --- a/dtool/PandaVersion.pp +++ b/dtool/PandaVersion.pp @@ -3,7 +3,7 @@ // ppremake scripts for Panda. // Use spaces to separate the major, minor, and sequence numbers here. -#define PANDA_VERSION 1 9 0 +#define PANDA_VERSION 1 10 0 // This variable will be defined to false in the CVS repository, but // scripts that generate source tarballs and/or binary releases for diff --git a/dtool/metalibs/dtoolconfig/pydtool.cxx b/dtool/metalibs/dtoolconfig/pydtool.cxx index 7b3a017b34..bde03f4197 100644 --- a/dtool/metalibs/dtoolconfig/pydtool.cxx +++ b/dtool/metalibs/dtoolconfig/pydtool.cxx @@ -2475,20 +2475,22 @@ static PyMethodDef python_simple_funcs[] = { #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef python_simple_module = { PyModuleDef_HEAD_INIT, - "dtoolconfig", + "interrogatedb", NULL, -1, python_simple_funcs, NULL, NULL, NULL, NULL }; -#define INIT_FUNC PyObject *PyInit_dtoolconfig +#define INIT_FUNC PyObject *PyInit_interrogatedb #else -#define INIT_FUNC void initdtoolconfig +#define INIT_FUNC void initinterrogatedb #endif #ifdef _WIN32 extern "C" __declspec(dllexport) INIT_FUNC(); +#elif __GNUC__ >= 4 +extern "C" __attribute__((visibility("default"))) INIT_FUNC(); #else extern "C" INIT_FUNC(); #endif @@ -2497,7 +2499,6 @@ INIT_FUNC() { #if PY_MAJOR_VERSION >= 3 return PyModule_Create(&python_simple_module); #else - Py_InitModule("dtoolconfig", python_simple_funcs); + Py_InitModule("interrogatedb", python_simple_funcs); #endif } - diff --git a/dtool/src/cppparser/Sources.pp b/dtool/src/cppparser/Sources.pp index c5ff050468..46aa8634e9 100644 --- a/dtool/src/cppparser/Sources.pp +++ b/dtool/src/cppparser/Sources.pp @@ -22,7 +22,7 @@ cppSimpleType.h cppStructType.h cppTBDType.h \ cppTemplateParameterList.h cppTemplateScope.h cppToken.h \ cppType.h cppTypeDeclaration.h cppTypeParser.h \ - cppTypeProxy.h cppTypedef.h cppUsing.h cppVisibility.h + cppTypeProxy.h cppTypedefType.h cppUsing.h cppVisibility.h #define INCLUDED_SOURCES \ cppArrayType.cxx cppClassTemplateParameter.cxx \ @@ -38,7 +38,7 @@ cppStructType.cxx cppTBDType.cxx \ cppTemplateParameterList.cxx cppTemplateScope.cxx \ cppToken.cxx cppType.cxx cppTypeDeclaration.cxx \ - cppTypeParser.cxx cppTypeProxy.cxx cppTypedef.cxx \ + cppTypeParser.cxx cppTypeProxy.cxx cppTypedefType.cxx \ cppUsing.cxx cppVisibility.cxx #end static_lib_target diff --git a/dtool/src/cppparser/cppArrayType.cxx b/dtool/src/cppparser/cppArrayType.cxx index 44714cc9bd..fa23f26e0f 100644 --- a/dtool/src/cppparser/cppArrayType.cxx +++ b/dtool/src/cppparser/cppArrayType.cxx @@ -76,6 +76,17 @@ is_tbd() const { return _element_type->is_tbd(); } +//////////////////////////////////////////////////////////////////// +// Function: CPPArrayType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPArrayType:: +is_trivial() const { + return _element_type->is_trivial(); +} + //////////////////////////////////////////////////////////////////// // Function: CPPArrayType::is_equivalent // Access: Public, Virtual @@ -206,11 +217,11 @@ is_equal(const CPPDeclaration *other) const { if (*_bounds != *ot->_bounds) { return false; } - } else if (_bounds == NULL || ot->_bounds == NULL) { + } else if ((_bounds == NULL) != (ot->_bounds == NULL)) { return false; } - return _element_type == ot->_element_type; + return *_element_type == *ot->_element_type; } @@ -230,10 +241,13 @@ is_less(const CPPDeclaration *other) const { if (*_bounds != *ot->_bounds) { return *_bounds < *ot->_bounds; } - } else if (_bounds == NULL || ot->_bounds == NULL) { + } else if ((_bounds == NULL) != (ot->_bounds == NULL)) { return _bounds < ot->_bounds; } - return _element_type < ot->_element_type; + if (*_element_type != *ot->_element_type) { + return *_element_type < *ot->_element_type; + } + return false; } diff --git a/dtool/src/cppparser/cppArrayType.h b/dtool/src/cppparser/cppArrayType.h index 335759c105..82a369a90e 100644 --- a/dtool/src/cppparser/cppArrayType.h +++ b/dtool/src/cppparser/cppArrayType.h @@ -40,6 +40,7 @@ public: virtual CPPType *resolve_type(CPPScope *current_scope, CPPScope *global_scope); virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual bool is_equivalent(const CPPType &other) const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index 37f6b532f4..058d1dc791 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -90,7 +90,7 @@ #include "cppClassTemplateParameter.h" #include "cppTemplateParameterList.h" #include "cppInstanceIdentifier.h" -#include "cppTypedef.h" +#include "cppTypedefType.h" #include "cppTypeDeclaration.h" #include "cppVisibility.h" #include "cppIdentifier.h" @@ -342,63 +342,65 @@ extern int cppyydebug; KW_BOOL = 300, KW_CATCH = 301, KW_CHAR = 302, - KW_WCHAR_T = 303, - KW_CLASS = 304, - KW_CONST = 305, - KW_DELETE = 306, - KW_DOUBLE = 307, - KW_DYNAMIC_CAST = 308, - KW_ELSE = 309, - KW_END_PUBLISH = 310, - KW_ENUM = 311, - KW_EXTENSION = 312, - KW_EXTERN = 313, - KW_EXPLICIT = 314, - KW_PUBLISHED = 315, - KW_FALSE = 316, - KW_FLOAT = 317, - KW_FRIEND = 318, - KW_FOR = 319, - KW_GOTO = 320, - KW_IF = 321, - KW_INLINE = 322, - KW_INT = 323, - KW_LONG = 324, - KW_LONGLONG = 325, - KW_MAKE_PROPERTY = 326, - KW_MAKE_SEQ = 327, - KW_MUTABLE = 328, - KW_NAMESPACE = 329, - KW_NEW = 330, - KW_NOEXCEPT = 331, - KW_OPERATOR = 332, - KW_PRIVATE = 333, - KW_PROTECTED = 334, - KW_PUBLIC = 335, - KW_REGISTER = 336, - KW_RETURN = 337, - KW_SHORT = 338, - KW_SIGNED = 339, - KW_SIZEOF = 340, - KW_STATIC = 341, - KW_STATIC_CAST = 342, - KW_STRUCT = 343, - KW_TEMPLATE = 344, - KW_THROW = 345, - KW_TRUE = 346, - KW_TRY = 347, - KW_TYPEDEF = 348, - KW_TYPENAME = 349, - KW_UNION = 350, - KW_UNSIGNED = 351, - KW_USING = 352, - KW_VIRTUAL = 353, - KW_VOID = 354, - KW_VOLATILE = 355, - KW_WHILE = 356, - START_CPP = 357, - START_CONST_EXPR = 358, - START_TYPE = 359 + KW_CHAR16_T = 303, + KW_CHAR32_T = 304, + KW_CLASS = 305, + KW_CONST = 306, + KW_DELETE = 307, + KW_DOUBLE = 308, + KW_DYNAMIC_CAST = 309, + KW_ELSE = 310, + KW_END_PUBLISH = 311, + KW_ENUM = 312, + KW_EXTENSION = 313, + KW_EXTERN = 314, + KW_EXPLICIT = 315, + KW_PUBLISHED = 316, + KW_FALSE = 317, + KW_FLOAT = 318, + KW_FRIEND = 319, + KW_FOR = 320, + KW_GOTO = 321, + KW_IF = 322, + KW_INLINE = 323, + KW_INT = 324, + KW_LONG = 325, + KW_LONGLONG = 326, + KW_MAKE_PROPERTY = 327, + KW_MAKE_SEQ = 328, + KW_MUTABLE = 329, + KW_NAMESPACE = 330, + KW_NEW = 331, + KW_NOEXCEPT = 332, + KW_OPERATOR = 333, + KW_PRIVATE = 334, + KW_PROTECTED = 335, + KW_PUBLIC = 336, + KW_REGISTER = 337, + KW_RETURN = 338, + KW_SHORT = 339, + KW_SIGNED = 340, + KW_SIZEOF = 341, + KW_STATIC = 342, + KW_STATIC_CAST = 343, + KW_STRUCT = 344, + KW_TEMPLATE = 345, + KW_THROW = 346, + KW_TRUE = 347, + KW_TRY = 348, + KW_TYPEDEF = 349, + KW_TYPENAME = 350, + KW_UNION = 351, + KW_UNSIGNED = 352, + KW_USING = 353, + KW_VIRTUAL = 354, + KW_VOID = 355, + KW_VOLATILE = 356, + KW_WCHAR_T = 357, + KW_WHILE = 358, + START_CPP = 359, + START_CONST_EXPR = 360, + START_TYPE = 361 }; #endif /* Tokens. */ @@ -447,63 +449,65 @@ extern int cppyydebug; #define KW_BOOL 300 #define KW_CATCH 301 #define KW_CHAR 302 -#define KW_WCHAR_T 303 -#define KW_CLASS 304 -#define KW_CONST 305 -#define KW_DELETE 306 -#define KW_DOUBLE 307 -#define KW_DYNAMIC_CAST 308 -#define KW_ELSE 309 -#define KW_END_PUBLISH 310 -#define KW_ENUM 311 -#define KW_EXTENSION 312 -#define KW_EXTERN 313 -#define KW_EXPLICIT 314 -#define KW_PUBLISHED 315 -#define KW_FALSE 316 -#define KW_FLOAT 317 -#define KW_FRIEND 318 -#define KW_FOR 319 -#define KW_GOTO 320 -#define KW_IF 321 -#define KW_INLINE 322 -#define KW_INT 323 -#define KW_LONG 324 -#define KW_LONGLONG 325 -#define KW_MAKE_PROPERTY 326 -#define KW_MAKE_SEQ 327 -#define KW_MUTABLE 328 -#define KW_NAMESPACE 329 -#define KW_NEW 330 -#define KW_NOEXCEPT 331 -#define KW_OPERATOR 332 -#define KW_PRIVATE 333 -#define KW_PROTECTED 334 -#define KW_PUBLIC 335 -#define KW_REGISTER 336 -#define KW_RETURN 337 -#define KW_SHORT 338 -#define KW_SIGNED 339 -#define KW_SIZEOF 340 -#define KW_STATIC 341 -#define KW_STATIC_CAST 342 -#define KW_STRUCT 343 -#define KW_TEMPLATE 344 -#define KW_THROW 345 -#define KW_TRUE 346 -#define KW_TRY 347 -#define KW_TYPEDEF 348 -#define KW_TYPENAME 349 -#define KW_UNION 350 -#define KW_UNSIGNED 351 -#define KW_USING 352 -#define KW_VIRTUAL 353 -#define KW_VOID 354 -#define KW_VOLATILE 355 -#define KW_WHILE 356 -#define START_CPP 357 -#define START_CONST_EXPR 358 -#define START_TYPE 359 +#define KW_CHAR16_T 303 +#define KW_CHAR32_T 304 +#define KW_CLASS 305 +#define KW_CONST 306 +#define KW_DELETE 307 +#define KW_DOUBLE 308 +#define KW_DYNAMIC_CAST 309 +#define KW_ELSE 310 +#define KW_END_PUBLISH 311 +#define KW_ENUM 312 +#define KW_EXTENSION 313 +#define KW_EXTERN 314 +#define KW_EXPLICIT 315 +#define KW_PUBLISHED 316 +#define KW_FALSE 317 +#define KW_FLOAT 318 +#define KW_FRIEND 319 +#define KW_FOR 320 +#define KW_GOTO 321 +#define KW_IF 322 +#define KW_INLINE 323 +#define KW_INT 324 +#define KW_LONG 325 +#define KW_LONGLONG 326 +#define KW_MAKE_PROPERTY 327 +#define KW_MAKE_SEQ 328 +#define KW_MUTABLE 329 +#define KW_NAMESPACE 330 +#define KW_NEW 331 +#define KW_NOEXCEPT 332 +#define KW_OPERATOR 333 +#define KW_PRIVATE 334 +#define KW_PROTECTED 335 +#define KW_PUBLIC 336 +#define KW_REGISTER 337 +#define KW_RETURN 338 +#define KW_SHORT 339 +#define KW_SIGNED 340 +#define KW_SIZEOF 341 +#define KW_STATIC 342 +#define KW_STATIC_CAST 343 +#define KW_STRUCT 344 +#define KW_TEMPLATE 345 +#define KW_THROW 346 +#define KW_TRUE 347 +#define KW_TRY 348 +#define KW_TYPEDEF 349 +#define KW_TYPENAME 350 +#define KW_UNION 351 +#define KW_UNSIGNED 352 +#define KW_USING 353 +#define KW_VIRTUAL 354 +#define KW_VOID 355 +#define KW_VOLATILE 356 +#define KW_WCHAR_T 357 +#define KW_WHILE 358 +#define START_CPP 359 +#define START_CONST_EXPR 360 +#define START_TYPE 361 @@ -546,7 +550,7 @@ int cppyyparse (); /* Copy the second part of user declarations. */ /* Line 390 of yacc.c */ -#line 550 "built/tmp/cppBison.yxx.c" +#line 554 "built/tmp/cppBison.yxx.c" #ifdef short # undef short @@ -766,22 +770,22 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 69 +#define YYFINAL 73 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 3615 +#define YYLAST 3636 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 129 +#define YYNTOKENS 131 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 94 +#define YYNNTS 93 /* YYNRULES -- Number of rules. */ -#define YYNRULES 540 +#define YYNRULES 548 /* YYNRULES -- Number of states. */ -#define YYNSTATES 977 +#define YYNSTATES 993 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 359 +#define YYMAXUTOK 361 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -792,16 +796,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 127, 2, 2, 2, 120, 113, 2, - 123, 125, 118, 116, 106, 117, 122, 119, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 108, 107, - 114, 109, 115, 110, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 129, 2, 2, 2, 122, 115, 2, + 125, 127, 120, 118, 108, 119, 124, 121, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 110, 109, + 116, 111, 117, 112, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 124, 2, 128, 112, 2, 2, 2, 2, 2, + 2, 126, 2, 130, 114, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 105, 111, 126, 121, 2, 2, 2, + 2, 2, 2, 107, 113, 128, 123, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -824,7 +828,8 @@ static const yytype_uint8 yytranslate[] = 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104 + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106 }; #if YYDEBUG @@ -853,273 +858,276 @@ static const yytype_uint16 yyprhs[] = 568, 570, 573, 576, 579, 582, 586, 591, 593, 595, 597, 600, 603, 606, 609, 613, 618, 626, 630, 632, 635, 638, 641, 644, 648, 653, 661, 663, 665, 668, - 670, 672, 674, 676, 679, 682, 684, 686, 689, 691, - 693, 695, 697, 700, 703, 705, 707, 710, 713, 716, - 719, 723, 724, 730, 731, 739, 741, 743, 746, 750, - 753, 756, 759, 763, 767, 771, 775, 779, 783, 784, - 790, 791, 798, 800, 804, 810, 812, 815, 820, 822, - 824, 826, 828, 829, 836, 841, 844, 848, 850, 852, - 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, - 875, 878, 881, 884, 886, 889, 891, 895, 898, 900, - 901, 904, 906, 909, 911, 913, 915, 917, 919, 921, - 923, 925, 927, 929, 931, 933, 935, 937, 939, 941, - 943, 945, 947, 949, 951, 953, 955, 957, 959, 961, - 963, 965, 967, 969, 971, 973, 975, 977, 979, 981, - 983, 985, 987, 989, 991, 993, 995, 997, 999, 1001, - 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019, 1021, - 1023, 1025, 1027, 1029, 1031, 1033, 1035, 1037, 1039, 1041, - 1043, 1045, 1047, 1049, 1051, 1053, 1055, 1057, 1059, 1061, - 1063, 1065, 1067, 1069, 1071, 1073, 1075, 1077, 1079, 1081, - 1083, 1085, 1087, 1089, 1091, 1093, 1095, 1097, 1099, 1101, - 1103, 1105, 1107, 1109, 1111, 1113, 1115, 1119, 1121, 1123, - 1125, 1127, 1129, 1133, 1135, 1140, 1148, 1156, 1161, 1164, - 1167, 1170, 1173, 1176, 1180, 1184, 1188, 1192, 1196, 1200, - 1204, 1208, 1212, 1216, 1220, 1224, 1228, 1232, 1236, 1240, - 1246, 1251, 1256, 1260, 1264, 1268, 1272, 1274, 1279, 1287, - 1295, 1300, 1305, 1310, 1315, 1320, 1325, 1330, 1335, 1340, - 1345, 1350, 1355, 1358, 1364, 1367, 1370, 1373, 1376, 1379, - 1383, 1387, 1391, 1395, 1399, 1403, 1407, 1411, 1415, 1419, - 1423, 1427, 1431, 1435, 1439, 1443, 1447, 1451, 1457, 1462, - 1467, 1471, 1475, 1479, 1483, 1485, 1487, 1489, 1491, 1493, - 1495, 1497, 1499, 1504, 1512, 1520, 1525, 1528, 1534, 1537, - 1540, 1543, 1546, 1550, 1554, 1558, 1562, 1566, 1570, 1574, - 1578, 1582, 1586, 1590, 1594, 1598, 1602, 1606, 1610, 1614, - 1618, 1624, 1629, 1634, 1638, 1642, 1646, 1650, 1652, 1654, - 1656, 1658, 1660, 1662, 1664, 1667, 1670, 1672, 1674, 1676, - 1679 + 670, 672, 674, 677, 682, 684, 686, 689, 691, 693, + 695, 698, 703, 706, 708, 710, 713, 716, 719, 722, + 726, 727, 733, 734, 742, 744, 746, 749, 753, 756, + 759, 762, 766, 770, 774, 778, 782, 786, 791, 796, + 799, 803, 805, 807, 809, 811, 815, 821, 823, 826, + 831, 833, 835, 837, 839, 840, 847, 852, 855, 859, + 861, 863, 865, 867, 869, 871, 873, 875, 877, 879, + 881, 883, 885, 887, 890, 893, 896, 899, 901, 904, + 906, 910, 913, 915, 916, 919, 921, 924, 926, 928, + 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, + 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, + 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, + 990, 992, 994, 996, 998, 1000, 1002, 1004, 1006, 1008, + 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024, 1026, 1028, + 1030, 1032, 1034, 1036, 1038, 1040, 1042, 1044, 1046, 1048, + 1050, 1052, 1054, 1056, 1058, 1060, 1062, 1064, 1066, 1068, + 1070, 1072, 1074, 1076, 1078, 1080, 1082, 1084, 1086, 1088, + 1090, 1092, 1094, 1096, 1098, 1100, 1102, 1104, 1106, 1108, + 1110, 1112, 1114, 1116, 1118, 1120, 1122, 1124, 1126, 1128, + 1130, 1132, 1134, 1138, 1140, 1142, 1144, 1146, 1148, 1152, + 1154, 1159, 1167, 1175, 1180, 1183, 1186, 1189, 1192, 1195, + 1199, 1203, 1207, 1211, 1215, 1219, 1223, 1227, 1231, 1235, + 1239, 1243, 1247, 1251, 1255, 1259, 1265, 1270, 1275, 1279, + 1283, 1287, 1291, 1293, 1298, 1306, 1314, 1319, 1324, 1329, + 1334, 1339, 1344, 1349, 1354, 1359, 1364, 1369, 1374, 1379, + 1384, 1387, 1393, 1396, 1399, 1402, 1405, 1408, 1412, 1416, + 1420, 1424, 1428, 1432, 1436, 1440, 1444, 1448, 1452, 1456, + 1460, 1464, 1468, 1472, 1476, 1480, 1486, 1491, 1496, 1500, + 1504, 1508, 1512, 1514, 1516, 1518, 1520, 1522, 1524, 1526, + 1528, 1533, 1541, 1549, 1554, 1557, 1563, 1566, 1569, 1572, + 1575, 1579, 1583, 1587, 1591, 1595, 1599, 1603, 1607, 1611, + 1615, 1619, 1623, 1627, 1631, 1635, 1639, 1643, 1647, 1653, + 1658, 1663, 1667, 1671, 1675, 1679, 1681, 1683, 1685, 1687, + 1689, 1691, 1693, 1696, 1699, 1701, 1703, 1705, 1708 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 130, 0, -1, 102, 131, -1, 103, 215, -1, 104, - 184, -1, 222, -1, 131, 107, -1, 131, 136, -1, - 133, -1, 132, 106, 133, -1, 220, 123, 212, 125, - -1, -1, 139, 105, 135, 131, 126, -1, 140, -1, - 162, -1, 134, -1, 200, -1, 202, -1, 137, -1, - 93, 146, -1, 43, -1, 55, -1, 60, 108, -1, - 80, 108, -1, 79, 108, -1, 78, 108, -1, 71, - 123, 8, 106, 8, 125, 107, -1, 71, 123, 8, - 106, 8, 106, 8, 125, 107, -1, 72, 123, 220, - 106, 220, 106, 220, 125, 107, -1, -1, 63, 138, - 136, -1, 222, -1, 139, 58, -1, 139, 58, 221, - -1, 139, 86, -1, 139, 67, -1, 139, 98, -1, - 139, 59, -1, 139, 100, -1, 139, 73, -1, 139, - 81, -1, 139, 44, -1, 139, 57, -1, 141, -1, - 139, 182, 107, -1, 139, 151, 174, -1, -1, 139, - 182, 142, 144, -1, -1, 139, 50, 181, 143, 145, - -1, 168, 174, -1, 168, 173, 106, 144, -1, 168, - 174, -1, 168, 173, 106, 145, -1, -1, 139, 182, - 147, 149, -1, -1, 139, 50, 181, 148, 150, -1, - 139, 151, 174, -1, 168, 174, -1, 168, 173, 106, - 149, -1, 168, 174, -1, 168, 173, 106, 150, -1, - -1, 8, 123, 152, 170, 125, 159, -1, -1, 9, - 123, 153, 170, 125, 159, -1, -1, 121, 220, 123, - 154, 170, 125, 159, -1, -1, 9, 123, 118, 168, - 125, 123, 155, 170, 125, 159, -1, -1, 9, 123, - 10, 118, 168, 125, 123, 156, 170, 125, 159, -1, - -1, 77, 181, 178, 123, 157, 170, 125, 159, -1, - -1, 77, 50, 181, 178, 123, 158, 170, 125, 159, - -1, 8, -1, 222, -1, 50, -1, 159, 76, -1, - 159, 90, 123, 125, -1, 159, 90, 123, 220, 125, - -1, 127, -1, 121, -1, 118, -1, 119, -1, 120, - -1, 116, -1, 117, -1, 111, -1, 113, -1, 112, + 132, 0, -1, 104, 133, -1, 105, 216, -1, 106, + 186, -1, 223, -1, 133, 109, -1, 133, 138, -1, + 135, -1, 134, 108, 135, -1, 221, 125, 213, 127, + -1, -1, 141, 107, 137, 133, 128, -1, 142, -1, + 164, -1, 136, -1, 201, -1, 203, -1, 139, -1, + 94, 148, -1, 43, -1, 56, -1, 61, 110, -1, + 81, 110, -1, 80, 110, -1, 79, 110, -1, 72, + 125, 8, 108, 8, 127, 109, -1, 72, 125, 8, + 108, 8, 108, 8, 127, 109, -1, 73, 125, 221, + 108, 221, 108, 221, 127, 109, -1, -1, 64, 140, + 138, -1, 223, -1, 141, 59, -1, 141, 59, 222, + -1, 141, 87, -1, 141, 68, -1, 141, 99, -1, + 141, 60, -1, 141, 101, -1, 141, 74, -1, 141, + 82, -1, 141, 44, -1, 141, 58, -1, 143, -1, + 141, 184, 109, -1, 141, 153, 176, -1, -1, 141, + 184, 144, 146, -1, -1, 141, 51, 183, 145, 147, + -1, 170, 176, -1, 170, 175, 108, 146, -1, 170, + 176, -1, 170, 175, 108, 147, -1, -1, 141, 184, + 149, 151, -1, -1, 141, 51, 183, 150, 152, -1, + 141, 153, 176, -1, 170, 176, -1, 170, 175, 108, + 151, -1, 170, 176, -1, 170, 175, 108, 152, -1, + -1, 8, 125, 154, 172, 127, 161, -1, -1, 9, + 125, 155, 172, 127, 161, -1, -1, 123, 221, 125, + 156, 172, 127, 161, -1, -1, 9, 125, 120, 170, + 127, 125, 157, 172, 127, 161, -1, -1, 9, 125, + 10, 120, 170, 127, 125, 158, 172, 127, 161, -1, + -1, 78, 183, 180, 125, 159, 172, 127, 161, -1, + -1, 78, 51, 183, 180, 125, 160, 172, 127, 161, + -1, 8, -1, 223, -1, 51, -1, 161, 77, -1, + 161, 91, 125, 127, -1, 161, 91, 125, 221, 127, + -1, 129, -1, 123, -1, 120, -1, 121, -1, 122, + -1, 118, -1, 119, -1, 113, -1, 115, -1, 114, -1, 13, -1, 14, -1, 15, -1, 16, -1, 17, - -1, 18, -1, 114, -1, 115, -1, 19, -1, 20, - -1, 109, -1, 106, -1, 31, -1, 32, -1, 33, + -1, 18, -1, 116, -1, 117, -1, 19, -1, 20, + -1, 111, -1, 108, -1, 31, -1, 32, -1, 33, -1, 34, -1, 35, -1, 36, -1, 37, -1, 38, -1, 39, -1, 40, -1, 41, -1, 42, -1, 29, - -1, 124, 128, -1, 123, 125, -1, 75, -1, 51, - -1, 140, -1, 162, -1, -1, 89, 163, 114, 164, - 115, 161, -1, 222, -1, 165, -1, 166, -1, 165, - 106, 166, -1, 49, 220, -1, 49, 220, 109, 184, - -1, 94, 220, -1, 94, 220, 109, 184, -1, 167, - 179, 172, -1, 50, 167, 179, 172, -1, 203, -1, - 8, -1, 9, -1, 220, -1, 77, 160, -1, 50, - 168, -1, 118, 168, -1, 113, 168, -1, 14, 168, - -1, 10, 118, 168, -1, 168, 124, 211, 128, -1, - 168, 108, 4, -1, 123, 168, 125, -1, -1, 168, - 123, 169, 170, 125, 159, -1, 222, -1, 12, -1, - 171, -1, 171, 106, 12, -1, 171, 12, -1, 177, - -1, 171, 106, 177, -1, 222, -1, 109, 214, -1, - 222, -1, 109, 215, -1, 107, -1, 105, 207, 126, - -1, 108, 132, 105, 207, 126, -1, 109, 215, 107, - -1, 109, 105, 175, 126, -1, 222, -1, 176, -1, - 176, 106, -1, 215, -1, 105, 175, 126, -1, 176, - 106, 215, -1, 176, 106, 105, 175, 126, -1, 181, - 179, 173, -1, 8, 179, 173, -1, 50, 181, 179, - 173, -1, 217, -1, 222, -1, 8, -1, 9, -1, - 50, 178, -1, 118, 178, -1, 113, 178, -1, 14, - 178, -1, 10, 118, 178, -1, 178, 124, 211, 128, - -1, 222, -1, 8, -1, 9, -1, 50, 179, -1, - 118, 179, -1, 113, 179, -1, 14, 179, -1, 10, - 118, 179, -1, 179, 124, 211, 128, -1, 123, 179, - 125, 123, 170, 125, 159, -1, 123, 179, 125, -1, - 222, -1, 50, 180, -1, 118, 180, -1, 113, 180, - -1, 14, 180, -1, 10, 118, 180, -1, 180, 124, - 211, 128, -1, 123, 180, 125, 123, 170, 125, 159, - -1, 203, -1, 9, -1, 94, 220, -1, 185, -1, - 187, -1, 192, -1, 194, -1, 199, 220, -1, 198, - 220, -1, 203, -1, 9, -1, 94, 220, -1, 185, - -1, 187, -1, 192, -1, 194, -1, 199, 220, -1, - 198, 220, -1, 203, -1, 9, -1, 94, 220, -1, - 199, 220, -1, 198, 220, -1, 181, 180, -1, 50, - 181, 180, -1, -1, 199, 105, 186, 131, 126, -1, - -1, 199, 220, 188, 189, 105, 131, 126, -1, 222, - -1, 190, -1, 108, 191, -1, 190, 106, 191, -1, - 80, 219, -1, 79, 219, -1, 78, 219, -1, 98, - 80, 219, -1, 98, 79, 219, -1, 98, 78, 219, - -1, 80, 98, 219, -1, 79, 98, 219, -1, 78, - 98, 219, -1, -1, 198, 105, 193, 197, 126, -1, - -1, 198, 220, 105, 195, 197, 126, -1, 222, -1, - 196, 220, 106, -1, 196, 220, 109, 215, 106, -1, - 196, -1, 196, 220, -1, 196, 220, 109, 215, -1, - 56, -1, 49, -1, 88, -1, 95, -1, -1, 74, - 220, 105, 201, 131, 126, -1, 74, 105, 131, 126, - -1, 97, 220, -1, 97, 74, 220, -1, 204, -1, - 205, -1, 206, -1, 45, -1, 47, -1, 48, -1, - 83, -1, 69, -1, 70, -1, 96, -1, 84, -1, - 68, -1, 83, 204, -1, 69, 204, -1, 96, 204, - -1, 84, 204, -1, 62, -1, 69, 62, -1, 52, - -1, 69, 69, 62, -1, 69, 52, -1, 99, -1, - -1, 208, 209, -1, 222, -1, 209, 210, -1, 3, - -1, 4, -1, 6, -1, 5, -1, 8, -1, 9, - -1, 10, -1, 7, -1, 12, -1, 13, -1, 14, - -1, 15, -1, 16, -1, 17, -1, 18, -1, 19, - -1, 20, -1, 21, -1, 22, -1, 29, -1, 30, - -1, 31, -1, 32, -1, 33, -1, 34, -1, 35, - -1, 36, -1, 37, -1, 38, -1, 39, -1, 40, - -1, 41, -1, 42, -1, 45, -1, 46, -1, 47, - -1, 48, -1, 49, -1, 50, -1, 51, -1, 52, - -1, 53, -1, 54, -1, 56, -1, 58, -1, 59, - -1, 61, -1, 62, -1, 63, -1, 64, -1, 65, - -1, 66, -1, 67, -1, 68, -1, 69, -1, 73, - -1, 75, -1, 78, -1, 79, -1, 80, -1, 60, - -1, 81, -1, 82, -1, 83, -1, 84, -1, 85, - -1, 86, -1, 87, -1, 88, -1, 90, -1, 91, - -1, 92, -1, 93, -1, 94, -1, 95, -1, 96, - -1, 98, -1, 99, -1, 100, -1, 101, -1, 77, - -1, 116, -1, 117, -1, 118, -1, 119, -1, 113, - -1, 111, -1, 112, -1, 127, -1, 121, -1, 109, - -1, 120, -1, 114, -1, 115, -1, 123, -1, 125, - -1, 122, -1, 106, -1, 107, -1, 108, -1, 124, - -1, 128, -1, 110, -1, 105, 209, 126, -1, 222, - -1, 215, -1, 222, -1, 213, -1, 215, -1, 213, - 106, 215, -1, 216, -1, 123, 184, 125, 214, -1, - 87, 114, 184, 115, 123, 213, 125, -1, 53, 114, - 184, 115, 123, 213, 125, -1, 85, 123, 184, 125, - -1, 127, 214, -1, 121, 214, -1, 117, 214, -1, - 118, 214, -1, 113, 214, -1, 214, 118, 214, -1, - 214, 119, 214, -1, 214, 120, 214, -1, 214, 116, - 214, -1, 214, 117, 214, -1, 214, 111, 214, -1, - 214, 112, 214, -1, 214, 113, 214, -1, 214, 13, - 214, -1, 214, 14, 214, -1, 214, 15, 214, -1, - 214, 16, 214, -1, 214, 17, 214, -1, 214, 18, - 214, -1, 214, 19, 214, -1, 214, 20, 214, -1, - 214, 110, 214, 108, 214, -1, 214, 124, 215, 128, - -1, 214, 123, 213, 125, -1, 214, 123, 125, -1, - 214, 122, 214, -1, 214, 29, 214, -1, 123, 213, - 125, -1, 216, -1, 123, 184, 125, 215, -1, 87, - 114, 184, 115, 123, 213, 125, -1, 53, 114, 184, - 115, 123, 213, 125, -1, 9, 123, 212, 125, -1, - 68, 123, 212, 125, -1, 47, 123, 212, 125, -1, - 48, 123, 212, 125, -1, 45, 123, 212, 125, -1, - 83, 123, 212, 125, -1, 69, 123, 212, 125, -1, - 96, 123, 212, 125, -1, 84, 123, 212, 125, -1, - 62, 123, 212, 125, -1, 52, 123, 212, 125, -1, - 85, 123, 184, 125, -1, 75, 183, -1, 75, 183, - 123, 212, 125, -1, 127, 215, -1, 121, 215, -1, - 117, 215, -1, 118, 215, -1, 113, 215, -1, 215, - 118, 215, -1, 215, 119, 215, -1, 215, 120, 215, - -1, 215, 116, 215, -1, 215, 117, 215, -1, 215, - 111, 215, -1, 215, 112, 215, -1, 215, 113, 215, - -1, 215, 13, 215, -1, 215, 14, 215, -1, 215, - 15, 215, -1, 215, 16, 215, -1, 215, 17, 215, - -1, 215, 18, 215, -1, 215, 114, 215, -1, 215, - 115, 215, -1, 215, 19, 215, -1, 215, 20, 215, - -1, 215, 110, 215, 108, 215, -1, 215, 124, 215, - 128, -1, 215, 123, 213, 125, -1, 215, 123, 125, - -1, 215, 122, 215, -1, 215, 29, 215, -1, 123, - 213, 125, -1, 4, -1, 91, -1, 61, -1, 5, - -1, 3, -1, 221, -1, 8, -1, 218, -1, 123, - 184, 125, 215, -1, 87, 114, 184, 115, 123, 213, - 125, -1, 53, 114, 184, 115, 123, 213, 125, -1, - 85, 123, 184, 125, -1, 75, 183, -1, 75, 183, - 123, 212, 125, -1, 127, 215, -1, 121, 215, -1, - 117, 215, -1, 113, 215, -1, 217, 118, 215, -1, - 217, 119, 215, -1, 217, 120, 215, -1, 217, 116, - 215, -1, 217, 117, 215, -1, 217, 111, 215, -1, - 217, 112, 215, -1, 217, 113, 215, -1, 217, 13, - 215, -1, 217, 14, 215, -1, 217, 15, 215, -1, - 217, 16, 215, -1, 217, 17, 215, -1, 217, 18, - 215, -1, 217, 114, 215, -1, 217, 115, 215, -1, - 217, 19, 215, -1, 217, 20, 215, -1, 217, 110, - 215, 108, 215, -1, 217, 124, 215, 128, -1, 217, - 123, 213, 125, -1, 217, 123, 125, -1, 217, 122, - 215, -1, 217, 29, 215, -1, 123, 213, 125, -1, - 4, -1, 91, -1, 61, -1, 5, -1, 3, -1, - 221, -1, 220, -1, 199, 220, -1, 94, 220, -1, - 8, -1, 9, -1, 6, -1, 221, 6, -1, -1 + -1, 126, 130, -1, 125, 127, -1, 76, -1, 52, + -1, 142, -1, 164, -1, -1, 90, 165, 116, 166, + 117, 163, -1, 223, -1, 167, -1, 168, -1, 167, + 108, 168, -1, 50, 221, -1, 50, 221, 111, 186, + -1, 95, 221, -1, 95, 221, 111, 186, -1, 169, + 181, 174, -1, 51, 169, 181, 174, -1, 204, -1, + 8, -1, 9, -1, 221, -1, 78, 162, -1, 51, + 170, -1, 120, 170, -1, 115, 170, -1, 14, 170, + -1, 10, 120, 170, -1, 170, 126, 212, 130, -1, + 170, 110, 4, -1, 125, 170, 127, -1, -1, 170, + 125, 171, 172, 127, 161, -1, 223, -1, 12, -1, + 173, -1, 173, 108, 12, -1, 173, 12, -1, 179, + -1, 173, 108, 179, -1, 223, -1, 111, 215, -1, + 223, -1, 111, 216, -1, 109, -1, 107, 208, 128, + -1, 110, 134, 107, 208, 128, -1, 111, 216, 109, + -1, 111, 107, 177, 128, -1, 223, -1, 178, -1, + 178, 108, -1, 216, -1, 107, 177, 128, -1, 178, + 108, 216, -1, 178, 108, 107, 177, 128, -1, 183, + 181, 175, -1, 8, 181, 175, -1, 51, 183, 181, + 175, -1, 218, -1, 223, -1, 8, -1, 9, -1, + 51, 180, -1, 120, 180, -1, 115, 180, -1, 14, + 180, -1, 10, 120, 180, -1, 180, 126, 212, 130, + -1, 223, -1, 8, -1, 9, -1, 51, 181, -1, + 120, 181, -1, 115, 181, -1, 14, 181, -1, 10, + 120, 181, -1, 181, 126, 212, 130, -1, 125, 181, + 127, 125, 172, 127, 161, -1, 125, 181, 127, -1, + 223, -1, 51, 182, -1, 120, 182, -1, 115, 182, + -1, 14, 182, -1, 10, 120, 182, -1, 182, 126, + 212, 130, -1, 125, 182, 127, 125, 172, 127, 161, + -1, 204, -1, 9, -1, 95, 221, -1, 187, -1, + 189, -1, 194, -1, 200, 221, -1, 199, 221, 110, + 196, -1, 204, -1, 9, -1, 95, 221, -1, 187, + -1, 189, -1, 194, -1, 200, 221, -1, 199, 221, + 110, 196, -1, 199, 221, -1, 204, -1, 9, -1, + 95, 221, -1, 200, 221, -1, 199, 221, -1, 183, + 182, -1, 51, 183, 182, -1, -1, 200, 107, 188, + 133, 128, -1, -1, 200, 221, 190, 191, 107, 133, + 128, -1, 223, -1, 192, -1, 110, 193, -1, 192, + 108, 193, -1, 81, 220, -1, 80, 220, -1, 79, + 220, -1, 99, 81, 220, -1, 99, 80, 220, -1, + 99, 79, 220, -1, 81, 99, 220, -1, 80, 99, + 220, -1, 79, 99, 220, -1, 195, 107, 198, 128, + -1, 199, 221, 110, 196, -1, 199, 221, -1, 199, + 110, 196, -1, 199, -1, 205, -1, 9, -1, 223, + -1, 197, 221, 108, -1, 197, 221, 111, 216, 108, + -1, 197, -1, 197, 221, -1, 197, 221, 111, 216, + -1, 57, -1, 50, -1, 89, -1, 96, -1, -1, + 75, 221, 107, 202, 133, 128, -1, 75, 107, 133, + 128, -1, 98, 221, -1, 98, 75, 221, -1, 205, + -1, 206, -1, 207, -1, 45, -1, 47, -1, 102, + -1, 48, -1, 49, -1, 84, -1, 70, -1, 71, + -1, 97, -1, 85, -1, 69, -1, 84, 205, -1, + 70, 205, -1, 97, 205, -1, 85, 205, -1, 63, + -1, 70, 63, -1, 53, -1, 70, 70, 63, -1, + 70, 53, -1, 100, -1, -1, 209, 210, -1, 223, + -1, 210, 211, -1, 3, -1, 4, -1, 6, -1, + 5, -1, 8, -1, 9, -1, 10, -1, 7, -1, + 12, -1, 13, -1, 14, -1, 15, -1, 16, -1, + 17, -1, 18, -1, 19, -1, 20, -1, 21, -1, + 22, -1, 29, -1, 30, -1, 31, -1, 32, -1, + 33, -1, 34, -1, 35, -1, 36, -1, 37, -1, + 38, -1, 39, -1, 40, -1, 41, -1, 42, -1, + 45, -1, 46, -1, 47, -1, 48, -1, 49, -1, + 102, -1, 50, -1, 51, -1, 52, -1, 53, -1, + 54, -1, 55, -1, 57, -1, 59, -1, 60, -1, + 62, -1, 63, -1, 64, -1, 65, -1, 66, -1, + 67, -1, 68, -1, 69, -1, 70, -1, 74, -1, + 76, -1, 79, -1, 80, -1, 81, -1, 61, -1, + 82, -1, 83, -1, 84, -1, 85, -1, 86, -1, + 87, -1, 88, -1, 89, -1, 91, -1, 92, -1, + 93, -1, 94, -1, 95, -1, 96, -1, 97, -1, + 99, -1, 100, -1, 101, -1, 103, -1, 78, -1, + 118, -1, 119, -1, 120, -1, 121, -1, 115, -1, + 113, -1, 114, -1, 129, -1, 123, -1, 111, -1, + 122, -1, 116, -1, 117, -1, 125, -1, 127, -1, + 124, -1, 108, -1, 109, -1, 110, -1, 126, -1, + 130, -1, 112, -1, 107, 210, 128, -1, 223, -1, + 216, -1, 223, -1, 214, -1, 216, -1, 214, 108, + 216, -1, 217, -1, 125, 186, 127, 215, -1, 88, + 116, 186, 117, 125, 214, 127, -1, 54, 116, 186, + 117, 125, 214, 127, -1, 86, 125, 186, 127, -1, + 129, 215, -1, 123, 215, -1, 119, 215, -1, 120, + 215, -1, 115, 215, -1, 215, 120, 215, -1, 215, + 121, 215, -1, 215, 122, 215, -1, 215, 118, 215, + -1, 215, 119, 215, -1, 215, 113, 215, -1, 215, + 114, 215, -1, 215, 115, 215, -1, 215, 13, 215, + -1, 215, 14, 215, -1, 215, 15, 215, -1, 215, + 16, 215, -1, 215, 17, 215, -1, 215, 18, 215, + -1, 215, 19, 215, -1, 215, 20, 215, -1, 215, + 112, 215, 110, 215, -1, 215, 126, 216, 130, -1, + 215, 125, 214, 127, -1, 215, 125, 127, -1, 215, + 124, 215, -1, 215, 29, 215, -1, 125, 214, 127, + -1, 217, -1, 125, 186, 127, 216, -1, 88, 116, + 186, 117, 125, 214, 127, -1, 54, 116, 186, 117, + 125, 214, 127, -1, 9, 125, 213, 127, -1, 69, + 125, 213, 127, -1, 47, 125, 213, 127, -1, 102, + 125, 213, 127, -1, 48, 125, 213, 127, -1, 49, + 125, 213, 127, -1, 45, 125, 213, 127, -1, 84, + 125, 213, 127, -1, 70, 125, 213, 127, -1, 97, + 125, 213, 127, -1, 85, 125, 213, 127, -1, 63, + 125, 213, 127, -1, 53, 125, 213, 127, -1, 86, + 125, 186, 127, -1, 76, 185, -1, 76, 185, 125, + 213, 127, -1, 129, 216, -1, 123, 216, -1, 119, + 216, -1, 120, 216, -1, 115, 216, -1, 216, 120, + 216, -1, 216, 121, 216, -1, 216, 122, 216, -1, + 216, 118, 216, -1, 216, 119, 216, -1, 216, 113, + 216, -1, 216, 114, 216, -1, 216, 115, 216, -1, + 216, 13, 216, -1, 216, 14, 216, -1, 216, 15, + 216, -1, 216, 16, 216, -1, 216, 17, 216, -1, + 216, 18, 216, -1, 216, 116, 216, -1, 216, 117, + 216, -1, 216, 19, 216, -1, 216, 20, 216, -1, + 216, 112, 216, 110, 216, -1, 216, 126, 216, 130, + -1, 216, 125, 214, 127, -1, 216, 125, 127, -1, + 216, 124, 216, -1, 216, 29, 216, -1, 125, 214, + 127, -1, 4, -1, 92, -1, 62, -1, 5, -1, + 3, -1, 222, -1, 8, -1, 219, -1, 125, 186, + 127, 216, -1, 88, 116, 186, 117, 125, 214, 127, + -1, 54, 116, 186, 117, 125, 214, 127, -1, 86, + 125, 186, 127, -1, 76, 185, -1, 76, 185, 125, + 213, 127, -1, 129, 216, -1, 123, 216, -1, 119, + 216, -1, 115, 216, -1, 218, 120, 216, -1, 218, + 121, 216, -1, 218, 122, 216, -1, 218, 118, 216, + -1, 218, 119, 216, -1, 218, 113, 216, -1, 218, + 114, 216, -1, 218, 115, 216, -1, 218, 13, 216, + -1, 218, 14, 216, -1, 218, 15, 216, -1, 218, + 16, 216, -1, 218, 17, 216, -1, 218, 18, 216, + -1, 218, 116, 216, -1, 218, 117, 216, -1, 218, + 19, 216, -1, 218, 20, 216, -1, 218, 112, 216, + 110, 216, -1, 218, 126, 216, 130, -1, 218, 125, + 214, 127, -1, 218, 125, 127, -1, 218, 124, 216, + -1, 218, 29, 216, -1, 125, 214, 127, -1, 4, + -1, 92, -1, 62, -1, 5, -1, 3, -1, 222, + -1, 221, -1, 200, 221, -1, 95, 221, -1, 8, + -1, 9, -1, 6, -1, 222, 6, -1, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 384, 384, 385, 389, 396, 397, 398, 402, 403, - 407, 420, 419, 431, 432, 433, 434, 435, 436, 437, - 438, 451, 460, 464, 472, 476, 480, 491, 508, 517, - 516, 531, 535, 539, 550, 554, 558, 562, 566, 570, - 574, 578, 582, 589, 593, 602, 614, 613, 629, 628, - 646, 654, 665, 674, 688, 687, 703, 702, 713, 727, - 735, 746, 755, 770, 769, 792, 791, 816, 815, 846, - 845, 861, 860, 878, 877, 909, 908, 934, 947, 951, - 955, 959, 963, 970, 974, 978, 982, 986, 990, 994, - 998, 1002, 1006, 1010, 1014, 1018, 1022, 1026, 1030, 1034, - 1038, 1042, 1046, 1050, 1054, 1058, 1062, 1066, 1070, 1074, - 1078, 1082, 1086, 1090, 1094, 1098, 1102, 1106, 1110, 1114, - 1118, 1122, 1129, 1130, 1135, 1134, 1145, 1146, 1150, 1156, - 1165, 1169, 1173, 1177, 1181, 1187, 1197, 1201, 1206, 1215, - 1219, 1233, 1238, 1243, 1248, 1253, 1258, 1263, 1268, 1274, - 1273, 1295, 1299, 1304, 1308, 1313, 1321, 1326, 1334, 1338, - 1345, 1349, 1356, 1360, 1364, 1368, 1372, 1379, 1380, 1381, - 1385, 1388, 1389, 1390, 1394, 1399, 1407, 1413, 1423, 1427, - 1431, 1435, 1440, 1445, 1450, 1455, 1460, 1468, 1472, 1476, - 1480, 1485, 1490, 1495, 1500, 1505, 1510, 1516, 1524, 1528, - 1533, 1538, 1543, 1548, 1553, 1558, 1567, 1571, 1576, 1580, - 1584, 1588, 1592, 1596, 1612, 1631, 1635, 1640, 1644, 1648, - 1652, 1656, 1660, 1676, 1695, 1699, 1704, 1708, 1724, 1743, - 1749, 1760, 1759, 1784, 1783, 1813, 1814, 1818, 1819, 1823, - 1827, 1831, 1835, 1839, 1843, 1847, 1851, 1855, 1863, 1862, - 1875, 1874, 1886, 1887, 1893, 1901, 1902, 1908, 1917, 1924, - 1928, 1932, 1940, 1939, 1961, 1965, 1971, 1980, 1981, 1982, - 1986, 1990, 1994, 1998, 2003, 2008, 2013, 2018, 2023, 2027, - 2032, 2041, 2046, 2054, 2058, 2063, 2067, 2072, 2080, 2090, - 2090, 2100, 2101, 2105, 2108, 2111, 2114, 2117, 2120, 2123, - 2126, 2129, 2129, 2129, 2130, 2130, 2130, 2130, 2131, 2131, - 2131, 2131, 2131, 2132, 2132, 2132, 2133, 2133, 2133, 2133, - 2133, 2134, 2134, 2134, 2134, 2134, 2135, 2135, 2135, 2135, - 2135, 2135, 2136, 2136, 2136, 2136, 2136, 2137, 2137, 2137, - 2138, 2138, 2138, 2138, 2139, 2139, 2139, 2140, 2140, 2140, - 2140, 2140, 2141, 2141, 2141, 2141, 2142, 2142, 2142, 2142, - 2142, 2143, 2143, 2143, 2143, 2143, 2143, 2144, 2144, 2144, - 2144, 2144, 2145, 2146, 2149, 2149, 2149, 2149, 2149, 2149, - 2149, 2149, 2149, 2149, 2149, 2150, 2150, 2150, 2150, 2150, - 2150, 2150, 2150, 2150, 2150, 2151, 2151, 2155, 2159, 2166, - 2170, 2177, 2181, 2188, 2192, 2196, 2200, 2204, 2208, 2212, - 2216, 2228, 2232, 2236, 2240, 2244, 2248, 2252, 2256, 2260, - 2264, 2268, 2272, 2276, 2280, 2284, 2288, 2292, 2296, 2300, - 2304, 2308, 2312, 2316, 2320, 2324, 2332, 2336, 2340, 2344, - 2348, 2355, 2361, 2367, 2373, 2379, 2386, 2393, 2400, 2407, - 2413, 2419, 2423, 2427, 2431, 2435, 2439, 2451, 2455, 2459, - 2463, 2467, 2471, 2475, 2479, 2483, 2487, 2491, 2495, 2499, - 2503, 2507, 2511, 2515, 2519, 2523, 2527, 2531, 2535, 2539, - 2543, 2547, 2551, 2555, 2562, 2566, 2570, 2574, 2578, 2582, - 2586, 2600, 2604, 2608, 2612, 2616, 2620, 2624, 2628, 2632, - 2636, 2648, 2652, 2656, 2660, 2664, 2668, 2672, 2676, 2680, - 2684, 2688, 2692, 2696, 2700, 2704, 2708, 2712, 2716, 2720, - 2724, 2728, 2732, 2736, 2740, 2744, 2748, 2755, 2759, 2763, - 2767, 2771, 2775, 2782, 2790, 2798, 2821, 2825, 2832, 2836, - 2842 + 0, 386, 386, 387, 391, 398, 399, 400, 404, 405, + 409, 422, 421, 433, 434, 435, 436, 437, 438, 439, + 440, 453, 462, 466, 474, 478, 482, 493, 514, 523, + 522, 537, 541, 545, 556, 560, 564, 568, 572, 576, + 580, 584, 588, 595, 599, 608, 620, 619, 635, 634, + 652, 660, 671, 680, 694, 693, 709, 708, 719, 734, + 740, 749, 756, 769, 768, 791, 790, 815, 814, 845, + 844, 860, 859, 877, 876, 908, 907, 933, 946, 950, + 954, 958, 962, 969, 973, 977, 981, 985, 989, 993, + 997, 1001, 1005, 1009, 1013, 1017, 1021, 1025, 1029, 1033, + 1037, 1041, 1045, 1049, 1053, 1057, 1061, 1065, 1069, 1073, + 1077, 1081, 1085, 1089, 1093, 1097, 1101, 1105, 1109, 1113, + 1117, 1121, 1128, 1129, 1134, 1133, 1144, 1145, 1149, 1155, + 1164, 1168, 1172, 1176, 1180, 1186, 1196, 1200, 1205, 1214, + 1218, 1232, 1237, 1242, 1247, 1252, 1257, 1262, 1267, 1273, + 1272, 1294, 1298, 1303, 1307, 1312, 1320, 1325, 1333, 1337, + 1344, 1348, 1355, 1359, 1363, 1367, 1371, 1378, 1379, 1380, + 1384, 1387, 1388, 1389, 1393, 1398, 1406, 1412, 1422, 1426, + 1430, 1434, 1439, 1444, 1449, 1454, 1459, 1467, 1471, 1475, + 1479, 1484, 1489, 1494, 1499, 1504, 1509, 1515, 1523, 1527, + 1532, 1537, 1542, 1547, 1552, 1557, 1566, 1570, 1575, 1579, + 1583, 1587, 1591, 1607, 1626, 1630, 1635, 1639, 1643, 1647, + 1651, 1667, 1683, 1704, 1708, 1713, 1717, 1733, 1752, 1758, + 1769, 1768, 1793, 1792, 1822, 1823, 1827, 1828, 1832, 1836, + 1840, 1844, 1848, 1852, 1856, 1860, 1864, 1871, 1879, 1883, + 1887, 1891, 1898, 1902, 1909, 1910, 1916, 1924, 1925, 1931, + 1940, 1947, 1951, 1955, 1963, 1962, 1984, 1988, 1994, 2003, + 2004, 2005, 2009, 2013, 2017, 2021, 2025, 2029, 2034, 2039, + 2044, 2049, 2054, 2058, 2063, 2072, 2077, 2085, 2089, 2094, + 2098, 2103, 2111, 2121, 2121, 2131, 2132, 2136, 2139, 2142, + 2145, 2148, 2151, 2154, 2157, 2160, 2160, 2160, 2161, 2161, + 2161, 2161, 2162, 2162, 2162, 2162, 2162, 2163, 2163, 2163, + 2164, 2164, 2164, 2164, 2164, 2165, 2165, 2165, 2165, 2165, + 2166, 2166, 2166, 2166, 2166, 2167, 2167, 2167, 2168, 2168, + 2168, 2168, 2168, 2169, 2169, 2169, 2170, 2170, 2170, 2170, + 2171, 2171, 2171, 2172, 2172, 2172, 2172, 2172, 2173, 2173, + 2173, 2173, 2174, 2174, 2174, 2174, 2174, 2175, 2175, 2175, + 2175, 2175, 2175, 2176, 2176, 2176, 2176, 2176, 2177, 2178, + 2181, 2181, 2181, 2181, 2181, 2181, 2181, 2181, 2181, 2181, + 2181, 2182, 2182, 2182, 2182, 2182, 2182, 2182, 2182, 2182, + 2182, 2183, 2183, 2187, 2191, 2198, 2202, 2209, 2213, 2220, + 2224, 2228, 2232, 2236, 2240, 2244, 2248, 2260, 2264, 2268, + 2272, 2276, 2280, 2284, 2288, 2292, 2296, 2300, 2304, 2308, + 2312, 2316, 2320, 2324, 2328, 2332, 2336, 2340, 2344, 2348, + 2352, 2356, 2364, 2368, 2372, 2376, 2380, 2387, 2393, 2399, + 2405, 2411, 2417, 2423, 2430, 2437, 2444, 2451, 2457, 2463, + 2467, 2471, 2475, 2479, 2483, 2495, 2499, 2503, 2507, 2511, + 2515, 2519, 2523, 2527, 2531, 2535, 2539, 2543, 2547, 2551, + 2555, 2559, 2563, 2567, 2571, 2575, 2579, 2583, 2587, 2591, + 2595, 2599, 2606, 2610, 2614, 2618, 2622, 2626, 2630, 2644, + 2648, 2652, 2656, 2660, 2664, 2668, 2672, 2676, 2680, 2692, + 2696, 2700, 2704, 2708, 2712, 2716, 2720, 2724, 2728, 2732, + 2736, 2740, 2744, 2748, 2752, 2756, 2760, 2764, 2768, 2772, + 2776, 2780, 2784, 2788, 2792, 2799, 2803, 2807, 2811, 2815, + 2819, 2826, 2834, 2842, 2865, 2869, 2876, 2880, 2886 }; #endif @@ -1137,8 +1145,8 @@ static const char *const yytname[] = "TIMESEQUAL", "DIVIDEEQUAL", "MODEQUAL", "PLUSEQUAL", "MINUSEQUAL", "OREQUAL", "ANDEQUAL", "XOREQUAL", "LSHIFTEQUAL", "RSHIFTEQUAL", "KW_BEGIN_PUBLISH", "KW_BLOCKING", "KW_BOOL", "KW_CATCH", "KW_CHAR", - "KW_WCHAR_T", "KW_CLASS", "KW_CONST", "KW_DELETE", "KW_DOUBLE", - "KW_DYNAMIC_CAST", "KW_ELSE", "KW_END_PUBLISH", "KW_ENUM", + "KW_CHAR16_T", "KW_CHAR32_T", "KW_CLASS", "KW_CONST", "KW_DELETE", + "KW_DOUBLE", "KW_DYNAMIC_CAST", "KW_ELSE", "KW_END_PUBLISH", "KW_ENUM", "KW_EXTENSION", "KW_EXTERN", "KW_EXPLICIT", "KW_PUBLISHED", "KW_FALSE", "KW_FLOAT", "KW_FRIEND", "KW_FOR", "KW_GOTO", "KW_IF", "KW_INLINE", "KW_INT", "KW_LONG", "KW_LONGLONG", "KW_MAKE_PROPERTY", "KW_MAKE_SEQ", @@ -1147,13 +1155,14 @@ static const char *const yytname[] = "KW_SHORT", "KW_SIGNED", "KW_SIZEOF", "KW_STATIC", "KW_STATIC_CAST", "KW_STRUCT", "KW_TEMPLATE", "KW_THROW", "KW_TRUE", "KW_TRY", "KW_TYPEDEF", "KW_TYPENAME", "KW_UNION", "KW_UNSIGNED", "KW_USING", - "KW_VIRTUAL", "KW_VOID", "KW_VOLATILE", "KW_WHILE", "START_CPP", - "START_CONST_EXPR", "START_TYPE", "'{'", "','", "';'", "':'", "'='", - "'?'", "'|'", "'^'", "'&'", "'<'", "'>'", "'+'", "'-'", "'*'", "'/'", - "'%'", "'~'", "'.'", "'('", "'['", "')'", "'}'", "'!'", "']'", "$accept", - "grammar", "cpp", "constructor_inits", "constructor_init", "extern_c", - "$@1", "declaration", "friend_declaration", "$@2", "storage_class", - "type_like_declaration", "multiple_var_declaration", "$@3", "$@4", + "KW_VIRTUAL", "KW_VOID", "KW_VOLATILE", "KW_WCHAR_T", "KW_WHILE", + "START_CPP", "START_CONST_EXPR", "START_TYPE", "'{'", "','", "';'", + "':'", "'='", "'?'", "'|'", "'^'", "'&'", "'<'", "'>'", "'+'", "'-'", + "'*'", "'/'", "'%'", "'~'", "'.'", "'('", "'['", "')'", "'}'", "'!'", + "']'", "$accept", "grammar", "cpp", "constructor_inits", + "constructor_init", "extern_c", "$@1", "declaration", + "friend_declaration", "$@2", "storage_class", "type_like_declaration", + "multiple_var_declaration", "$@3", "$@4", "multiple_instance_identifiers", "multiple_const_instance_identifiers", "typedef_declaration", "$@5", "$@6", "typedef_instance_identifiers", "typedef_const_instance_identifiers", "function_prototype", "$@7", "$@8", @@ -1170,15 +1179,14 @@ static const char *const yytname[] = "empty_instance_identifier", "type", "type_decl", "predefined_type", "full_type", "anonymous_struct", "$@16", "named_struct", "$@17", "maybe_class_derivation", "class_derivation", "base_specification", - "anonymous_enum", "$@18", "named_enum", "$@19", - "enum_body_trailing_comma", "enum_body", "enum_keyword", - "struct_keyword", "namespace_declaration", "$@20", "using_declaration", - "simple_type", "simple_int_type", "simple_float_type", - "simple_void_type", "code", "$@21", "code_block", "element", - "optional_const_expr", "optional_const_expr_comma", "const_expr_comma", - "no_angle_bracket_const_expr", "const_expr", "const_operand", - "formal_const_expr", "formal_const_operand", "class_derivation_name", - "name", "string", "empty", YY_NULL + "enum", "enum_decl", "enum_element_type", "enum_body_trailing_comma", + "enum_body", "enum_keyword", "struct_keyword", "namespace_declaration", + "$@18", "using_declaration", "simple_type", "simple_int_type", + "simple_float_type", "simple_void_type", "code", "$@19", "code_block", + "element", "optional_const_expr", "optional_const_expr_comma", + "const_expr_comma", "no_angle_bracket_const_expr", "const_expr", + "const_operand", "formal_const_expr", "formal_const_operand", + "class_derivation_name", "name", "string", "empty", YY_NULL }; #endif @@ -1197,70 +1205,71 @@ static const yytype_uint16 yytoknum[] = 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 123, 44, 59, 58, 61, - 63, 124, 94, 38, 60, 62, 43, 45, 42, 47, - 37, 126, 46, 40, 91, 41, 125, 33, 93 + 355, 356, 357, 358, 359, 360, 361, 123, 44, 59, + 58, 61, 63, 124, 94, 38, 60, 62, 43, 45, + 42, 47, 37, 126, 46, 40, 91, 41, 125, 33, + 93 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 129, 130, 130, 130, 131, 131, 131, 132, 132, - 133, 135, 134, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 138, - 137, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 140, 140, 140, 142, 141, 143, 141, - 144, 144, 145, 145, 147, 146, 148, 146, 146, 149, - 149, 150, 150, 152, 151, 153, 151, 154, 151, 155, - 151, 156, 151, 157, 151, 158, 151, 151, 159, 159, - 159, 159, 159, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 161, 161, 163, 162, 164, 164, 165, 165, - 166, 166, 166, 166, 166, 166, 167, 167, 167, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 169, - 168, 170, 170, 170, 170, 170, 171, 171, 172, 172, - 173, 173, 174, 174, 174, 174, 174, 175, 175, 175, - 176, 176, 176, 176, 177, 177, 177, 177, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 179, 179, 179, - 179, 179, 179, 179, 179, 179, 179, 179, 180, 180, - 180, 180, 180, 180, 180, 180, 181, 181, 181, 181, - 181, 181, 181, 181, 181, 182, 182, 182, 182, 182, - 182, 182, 182, 182, 183, 183, 183, 183, 183, 184, - 184, 186, 185, 188, 187, 189, 189, 190, 190, 191, - 191, 191, 191, 191, 191, 191, 191, 191, 193, 192, - 195, 194, 196, 196, 196, 197, 197, 197, 198, 199, - 199, 199, 201, 200, 200, 202, 202, 203, 203, 203, - 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, - 204, 204, 204, 205, 205, 205, 205, 205, 206, 208, - 207, 209, 209, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 211, 211, 212, - 212, 213, 213, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 215, 215, 215, 215, + 0, 131, 132, 132, 132, 133, 133, 133, 134, 134, + 135, 137, 136, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 140, + 139, 141, 141, 141, 141, 141, 141, 141, 141, 141, + 141, 141, 141, 142, 142, 142, 144, 143, 145, 143, + 146, 146, 147, 147, 149, 148, 150, 148, 148, 151, + 151, 152, 152, 154, 153, 155, 153, 156, 153, 157, + 153, 158, 153, 159, 153, 160, 153, 153, 161, 161, + 161, 161, 161, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 163, 163, 165, 164, 166, 166, 167, 167, + 168, 168, 168, 168, 168, 168, 169, 169, 169, 170, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 171, + 170, 172, 172, 172, 172, 172, 173, 173, 174, 174, + 175, 175, 176, 176, 176, 176, 176, 177, 177, 177, + 178, 178, 178, 178, 179, 179, 179, 179, 180, 180, + 180, 180, 180, 180, 180, 180, 180, 181, 181, 181, + 181, 181, 181, 181, 181, 181, 181, 181, 182, 182, + 182, 182, 182, 182, 182, 182, 183, 183, 183, 183, + 183, 183, 183, 183, 184, 184, 184, 184, 184, 184, + 184, 184, 184, 185, 185, 185, 185, 185, 186, 186, + 188, 187, 190, 189, 191, 191, 192, 192, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 194, 195, 195, + 195, 195, 196, 196, 197, 197, 197, 198, 198, 198, + 199, 200, 200, 200, 202, 201, 201, 203, 203, 204, + 204, 204, 205, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 205, 205, 205, 205, 205, 206, 206, 206, + 206, 206, 207, 209, 208, 210, 210, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 212, 212, 213, 213, 214, 214, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 216, 216, 216, 216, 216, 216, - 216, 217, 217, 217, 217, 217, 217, 217, 217, 217, - 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, - 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, - 217, 217, 217, 217, 217, 217, 217, 218, 218, 218, - 218, 218, 218, 219, 219, 219, 220, 220, 221, 221, - 222 + 215, 215, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 216, 217, 217, 217, 217, 217, 217, 217, 218, + 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + 218, 218, 218, 218, 218, 219, 219, 219, 219, 219, + 219, 220, 220, 220, 221, 221, 222, 222, 223 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -1287,15 +1296,15 @@ static const yytype_uint8 yyr2[] = 1, 2, 2, 2, 2, 3, 4, 1, 1, 1, 2, 2, 2, 2, 3, 4, 7, 3, 1, 2, 2, 2, 2, 3, 4, 7, 1, 1, 2, 1, - 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, - 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, - 3, 0, 5, 0, 7, 1, 1, 2, 3, 2, - 2, 2, 3, 3, 3, 3, 3, 3, 0, 5, - 0, 6, 1, 3, 5, 1, 2, 4, 1, 1, - 1, 1, 0, 6, 4, 2, 3, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 2, 2, 1, 2, 1, 3, 2, 1, 0, - 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 4, 1, 1, 2, 1, 1, 1, + 2, 4, 2, 1, 1, 2, 2, 2, 2, 3, + 0, 5, 0, 7, 1, 1, 2, 3, 2, 2, + 2, 3, 3, 3, 3, 3, 3, 4, 4, 2, + 3, 1, 1, 1, 1, 3, 5, 1, 2, 4, + 1, 1, 1, 1, 0, 6, 4, 2, 3, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 2, 2, 2, 1, 2, 1, + 3, 2, 1, 0, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1305,22 +1314,22 @@ static const yytype_uint8 yyr2[] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, - 1, 1, 3, 1, 4, 7, 7, 4, 2, 2, - 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, - 4, 4, 3, 3, 3, 3, 1, 4, 7, 7, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 1, 1, 1, 1, 1, 3, 1, + 4, 7, 7, 4, 2, 2, 2, 2, 2, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, + 3, 3, 1, 4, 7, 7, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 2, 5, 2, 2, 2, 2, 2, 3, + 2, 5, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, - 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, - 1, 1, 4, 7, 7, 4, 2, 5, 2, 2, - 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, + 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 4, 7, 7, 4, 2, 5, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 5, 4, 4, 3, 3, 3, 3, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, - 0 + 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, + 4, 3, 3, 3, 3, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 1, 1, 1, 2, 0 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. @@ -1328,1085 +1337,1095 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint16 yydefact[] = { - 0, 540, 0, 0, 0, 540, 5, 488, 484, 487, - 538, 490, 0, 0, 0, 0, 0, 0, 486, 0, - 0, 0, 0, 0, 0, 0, 0, 485, 0, 0, - 0, 0, 0, 0, 0, 3, 436, 489, 207, 270, - 271, 272, 259, 0, 285, 258, 283, 278, 274, 275, - 273, 277, 260, 0, 261, 276, 288, 540, 4, 209, - 210, 211, 212, 0, 0, 206, 267, 268, 269, 1, - 20, 21, 0, 29, 0, 0, 0, 0, 0, 0, - 124, 540, 0, 6, 15, 7, 18, 0, 13, 43, - 14, 16, 17, 31, 540, 540, 540, 540, 540, 0, - 540, 540, 540, 225, 0, 452, 0, 0, 224, 540, - 540, 0, 0, 540, 458, 456, 457, 455, 207, 270, - 271, 272, 285, 283, 278, 274, 273, 277, 276, 0, - 0, 401, 454, 0, 0, 0, 0, 0, 0, 0, + 0, 548, 0, 0, 0, 548, 5, 496, 492, 495, + 546, 498, 0, 0, 0, 0, 0, 0, 0, 494, + 0, 0, 0, 0, 0, 0, 0, 0, 493, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 442, 497, + 207, 272, 273, 275, 276, 261, 0, 289, 260, 287, + 282, 278, 279, 277, 281, 262, 0, 263, 280, 292, + 274, 548, 4, 209, 210, 211, 0, 251, 0, 206, + 269, 270, 271, 1, 20, 21, 0, 29, 0, 0, + 0, 0, 0, 0, 124, 548, 0, 6, 15, 7, + 18, 0, 13, 43, 14, 16, 17, 31, 548, 548, + 548, 548, 548, 548, 0, 548, 548, 548, 224, 0, + 460, 0, 0, 223, 548, 548, 0, 0, 548, 548, + 466, 464, 465, 463, 207, 272, 273, 275, 276, 289, + 287, 282, 278, 277, 281, 280, 274, 0, 0, 407, + 462, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 539, 540, 287, 284, - 274, 280, 274, 279, 282, 536, 537, 208, 281, 0, - 540, 540, 540, 540, 540, 229, 198, 248, 214, 231, - 213, 22, 540, 0, 0, 540, 0, 25, 24, 23, - 0, 0, 19, 0, 265, 77, 216, 41, 0, 42, - 32, 37, 35, 39, 0, 40, 34, 0, 36, 38, - 11, 0, 0, 46, 218, 219, 220, 221, 0, 0, - 215, 0, 400, 399, 0, 0, 0, 0, 0, 0, - 0, 0, 226, 540, 228, 227, 0, 0, 0, 0, - 0, 0, 0, 483, 467, 468, 469, 470, 471, 472, - 475, 476, 482, 0, 464, 465, 466, 473, 474, 462, - 463, 459, 460, 461, 481, 480, 0, 0, 230, 286, - 540, 202, 199, 201, 200, 0, 540, 540, 250, 540, - 540, 30, 0, 0, 540, 262, 540, 0, 0, 54, - 266, 63, 65, 48, 33, 0, 540, 217, 540, 0, - 289, 162, 0, 0, 45, 44, 0, 223, 222, 440, - 444, 442, 443, 450, 0, 449, 441, 446, 0, 445, - 448, 451, 0, 447, 437, 402, 0, 479, 478, 203, - 0, 0, 398, 397, 255, 0, 252, 540, 540, 0, - 0, 236, 235, 0, 0, 264, 540, 137, 138, 0, - 0, 0, 0, 127, 128, 540, 136, 126, 56, 58, - 0, 540, 0, 0, 540, 0, 540, 179, 180, 0, - 540, 540, 540, 540, 0, 178, 540, 67, 0, 540, - 0, 8, 0, 540, 0, 0, 0, 0, 0, 0, - 0, 0, 47, 540, 139, 0, 453, 0, 477, 540, - 204, 256, 249, 0, 232, 0, 0, 0, 0, 237, - 540, 0, 0, 0, 540, 130, 540, 132, 540, 0, - 188, 189, 0, 540, 540, 540, 540, 540, 540, 187, - 0, 55, 540, 531, 527, 530, 540, 152, 0, 0, - 529, 0, 0, 0, 528, 0, 0, 0, 0, 0, - 0, 153, 156, 540, 177, 491, 532, 151, 0, 0, - 0, 49, 540, 0, 540, 184, 181, 183, 182, 73, - 540, 12, 540, 163, 290, 291, 289, 0, 540, 540, - 0, 168, 170, 167, 165, 0, 144, 141, 93, 94, - 95, 96, 97, 98, 101, 102, 117, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 121, - 120, 104, 103, 90, 92, 91, 99, 100, 88, 89, - 85, 86, 87, 84, 0, 0, 83, 140, 143, 142, - 0, 0, 0, 149, 540, 0, 50, 160, 0, 0, - 0, 253, 0, 251, 0, 0, 0, 241, 533, 0, - 240, 0, 239, 0, 0, 0, 540, 238, 0, 0, - 0, 263, 0, 540, 0, 0, 122, 125, 123, 129, - 540, 193, 190, 192, 191, 0, 0, 540, 134, 158, - 57, 540, 0, 59, 540, 540, 0, 496, 0, 0, - 501, 500, 499, 0, 0, 498, 540, 155, 0, 540, + 0, 0, 0, 0, 547, 548, 291, 288, 278, 284, + 278, 283, 286, 544, 545, 208, 285, 0, 548, 548, + 548, 548, 548, 228, 198, 548, 0, 249, 230, 212, + 22, 548, 0, 0, 548, 0, 25, 24, 23, 0, + 0, 19, 0, 267, 77, 215, 41, 0, 42, 32, + 37, 35, 39, 0, 40, 34, 0, 36, 38, 11, + 0, 0, 46, 217, 218, 219, 251, 0, 214, 0, + 406, 405, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 225, 548, 227, 226, 0, 0, 0, 0, 0, + 0, 0, 0, 491, 475, 476, 477, 478, 479, 480, + 483, 484, 490, 0, 472, 473, 474, 481, 482, 470, + 471, 467, 468, 469, 489, 488, 0, 0, 229, 290, + 548, 202, 199, 201, 200, 0, 548, 257, 0, 254, + 253, 250, 252, 0, 548, 548, 30, 0, 0, 548, + 264, 548, 0, 0, 54, 268, 63, 65, 48, 33, + 0, 548, 216, 548, 0, 293, 162, 0, 0, 45, + 44, 0, 222, 220, 446, 452, 448, 450, 451, 458, + 0, 457, 447, 454, 0, 453, 456, 459, 0, 455, + 449, 443, 408, 0, 487, 486, 203, 0, 0, 404, + 403, 258, 247, 213, 548, 0, 0, 235, 234, 0, + 0, 266, 548, 137, 138, 0, 0, 0, 0, 127, + 128, 548, 136, 126, 56, 58, 0, 548, 0, 0, + 548, 0, 548, 179, 180, 0, 548, 548, 548, 548, + 0, 178, 548, 67, 0, 548, 0, 8, 0, 548, + 0, 0, 0, 0, 0, 0, 0, 0, 47, 548, + 139, 0, 0, 461, 0, 485, 548, 204, 255, 0, + 231, 0, 0, 0, 0, 236, 548, 0, 0, 0, + 548, 130, 548, 132, 548, 0, 188, 189, 0, 548, + 548, 548, 548, 548, 548, 187, 0, 55, 548, 539, + 535, 538, 548, 152, 0, 0, 537, 0, 0, 0, + 536, 0, 0, 0, 0, 0, 0, 153, 156, 548, + 177, 499, 540, 151, 0, 0, 0, 49, 548, 0, + 548, 184, 181, 183, 182, 73, 548, 12, 548, 163, + 294, 295, 293, 0, 548, 548, 0, 168, 170, 167, + 165, 0, 144, 141, 93, 94, 95, 96, 97, 98, + 101, 102, 117, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 121, 120, 104, 103, 90, + 92, 91, 99, 100, 88, 89, 85, 86, 87, 84, + 0, 0, 83, 140, 143, 142, 0, 0, 0, 149, + 548, 0, 50, 160, 221, 0, 0, 0, 259, 0, + 0, 0, 240, 541, 0, 239, 0, 238, 0, 0, + 0, 548, 237, 0, 0, 0, 265, 0, 548, 0, + 0, 122, 125, 123, 129, 548, 193, 190, 192, 191, + 0, 0, 548, 134, 158, 57, 548, 0, 59, 548, + 548, 0, 504, 0, 0, 509, 508, 507, 0, 0, + 506, 548, 155, 0, 548, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 540, 0, 52, 75, - 185, 540, 0, 0, 293, 294, 296, 295, 300, 297, - 298, 299, 301, 302, 303, 304, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, - 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, - 353, 339, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 373, 350, 351, 352, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, - 368, 369, 370, 371, 372, 540, 390, 391, 392, 383, - 395, 379, 380, 378, 385, 386, 374, 375, 376, 377, - 384, 382, 389, 387, 393, 388, 381, 394, 292, 0, - 9, 0, 0, 166, 169, 145, 119, 118, 148, 147, - 161, 540, 0, 0, 439, 438, 540, 257, 535, 247, - 534, 246, 245, 244, 243, 242, 234, 0, 26, 0, - 131, 135, 133, 194, 197, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 159, 403, 0, 0, 61, 0, - 0, 175, 540, 0, 540, 0, 0, 0, 526, 79, - 64, 78, 154, 157, 174, 510, 511, 512, 513, 514, - 515, 518, 519, 525, 0, 507, 508, 509, 516, 517, - 505, 506, 502, 503, 504, 524, 523, 0, 0, 0, - 69, 66, 0, 540, 0, 186, 540, 0, 164, 10, - 171, 540, 172, 0, 146, 51, 205, 254, 0, 0, - 540, 0, 0, 0, 412, 410, 411, 409, 0, 0, - 408, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 548, 0, 52, 75, 185, 548, 0, 0, 297, + 298, 300, 299, 304, 301, 302, 303, 305, 306, 307, + 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, + 328, 329, 330, 331, 332, 333, 334, 336, 337, 338, + 339, 340, 341, 342, 343, 344, 359, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 379, 356, + 357, 358, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 335, 378, 548, 396, 397, 398, 389, 401, 385, 386, + 384, 391, 392, 380, 381, 382, 383, 390, 388, 395, + 393, 399, 394, 387, 400, 296, 0, 9, 0, 0, + 166, 169, 145, 119, 118, 148, 147, 161, 548, 0, + 0, 445, 444, 548, 256, 543, 246, 542, 245, 244, + 243, 242, 241, 233, 0, 26, 0, 131, 135, 133, + 194, 197, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 159, 409, 0, 0, 61, 0, 0, 175, 548, + 0, 548, 0, 0, 0, 534, 79, 64, 78, 154, + 157, 174, 518, 519, 520, 521, 522, 523, 526, 527, + 533, 0, 515, 516, 517, 524, 525, 513, 514, 510, + 511, 512, 532, 531, 0, 0, 0, 69, 66, 0, + 548, 0, 186, 548, 0, 164, 10, 171, 548, 172, + 0, 146, 51, 205, 0, 0, 548, 0, 0, 0, + 418, 416, 417, 415, 0, 0, 414, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 195, 0, 60, 161, 176, 0, 0, 495, - 0, 492, 80, 0, 0, 522, 521, 71, 540, 53, - 0, 540, 68, 396, 0, 540, 27, 28, 0, 0, - 0, 0, 0, 435, 421, 422, 423, 424, 425, 426, - 427, 428, 434, 0, 418, 419, 420, 416, 417, 413, - 414, 415, 433, 432, 0, 0, 62, 0, 497, 0, - 0, 520, 540, 0, 540, 74, 173, 150, 540, 0, - 407, 0, 404, 0, 431, 430, 0, 0, 81, 0, - 0, 540, 76, 196, 0, 0, 429, 494, 493, 82, - 540, 70, 0, 0, 72, 406, 405 + 0, 0, 0, 0, 0, 0, 0, 0, 195, 0, + 60, 161, 176, 0, 0, 503, 0, 500, 80, 0, + 0, 530, 529, 71, 548, 53, 0, 548, 68, 402, + 0, 548, 27, 28, 0, 0, 0, 0, 0, 441, + 427, 428, 429, 430, 431, 432, 433, 434, 440, 0, + 424, 425, 426, 422, 423, 419, 420, 421, 439, 438, + 0, 0, 62, 0, 505, 0, 0, 528, 548, 0, + 548, 74, 173, 150, 548, 0, 413, 0, 410, 0, + 437, 436, 0, 0, 81, 0, 0, 548, 76, 196, + 0, 0, 435, 502, 501, 82, 548, 70, 0, 0, + 72, 412, 411 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 4, 5, 380, 381, 84, 298, 85, 86, 182, - 87, 88, 89, 306, 365, 392, 461, 192, 360, 430, - 431, 580, 212, 361, 364, 472, 898, 942, 631, 833, - 800, 527, 567, 90, 190, 352, 353, 354, 355, 393, - 751, 450, 451, 578, 535, 304, 480, 481, 452, 374, - 428, 175, 57, 213, 105, 58, 59, 279, 60, 280, - 340, 341, 409, 61, 277, 62, 337, 334, 335, 63, - 64, 91, 346, 92, 65, 66, 67, 68, 378, 379, - 474, 738, 331, 221, 222, 784, 131, 36, 454, 455, - 547, 394, 37, 223 + -1, 4, 5, 396, 397, 88, 313, 89, 90, 191, + 91, 92, 93, 321, 381, 408, 477, 201, 376, 446, + 447, 595, 221, 377, 380, 488, 914, 958, 646, 850, + 817, 543, 582, 94, 199, 368, 369, 370, 371, 409, + 768, 466, 467, 593, 551, 319, 496, 497, 468, 390, + 444, 183, 61, 222, 110, 62, 63, 294, 64, 295, + 356, 357, 425, 65, 66, 291, 287, 288, 67, 68, + 95, 362, 96, 69, 70, 71, 72, 394, 395, 490, + 755, 348, 229, 230, 801, 139, 38, 470, 471, 562, + 410, 39, 231 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -547 +#define YYPACT_NINF -491 static const yytype_int16 yypact[] = { - 136, -547, 2122, 3147, 45, 798, -547, -547, -547, -547, - -547, -547, -56, -40, 14, 31, 36, -65, -547, 41, - 56, 62, 3257, 78, 105, 118, -20, -547, 133, 2122, - 2122, 2122, 2122, 1297, 2122, 2640, -547, 116, -547, -547, - -547, -547, -547, 3312, -547, -547, -547, -547, 1915, -547, - 887, 887, -547, 28, -547, 887, -547, 79, -547, -547, - -547, -547, -547, 44, 69, -547, -547, -547, -547, -547, - -547, -547, 34, -547, 141, 147, 153, 145, 173, 193, - -547, -547, 77, -547, -547, -547, -547, 2374, -547, -547, - -547, -547, -547, -547, 2122, 2122, 2122, 2122, 2122, 3147, - 2122, 2122, 2122, -547, 28, 154, 28, 28, -547, 2122, - 2122, 3147, 3147, 2122, 123, 123, 123, 123, -56, -40, - 14, 31, 36, 41, 56, 2093, 1487, 1620, 1798, 182, - -74, 2640, 123, 2122, 2122, 2122, 2122, 2122, 2122, 2122, - 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, - 2122, 2122, 2122, 2122, 1588, 2122, -547, 79, -547, -547, - 1829, -547, 887, -547, -547, -547, -547, -547, -547, 190, - 79, 79, 79, 79, 79, 186, -547, -547, 230, -547, - -29, -547, 3518, 336, 28, -547, 246, -547, -547, -547, - 239, 2440, -547, 28, -547, 232, 238, -547, 3312, -547, - 356, -547, -547, -547, 3202, -547, -547, 28, -547, -547, - -547, 28, 340, 257, -547, -547, -547, -547, 44, 69, - -547, 242, 262, -547, 249, 252, 258, 268, 286, 272, - 277, 283, -547, 2122, -547, -547, 289, 291, 295, 314, - 315, 2122, 2122, -547, 1314, 2801, 2999, 2999, 683, 683, - 405, 405, -547, 2287, 2816, 2831, 2956, 683, 683, 169, - 169, 123, 123, 123, -547, -547, -41, 911, 186, -547, - 79, 186, 186, 186, 186, 6, 2122, -547, -547, -547, - 322, -547, 337, 338, 3342, -547, 3092, 3312, 340, -547, - -547, -547, 17, -547, 116, 3312, 82, -547, -547, 327, - -547, -547, 28, 1677, -547, -547, 578, 230, -29, -547, - -547, -547, -547, -547, 328, -547, -547, -547, 333, -547, - -547, -547, 339, -547, 123, 2640, 2122, -547, -547, 186, - 342, 332, 2640, -547, 28, 344, -547, -547, 3374, 306, - 361, 366, -547, 465, 28, -547, -547, -547, -547, 28, - 1740, 28, 359, 369, -547, 234, -547, -547, -547, -547, - 578, 1394, 358, 578, 1394, 578, 82, -547, -547, 363, - 82, 82, 82, 82, 52, -547, 3414, -547, 357, -547, - 83, -547, 362, 1766, 2585, 368, 578, 578, 2257, 578, - 578, 578, -547, 282, -547, 2122, -547, 2122, 2640, 1394, - -547, 120, -547, 364, -547, 699, 721, 1313, 261, -547, - -547, 306, -9, 381, 3446, 379, 234, 380, 402, 3092, - -547, -547, 378, 234, 234, 234, 234, 234, -80, -547, - 578, -547, 282, -547, -547, -547, 234, -547, 3312, 384, - -547, 3257, 382, 387, -547, 2122, 2122, 2122, 1297, 2122, - 377, 22, -547, 234, 2657, -547, 116, -547, 578, 287, - 386, -547, 282, 150, 82, 388, 388, 388, 388, -547, - 2122, -547, 1394, -547, 1170, -547, -547, 28, 2122, 1766, - 392, 397, 2640, -547, -547, 578, 175, 175, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, 389, 376, -547, -547, 175, 175, - 313, 305, 1677, -547, 2122, 400, -547, -547, 2, 9, - 395, -547, 2122, -547, 28, 254, 28, -547, -547, 254, - -547, 254, -547, 254, 254, 254, 3486, -547, 518, 423, - 28, -547, 3147, -80, 3147, 2497, -547, -547, -547, -547, - 234, 407, 407, 407, 407, 142, 656, 2122, -547, -547, - -547, 282, 430, -547, -36, 234, 3147, 416, 3147, 3147, - 123, 123, 123, 417, 11, 123, 491, -547, 1491, -36, - 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, - 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, 2122, - 2122, 1855, 2122, 331, 539, 422, 491, 442, -547, -547, - 388, 1394, 425, 429, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, -547, - -547, -547, -547, -547, -547, -547, -547, -547, -547, 424, - -547, 432, 434, -547, 1944, 175, -547, -547, -547, -547, - 2585, 1394, 433, 578, -547, -547, 491, 2606, -547, -547, - -547, -547, -547, -547, -547, -547, -547, 438, -547, 439, - -547, -547, -547, 407, 450, 460, 452, 463, 656, 656, - 656, 656, 1297, 656, 2786, -547, 451, 472, -547, 578, - 2122, -547, -36, 466, 2122, 457, 470, 2122, -547, -547, - 19, -547, -547, -547, -547, 1314, 2801, 2999, 2999, 683, - 683, 405, 405, -547, 2623, 2816, 2831, 2956, 683, 683, - 169, 169, 123, 123, 123, -547, -547, 38, 2207, 467, - -547, 19, 578, 1394, 464, -547, 491, 1044, -547, -547, - -547, 1766, 2640, 469, -547, -547, 19, -547, 489, 490, - 1394, 3147, 3147, 3147, 137, 137, 137, 137, 474, 61, - 137, 656, 656, 656, 656, 656, 656, 656, 656, 656, - 656, 656, 656, 656, 656, 656, 656, 656, 656, 656, - 2033, 2122, -547, 578, -547, 2640, -547, 477, 476, -547, - 480, 123, -547, 483, 2122, -547, -547, -547, 1394, -547, - 482, 491, 19, -547, 484, 491, -547, -547, 486, 493, - 488, 494, 656, -547, 1508, 2846, 3012, 3012, 766, 766, - 517, 517, -547, 2769, 2971, 2986, 603, 448, 448, 137, - 137, 137, -547, -547, 71, 2237, -547, 2122, -547, 2122, - 16, 2640, 1394, 502, 491, 19, -547, 19, 491, 506, - -547, 508, 137, 656, -547, -547, 125, 130, -547, 519, - 520, 491, 19, 19, 2122, 2122, 2786, -547, -547, -547, - 491, 19, 143, 146, 19, -547, -547 + 252, -491, 2070, 3145, 17, 3049, -491, -491, -491, -491, + -491, -491, -99, -95, -74, -54, -48, 12, -23, -491, + 14, 46, 57, 3257, 62, 75, 82, 94, -491, 105, + 115, 2070, 2070, 2070, 2070, 1230, 2070, 2712, -491, 208, + -491, -491, -491, -491, -491, -491, 3313, -491, -491, -491, + -491, 1681, -491, 1861, 1861, -491, 96, -491, 1861, -491, + -491, 184, -491, -491, -491, -491, 137, 11, 29, -491, + -491, -491, -491, -491, -491, -491, -47, -491, 131, 156, + 31, 173, 193, 198, -491, -491, 60, -491, -491, -491, + -491, 2407, -491, -491, -491, -491, -491, -491, 2070, 2070, + 2070, 2070, 2070, 2070, 3145, 2070, 2070, 2070, -491, 96, + 191, 96, 96, -491, 2070, 2070, 3145, 3145, 2070, 2070, + -6, -6, -6, -6, -99, -95, -74, -54, -48, 12, + 14, 46, 2041, 2334, 3302, 3506, 115, 192, -61, 2712, + -6, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, + 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, + 2070, 2070, 1530, 2070, -491, 184, -491, -491, 1771, -491, + 1861, -491, -491, -491, -491, -491, -491, 201, 184, 184, + 184, 184, 184, 197, -491, -491, 3246, 236, -491, -85, + -491, 3538, 320, 96, -491, 241, -491, -491, -491, 244, + 2474, -491, 96, -491, 246, 249, -491, 3313, -491, 363, + -491, -491, -491, 3201, -491, -491, 96, -491, -491, -491, + 96, 167, 273, -491, -491, -491, 11, 29, -491, 268, + 292, -491, 274, 276, 277, 280, 283, 300, 291, 297, + 299, -491, 2070, -491, -491, 301, 305, 307, 310, 309, + 325, 2070, 2070, -491, 1247, 819, 556, 556, 1483, 1483, + 216, 216, -491, 2564, 2132, 2874, 2904, 1483, 1483, 406, + 406, -6, -6, -6, -491, -491, -55, 2162, 197, -491, + 184, 197, 197, 197, 197, -13, 2070, 96, 281, -491, + -491, -491, -491, 3246, -491, 345, -491, 350, 351, 3350, + -491, 3136, 3313, 167, -491, -491, -491, 3, -491, 208, + 3313, 282, -491, -491, 328, -491, -491, 96, 1620, -491, + -491, 224, -51, -85, -491, -491, -491, -491, -491, -491, + 335, -491, -491, -491, 337, -491, -491, -491, 341, -491, + -491, -6, 2712, 2070, -491, -491, 197, 342, 346, 2712, + -491, 54, -491, 365, 3377, 168, 366, 367, -491, 470, + 96, -491, -491, -491, -491, 96, 2325, 96, 364, 372, + -491, 207, -491, -491, -491, -491, 224, 1330, 370, 224, + 1330, 224, 282, -491, -491, 371, 282, 282, 282, 282, + 237, -491, 3404, -491, 356, -491, 89, -491, 368, 1710, + 2631, 378, 224, 224, 2324, 224, 224, 224, -491, 204, + -491, 3246, 2070, -491, 2070, 2712, 1330, -491, -491, 2070, + -491, 1199, 1348, 1448, 286, -491, -491, 168, -53, 393, + 3431, 391, 207, 392, 420, 3136, -491, -491, 398, 207, + 207, 207, 207, 207, 139, -491, 224, -491, 204, -491, + -491, -491, 207, -491, 3313, 403, -491, 3257, 395, 405, + -491, 2070, 2070, 2070, 1230, 2070, 396, -2, -491, 207, + 2745, -491, 208, -491, 224, 295, 407, -491, 204, 264, + 282, 399, 399, 399, 399, -491, 2070, -491, 1330, -491, + 1102, -491, -491, 96, 2070, 1710, 408, 425, 2712, -491, + -491, 224, 267, 267, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + 411, 409, -491, -491, 267, 267, 344, 343, 1620, -491, + 2070, 427, -491, -491, 365, -44, -32, 413, 2678, 96, + 123, 96, -491, -491, 123, -491, 123, -491, 123, 123, + 123, 3458, -491, 533, 433, 96, -491, 3145, 139, 3145, + 2541, -491, -491, -491, -491, 207, 418, 418, 418, 418, + 144, 651, 2070, -491, -491, -491, 204, 437, -491, 169, + 207, 3145, 421, 3145, 3145, -6, -6, -6, 426, 128, + -6, 496, -491, 1430, 169, 2070, 2070, 2070, 2070, 2070, + 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, + 2070, 2070, 2070, 2070, 2070, 2070, 1800, 2070, 389, 550, + 431, 496, 450, -491, -491, 399, 1330, 432, 439, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, -491, -491, 436, -491, 440, 453, + -491, 1890, 267, -491, -491, -491, -491, 2631, 1330, 452, + 224, -491, -491, 496, -491, -491, -491, -491, -491, -491, + -491, -491, -491, -491, 456, -491, 459, -491, -491, -491, + 418, 463, 478, 472, 484, 651, 651, 651, 651, 1230, + 651, 2859, -491, 473, 498, -491, 224, 2070, -491, 169, + 487, 2070, 480, 492, 2070, -491, -491, -10, -491, -491, + -491, -491, 1247, 819, 556, 556, 1483, 1483, 216, 216, + -491, 2695, 2132, 2874, 2904, 1483, 1483, 406, 406, -6, + -6, -6, -491, -491, 134, 2187, 489, -491, -10, 224, + 1330, 485, -491, 496, 974, -491, -491, -491, 1710, 2712, + 509, -491, -491, -10, 529, 530, 1330, 3145, 3145, 3145, + 138, 138, 138, 138, 515, 145, 138, 651, 651, 651, + 651, 651, 651, 651, 651, 651, 651, 651, 651, 651, + 651, 651, 651, 651, 651, 651, 1980, 2070, -491, 224, + -491, 2712, -491, 518, 519, -491, 522, -6, -491, 524, + 2070, -491, -491, -491, 1330, -491, 525, 496, -10, -491, + 523, 496, -491, -491, 526, 541, 535, 549, 651, -491, + 1447, 2889, 780, 780, 1522, 1522, 387, 387, -491, 2826, + 2938, 3016, 3050, 543, 543, 138, 138, 138, -491, -491, + 146, 2206, -491, 2070, -491, 2070, 7, 2712, 1330, 544, + 496, -10, -491, -10, 496, 554, -491, 558, 138, 651, + -491, -491, 174, 179, -491, 557, 559, 496, -10, -10, + 2070, 2070, 2859, -491, -491, -491, 496, -10, 180, 218, + -10, -491, -491 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -547, -547, -159, -547, 139, -547, -547, 461, -547, -547, - -60, 196, -547, -547, -547, -107, -181, -547, -547, -547, - -136, -220, 475, -547, -547, -547, -547, -547, -547, -547, - -502, -547, -547, 247, -547, -547, -547, 248, 319, -332, - -547, -351, -547, 131, -416, -238, -461, -547, 95, -331, - -313, -110, -5, 504, 256, -30, -86, -547, -85, -547, - -547, -547, 294, -73, -547, -72, -547, -547, 373, -13, - 103, -547, -547, -547, 0, 20, -547, -547, 222, -547, - -15, -547, -427, -90, -16, 134, 70, -546, -547, -547, - -249, 431, -134, -1 + -491, -491, -102, -491, 194, -491, -491, 469, -491, -491, + -79, 251, -491, -491, -491, -82, -159, -491, -491, -491, + -117, -208, 494, -491, -491, -491, -491, -491, -491, -491, + -316, -491, -491, 258, -491, -491, -491, 260, 330, -306, + -491, -362, -491, 119, -413, -279, -490, -491, 85, -160, + -354, -71, -5, 499, 243, -14, -88, -491, -84, -491, + -491, -491, 275, -83, -491, -284, -491, -491, -11, -9, + -491, -491, -491, -12, 71, -491, -491, 209, -491, -29, + -491, -459, -57, -34, -4, 0, -62, -491, -491, -394, + 157, -157, -1 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -234 +#define YYTABLE_NINF -250 static const yytype_int16 yytable[] = { - 6, 214, 215, 129, 93, 224, 225, 226, 227, 106, - 229, 230, 231, 460, 216, 217, 582, 130, 742, 236, - 237, 191, 108, 240, 165, 166, 284, 362, 432, 576, - 785, 459, 242, 462, 597, 463, 165, 166, 157, 465, - 466, 467, 468, 632, 577, 69, 627, 268, 540, 99, - 359, 243, 165, 166, 486, 487, 176, 528, 529, 530, - 271, 272, 273, 274, 275, 242, 294, 94, 161, 228, - 163, 164, 35, 790, 218, 168, -233, 165, 166, -233, - 93, 238, 239, 95, 327, 165, 166, 220, 577, 169, - 367, 368, 369, 170, 112, 892, 370, 558, 581, 114, - 115, 116, 117, 563, 132, 214, 215, 752, 242, 893, - 571, 572, 573, 574, 575, 242, 559, 242, 216, 217, - 338, 633, 156, 584, 831, 107, 623, 754, 598, 171, - 276, 330, 371, 630, 755, 363, 798, 96, 266, 376, - 599, 958, 181, 318, 242, 161, 163, 164, 168, 177, - 786, 193, 141, 745, 97, 536, 176, 550, 552, 98, - 329, 165, 166, 895, 100, 787, 869, 242, 791, 176, - 176, 176, 176, 176, 179, 469, 470, 242, 218, 101, - 161, 93, 161, 804, 6, 102, 913, 414, 476, 477, - 219, 220, 172, 293, 583, 372, 954, 173, 141, 296, - 373, 109, 174, 244, 245, 246, 247, 248, 249, 250, - 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, - 261, 262, 263, 264, 628, 267, 541, 456, 110, 542, - 456, 242, 785, 785, 785, 785, 242, 785, 1, 2, - 3, 111, 420, 421, 422, 153, 154, 155, 423, 242, - 967, 556, 242, 187, 846, 968, 113, 773, 185, 879, - 880, 881, 165, 166, 183, 456, 577, 774, 975, 176, - 184, 976, 792, 629, 470, 333, 336, 233, 6, 342, - 834, 188, 358, 93, 424, 357, 356, 150, 151, 152, - 366, 153, 154, 155, 219, 375, 759, 6, 533, 534, - 761, 189, 762, 42, 763, 764, 765, 241, 270, 749, - 276, 324, 325, 165, 166, 785, 785, 785, 785, 785, - 785, 785, 785, 785, 785, 785, 785, 785, 785, 785, - 785, 785, 785, 785, 902, 278, 336, 93, 456, 553, - 554, 555, 52, 788, 282, 6, 332, 425, 544, 54, - 356, 285, 426, 286, 429, 291, 453, 427, 565, 453, - 457, 292, 10, 457, 305, 375, 785, 309, 242, 375, - 375, 375, 375, 384, 310, 93, 886, 311, 475, 538, - 904, 539, 483, 312, 405, 406, 407, 300, 741, 301, - 531, 532, 537, 313, 453, 624, 398, 315, 457, 945, - 843, 314, 316, 947, 408, 533, 534, 785, 317, 6, - 533, 534, 625, 93, 319, 429, 320, 93, 593, 356, - 321, 624, 429, 429, 429, 429, 429, 579, 106, 322, - 339, 537, 594, 585, 141, 429, 533, 534, 748, 624, - 323, 108, 962, 343, 344, 300, 963, 301, 302, 303, - 377, 395, 429, 482, 533, 534, 829, 432, 396, 971, - 400, 537, 397, 375, 456, 399, 410, 453, 974, 333, - 402, 457, 411, 412, 418, 419, 458, 869, 483, 214, - 215, 464, 900, 473, 167, 478, 485, 560, 562, 564, - 543, 80, 216, 217, 178, 180, 570, 456, 586, 908, - 462, 589, 596, 744, 747, 588, 753, 186, 546, 546, - 546, 626, 470, 194, 746, 590, 591, 592, 743, 595, - 756, 148, 149, 150, 151, 152, 767, 153, 154, 155, - 768, 577, 770, 333, 772, 232, 789, 234, 235, 794, - 332, 799, 797, 749, 107, 830, 869, 943, 832, 482, - 838, 581, 218, 835, 836, 93, 793, 839, 795, 796, - 840, 844, 579, 848, 849, 220, 876, 877, 878, 429, - 879, 880, 881, 850, 851, 852, 333, 853, 883, 882, - 537, 887, 889, 537, 429, 890, 165, 166, 385, 901, - 897, 960, 386, 453, 905, 801, 906, 907, 537, 912, - 937, 938, 750, 939, 332, 827, 940, 944, 949, 951, - 946, 948, 757, 950, 566, 283, 740, 456, 863, 864, - 865, 866, 867, 868, 290, 801, 453, 961, 387, 964, - 457, 965, 869, 874, 875, 876, 877, 878, 297, 879, - 880, 881, 299, 281, 969, 970, 845, 332, 546, 307, - 308, 899, 546, 884, 546, 388, 546, 546, 546, 7, - 8, 9, 10, 936, 11, 568, 288, 569, 219, 416, - 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, - 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, - 825, 389, 828, 803, 771, 289, 390, 587, 739, 456, - 837, 391, 139, 140, 888, 557, 0, 165, 166, 775, - 403, 0, 141, 0, 475, 0, 456, 18, 0, 874, - 875, 876, 877, 878, 0, 879, 880, 881, 0, 165, - 166, 0, 0, 382, 0, 0, 0, 0, 0, 0, - 0, 776, 0, 777, 0, 0, 453, 27, 42, 0, - 457, 0, 858, 0, 0, 801, 0, 0, 0, 0, - 0, 0, 0, 0, 456, 401, 859, 0, 0, 778, - 42, 0, 0, 779, 780, 413, 0, 781, 0, 782, - 415, 0, 417, 783, 0, 867, 868, 52, 0, 0, - 0, 537, 0, 544, 54, 869, 0, 545, -2, 148, - 149, 150, 151, 152, 0, 153, 154, 155, 456, 52, - 0, 0, 0, 0, 842, 544, 54, 0, 0, 549, - 0, 909, 910, 911, 0, 0, 0, 0, 453, 0, - 0, 0, 457, 0, 0, 801, 548, 548, 548, 0, - 483, 70, 0, 0, 0, 453, 0, 0, 0, 457, - 0, 0, 0, 71, 0, 0, 0, 0, 72, 0, - 885, 73, 0, 0, 934, 0, 0, 891, 0, 74, - 75, 0, 76, 0, 0, 0, 77, 78, 79, 0, - 0, 0, 874, 875, 876, 877, 878, 80, 879, 880, - 881, 81, 0, 453, 0, 82, 0, 457, 0, 0, - 801, 0, 0, 0, 801, 83, 0, 0, 382, 0, - 0, 482, 854, 855, 856, 857, 0, 860, 0, 0, - 0, 956, 0, 957, 133, 134, 135, 136, 137, 138, - 139, 140, 39, 0, 40, 41, 0, 453, 0, 0, - 141, 457, 0, 801, 0, 0, 0, 801, 972, 973, - 0, 935, 0, 0, 0, 47, 162, 49, 0, 0, - 801, 0, 382, 0, 941, 0, 0, 0, 0, 801, - 50, 51, 0, 0, 0, 758, 548, 760, 0, 0, - 548, 0, 548, 55, 548, 548, 548, 0, 0, 0, - 0, 769, 0, 0, 0, 914, 915, 916, 917, 918, - 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, - 929, 930, 931, 932, 0, 0, 0, 0, 0, 0, - 0, 142, 143, 144, 145, 146, 147, 148, 149, 150, - 151, 152, 0, 153, 154, 155, 0, 0, 0, 328, - 0, 0, 0, 0, 0, 0, 952, 634, 635, 636, - 637, 638, 639, 640, 641, 0, 642, 643, 644, 645, - 646, 647, 648, 649, 650, 651, 652, 0, 0, 0, - 0, 0, 0, 653, 654, 655, 656, 657, 658, 659, - 660, 661, 662, 663, 664, 665, 666, 966, 0, 667, - 668, 669, 670, 671, 672, 673, 674, 675, 676, 0, - 677, 0, 678, 679, 680, 681, 682, 683, 684, 685, - 686, 687, 688, 689, 0, 0, 0, 690, 0, 691, - 0, 692, 693, 694, 695, 696, 697, 698, 699, 700, - 701, 702, 703, 0, 704, 705, 706, 707, 708, 709, - 710, 0, 711, 712, 713, 714, 0, 0, 0, 715, - 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, - 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, - 903, 736, 737, 634, 635, 636, 637, 638, 639, 640, - 641, 0, 642, 643, 644, 645, 646, 647, 648, 649, - 650, 651, 652, 0, 0, 0, 0, 0, 0, 653, - 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, - 664, 665, 666, 0, 0, 667, 668, 669, 670, 671, - 672, 673, 674, 675, 676, 0, 677, 0, 678, 679, - 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, - 0, 0, 0, 690, 0, 691, 0, 692, 693, 694, - 695, 696, 697, 698, 699, 700, 701, 702, 703, 0, - 704, 705, 706, 707, 708, 709, 710, 0, 711, 712, - 713, 714, 0, 0, 0, 715, 716, 717, 718, 719, - 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, - 730, 731, 732, 733, 734, 735, 0, 736, 737, 0, - 7, 8, 9, 10, 0, 11, 118, 0, 0, 0, + 6, 138, 37, 223, 97, 759, 200, 224, 225, 353, + 612, 113, 111, 378, 112, 173, 174, 73, 476, 173, + 174, 137, -232, 149, 375, -232, 98, 647, 565, 567, + 99, 120, 121, 122, 123, 597, 140, 173, 174, 173, + 174, 165, 232, 233, 234, 235, 236, 252, 238, 239, + 240, 100, 309, 252, 557, 573, -249, 245, 246, 411, + 184, 249, 250, 190, 252, 642, 253, 908, 173, 174, + 448, 101, 344, 475, 574, 478, 252, 102, 578, 228, + 226, 909, 227, 771, 97, 586, 587, 588, 589, 590, + 237, 769, 299, 104, 278, 772, 502, 503, 599, 544, + 545, 546, 247, 248, 173, 174, 613, 281, 282, 283, + 284, 285, 223, 286, 347, 614, 224, 225, 161, 162, + 163, 186, 169, 379, 171, 172, 648, 554, 276, 176, + 552, 173, 174, 803, 974, 202, 188, 103, 194, 105, + 596, 254, 255, 256, 257, 258, 259, 260, 261, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 418, 277, 184, 419, 776, 885, 638, 598, + 778, 106, 779, 45, 780, 781, 782, 184, 184, 184, + 184, 184, 107, 804, 289, 334, 808, 114, 228, 226, + 97, 227, 354, 6, 177, 762, 492, 493, 178, 643, + 115, 821, 308, 169, 171, 172, 176, 116, 311, 346, + 117, 392, 55, 175, 164, 436, 437, 438, 559, 57, + 472, 439, 479, 472, 187, 189, 481, 482, 483, 484, + 118, 790, 173, 174, 401, 179, 252, 195, 402, 169, + 119, 169, 252, 203, 185, 149, 809, 421, 422, 423, + 591, 341, 342, 252, 252, 815, 192, 292, 440, 472, + 430, 911, 895, 896, 897, 592, 241, 424, 243, 244, + 592, 791, 929, 970, 315, 403, 316, 317, 318, 184, + 807, 193, 252, 196, 851, 350, 349, 252, 252, 372, + 383, 384, 385, 6, 358, 592, 386, 374, 97, 180, + 373, 983, 404, 197, 181, 382, 984, 991, 198, 182, + 391, 315, 6, 316, 547, 548, 242, 805, 400, 251, + 645, 280, 441, 286, 571, 848, 252, 442, 297, 549, + 550, 472, 443, 387, 156, 157, 158, 159, 160, 405, + 161, 162, 163, 415, 406, 992, 293, 766, 300, 407, + 298, 173, 174, 97, 372, 580, 1, 2, 3, 305, + 301, 6, 485, 486, 292, 568, 569, 570, 920, 10, + 445, 306, 469, 312, 307, 469, 473, 314, 555, 473, + 556, 391, 320, 322, 323, 391, 391, 391, 391, 644, + 486, 97, 549, 550, 491, 324, 902, 388, 499, 498, + 252, 325, 389, 326, 327, 639, 860, 328, 553, 352, + 329, 469, 561, 561, 561, 473, 885, 330, 331, 558, + 549, 550, 640, 372, 332, 6, 333, 338, 335, 97, + 609, 445, 336, 97, 337, 149, 339, 758, 445, 445, + 445, 445, 445, 594, 351, 113, 111, 553, 112, 600, + 608, 445, 340, 393, 639, 355, 472, 863, 359, 360, + 412, 605, 606, 607, 413, 610, 414, 416, 445, 549, + 550, 765, -248, 426, 398, 427, 417, 553, 428, 391, + 435, 434, 292, 469, 489, 350, 349, 473, 916, 472, + 474, 480, 223, 494, 499, 498, 224, 225, 501, 639, + 448, 575, 577, 579, 924, 890, 891, 892, 893, 894, + 84, 895, 896, 897, 549, 550, 846, 429, 585, 601, + 603, 604, 431, 611, 433, 486, 158, 159, 160, 802, + 161, 162, 163, 761, 641, 770, 760, 918, 763, 764, + 773, 784, 785, 478, 592, 806, 811, 816, 767, 350, + 349, 561, 959, 814, 766, 561, 847, 561, 849, 561, + 561, 561, 852, 787, 855, 789, 853, 856, 228, 226, + 97, 227, 885, 145, 146, 147, 148, 594, 563, 563, + 563, 857, 861, 864, 445, 149, 865, 810, 866, 812, + 813, 350, 349, 596, 867, 553, 976, 868, 553, 445, + 869, 961, 844, 898, 903, 963, 899, 905, 469, 906, + 818, 472, 917, 553, 913, 822, 823, 824, 825, 826, + 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, + 837, 838, 839, 840, 841, 842, 921, 845, 922, 923, + 818, 469, 928, 953, 978, 473, 954, 955, 979, 956, + 398, 962, 960, 964, 7, 8, 9, 10, 965, 11, + 296, 987, 966, 892, 893, 894, 967, 895, 896, 897, + 990, 977, 154, 155, 156, 157, 158, 159, 160, 980, + 161, 162, 163, 981, 985, 581, 986, 757, 862, 900, + 915, 952, 583, 472, 303, 584, 432, 788, 820, 304, + 602, 756, 572, 854, 398, 792, 0, 0, 0, 472, + 0, 0, 0, 19, 0, 0, 775, 563, 777, 0, + 0, 563, 0, 563, 0, 563, 563, 563, 0, 0, + 0, 491, 786, 802, 802, 802, 802, 793, 802, 794, + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 904, 0, 0, 472, 0, 0, + 0, 859, 0, 469, 0, 875, 795, 473, 0, 0, + 796, 797, 818, 0, 798, 0, 799, 0, 0, 0, + 800, 0, 0, 0, 0, 874, 0, 0, 0, 0, + 0, 870, 871, 872, 873, 0, 876, 881, 882, 883, + 884, 472, 0, 0, 0, 0, 0, 901, 553, 885, + 0, 0, 0, 0, 907, 802, 802, 802, 802, 802, + 802, 802, 802, 802, 802, 802, 802, 802, 802, 802, + 802, 802, 802, 802, 143, 144, 145, 146, 147, 148, + 0, 0, 0, 0, 0, 469, 0, 0, 149, 473, + 0, 0, 818, 925, 926, 927, 0, 499, 498, 0, + 0, 469, 950, 0, 0, 473, 802, 0, 0, 0, + 0, 0, 0, 930, 931, 932, 933, 934, 935, 936, + 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, + 947, 948, 0, 0, 0, 0, 0, 951, 890, 891, + 892, 893, 894, 0, 895, 896, 897, 802, 0, 469, + 957, 0, 0, 473, 0, 0, 818, 0, 0, 972, + 818, 973, 0, 0, 968, 0, 0, 0, 0, 0, + 0, 0, 151, 152, 153, 154, 155, 156, 157, 158, + 159, 160, 0, 161, 162, 163, 988, 989, 0, 0, + 0, 0, 0, 469, 0, 0, 0, 473, 0, 818, + 0, 0, 0, 818, 0, 982, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 818, 649, 650, 651, + 652, 653, 654, 655, 656, 818, 657, 658, 659, 660, + 661, 662, 663, 664, 665, 666, 667, 0, 0, 0, + 0, 0, 0, 668, 669, 670, 671, 672, 673, 674, + 675, 676, 677, 678, 679, 680, 681, 0, 0, 682, + 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, + 0, 693, 0, 694, 695, 696, 697, 698, 699, 700, + 701, 702, 703, 704, 705, 0, 0, 0, 706, 0, + 707, 0, 708, 709, 710, 711, 712, 713, 714, 715, + 716, 717, 718, 719, 0, 720, 721, 722, 723, 724, + 725, 726, 0, 727, 728, 729, 730, 731, 0, 0, + 0, 732, 733, 734, 735, 736, 737, 738, 739, 740, + 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, + 751, 752, 919, 753, 754, 649, 650, 651, 652, 653, + 654, 655, 656, 975, 657, 658, 659, 660, 661, 662, + 663, 664, 665, 666, 667, 0, 0, 0, 0, 0, + 0, 668, 669, 670, 671, 672, 673, 674, 675, 676, + 677, 678, 679, 680, 681, 0, 0, 682, 683, 684, + 685, 686, 687, 688, 689, 690, 691, 692, 0, 693, + 0, 694, 695, 696, 697, 698, 699, 700, 701, 702, + 703, 704, 705, 0, 0, 0, 706, 0, 707, 0, + 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, + 718, 719, 0, 720, 721, 722, 723, 724, 725, 726, + 0, 727, 728, 729, 730, 731, 0, 173, 174, 732, + 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, + 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, + 0, 753, 754, 7, 8, 9, 10, 0, 11, 124, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 165, 166, 0, 0, 0, 0, 0, 134, 135, - 136, 137, 138, 139, 140, 0, 0, 0, 0, 0, - 0, 0, 119, 141, 120, 121, 42, 43, 0, 122, - 17, 0, 0, 45, 0, 0, 0, 0, 18, 123, - 0, 0, 42, 0, 0, 124, 125, 49, 0, 0, - 0, 959, 22, 0, 0, 0, 0, 0, 0, 0, - 126, 127, 25, 0, 26, 52, 0, 0, 27, 0, - 0, 53, 54, 128, 0, 0, 56, 433, 434, 435, - 10, 52, 436, 38, 0, 0, 437, 544, 54, 0, - 29, 551, 0, 0, 30, 31, 0, 0, 32, 0, - 33, 0, 0, 0, 34, 143, 144, 145, 146, 147, - 148, 149, 150, 151, 152, 0, 153, 154, 155, 39, - 0, 40, 41, 42, 438, 0, 44, 439, 0, 0, - 45, 0, 0, 0, 0, 440, 46, 0, 0, 0, - 0, 0, 47, 48, 49, 0, 0, 0, 0, 441, - 0, 0, 0, 0, 0, 0, 0, 50, 51, 442, - 0, 443, 52, 0, 0, 444, 0, 0, 53, 54, - 55, 0, 0, 56, 433, 434, 435, 10, 0, 436, - 38, 0, 0, 802, 0, 0, 0, 445, 0, 0, - 0, 446, 0, 0, 0, 447, 0, 448, 0, 0, - 0, 449, 862, 863, 864, 865, 866, 867, 868, 0, - 0, 0, 39, 0, 40, 41, 39, 869, 40, 41, - 42, 438, 0, 44, 439, 0, 0, 45, 0, 0, - 0, 0, 440, 46, 0, 47, 162, 49, 0, 47, - 48, 49, 0, 0, 0, 0, 441, 0, 0, 0, - 50, 51, 0, 0, 50, 51, 442, 0, 443, 52, - 0, 0, 444, 55, 0, 53, 54, 55, 0, 0, - 56, 7, 8, 9, 10, 0, 11, 12, 0, 0, - 0, 0, 0, 0, 445, 0, 0, 0, 446, 0, - 109, 0, 447, 0, 448, 0, 0, 0, 449, 871, - 872, 873, 0, 0, 874, 875, 876, 877, 878, 0, - 879, 880, 881, 13, 0, 14, 15, 0, 0, 0, - 16, 17, 0, 0, 0, 0, 0, 0, 0, 18, - 19, 0, 0, 0, 0, 0, 20, 21, 0, 0, - 0, 0, 0, 22, 0, 39, 0, 40, 41, 0, - 0, 23, 24, 25, 0, 26, 0, 0, 0, 27, - 7, 8, 9, 10, 28, 11, 12, 0, 47, 162, - 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 29, 0, 50, 51, 30, 31, 0, 0, 32, - 0, 33, 0, 265, 0, 34, 55, 0, 0, 0, - 0, 0, 13, 0, 14, 15, 0, 0, 0, 16, - 17, 0, 0, 0, 0, 0, 0, 0, 18, 19, - 0, 0, 0, 110, 0, 20, 21, 0, 347, 348, - 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, - 23, 24, 25, 0, 26, 0, 0, 0, 27, 7, - 8, 9, 10, 28, 11, 12, 0, 0, 0, 0, - 0, 0, 383, 0, 0, 39, 0, 40, 41, 0, - 29, 0, 44, 0, 30, 31, 0, 0, 32, 0, - 33, 0, 46, 0, 34, 0, 0, 0, 47, 48, - 49, 13, 0, 14, 15, 0, 0, 0, 16, 17, - 0, 0, 0, 50, 51, 0, 0, 18, 19, 0, - 0, 0, 0, 0, 20, 21, 55, 0, 0, 56, - 0, 22, 0, 39, 0, 40, 41, 0, 0, 23, - 24, 25, 0, 26, 0, 0, 0, 27, 7, 8, - 9, 10, 28, 11, 12, 0, 47, 162, 49, 0, - 0, 479, 0, 0, 39, 0, 40, 41, 0, 29, - 0, 50, 51, 30, 31, 0, 0, 32, 0, 33, - 0, 269, 0, 34, 55, 0, 0, 47, 162, 49, - 13, 0, 14, 15, 0, 0, 0, 16, 17, 0, - 0, 0, 50, 51, 0, 0, 18, 19, 0, 0, - 0, 113, 0, 20, 21, 55, 0, 0, 0, 0, - 22, 0, 0, 0, 0, 0, 0, 0, 23, 24, - 25, 0, 26, 0, 0, 0, 27, 7, 8, 9, - 10, 28, 11, 12, 0, 0, 0, 0, 0, 0, - 39, 0, 40, 41, 0, 0, 0, 158, 29, 0, - 0, 0, 30, 31, 0, 0, 32, 159, 33, 0, - 826, 0, 34, 47, 160, 49, 0, 0, 0, 13, - 0, 14, 15, 0, 0, 0, 16, 17, 50, 51, - 0, 0, 0, 0, 0, 18, 19, 0, 0, 0, - 0, 55, 20, 21, 0, 0, 0, 0, 0, 22, - 0, 0, 0, 0, 0, 0, 0, 23, 24, 25, - 0, 26, 0, 0, 0, 27, 7, 8, 9, 10, - 28, 11, 12, 0, 0, 0, 0, 0, 0, 841, - 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, - 0, 30, 31, 0, 0, 32, 0, 33, 0, 0, - 0, 34, 0, 0, 0, 0, 0, 0, 13, 0, - 14, 15, 0, 0, 0, 16, 17, 0, 0, 0, - 0, 0, 0, 0, 18, 19, 0, 0, 0, 0, - 0, 20, 21, 0, 0, 0, 0, 0, 22, 0, - 0, 0, 0, 0, 0, 0, 23, 24, 25, 0, - 26, 0, 0, 0, 27, 7, 8, 9, 10, 28, - 11, 12, 0, 0, 0, 0, 0, 0, 39, 0, - 40, 41, 0, 0, 0, 158, 29, 0, 0, 0, - 30, 31, 0, 0, 32, 159, 33, 0, 933, 0, - 34, 47, 160, 49, 0, 0, 0, 13, 0, 14, - 15, 0, 0, 0, 16, 17, 50, 51, 0, 0, - 0, 0, 0, 18, 19, 0, 0, 0, 0, 55, - 20, 21, 0, 0, 0, 0, 0, 22, 0, 0, - 0, 0, 0, 0, 0, 23, 24, 25, 0, 26, - 0, 0, 0, 27, 0, 0, 102, 0, 28, 0, - 133, 134, 135, 136, 137, 138, 139, 140, 0, 0, - 0, 0, 0, 0, 0, 29, 141, 0, 0, 30, - 31, 0, 0, 32, 0, 33, 0, 0, 0, 34, - 133, 134, 135, 136, 137, 138, 139, 140, 0, 0, - 0, 0, 0, 0, 0, 0, 141, 0, 0, 0, - 488, 489, 490, 491, 492, 493, 494, 495, 0, 0, - 0, 0, 0, 0, 0, 0, 496, 0, 497, 498, - 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, - 133, 134, 135, 136, 137, 138, 139, 140, 509, 0, - 0, 0, 0, 0, 0, 0, 141, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 151, 152, 0, 153, - 154, 155, 510, 0, 0, 896, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 151, 152, 0, 153, - 154, 155, 0, 511, 0, 955, 512, 0, 513, 514, - 515, 516, 517, 518, 519, 520, 521, 522, 523, 0, - 524, 525, 195, 196, 526, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 326, 0, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 151, 152, 0, 153, - 154, 155, 0, 0, 0, 0, 0, 0, 197, 39, - 0, 40, 41, 42, 198, 0, 44, 0, 0, 0, - 45, 199, 200, 201, 0, 0, 46, 0, 0, 0, - 0, 202, 47, 48, 49, 0, 0, 203, 195, 196, - 0, 204, 0, 0, 0, 205, 0, 50, 51, 0, - 206, 0, 52, 0, 0, 0, 0, 0, 207, 54, - 55, 0, 208, 56, 209, 0, 0, 0, 0, 210, - 0, 0, 0, 0, 197, 39, 0, 40, 41, 42, - 287, 0, 44, 0, 0, 211, 45, 199, 200, 201, - 0, 0, 46, 0, 0, 195, 196, 202, 47, 48, - 49, 0, 0, 203, 0, 0, 0, 204, 0, 0, - 0, 205, 0, 50, 51, 0, 206, 0, 52, 0, - 0, 0, 0, 0, 207, 54, 55, 0, 208, 56, - 209, 197, 39, 0, 40, 41, 42, 198, 0, 44, - 0, 0, 0, 45, 199, 200, 201, 0, 0, 46, - 0, 211, 0, 0, 202, 47, 48, 49, 0, 0, - 203, 0, 0, 0, 204, 0, 0, 0, 205, 0, - 50, 51, 0, 206, 0, 52, 0, 0, 0, 0, - 0, 207, 54, 55, 0, 208, 56, 209, 133, 134, - 135, 136, 137, 138, 139, 140, 0, 0, 0, 0, - 0, 0, 0, 0, 141, 0, 0, 0, 211, 133, - 134, 135, 136, 137, 138, 139, 140, 0, 0, 0, - 0, 0, 0, 0, 0, 141, 133, 134, 135, 136, - 137, 138, 139, 140, 0, 0, 0, 0, 0, 0, - 0, 0, 141, 133, 134, 135, 136, 137, 138, 139, - 140, 0, 0, 0, 0, 0, 0, 0, 0, 141, - 600, 601, 602, 603, 604, 605, 606, 607, 0, 0, - 0, 0, 0, 0, 0, 0, 608, 0, 0, 0, - 0, 0, 484, 0, 0, 142, 143, 144, 145, 146, - 147, 148, 149, 150, 151, 152, 0, 153, 154, 155, - 0, 0, 847, 0, 0, 0, 142, 143, 144, 145, - 146, 147, 148, 149, 150, 151, 152, 0, 153, 154, - 155, 894, 0, 142, 143, 144, 145, 146, 147, 148, - 149, 150, 151, 152, 0, 153, 154, 155, 0, 0, - 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, - 152, 0, 153, 154, 155, 0, 0, 609, 610, 611, - 612, 613, 614, 615, 616, 617, 618, 619, 0, 620, - 621, 622, 861, 862, 863, 864, 865, 866, 867, 868, - 0, 0, 0, 0, 0, 0, 0, 0, 869, 861, - 862, 863, 864, 865, 866, 867, 868, 0, 0, 0, - 0, 0, 0, 0, 0, 869, 135, 136, 137, 138, - 139, 140, 0, 0, 0, 0, 0, 0, 0, 0, - 141, 135, 136, 137, 138, 139, 140, 0, 0, 0, - 0, 0, 0, 0, 0, 141, 135, 136, 137, 138, - 139, 140, 0, 0, 0, 0, 0, 0, 0, 0, - 141, 863, 864, 865, 866, 867, 868, 0, 0, 0, - 0, 0, 0, 0, 0, 869, 0, 953, 0, 870, - 871, 872, 873, 0, 0, 874, 875, 876, 877, 878, - 0, 879, 880, 881, 0, 0, 870, 871, 872, 873, - 0, 0, 874, 875, 876, 877, 878, 0, 879, 880, - 881, 0, 143, 144, 145, 146, 147, 148, 149, 150, - 151, 152, 0, 153, 154, 155, 0, 0, 144, 145, - 146, 147, 148, 149, 150, 151, 152, 0, 153, 154, - 155, 0, 0, 0, 145, 146, 147, 148, 149, 150, - 151, 152, 0, 153, 154, 155, 0, 871, 872, 873, - 0, 0, 874, 875, 876, 877, 878, 0, 879, 880, - 881, 135, 136, 137, 138, 139, 140, 0, 0, 0, - 0, 0, 0, 0, 0, 141, 863, 864, 865, 866, - 867, 868, 0, 0, 0, 0, 0, 0, 0, 0, - 869, 863, 864, 865, 866, 867, 868, 0, 0, 0, - 0, 0, 0, 0, 0, 869, 137, 138, 139, 140, - 0, 0, 0, 0, 0, 0, 0, 0, 141, 865, - 866, 867, 868, 0, 0, 0, 0, 0, 0, 0, - 0, 869, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 142, 143, 144, 145, 146, 147, 148, 0, 0, + 0, 0, 0, 0, 0, 125, 149, 126, 127, 128, + 45, 46, 0, 129, 18, 0, 0, 48, 55, 0, + 0, 0, 19, 130, 559, 57, 0, 0, 560, 131, + 132, 52, 0, 0, 0, 0, 23, 0, 0, 0, + 0, 0, 0, 0, 133, 134, 26, 0, 27, 55, + 0, 0, 28, 0, 0, 56, 57, 135, 0, 0, + 59, 0, 136, 449, 450, 451, 10, 0, 452, 40, + 0, 0, 453, 0, 0, 31, 0, 0, 0, 32, + 33, 0, 0, 34, 0, 35, 173, 174, 0, 36, + 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, + 0, 161, 162, 163, 0, 41, 0, 42, 43, 44, + 45, 454, 0, 47, 455, 0, 0, 48, 0, 0, + 0, 0, 456, 49, 0, 0, 0, 0, 45, 50, + 51, 52, 0, 0, 0, 0, 457, 0, 0, 0, + 0, 0, 0, 0, 53, 54, 458, 0, 459, 55, + 0, 0, 460, 0, 0, 56, 57, 58, 0, 0, + 59, 0, 60, 449, 450, 451, 10, 55, 452, 40, + 0, 0, 819, 559, 57, 461, 0, 564, 0, 462, + 0, 0, 0, 463, 0, 464, 173, 174, 0, 465, + 0, 878, 879, 880, 881, 882, 883, 884, 0, 0, + 0, 0, 0, 0, 0, 41, 885, 42, 43, 44, + 45, 454, 0, 47, 455, 0, 0, 48, 0, 0, + 0, 0, 456, 49, 0, 0, 0, 0, 45, 50, + 51, 52, 147, 148, 0, 0, 457, 0, 0, 0, + 0, 0, 149, 0, 53, 54, 458, 0, 459, 55, + 0, 0, 460, 0, 0, 56, 57, 58, 0, 0, + 59, 0, 60, 7, 8, 9, 10, 55, 11, 12, + 0, 883, 884, 559, 57, 461, 0, 566, 0, 462, + 0, 885, 0, 463, 0, 464, 0, 0, 0, 465, + 887, 888, 889, 0, 0, 890, 891, 892, 893, 894, + 0, 895, 896, 897, 0, 13, 0, 14, 15, 16, + 0, 0, 0, 17, 18, 0, 0, 0, 0, 0, + 0, 0, 19, 20, 0, 0, 0, 0, 0, 21, + 22, 156, 157, 158, 159, 160, 23, 161, 162, 163, + 0, 0, 0, 0, 24, 25, 26, 0, 27, 0, + 0, 0, 28, 7, 8, 9, 10, 29, 11, 12, + 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, + 890, 891, 892, 893, 894, 31, 895, 896, 897, 32, + 33, 0, 0, 34, 0, 35, 0, 275, 0, 36, + 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, + 0, 0, 0, 17, 18, 0, 0, 0, 0, 0, + 0, 0, 19, 20, 0, 0, 0, 0, 0, 21, + 22, 0, 0, 0, 0, 0, 23, 0, 0, 0, + 0, 0, 0, 0, 24, 25, 26, 0, 27, 0, + 0, 0, 28, 7, 8, 9, 10, 29, 11, 12, + 0, 0, 30, 0, 0, 0, 41, 399, 42, 43, + 44, 0, 0, 0, 166, 31, 0, 0, 0, 32, + 33, 0, 0, 34, 167, 35, 0, 0, 0, 36, + 50, 168, 52, 0, 0, 13, 0, 14, 15, 16, + 0, 0, 0, 17, 18, 53, 54, 0, 0, 0, + 0, 0, 19, 20, 0, 0, 0, 0, 58, 21, + 22, 0, 0, 60, 0, 0, 23, 0, 0, 0, + 0, 0, 0, 0, 24, 25, 26, 0, 27, 0, + 0, 0, 28, 7, 8, 9, 10, 29, 11, 12, + 0, 0, 30, 0, 0, 0, 41, 495, 42, 43, + 44, 0, 0, 0, 0, 31, 0, 0, 0, 32, + 33, 0, 0, 34, 279, 35, 0, 0, 0, 36, + 50, 170, 52, 0, 0, 13, 0, 14, 15, 16, + 0, 0, 0, 17, 18, 53, 54, 0, 0, 0, + 0, 0, 19, 20, 0, 0, 0, 0, 58, 21, + 22, 0, 0, 60, 0, 0, 23, 0, 0, 0, + 0, 0, 0, 0, 24, 25, 26, 0, 27, 0, + 0, 0, 28, 7, 8, 9, 10, 29, 11, 12, + 0, 0, 30, 0, 0, 0, 41, 0, 42, 43, + 44, 0, 0, 0, 0, 31, 0, 0, 0, 32, + 33, 0, 0, 34, 0, 35, 0, 843, 0, 36, + 50, 170, 52, 0, 0, 13, 0, 14, 15, 16, + 0, 0, 0, 17, 18, 53, 54, 0, 0, 0, + 0, 0, 19, 20, 0, 0, 0, 0, 58, 21, + 22, 0, 0, 60, 0, 0, 23, 0, 0, 0, + 0, 0, 0, 0, 24, 25, 26, 0, 27, 0, + 0, 0, 28, 7, 8, 9, 10, 29, 11, 12, + 0, 0, 30, 0, 0, 0, 0, 858, 0, 0, + 0, 0, 0, 0, 0, 31, 0, 0, 0, 32, + 33, 0, 0, 34, 0, 35, 0, 0, 0, 36, + 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, + 0, 0, 0, 17, 18, 0, 0, 0, 0, 0, + 0, 0, 19, 20, 0, 0, 0, 0, 0, 21, + 22, 0, 0, 0, 0, 0, 23, 0, 0, 0, + 0, 0, 0, 0, 24, 25, 26, 0, 27, 0, + 0, 0, 28, 7, 8, 9, 10, 29, 11, 12, + 0, 0, 30, 0, 0, 0, 41, 0, 42, 43, + 44, 0, 0, 0, 166, 31, 0, 0, 0, 32, + 33, 0, 0, 34, 167, 35, 0, 949, 0, 36, + 50, 168, 52, 0, 0, 13, 0, 14, 15, 16, + 0, 0, 0, 17, 18, 53, 54, 0, 0, 0, + 0, 0, 19, 20, 0, 0, 0, 0, 58, 21, + 22, 0, 0, 60, 0, 0, 23, 143, 144, 145, + 146, 147, 148, 0, 24, 25, 26, 0, 27, 0, + 0, 149, 28, 0, 0, 0, 107, 29, 0, 0, + 0, 0, 30, 0, 0, 141, 142, 143, 144, 145, + 146, 147, 148, 0, 0, 31, 0, 0, 0, 32, + 33, 149, 0, 34, 0, 35, 0, 0, 0, 36, + 141, 142, 143, 144, 145, 146, 147, 148, 0, 0, + 0, 0, 0, 0, 0, 0, 149, 0, 0, 141, + 142, 143, 144, 145, 146, 147, 148, 0, 0, 0, + 0, 0, 0, 0, 0, 149, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 152, 153, 154, 155, + 156, 157, 158, 159, 160, 0, 161, 162, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 150, 151, 152, 153, 154, 155, + 156, 157, 158, 159, 160, 0, 161, 162, 163, 0, + 0, 0, 345, 0, 0, 0, 0, 0, 0, 150, + 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, + 0, 161, 162, 163, 0, 0, 0, 912, 150, 151, + 152, 153, 154, 155, 156, 157, 158, 159, 160, 0, + 161, 162, 163, 363, 364, 0, 971, 504, 505, 506, + 507, 508, 509, 510, 511, 0, 0, 0, 0, 0, + 0, 0, 0, 512, 0, 513, 514, 515, 516, 517, + 518, 519, 520, 521, 522, 523, 524, 0, 0, 0, + 41, 0, 42, 43, 44, 0, 525, 0, 47, 41, + 0, 42, 43, 44, 0, 0, 0, 0, 49, 0, + 0, 0, 0, 0, 50, 51, 52, 0, 0, 0, + 526, 0, 0, 50, 170, 52, 0, 0, 0, 53, + 54, 0, 0, 0, 0, 204, 205, 0, 53, 54, + 0, 0, 58, 0, 0, 59, 0, 60, 0, 0, + 0, 58, 527, 0, 0, 528, 60, 529, 530, 531, + 532, 533, 534, 535, 536, 537, 538, 539, 0, 540, + 541, 206, 41, 542, 42, 43, 44, 45, 207, 114, + 47, 0, 0, 0, 48, 208, 209, 210, 0, 0, + 49, 0, 0, 0, 0, 211, 50, 51, 52, 0, + 0, 212, 204, 205, 0, 213, 0, 0, 0, 214, + 0, 53, 54, 0, 215, 0, 55, 0, 0, 0, + 0, 0, 216, 57, 58, 0, 217, 59, 218, 60, + 0, 0, 0, 0, 219, 0, 0, 0, 206, 41, + 0, 42, 43, 44, 45, 302, 0, 47, 0, 0, + 220, 48, 208, 209, 210, 0, 0, 49, 0, 0, + 0, 0, 211, 50, 51, 52, 0, 0, 212, 204, + 205, 0, 213, 0, 0, 0, 214, 0, 53, 54, + 0, 215, 0, 55, 0, 0, 0, 0, 0, 216, + 57, 58, 0, 217, 59, 218, 60, 141, 142, 143, + 144, 145, 146, 147, 148, 206, 41, 0, 42, 43, + 44, 45, 207, 149, 47, 0, 0, 220, 48, 208, + 209, 210, 0, 0, 49, 0, 0, 0, 0, 211, + 50, 51, 52, 0, 0, 212, 0, 0, 0, 213, + 0, 0, 0, 214, 0, 53, 54, 0, 215, 0, + 55, 0, 0, 0, 0, 0, 216, 57, 58, 0, + 217, 59, 218, 60, 141, 142, 143, 144, 145, 146, + 147, 148, 0, 0, 0, 0, 0, 0, 0, 0, + 149, 0, 0, 0, 220, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 343, 0, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 0, 161, 162, + 163, 141, 142, 143, 144, 145, 146, 147, 148, 0, + 0, 0, 0, 0, 0, 0, 0, 149, 141, 142, + 143, 144, 145, 146, 147, 148, 0, 0, 0, 0, + 0, 0, 0, 0, 149, 141, 142, 143, 144, 145, + 146, 147, 148, 0, 0, 0, 0, 0, 0, 0, + 500, 149, 0, 150, 151, 152, 153, 154, 155, 156, + 157, 158, 159, 160, 0, 161, 162, 163, 615, 616, + 617, 618, 619, 620, 621, 622, 0, 0, 0, 0, + 0, 0, 0, 0, 623, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 774, 0, 0, 0, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 0, 161, 162, 163, 910, 0, 150, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 0, 161, + 162, 163, 0, 0, 150, 151, 152, 153, 154, 155, + 156, 157, 158, 159, 160, 0, 161, 162, 163, 877, + 878, 879, 880, 881, 882, 883, 884, 0, 0, 0, + 0, 0, 0, 0, 0, 885, 0, 624, 625, 626, + 627, 628, 629, 630, 631, 632, 633, 634, 0, 635, + 636, 637, 877, 878, 879, 880, 881, 882, 883, 884, + 0, 0, 0, 0, 0, 0, 0, 0, 885, 143, + 144, 145, 146, 147, 148, 0, 0, 0, 0, 0, + 0, 0, 0, 149, 879, 880, 881, 882, 883, 884, + 0, 0, 0, 0, 0, 0, 0, 0, 885, 143, + 144, 145, 146, 147, 148, 0, 0, 0, 0, 0, + 0, 0, 0, 149, 0, 0, 969, 0, 886, 887, + 888, 889, 0, 0, 890, 891, 892, 893, 894, 0, + 895, 896, 897, 879, 880, 881, 882, 883, 884, 0, + 0, 0, 0, 0, 0, 0, 0, 885, 0, 0, + 0, 886, 887, 888, 889, 0, 0, 890, 891, 892, + 893, 894, 0, 895, 896, 897, 0, 0, 0, 153, + 154, 155, 156, 157, 158, 159, 160, 0, 161, 162, + 163, 0, 887, 888, 889, 0, 0, 890, 891, 892, + 893, 894, 0, 895, 896, 897, 0, 0, 0, 0, + 154, 155, 156, 157, 158, 159, 160, 0, 161, 162, + 163, 879, 880, 881, 882, 883, 884, 0, 0, 0, + 0, 0, 0, 0, 0, 885, 0, 0, 0, -2, + 0, 0, 888, 889, 0, 0, 890, 891, 892, 893, + 894, 0, 895, 896, 897, 879, 880, 881, 882, 883, + 884, 0, 0, 0, 0, 0, 0, 0, 0, 885, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 146, 147, 148, 149, 150, 151, 152, 0, 153, 154, - 155, 0, 0, 872, 873, 0, 0, 874, 875, 876, - 877, 878, 0, 879, 880, 881, 0, 0, 0, 873, - 347, 348, 874, 875, 876, 877, 878, 0, 879, 880, - 881, 0, 0, 146, 147, 148, 149, 150, 151, 152, - 0, 153, 154, 155, 0, 0, 0, 0, 874, 875, - 876, 877, 878, 0, 879, 880, 881, 39, 0, 40, - 41, 349, 350, 0, 44, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 46, 0, 38, 0, 0, 0, - 47, 48, 49, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 50, 51, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 351, 0, 55, 0, - 0, 56, 39, 0, 40, 41, 42, 43, 0, 44, - 0, 0, 0, 45, 0, 0, 0, 0, 0, 46, - 0, 38, 0, 0, 0, 47, 48, 49, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 50, 51, 0, 0, 0, 52, 0, 0, 0, 0, - 0, 53, 54, 55, 0, 0, 56, 39, 0, 40, - 41, 42, 295, 0, 44, 0, 0, 0, 45, 0, - 0, 0, 0, 0, 46, 0, 103, 0, 0, 0, - 47, 48, 49, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 50, 51, 0, 0, 0, - 52, 0, 0, 0, 0, 0, 53, 54, 55, 0, - 0, 56, 39, 0, 40, 41, 42, 0, 0, 44, - 0, 0, 0, 45, 0, 0, 0, 0, 0, 46, - 0, 38, 0, 0, 0, 47, 48, 49, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 50, 51, 0, 0, 0, 52, 0, 0, 0, 0, - 0, 104, 54, 55, 0, 0, 56, 39, 0, 40, - 41, 42, 0, 0, 44, 0, 0, 0, 45, 0, - 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, - 47, 48, 49, 0, 0, 70, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 50, 51, 71, 0, 0, - 52, 0, 72, 0, 0, 73, 53, 54, 55, 0, - 0, 56, 0, 74, 75, 0, 76, 70, 0, 0, - 77, 78, 79, 0, 0, 0, 0, 0, 0, 71, - 0, 80, 0, 0, 72, 81, 0, 73, 0, 82, - 0, 0, 0, 0, 0, 74, 75, 0, 76, 83, - 0, 0, 77, 78, 79, 0, 0, 70, 0, 0, - 0, 0, 0, 80, 0, 0, 0, 81, 345, 71, - 0, 82, 0, 0, 72, 0, 0, 73, 0, 0, - 0, 83, 0, 0, 0, 74, 75, 0, 76, 70, - 0, 0, 77, 78, 79, 0, 0, 0, 0, 0, - 404, 71, 0, 80, 0, 0, 72, 81, 0, 73, - 0, 82, 0, 0, 0, 0, 0, 74, 75, 0, - 76, 83, 0, 0, 77, 78, 79, 0, 0, 70, - 0, 0, 0, 0, 0, 80, 0, 0, 0, 81, - 471, 71, 0, 82, 0, 0, 72, 0, 0, 73, - 0, 0, 0, 83, 0, 0, 0, 74, 75, 0, - 76, 70, 0, 0, 77, 78, 79, 0, 0, 0, - 0, 0, 561, 71, 0, 80, 0, 0, 72, 81, - 0, 73, 0, 82, 0, 0, 0, 0, 0, 74, - 75, 0, 76, 83, 0, 0, 77, 78, 79, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, - 0, 81, 766, 0, 0, 82 + 0, 0, 74, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 75, 0, 0, 0, 0, + 76, 0, 0, 77, 0, 0, 0, 0, 0, 0, + 0, 78, 79, 0, 80, 0, 0, 0, 81, 82, + 83, 889, 0, 0, 890, 891, 892, 893, 894, 84, + 895, 896, 897, 85, 363, 364, 0, 86, 0, 0, + 0, 0, 0, 0, 40, 0, 0, 0, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 890, 891, + 892, 893, 894, 0, 895, 896, 897, 0, 0, 0, + 0, 41, 0, 42, 43, 44, 365, 366, 0, 47, + 41, 0, 42, 43, 44, 45, 46, 0, 47, 49, + 0, 0, 48, 0, 0, 50, 51, 52, 49, 0, + 40, 0, 0, 0, 50, 51, 52, 0, 0, 0, + 53, 54, 0, 0, 0, 0, 0, 0, 0, 53, + 54, 367, 0, 58, 55, 0, 59, 0, 60, 0, + 56, 57, 58, 0, 0, 59, 41, 60, 42, 43, + 44, 45, 310, 0, 47, 290, 0, 0, 48, 0, + 0, 0, 0, 0, 49, 0, 108, 0, 0, 0, + 50, 51, 52, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 53, 54, 0, 0, 0, + 55, 41, 0, 42, 43, 44, 56, 57, 58, 0, + 0, 59, 41, 60, 42, 43, 44, 45, 0, 0, + 47, 0, 0, 0, 48, 50, 170, 52, 0, 0, + 49, 0, 40, 0, 0, 0, 50, 51, 52, 0, + 53, 54, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 53, 54, 58, 0, 0, 55, 41, 60, 42, + 43, 44, 109, 57, 58, 0, 0, 59, 41, 60, + 42, 43, 44, 45, 0, 0, 47, 0, 0, 0, + 48, 50, 170, 52, 0, 0, 49, 0, 0, 0, + 0, 0, 50, 51, 52, 0, 53, 54, 0, 0, + 0, 0, 0, 74, 0, 0, 0, 53, 54, 58, + 0, 0, 55, 0, 60, 0, 75, 0, 56, 57, + 58, 76, 0, 59, 77, 60, 0, 0, 0, 0, + 74, 0, 78, 79, 0, 80, 0, 115, 0, 81, + 82, 83, 0, 75, 0, 0, 0, 0, 76, 0, + 84, 77, 0, 0, 85, 0, 0, 74, 86, 78, + 79, 0, 80, 0, 0, 0, 81, 82, 83, 87, + 75, 0, 0, 0, 0, 76, 0, 84, 77, 0, + 0, 85, 0, 0, 74, 86, 78, 79, 361, 80, + 0, 0, 0, 81, 82, 83, 87, 75, 0, 0, + 0, 0, 76, 0, 84, 77, 0, 0, 85, 0, + 0, 74, 86, 78, 79, 420, 80, 0, 0, 0, + 81, 82, 83, 87, 75, 0, 0, 0, 0, 76, + 0, 84, 77, 0, 0, 85, 0, 0, 0, 86, + 78, 79, 487, 80, 0, 0, 0, 81, 82, 83, + 87, 0, 0, 0, 0, 0, 0, 0, 84, 0, + 0, 41, 85, 42, 43, 44, 86, 0, 0, 576, + 0, 0, 0, 0, 0, 0, 0, 87, 0, 0, + 0, 0, 0, 0, 0, 50, 170, 52, 0, 0, + 0, 74, 0, 0, 0, 0, 783, 0, 0, 0, + 53, 54, 0, 0, 75, 0, 0, 0, 0, 76, + 0, 0, 77, 58, 0, 0, 0, 0, 60, 0, + 78, 79, 0, 80, 0, 0, 0, 81, 82, 83, + 0, 0, 0, 0, 0, 0, 0, 0, 84, 0, + 0, 118, 85, 0, 0, 0, 86 }; #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-547))) + (!!((Yystate) == (-491))) #define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_int16 yycheck[] = { - 1, 87, 87, 33, 5, 95, 96, 97, 98, 22, - 100, 101, 102, 364, 87, 87, 432, 33, 479, 109, - 110, 81, 22, 113, 8, 9, 185, 10, 360, 109, - 576, 363, 106, 365, 12, 366, 8, 9, 43, 370, - 371, 372, 373, 470, 124, 0, 462, 157, 399, 114, - 288, 125, 8, 9, 386, 387, 57, 389, 390, 391, - 170, 171, 172, 173, 174, 106, 200, 123, 48, 99, - 50, 51, 2, 109, 87, 55, 105, 8, 9, 108, - 81, 111, 112, 123, 125, 8, 9, 87, 124, 10, - 8, 9, 10, 14, 114, 76, 14, 106, 430, 29, - 30, 31, 32, 416, 34, 191, 191, 534, 106, 90, - 423, 424, 425, 426, 427, 106, 125, 106, 191, 191, - 279, 472, 6, 436, 626, 22, 458, 125, 106, 50, - 124, 125, 50, 464, 125, 118, 125, 123, 154, 298, - 453, 125, 108, 233, 106, 125, 126, 127, 128, 105, - 577, 74, 29, 485, 123, 393, 157, 406, 407, 123, - 270, 8, 9, 125, 123, 581, 29, 106, 584, 170, - 171, 172, 173, 174, 105, 123, 124, 106, 191, 123, - 160, 182, 162, 599, 185, 123, 125, 346, 105, 106, - 87, 191, 113, 198, 432, 113, 125, 118, 29, 204, - 118, 123, 123, 133, 134, 135, 136, 137, 138, 139, - 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, - 150, 151, 152, 153, 462, 155, 106, 361, 123, 109, - 364, 106, 778, 779, 780, 781, 106, 783, 102, 103, - 104, 123, 8, 9, 10, 122, 123, 124, 14, 106, - 125, 410, 106, 108, 756, 125, 123, 570, 105, 122, - 123, 124, 8, 9, 123, 399, 124, 125, 125, 270, - 123, 125, 585, 123, 124, 276, 277, 123, 279, 280, - 631, 108, 287, 284, 50, 286, 286, 118, 119, 120, - 295, 122, 123, 124, 191, 296, 545, 298, 123, 124, - 549, 108, 551, 49, 553, 554, 555, 125, 118, 4, - 124, 241, 242, 8, 9, 861, 862, 863, 864, 865, - 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, - 876, 877, 878, 879, 836, 105, 337, 338, 472, 78, - 79, 80, 88, 581, 8, 346, 276, 113, 94, 95, - 350, 105, 118, 114, 355, 123, 361, 123, 418, 364, - 361, 123, 6, 364, 107, 366, 912, 125, 106, 370, - 371, 372, 373, 303, 125, 376, 792, 125, 379, 395, - 841, 397, 383, 125, 78, 79, 80, 105, 478, 107, - 108, 109, 393, 125, 399, 108, 326, 125, 399, 901, - 751, 115, 125, 905, 98, 123, 124, 953, 125, 410, - 123, 124, 125, 414, 125, 416, 125, 418, 448, 419, - 125, 108, 423, 424, 425, 426, 427, 428, 441, 115, - 108, 432, 448, 438, 29, 436, 123, 124, 125, 108, - 125, 441, 944, 106, 106, 105, 948, 107, 108, 109, - 123, 123, 453, 383, 123, 124, 125, 789, 125, 961, - 128, 462, 123, 464, 598, 123, 105, 472, 970, 470, - 126, 472, 106, 8, 115, 106, 118, 29, 479, 565, - 565, 118, 833, 126, 53, 123, 118, 106, 109, 109, - 126, 89, 565, 565, 63, 64, 118, 631, 114, 850, - 832, 114, 125, 106, 128, 123, 106, 76, 405, 406, - 407, 125, 124, 82, 125, 445, 446, 447, 126, 449, - 125, 116, 117, 118, 119, 120, 8, 122, 123, 124, - 107, 124, 562, 534, 564, 104, 106, 106, 107, 123, - 470, 50, 125, 4, 441, 123, 29, 898, 106, 479, - 126, 883, 565, 128, 125, 556, 586, 125, 588, 589, - 126, 128, 563, 125, 125, 565, 118, 119, 120, 570, - 122, 123, 124, 123, 114, 123, 577, 114, 106, 128, - 581, 115, 125, 584, 585, 115, 8, 9, 10, 125, - 123, 942, 14, 598, 125, 596, 107, 107, 599, 125, - 123, 125, 532, 123, 534, 621, 123, 125, 115, 115, - 126, 125, 542, 125, 418, 184, 477, 751, 15, 16, - 17, 18, 19, 20, 193, 626, 631, 125, 50, 123, - 631, 123, 29, 116, 117, 118, 119, 120, 207, 122, - 123, 124, 211, 182, 125, 125, 753, 577, 545, 218, - 219, 832, 549, 789, 551, 77, 553, 554, 555, 3, - 4, 5, 6, 883, 8, 418, 191, 419, 565, 350, - 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, - 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, - 620, 113, 622, 598, 563, 191, 118, 441, 476, 833, - 715, 123, 19, 20, 794, 411, -1, 8, 9, 53, - 337, -1, 29, -1, 715, -1, 850, 61, -1, 116, - 117, 118, 119, 120, -1, 122, 123, 124, -1, 8, - 9, -1, -1, 302, -1, -1, -1, -1, -1, -1, - -1, 85, -1, 87, -1, -1, 751, 91, 49, -1, - 751, -1, 782, -1, -1, 756, -1, -1, -1, -1, - -1, -1, -1, -1, 898, 334, 782, -1, -1, 113, - 49, -1, -1, 117, 118, 344, -1, 121, -1, 123, - 349, -1, 351, 127, -1, 19, 20, 88, -1, -1, - -1, 792, -1, 94, 95, 29, -1, 98, 0, 116, - 117, 118, 119, 120, -1, 122, 123, 124, 942, 88, - -1, -1, -1, -1, 744, 94, 95, -1, -1, 98, - -1, 851, 852, 853, -1, -1, -1, -1, 833, -1, - -1, -1, 833, -1, -1, 836, 405, 406, 407, -1, - 841, 43, -1, -1, -1, 850, -1, -1, -1, 850, - -1, -1, -1, 55, -1, -1, -1, -1, 60, -1, - 790, 63, -1, -1, 880, -1, -1, 797, -1, 71, - 72, -1, 74, -1, -1, -1, 78, 79, 80, -1, - -1, -1, 116, 117, 118, 119, 120, 89, 122, 123, - 124, 93, -1, 898, -1, 97, -1, 898, -1, -1, - 901, -1, -1, -1, 905, 107, -1, -1, 477, -1, - -1, 841, 778, 779, 780, 781, -1, 783, -1, -1, - -1, 937, -1, 939, 13, 14, 15, 16, 17, 18, - 19, 20, 45, -1, 47, 48, -1, 942, -1, -1, - 29, 942, -1, 944, -1, -1, -1, 948, 964, 965, - -1, 881, -1, -1, -1, 68, 69, 70, -1, -1, - 961, -1, 531, -1, 894, -1, -1, -1, -1, 970, - 83, 84, -1, -1, -1, 544, 545, 546, -1, -1, - 549, -1, 551, 96, 553, 554, 555, -1, -1, -1, - -1, 560, -1, -1, -1, 861, 862, 863, 864, 865, - 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, - 876, 877, 878, 879, -1, -1, -1, -1, -1, -1, - -1, 110, 111, 112, 113, 114, 115, 116, 117, 118, - 119, 120, -1, 122, 123, 124, -1, -1, -1, 128, - -1, -1, -1, -1, -1, -1, 912, 3, 4, 5, - 6, 7, 8, 9, 10, -1, 12, 13, 14, 15, + 1, 35, 2, 91, 5, 495, 85, 91, 91, 293, + 12, 23, 23, 10, 23, 8, 9, 0, 380, 8, + 9, 35, 107, 29, 303, 110, 125, 486, 422, 423, + 125, 31, 32, 33, 34, 448, 36, 8, 9, 8, + 9, 46, 99, 100, 101, 102, 103, 108, 105, 106, + 107, 125, 209, 108, 416, 108, 107, 114, 115, 110, + 61, 118, 119, 110, 108, 478, 127, 77, 8, 9, + 376, 125, 127, 379, 127, 381, 108, 125, 432, 91, + 91, 91, 91, 127, 85, 439, 440, 441, 442, 443, + 104, 550, 194, 116, 165, 127, 402, 403, 452, 405, + 406, 407, 116, 117, 8, 9, 108, 178, 179, 180, + 181, 182, 200, 126, 127, 469, 200, 200, 124, 125, + 126, 110, 51, 120, 53, 54, 488, 411, 162, 58, + 409, 8, 9, 592, 127, 75, 107, 125, 107, 125, + 446, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 108, 163, 165, 111, 560, 29, 474, 448, + 564, 125, 566, 50, 568, 569, 570, 178, 179, 180, + 181, 182, 125, 596, 185, 242, 599, 125, 200, 200, + 191, 200, 294, 194, 10, 501, 107, 108, 14, 478, + 125, 614, 207, 132, 133, 134, 135, 125, 213, 280, + 116, 313, 89, 56, 6, 8, 9, 10, 95, 96, + 377, 14, 382, 380, 67, 68, 386, 387, 388, 389, + 125, 585, 8, 9, 10, 51, 108, 80, 14, 168, + 125, 170, 108, 86, 107, 29, 600, 79, 80, 81, + 111, 251, 252, 108, 108, 127, 125, 186, 51, 416, + 362, 127, 124, 125, 126, 126, 109, 99, 111, 112, + 126, 127, 127, 127, 107, 51, 109, 110, 111, 280, + 111, 125, 108, 110, 646, 286, 286, 108, 108, 301, + 8, 9, 10, 294, 295, 126, 14, 302, 299, 115, + 301, 127, 78, 110, 120, 310, 127, 127, 110, 125, + 311, 107, 313, 109, 110, 111, 125, 596, 318, 127, + 480, 120, 115, 126, 426, 641, 108, 120, 8, 125, + 126, 488, 125, 51, 118, 119, 120, 121, 122, 115, + 124, 125, 126, 343, 120, 127, 110, 4, 107, 125, + 193, 8, 9, 354, 366, 434, 104, 105, 106, 202, + 116, 362, 125, 126, 293, 79, 80, 81, 858, 6, + 371, 125, 377, 216, 125, 380, 377, 220, 412, 380, + 414, 382, 109, 226, 227, 386, 387, 388, 389, 125, + 126, 392, 125, 126, 395, 127, 809, 115, 399, 399, + 108, 127, 120, 127, 127, 110, 768, 127, 409, 128, + 127, 416, 421, 422, 423, 416, 29, 117, 127, 419, + 125, 126, 127, 435, 127, 426, 127, 117, 127, 430, + 464, 432, 127, 434, 127, 29, 127, 494, 439, 440, + 441, 442, 443, 444, 287, 457, 457, 448, 457, 454, + 464, 452, 127, 125, 110, 110, 613, 773, 108, 108, + 125, 461, 462, 463, 127, 465, 125, 125, 469, 125, + 126, 127, 107, 107, 317, 108, 130, 478, 8, 480, + 108, 117, 411, 488, 128, 486, 486, 488, 850, 646, + 120, 120, 580, 125, 495, 495, 580, 580, 120, 110, + 806, 108, 111, 111, 866, 118, 119, 120, 121, 122, + 90, 124, 125, 126, 125, 126, 127, 360, 120, 116, + 125, 116, 365, 127, 367, 126, 120, 121, 122, 591, + 124, 125, 126, 108, 127, 108, 128, 853, 127, 130, + 127, 8, 109, 849, 126, 108, 125, 51, 548, 550, + 550, 560, 914, 127, 4, 564, 125, 566, 108, 568, + 569, 570, 130, 577, 128, 579, 127, 127, 580, 580, + 571, 580, 29, 17, 18, 19, 20, 578, 421, 422, + 423, 128, 130, 127, 585, 29, 127, 601, 125, 603, + 604, 592, 592, 899, 116, 596, 958, 125, 599, 600, + 116, 917, 636, 130, 117, 921, 108, 127, 613, 117, + 611, 768, 127, 614, 125, 615, 616, 617, 618, 619, + 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, + 630, 631, 632, 633, 634, 635, 127, 637, 109, 109, + 641, 646, 127, 125, 960, 646, 127, 125, 964, 125, + 493, 128, 127, 127, 3, 4, 5, 6, 117, 8, + 191, 977, 127, 120, 121, 122, 117, 124, 125, 126, + 986, 127, 116, 117, 118, 119, 120, 121, 122, 125, + 124, 125, 126, 125, 127, 434, 127, 493, 770, 806, + 849, 899, 434, 850, 200, 435, 366, 578, 613, 200, + 457, 492, 427, 732, 547, 54, -1, -1, -1, 866, + -1, -1, -1, 62, -1, -1, 559, 560, 561, -1, + -1, 564, -1, 566, -1, 568, 569, 570, -1, -1, + -1, 732, 575, 795, 796, 797, 798, 86, 800, 88, + -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 811, -1, -1, 914, -1, -1, + -1, 761, -1, 768, -1, 799, 115, 768, -1, -1, + 119, 120, 773, -1, 123, -1, 125, -1, -1, -1, + 129, -1, -1, -1, -1, 799, -1, -1, -1, -1, + -1, 795, 796, 797, 798, -1, 800, 17, 18, 19, + 20, 958, -1, -1, -1, -1, -1, 807, 809, 29, + -1, -1, -1, -1, 814, 877, 878, 879, 880, 881, + 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, + 892, 893, 894, 895, 15, 16, 17, 18, 19, 20, + -1, -1, -1, -1, -1, 850, -1, -1, 29, 850, + -1, -1, 853, 867, 868, 869, -1, 858, 858, -1, + -1, 866, 896, -1, -1, 866, 928, -1, -1, -1, + -1, -1, -1, 877, 878, 879, 880, 881, 882, 883, + 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, + 894, 895, -1, -1, -1, -1, -1, 897, 118, 119, + 120, 121, 122, -1, 124, 125, 126, 969, -1, 914, + 910, -1, -1, 914, -1, -1, 917, -1, -1, 953, + 921, 955, -1, -1, 928, -1, -1, -1, -1, -1, + -1, -1, 113, 114, 115, 116, 117, 118, 119, 120, + 121, 122, -1, 124, 125, 126, 980, 981, -1, -1, + -1, -1, -1, 958, -1, -1, -1, 958, -1, 960, + -1, -1, -1, 964, -1, 969, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 977, 3, 4, 5, + 6, 7, 8, 9, 10, 986, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 953, -1, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, -1, - 56, -1, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, -1, -1, -1, 73, -1, 75, - -1, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, -1, 90, 91, 92, 93, 94, 95, - 96, -1, 98, 99, 100, 101, -1, -1, -1, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, + 36, 37, 38, 39, 40, 41, 42, -1, -1, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + -1, 57, -1, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, -1, -1, -1, 74, -1, + 76, -1, 78, 79, 80, 81, 82, 83, 84, 85, + 86, 87, 88, 89, -1, 91, 92, 93, 94, 95, + 96, 97, -1, 99, 100, 101, 102, 103, -1, -1, + -1, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, 128, 3, 4, 5, 6, 7, 8, 9, - 10, -1, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, -1, -1, -1, -1, -1, -1, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, -1, -1, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, -1, 56, -1, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - -1, -1, -1, 73, -1, 75, -1, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, -1, - 90, 91, 92, 93, 94, 95, 96, -1, 98, 99, - 100, 101, -1, -1, -1, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, -1, 127, 128, -1, - 3, 4, 5, 6, -1, 8, 9, -1, -1, -1, + 126, 127, 128, 129, 130, 3, 4, 5, 6, 7, + 8, 9, 10, 956, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, -1, -1, -1, -1, -1, + -1, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, -1, 57, + -1, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, -1, -1, -1, 74, -1, 76, -1, + 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, -1, 91, 92, 93, 94, 95, 96, 97, + -1, 99, 100, 101, 102, 103, -1, 8, 9, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + -1, 129, 130, 3, 4, 5, 6, -1, 8, 9, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 8, 9, -1, -1, -1, -1, -1, 14, 15, + -1, 14, 15, 16, 17, 18, 19, 20, -1, -1, + -1, -1, -1, -1, -1, 45, 29, 47, 48, 49, + 50, 51, -1, 53, 54, -1, -1, 57, 89, -1, + -1, -1, 62, 63, 95, 96, -1, -1, 99, 69, + 70, 71, -1, -1, -1, -1, 76, -1, -1, -1, + -1, -1, -1, -1, 84, 85, 86, -1, 88, 89, + -1, -1, 92, -1, -1, 95, 96, 97, -1, -1, + 100, -1, 102, 3, 4, 5, 6, -1, 8, 9, + -1, -1, 12, -1, -1, 115, -1, -1, -1, 119, + 120, -1, -1, 123, -1, 125, 8, 9, -1, 129, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + -1, 124, 125, 126, -1, 45, -1, 47, 48, 49, + 50, 51, -1, 53, 54, -1, -1, 57, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, 50, 69, + 70, 71, -1, -1, -1, -1, 76, -1, -1, -1, + -1, -1, -1, -1, 84, 85, 86, -1, 88, 89, + -1, -1, 92, -1, -1, 95, 96, 97, -1, -1, + 100, -1, 102, 3, 4, 5, 6, 89, 8, 9, + -1, -1, 12, 95, 96, 115, -1, 99, -1, 119, + -1, -1, -1, 123, -1, 125, 8, 9, -1, 129, + -1, 14, 15, 16, 17, 18, 19, 20, -1, -1, + -1, -1, -1, -1, -1, 45, 29, 47, 48, 49, + 50, 51, -1, 53, 54, -1, -1, 57, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, 50, 69, + 70, 71, 19, 20, -1, -1, 76, -1, -1, -1, + -1, -1, 29, -1, 84, 85, 86, -1, 88, 89, + -1, -1, 92, -1, -1, 95, 96, 97, -1, -1, + 100, -1, 102, 3, 4, 5, 6, 89, 8, 9, + -1, 19, 20, 95, 96, 115, -1, 99, -1, 119, + -1, 29, -1, 123, -1, 125, -1, -1, -1, 129, + 113, 114, 115, -1, -1, 118, 119, 120, 121, 122, + -1, 124, 125, 126, -1, 45, -1, 47, 48, 49, + -1, -1, -1, 53, 54, -1, -1, -1, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, -1, 69, + 70, 118, 119, 120, 121, 122, 76, 124, 125, 126, + -1, -1, -1, -1, 84, 85, 86, -1, 88, -1, + -1, -1, 92, 3, 4, 5, 6, 97, 8, 9, + -1, -1, 102, -1, -1, -1, -1, -1, -1, -1, + 118, 119, 120, 121, 122, 115, 124, 125, 126, 119, + 120, -1, -1, 123, -1, 125, -1, 127, -1, 129, + -1, -1, -1, -1, -1, 45, -1, 47, 48, 49, + -1, -1, -1, 53, 54, -1, -1, -1, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, -1, 69, + 70, -1, -1, -1, -1, -1, 76, -1, -1, -1, + -1, -1, -1, -1, 84, 85, 86, -1, 88, -1, + -1, -1, 92, 3, 4, 5, 6, 97, 8, 9, + -1, -1, 102, -1, -1, -1, 45, 107, 47, 48, + 49, -1, -1, -1, 53, 115, -1, -1, -1, 119, + 120, -1, -1, 123, 63, 125, -1, -1, -1, 129, + 69, 70, 71, -1, -1, 45, -1, 47, 48, 49, + -1, -1, -1, 53, 54, 84, 85, -1, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, 97, 69, + 70, -1, -1, 102, -1, -1, 76, -1, -1, -1, + -1, -1, -1, -1, 84, 85, 86, -1, 88, -1, + -1, -1, 92, 3, 4, 5, 6, 97, 8, 9, + -1, -1, 102, -1, -1, -1, 45, 107, 47, 48, + 49, -1, -1, -1, -1, 115, -1, -1, -1, 119, + 120, -1, -1, 123, 63, 125, -1, -1, -1, 129, + 69, 70, 71, -1, -1, 45, -1, 47, 48, 49, + -1, -1, -1, 53, 54, 84, 85, -1, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, 97, 69, + 70, -1, -1, 102, -1, -1, 76, -1, -1, -1, + -1, -1, -1, -1, 84, 85, 86, -1, 88, -1, + -1, -1, 92, 3, 4, 5, 6, 97, 8, 9, + -1, -1, 102, -1, -1, -1, 45, -1, 47, 48, + 49, -1, -1, -1, -1, 115, -1, -1, -1, 119, + 120, -1, -1, 123, -1, 125, -1, 127, -1, 129, + 69, 70, 71, -1, -1, 45, -1, 47, 48, 49, + -1, -1, -1, 53, 54, 84, 85, -1, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, 97, 69, + 70, -1, -1, 102, -1, -1, 76, -1, -1, -1, + -1, -1, -1, -1, 84, 85, 86, -1, 88, -1, + -1, -1, 92, 3, 4, 5, 6, 97, 8, 9, + -1, -1, 102, -1, -1, -1, -1, 107, -1, -1, + -1, -1, -1, -1, -1, 115, -1, -1, -1, 119, + 120, -1, -1, 123, -1, 125, -1, -1, -1, 129, + -1, -1, -1, -1, -1, 45, -1, 47, 48, 49, + -1, -1, -1, 53, 54, -1, -1, -1, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, -1, 69, + 70, -1, -1, -1, -1, -1, 76, -1, -1, -1, + -1, -1, -1, -1, 84, 85, 86, -1, 88, -1, + -1, -1, 92, 3, 4, 5, 6, 97, 8, 9, + -1, -1, 102, -1, -1, -1, 45, -1, 47, 48, + 49, -1, -1, -1, 53, 115, -1, -1, -1, 119, + 120, -1, -1, 123, 63, 125, -1, 127, -1, 129, + 69, 70, 71, -1, -1, 45, -1, 47, 48, 49, + -1, -1, -1, 53, 54, 84, 85, -1, -1, -1, + -1, -1, 62, 63, -1, -1, -1, -1, 97, 69, + 70, -1, -1, 102, -1, -1, 76, 15, 16, 17, + 18, 19, 20, -1, 84, 85, 86, -1, 88, -1, + -1, 29, 92, -1, -1, -1, 125, 97, -1, -1, + -1, -1, 102, -1, -1, 13, 14, 15, 16, 17, + 18, 19, 20, -1, -1, 115, -1, -1, -1, 119, + 120, 29, -1, 123, -1, 125, -1, -1, -1, 129, + 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, + -1, -1, -1, -1, -1, -1, 29, -1, -1, 13, + 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, + -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 114, 115, 116, 117, + 118, 119, 120, 121, 122, -1, 124, 125, 126, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, -1, 124, 125, 126, -1, + -1, -1, 130, -1, -1, -1, -1, -1, -1, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + -1, 124, 125, 126, -1, -1, -1, 130, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, -1, + 124, 125, 126, 8, 9, -1, 130, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, - -1, -1, 45, 29, 47, 48, 49, 50, -1, 52, - 53, -1, -1, 56, -1, -1, -1, -1, 61, 62, - -1, -1, 49, -1, -1, 68, 69, 70, -1, -1, - -1, 940, 75, -1, -1, -1, -1, -1, -1, -1, - 83, 84, 85, -1, 87, 88, -1, -1, 91, -1, - -1, 94, 95, 96, -1, -1, 99, 3, 4, 5, - 6, 88, 8, 9, -1, -1, 12, 94, 95, -1, - 113, 98, -1, -1, 117, 118, -1, -1, 121, -1, - 123, -1, -1, -1, 127, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, -1, 122, 123, 124, 45, - -1, 47, 48, 49, 50, -1, 52, 53, -1, -1, - 56, -1, -1, -1, -1, 61, 62, -1, -1, -1, - -1, -1, 68, 69, 70, -1, -1, -1, -1, 75, - -1, -1, -1, -1, -1, -1, -1, 83, 84, 85, - -1, 87, 88, -1, -1, 91, -1, -1, 94, 95, - 96, -1, -1, 99, 3, 4, 5, 6, -1, 8, - 9, -1, -1, 12, -1, -1, -1, 113, -1, -1, - -1, 117, -1, -1, -1, 121, -1, 123, -1, -1, - -1, 127, 14, 15, 16, 17, 18, 19, 20, -1, - -1, -1, 45, -1, 47, 48, 45, 29, 47, 48, - 49, 50, -1, 52, 53, -1, -1, 56, -1, -1, - -1, -1, 61, 62, -1, 68, 69, 70, -1, 68, - 69, 70, -1, -1, -1, -1, 75, -1, -1, -1, - 83, 84, -1, -1, 83, 84, 85, -1, 87, 88, - -1, -1, 91, 96, -1, 94, 95, 96, -1, -1, - 99, 3, 4, 5, 6, -1, 8, 9, -1, -1, - -1, -1, -1, -1, 113, -1, -1, -1, 117, -1, - 123, -1, 121, -1, 123, -1, -1, -1, 127, 111, - 112, 113, -1, -1, 116, 117, 118, 119, 120, -1, - 122, 123, 124, 45, -1, 47, 48, -1, -1, -1, - 52, 53, -1, -1, -1, -1, -1, -1, -1, 61, - 62, -1, -1, -1, -1, -1, 68, 69, -1, -1, - -1, -1, -1, 75, -1, 45, -1, 47, 48, -1, - -1, 83, 84, 85, -1, 87, -1, -1, -1, 91, - 3, 4, 5, 6, 96, 8, 9, -1, 68, 69, - 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 113, -1, 83, 84, 117, 118, -1, -1, 121, - -1, 123, -1, 125, -1, 127, 96, -1, -1, -1, - -1, -1, 45, -1, 47, 48, -1, -1, -1, 52, - 53, -1, -1, -1, -1, -1, -1, -1, 61, 62, - -1, -1, -1, 123, -1, 68, 69, -1, 8, 9, - -1, -1, 75, -1, -1, -1, -1, -1, -1, -1, - 83, 84, 85, -1, 87, -1, -1, -1, 91, 3, - 4, 5, 6, 96, 8, 9, -1, -1, -1, -1, - -1, -1, 105, -1, -1, 45, -1, 47, 48, -1, - 113, -1, 52, -1, 117, 118, -1, -1, 121, -1, - 123, -1, 62, -1, 127, -1, -1, -1, 68, 69, - 70, 45, -1, 47, 48, -1, -1, -1, 52, 53, - -1, -1, -1, 83, 84, -1, -1, 61, 62, -1, - -1, -1, -1, -1, 68, 69, 96, -1, -1, 99, - -1, 75, -1, 45, -1, 47, 48, -1, -1, 83, - 84, 85, -1, 87, -1, -1, -1, 91, 3, 4, - 5, 6, 96, 8, 9, -1, 68, 69, 70, -1, - -1, 105, -1, -1, 45, -1, 47, 48, -1, 113, - -1, 83, 84, 117, 118, -1, -1, 121, -1, 123, - -1, 62, -1, 127, 96, -1, -1, 68, 69, 70, - 45, -1, 47, 48, -1, -1, -1, 52, 53, -1, - -1, -1, 83, 84, -1, -1, 61, 62, -1, -1, - -1, 123, -1, 68, 69, 96, -1, -1, -1, -1, - 75, -1, -1, -1, -1, -1, -1, -1, 83, 84, - 85, -1, 87, -1, -1, -1, 91, 3, 4, 5, - 6, 96, 8, 9, -1, -1, -1, -1, -1, -1, - 45, -1, 47, 48, -1, -1, -1, 52, 113, -1, - -1, -1, 117, 118, -1, -1, 121, 62, 123, -1, - 125, -1, 127, 68, 69, 70, -1, -1, -1, 45, - -1, 47, 48, -1, -1, -1, 52, 53, 83, 84, - -1, -1, -1, -1, -1, 61, 62, -1, -1, -1, - -1, 96, 68, 69, -1, -1, -1, -1, -1, 75, - -1, -1, -1, -1, -1, -1, -1, 83, 84, 85, - -1, 87, -1, -1, -1, 91, 3, 4, 5, 6, - 96, 8, 9, -1, -1, -1, -1, -1, -1, 105, - -1, -1, -1, -1, -1, -1, -1, 113, -1, -1, - -1, 117, 118, -1, -1, 121, -1, 123, -1, -1, - -1, 127, -1, -1, -1, -1, -1, -1, 45, -1, - 47, 48, -1, -1, -1, 52, 53, -1, -1, -1, - -1, -1, -1, -1, 61, 62, -1, -1, -1, -1, - -1, 68, 69, -1, -1, -1, -1, -1, 75, -1, - -1, -1, -1, -1, -1, -1, 83, 84, 85, -1, - 87, -1, -1, -1, 91, 3, 4, 5, 6, 96, - 8, 9, -1, -1, -1, -1, -1, -1, 45, -1, - 47, 48, -1, -1, -1, 52, 113, -1, -1, -1, - 117, 118, -1, -1, 121, 62, 123, -1, 125, -1, - 127, 68, 69, 70, -1, -1, -1, 45, -1, 47, - 48, -1, -1, -1, 52, 53, 83, 84, -1, -1, - -1, -1, -1, 61, 62, -1, -1, -1, -1, 96, - 68, 69, -1, -1, -1, -1, -1, 75, -1, -1, - -1, -1, -1, -1, -1, 83, 84, 85, -1, 87, - -1, -1, -1, 91, -1, -1, 123, -1, 96, -1, - 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, - -1, -1, -1, -1, -1, 113, 29, -1, -1, 117, - 118, -1, -1, 121, -1, 123, -1, -1, -1, 127, - 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, - -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, - 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, - -1, -1, -1, -1, -1, -1, 29, -1, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 13, 14, 15, 16, 17, 18, 19, 20, 51, -1, - -1, -1, -1, -1, -1, -1, 29, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, -1, 122, - 123, 124, 75, -1, -1, 128, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, -1, 122, - 123, 124, -1, 106, -1, 128, 109, -1, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, 121, -1, - 123, 124, 8, 9, 127, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 108, -1, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, -1, 122, - 123, 124, -1, -1, -1, -1, -1, -1, 44, 45, - -1, 47, 48, 49, 50, -1, 52, -1, -1, -1, - 56, 57, 58, 59, -1, -1, 62, -1, -1, -1, - -1, 67, 68, 69, 70, -1, -1, 73, 8, 9, - -1, 77, -1, -1, -1, 81, -1, 83, 84, -1, - 86, -1, 88, -1, -1, -1, -1, -1, 94, 95, - 96, -1, 98, 99, 100, -1, -1, -1, -1, 105, - -1, -1, -1, -1, 44, 45, -1, 47, 48, 49, - 50, -1, 52, -1, -1, 121, 56, 57, 58, 59, - -1, -1, 62, -1, -1, 8, 9, 67, 68, 69, - 70, -1, -1, 73, -1, -1, -1, 77, -1, -1, - -1, 81, -1, 83, 84, -1, 86, -1, 88, -1, - -1, -1, -1, -1, 94, 95, 96, -1, 98, 99, - 100, 44, 45, -1, 47, 48, 49, 50, -1, 52, - -1, -1, -1, 56, 57, 58, 59, -1, -1, 62, - -1, 121, -1, -1, 67, 68, 69, 70, -1, -1, - 73, -1, -1, -1, 77, -1, -1, -1, 81, -1, - 83, 84, -1, 86, -1, 88, -1, -1, -1, -1, - -1, 94, 95, 96, -1, 98, 99, 100, 13, 14, + -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, -1, -1, -1, + 45, -1, 47, 48, 49, -1, 52, -1, 53, 45, + -1, 47, 48, 49, -1, -1, -1, -1, 63, -1, + -1, -1, -1, -1, 69, 70, 71, -1, -1, -1, + 76, -1, -1, 69, 70, 71, -1, -1, -1, 84, + 85, -1, -1, -1, -1, 8, 9, -1, 84, 85, + -1, -1, 97, -1, -1, 100, -1, 102, -1, -1, + -1, 97, 108, -1, -1, 111, 102, 113, 114, 115, + 116, 117, 118, 119, 120, 121, 122, 123, -1, 125, + 126, 44, 45, 129, 47, 48, 49, 50, 51, 125, + 53, -1, -1, -1, 57, 58, 59, 60, -1, -1, + 63, -1, -1, -1, -1, 68, 69, 70, 71, -1, + -1, 74, 8, 9, -1, 78, -1, -1, -1, 82, + -1, 84, 85, -1, 87, -1, 89, -1, -1, -1, + -1, -1, 95, 96, 97, -1, 99, 100, 101, 102, + -1, -1, -1, -1, 107, -1, -1, -1, 44, 45, + -1, 47, 48, 49, 50, 51, -1, 53, -1, -1, + 123, 57, 58, 59, 60, -1, -1, 63, -1, -1, + -1, -1, 68, 69, 70, 71, -1, -1, 74, 8, + 9, -1, 78, -1, -1, -1, 82, -1, 84, 85, + -1, 87, -1, 89, -1, -1, -1, -1, -1, 95, + 96, 97, -1, 99, 100, 101, 102, 13, 14, 15, + 16, 17, 18, 19, 20, 44, 45, -1, 47, 48, + 49, 50, 51, 29, 53, -1, -1, 123, 57, 58, + 59, 60, -1, -1, 63, -1, -1, -1, -1, 68, + 69, 70, 71, -1, -1, 74, -1, -1, -1, 78, + -1, -1, -1, 82, -1, 84, 85, -1, 87, -1, + 89, -1, -1, -1, -1, -1, 95, 96, 97, -1, + 99, 100, 101, 102, 13, 14, 15, 16, 17, 18, + 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, + 29, -1, -1, -1, 123, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 110, -1, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 121, 122, -1, 124, 125, + 126, 13, 14, 15, 16, 17, 18, 19, 20, -1, + -1, -1, -1, -1, -1, -1, -1, 29, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, - -1, -1, -1, -1, 29, -1, -1, -1, 121, 13, - 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, - -1, -1, -1, -1, -1, 29, 13, 14, 15, 16, - 17, 18, 19, 20, -1, -1, -1, -1, -1, -1, - -1, -1, 29, 13, 14, 15, 16, 17, 18, 19, - 20, -1, -1, -1, -1, -1, -1, -1, -1, 29, - 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, - -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, - -1, -1, 107, -1, -1, 110, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 120, -1, 122, 123, 124, - -1, -1, 106, -1, -1, -1, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, - 124, 108, -1, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 120, -1, 122, 123, 124, -1, -1, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, -1, 122, 123, 124, -1, -1, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, -1, 122, - 123, 124, 13, 14, 15, 16, 17, 18, 19, 20, - -1, -1, -1, -1, -1, -1, -1, -1, 29, 13, - 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, - -1, -1, -1, -1, -1, 29, 15, 16, 17, 18, - 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, - 29, 15, 16, 17, 18, 19, 20, -1, -1, -1, - -1, -1, -1, -1, -1, 29, 15, 16, 17, 18, - 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, - 29, 15, 16, 17, 18, 19, 20, -1, -1, -1, - -1, -1, -1, -1, -1, 29, -1, 108, -1, 110, - 111, 112, 113, -1, -1, 116, 117, 118, 119, 120, - -1, 122, 123, 124, -1, -1, 110, 111, 112, 113, - -1, -1, 116, 117, 118, 119, 120, -1, 122, 123, - 124, -1, 111, 112, 113, 114, 115, 116, 117, 118, - 119, 120, -1, 122, 123, 124, -1, -1, 112, 113, - 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, - 124, -1, -1, -1, 113, 114, 115, 116, 117, 118, - 119, 120, -1, 122, 123, 124, -1, 111, 112, 113, - -1, -1, 116, 117, 118, 119, 120, -1, 122, 123, - 124, 15, 16, 17, 18, 19, 20, -1, -1, -1, - -1, -1, -1, -1, -1, 29, 15, 16, 17, 18, - 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, - 29, 15, 16, 17, 18, 19, 20, -1, -1, -1, - -1, -1, -1, -1, -1, 29, 17, 18, 19, 20, - -1, -1, -1, -1, -1, -1, -1, -1, 29, 17, + -1, -1, -1, -1, 29, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, -1, -1, - -1, 29, -1, -1, -1, -1, -1, -1, -1, -1, + 109, 29, -1, 112, 113, 114, 115, 116, 117, 118, + 119, 120, 121, 122, -1, 124, 125, 126, 13, 14, + 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, + -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 108, -1, -1, -1, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 122, -1, 124, 125, 126, 110, -1, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, -1, 124, + 125, 126, -1, -1, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, -1, 124, 125, 126, 13, + 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, + -1, -1, -1, -1, -1, 29, -1, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, -1, 124, + 125, 126, 13, 14, 15, 16, 17, 18, 19, 20, + -1, -1, -1, -1, -1, -1, -1, -1, 29, 15, + 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, + -1, -1, -1, 29, 15, 16, 17, 18, 19, 20, + -1, -1, -1, -1, -1, -1, -1, -1, 29, 15, + 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, + -1, -1, -1, 29, -1, -1, 110, -1, 112, 113, + 114, 115, -1, -1, 118, 119, 120, 121, 122, -1, + 124, 125, 126, 15, 16, 17, 18, 19, 20, -1, + -1, -1, -1, -1, -1, -1, -1, 29, -1, -1, + -1, 112, 113, 114, 115, -1, -1, 118, 119, 120, + 121, 122, -1, 124, 125, 126, -1, -1, -1, 115, + 116, 117, 118, 119, 120, 121, 122, -1, 124, 125, + 126, -1, 113, 114, 115, -1, -1, 118, 119, 120, + 121, 122, -1, 124, 125, 126, -1, -1, -1, -1, + 116, 117, 118, 119, 120, 121, 122, -1, 124, 125, + 126, 15, 16, 17, 18, 19, 20, -1, -1, -1, + -1, -1, -1, -1, -1, 29, -1, -1, -1, 0, + -1, -1, 114, 115, -1, -1, 118, 119, 120, 121, + 122, -1, 124, 125, 126, 15, 16, 17, 18, 19, + 20, -1, -1, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, - 124, -1, -1, 112, 113, -1, -1, 116, 117, 118, - 119, 120, -1, 122, 123, 124, -1, -1, -1, 113, - 8, 9, 116, 117, 118, 119, 120, -1, 122, 123, - 124, -1, -1, 114, 115, 116, 117, 118, 119, 120, - -1, 122, 123, 124, -1, -1, -1, -1, 116, 117, - 118, 119, 120, -1, 122, 123, 124, 45, -1, 47, - 48, 49, 50, -1, 52, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 62, -1, 9, -1, -1, -1, - 68, 69, 70, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 83, 84, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 94, -1, 96, -1, - -1, 99, 45, -1, 47, 48, 49, 50, -1, 52, - -1, -1, -1, 56, -1, -1, -1, -1, -1, 62, - -1, 9, -1, -1, -1, 68, 69, 70, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 83, 84, -1, -1, -1, 88, -1, -1, -1, -1, - -1, 94, 95, 96, -1, -1, 99, 45, -1, 47, - 48, 49, 50, -1, 52, -1, -1, -1, 56, -1, - -1, -1, -1, -1, 62, -1, 9, -1, -1, -1, - 68, 69, 70, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 83, 84, -1, -1, -1, - 88, -1, -1, -1, -1, -1, 94, 95, 96, -1, - -1, 99, 45, -1, 47, 48, 49, -1, -1, 52, - -1, -1, -1, 56, -1, -1, -1, -1, -1, 62, - -1, 9, -1, -1, -1, 68, 69, 70, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 83, 84, -1, -1, -1, 88, -1, -1, -1, -1, - -1, 94, 95, 96, -1, -1, 99, 45, -1, 47, - 48, 49, -1, -1, 52, -1, -1, -1, 56, -1, - -1, -1, -1, -1, 62, -1, -1, -1, -1, -1, - 68, 69, 70, -1, -1, 43, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 83, 84, 55, -1, -1, - 88, -1, 60, -1, -1, 63, 94, 95, 96, -1, - -1, 99, -1, 71, 72, -1, 74, 43, -1, -1, - 78, 79, 80, -1, -1, -1, -1, -1, -1, 55, - -1, 89, -1, -1, 60, 93, -1, 63, -1, 97, - -1, -1, -1, -1, -1, 71, 72, -1, 74, 107, - -1, -1, 78, 79, 80, -1, -1, 43, -1, -1, - -1, -1, -1, 89, -1, -1, -1, 93, 126, 55, - -1, 97, -1, -1, 60, -1, -1, 63, -1, -1, - -1, 107, -1, -1, -1, 71, 72, -1, 74, 43, - -1, -1, 78, 79, 80, -1, -1, -1, -1, -1, - 126, 55, -1, 89, -1, -1, 60, 93, -1, 63, - -1, 97, -1, -1, -1, -1, -1, 71, 72, -1, - 74, 107, -1, -1, 78, 79, 80, -1, -1, 43, - -1, -1, -1, -1, -1, 89, -1, -1, -1, 93, - 126, 55, -1, 97, -1, -1, 60, -1, -1, 63, - -1, -1, -1, 107, -1, -1, -1, 71, 72, -1, - 74, 43, -1, -1, 78, 79, 80, -1, -1, -1, - -1, -1, 126, 55, -1, 89, -1, -1, 60, 93, - -1, 63, -1, 97, -1, -1, -1, -1, -1, 71, - 72, -1, 74, 107, -1, -1, 78, 79, 80, -1, - -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, - -1, 93, 126, -1, -1, 97 + -1, -1, 43, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 56, -1, -1, -1, -1, + 61, -1, -1, 64, -1, -1, -1, -1, -1, -1, + -1, 72, 73, -1, 75, -1, -1, -1, 79, 80, + 81, 115, -1, -1, 118, 119, 120, 121, 122, 90, + 124, 125, 126, 94, 8, 9, -1, 98, -1, -1, + -1, -1, -1, -1, 9, -1, -1, -1, 109, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 118, 119, + 120, 121, 122, -1, 124, 125, 126, -1, -1, -1, + -1, 45, -1, 47, 48, 49, 50, 51, -1, 53, + 45, -1, 47, 48, 49, 50, 51, -1, 53, 63, + -1, -1, 57, -1, -1, 69, 70, 71, 63, -1, + 9, -1, -1, -1, 69, 70, 71, -1, -1, -1, + 84, 85, -1, -1, -1, -1, -1, -1, -1, 84, + 85, 95, -1, 97, 89, -1, 100, -1, 102, -1, + 95, 96, 97, -1, -1, 100, 45, 102, 47, 48, + 49, 50, 51, -1, 53, 9, -1, -1, 57, -1, + -1, -1, -1, -1, 63, -1, 9, -1, -1, -1, + 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 84, 85, -1, -1, -1, + 89, 45, -1, 47, 48, 49, 95, 96, 97, -1, + -1, 100, 45, 102, 47, 48, 49, 50, -1, -1, + 53, -1, -1, -1, 57, 69, 70, 71, -1, -1, + 63, -1, 9, -1, -1, -1, 69, 70, 71, -1, + 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 84, 85, 97, -1, -1, 89, 45, 102, 47, + 48, 49, 95, 96, 97, -1, -1, 100, 45, 102, + 47, 48, 49, 50, -1, -1, 53, -1, -1, -1, + 57, 69, 70, 71, -1, -1, 63, -1, -1, -1, + -1, -1, 69, 70, 71, -1, 84, 85, -1, -1, + -1, -1, -1, 43, -1, -1, -1, 84, 85, 97, + -1, -1, 89, -1, 102, -1, 56, -1, 95, 96, + 97, 61, -1, 100, 64, 102, -1, -1, -1, -1, + 43, -1, 72, 73, -1, 75, -1, 125, -1, 79, + 80, 81, -1, 56, -1, -1, -1, -1, 61, -1, + 90, 64, -1, -1, 94, -1, -1, 43, 98, 72, + 73, -1, 75, -1, -1, -1, 79, 80, 81, 109, + 56, -1, -1, -1, -1, 61, -1, 90, 64, -1, + -1, 94, -1, -1, 43, 98, 72, 73, 128, 75, + -1, -1, -1, 79, 80, 81, 109, 56, -1, -1, + -1, -1, 61, -1, 90, 64, -1, -1, 94, -1, + -1, 43, 98, 72, 73, 128, 75, -1, -1, -1, + 79, 80, 81, 109, 56, -1, -1, -1, -1, 61, + -1, 90, 64, -1, -1, 94, -1, -1, -1, 98, + 72, 73, 128, 75, -1, -1, -1, 79, 80, 81, + 109, -1, -1, -1, -1, -1, -1, -1, 90, -1, + -1, 45, 94, 47, 48, 49, 98, -1, -1, 128, + -1, -1, -1, -1, -1, -1, -1, 109, -1, -1, + -1, -1, -1, -1, -1, 69, 70, 71, -1, -1, + -1, 43, -1, -1, -1, -1, 128, -1, -1, -1, + 84, 85, -1, -1, 56, -1, -1, -1, -1, 61, + -1, -1, 64, 97, -1, -1, -1, -1, 102, -1, + 72, 73, -1, 75, -1, -1, -1, 79, 80, 81, + -1, -1, -1, -1, -1, -1, -1, -1, 90, -1, + -1, 125, 94, -1, -1, -1, 98 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 102, 103, 104, 130, 131, 222, 3, 4, 5, - 6, 8, 9, 45, 47, 48, 52, 53, 61, 62, - 68, 69, 75, 83, 84, 85, 87, 91, 96, 113, - 117, 118, 121, 123, 127, 215, 216, 221, 9, 45, - 47, 48, 49, 50, 52, 56, 62, 68, 69, 70, - 83, 84, 88, 94, 95, 96, 99, 181, 184, 185, - 187, 192, 194, 198, 199, 203, 204, 205, 206, 0, - 43, 55, 60, 63, 71, 72, 74, 78, 79, 80, - 89, 93, 97, 107, 134, 136, 137, 139, 140, 141, - 162, 200, 202, 222, 123, 123, 123, 123, 123, 114, - 123, 123, 123, 9, 94, 183, 198, 199, 203, 123, - 123, 123, 114, 123, 215, 215, 215, 215, 9, 45, - 47, 48, 52, 62, 68, 69, 83, 84, 96, 184, - 213, 215, 215, 13, 14, 15, 16, 17, 18, 19, - 20, 29, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 122, 123, 124, 6, 181, 52, 62, - 69, 204, 69, 204, 204, 8, 9, 220, 204, 10, - 14, 50, 113, 118, 123, 180, 222, 105, 220, 105, - 220, 108, 138, 123, 123, 105, 220, 108, 108, 108, - 163, 139, 146, 74, 220, 8, 9, 44, 50, 57, - 58, 59, 67, 73, 77, 81, 86, 94, 98, 100, - 105, 121, 151, 182, 185, 187, 192, 194, 198, 199, - 203, 212, 213, 222, 212, 212, 212, 212, 184, 212, - 212, 212, 220, 123, 220, 220, 212, 212, 184, 184, - 212, 125, 106, 125, 215, 215, 215, 215, 215, 215, + 0, 104, 105, 106, 132, 133, 223, 3, 4, 5, + 6, 8, 9, 45, 47, 48, 49, 53, 54, 62, + 63, 69, 70, 76, 84, 85, 86, 88, 92, 97, + 102, 115, 119, 120, 123, 125, 129, 216, 217, 222, + 9, 45, 47, 48, 49, 50, 51, 53, 57, 63, + 69, 70, 71, 84, 85, 89, 95, 96, 97, 100, + 102, 183, 186, 187, 189, 194, 195, 199, 200, 204, + 205, 206, 207, 0, 43, 56, 61, 64, 72, 73, + 75, 79, 80, 81, 90, 94, 98, 109, 136, 138, + 139, 141, 142, 143, 164, 201, 203, 223, 125, 125, + 125, 125, 125, 125, 116, 125, 125, 125, 9, 95, + 185, 199, 200, 204, 125, 125, 125, 116, 125, 125, + 216, 216, 216, 216, 9, 45, 47, 48, 49, 53, + 63, 69, 70, 84, 85, 97, 102, 186, 214, 216, + 216, 13, 14, 15, 16, 17, 18, 19, 20, 29, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 122, 124, 125, 126, 6, 183, 53, 63, 70, 205, + 70, 205, 205, 8, 9, 221, 205, 10, 14, 51, + 115, 120, 125, 182, 223, 107, 110, 221, 107, 221, + 110, 140, 125, 125, 107, 221, 110, 110, 110, 165, + 141, 148, 75, 221, 8, 9, 44, 51, 58, 59, + 60, 68, 74, 78, 82, 87, 95, 99, 101, 107, + 123, 153, 184, 187, 189, 194, 199, 200, 204, 213, + 214, 223, 213, 213, 213, 213, 213, 186, 213, 213, + 213, 221, 125, 221, 221, 213, 213, 186, 186, 213, + 213, 127, 108, 127, 216, 216, 216, 216, 216, 216, + 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 216, 216, 216, 216, 127, 214, 216, 182, 63, + 120, 182, 182, 182, 182, 182, 126, 197, 198, 223, + 9, 196, 205, 110, 188, 190, 138, 8, 221, 133, + 107, 116, 51, 153, 184, 221, 125, 125, 183, 222, + 51, 183, 221, 137, 221, 107, 109, 110, 111, 176, + 109, 144, 221, 221, 127, 127, 127, 127, 127, 127, + 117, 127, 127, 127, 213, 127, 127, 127, 117, 127, + 127, 216, 216, 110, 127, 130, 182, 127, 212, 216, + 223, 221, 128, 196, 133, 110, 191, 192, 223, 108, + 108, 128, 202, 8, 9, 50, 51, 95, 166, 167, + 168, 169, 204, 223, 183, 176, 149, 154, 10, 120, + 155, 145, 183, 8, 9, 10, 14, 51, 115, 120, + 180, 223, 133, 125, 208, 209, 134, 135, 221, 107, + 216, 10, 14, 51, 78, 115, 120, 125, 146, 170, + 221, 110, 125, 127, 125, 216, 125, 130, 108, 111, + 128, 79, 80, 81, 99, 193, 107, 108, 8, 221, + 133, 221, 169, 221, 117, 108, 8, 9, 10, 14, + 51, 115, 120, 125, 181, 223, 150, 151, 170, 3, + 4, 5, 8, 12, 51, 54, 62, 76, 86, 88, + 92, 115, 119, 123, 125, 129, 172, 173, 179, 183, + 218, 219, 222, 223, 120, 170, 172, 147, 170, 180, + 120, 180, 180, 180, 180, 125, 126, 128, 156, 128, + 210, 223, 107, 108, 125, 107, 177, 178, 216, 223, + 109, 120, 170, 170, 13, 14, 15, 16, 17, 18, + 19, 20, 29, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 52, 76, 108, 111, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 125, 126, 129, 162, 170, 170, 170, 110, 111, 125, + 126, 175, 176, 223, 196, 214, 214, 172, 216, 95, + 99, 200, 220, 221, 99, 220, 99, 220, 79, 80, + 81, 133, 193, 108, 127, 108, 128, 111, 181, 111, + 141, 142, 163, 164, 168, 120, 181, 181, 181, 181, + 181, 111, 126, 174, 223, 152, 170, 175, 176, 181, + 183, 116, 185, 125, 116, 216, 216, 216, 186, 214, + 216, 127, 12, 108, 181, 13, 14, 15, 16, 17, + 18, 19, 20, 29, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 124, 125, 126, 170, 110, + 127, 127, 175, 176, 125, 180, 159, 212, 172, 3, + 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 57, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 74, 76, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 91, 92, 93, 94, 95, 96, 97, 99, 100, 101, + 102, 103, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 129, 130, 211, 208, 135, 213, 177, + 128, 108, 170, 127, 130, 127, 4, 216, 171, 212, + 108, 127, 127, 127, 108, 221, 220, 221, 220, 220, + 220, 220, 220, 128, 8, 109, 221, 186, 174, 186, + 181, 127, 54, 86, 88, 115, 119, 120, 123, 125, + 129, 215, 217, 212, 175, 176, 108, 111, 175, 181, + 186, 125, 186, 186, 127, 127, 51, 161, 223, 12, + 179, 175, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + 216, 216, 216, 127, 214, 216, 127, 125, 161, 108, + 160, 172, 130, 127, 210, 128, 127, 128, 107, 216, + 172, 130, 146, 161, 127, 127, 125, 116, 125, 116, + 215, 215, 215, 215, 186, 214, 215, 13, 14, 15, + 16, 17, 18, 19, 20, 29, 112, 113, 114, 115, + 118, 119, 120, 121, 122, 124, 125, 126, 130, 108, + 151, 216, 175, 117, 213, 127, 117, 216, 77, 91, + 110, 127, 130, 125, 157, 147, 172, 127, 161, 128, + 177, 127, 109, 109, 172, 186, 186, 186, 127, 127, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 215, 125, 213, 215, 180, 62, - 118, 180, 180, 180, 180, 180, 124, 193, 105, 186, - 188, 136, 8, 220, 131, 105, 114, 50, 151, 182, - 220, 123, 123, 181, 221, 50, 181, 220, 135, 220, - 105, 107, 108, 109, 174, 107, 142, 220, 220, 125, - 125, 125, 125, 125, 115, 125, 125, 125, 212, 125, - 125, 125, 115, 125, 215, 215, 108, 125, 128, 180, - 125, 211, 215, 222, 196, 197, 222, 195, 131, 108, - 189, 190, 222, 106, 106, 126, 201, 8, 9, 49, - 50, 94, 164, 165, 166, 167, 203, 222, 181, 174, - 147, 152, 10, 118, 153, 143, 181, 8, 9, 10, - 14, 50, 113, 118, 178, 222, 131, 123, 207, 208, - 132, 133, 220, 105, 215, 10, 14, 50, 77, 113, - 118, 123, 144, 168, 220, 123, 125, 123, 215, 123, - 128, 220, 126, 197, 126, 78, 79, 80, 98, 191, - 105, 106, 8, 220, 131, 220, 167, 220, 115, 106, - 8, 9, 10, 14, 50, 113, 118, 123, 179, 222, - 148, 149, 168, 3, 4, 5, 8, 12, 50, 53, - 61, 75, 85, 87, 91, 113, 117, 121, 123, 127, - 170, 171, 177, 181, 217, 218, 221, 222, 118, 168, - 170, 145, 168, 178, 118, 178, 178, 178, 178, 123, - 124, 126, 154, 126, 209, 222, 105, 106, 123, 105, - 175, 176, 215, 222, 107, 118, 168, 168, 13, 14, - 15, 16, 17, 18, 19, 20, 29, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 51, - 75, 106, 109, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 123, 124, 127, 160, 168, 168, - 168, 108, 109, 123, 124, 173, 174, 222, 213, 213, - 170, 106, 109, 126, 94, 98, 199, 219, 220, 98, - 219, 98, 219, 78, 79, 80, 131, 191, 106, 125, - 106, 126, 109, 179, 109, 139, 140, 161, 162, 166, - 118, 179, 179, 179, 179, 179, 109, 124, 172, 222, - 150, 168, 173, 174, 179, 181, 114, 183, 123, 114, - 215, 215, 215, 184, 213, 215, 125, 12, 106, 179, - 13, 14, 15, 16, 17, 18, 19, 20, 29, 110, - 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, - 122, 123, 124, 168, 108, 125, 125, 173, 174, 123, - 178, 157, 211, 170, 3, 4, 5, 6, 7, 8, - 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 56, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 73, 75, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, - 96, 98, 99, 100, 101, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 127, 128, 210, 207, - 133, 212, 175, 126, 106, 168, 125, 128, 125, 4, - 215, 169, 211, 106, 125, 125, 125, 215, 220, 219, - 220, 219, 219, 219, 219, 219, 126, 8, 107, 220, - 184, 172, 184, 179, 125, 53, 85, 87, 113, 117, - 118, 121, 123, 127, 214, 216, 211, 173, 174, 106, - 109, 173, 179, 184, 123, 184, 184, 125, 125, 50, - 159, 222, 12, 177, 173, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 215, 215, 125, 213, 215, 125, - 123, 159, 106, 158, 170, 128, 125, 209, 126, 125, - 126, 105, 215, 170, 128, 144, 159, 106, 125, 125, - 123, 114, 123, 114, 214, 214, 214, 214, 184, 213, - 214, 13, 14, 15, 16, 17, 18, 19, 20, 29, - 110, 111, 112, 113, 116, 117, 118, 119, 120, 122, - 123, 124, 128, 106, 149, 215, 173, 115, 212, 125, - 115, 215, 76, 90, 108, 125, 128, 123, 155, 145, - 170, 125, 159, 126, 175, 125, 107, 107, 170, 184, - 184, 184, 125, 125, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 214, 214, 214, 125, 213, 215, 150, 123, 125, 123, - 123, 215, 156, 170, 125, 159, 126, 159, 125, 115, - 125, 115, 214, 108, 125, 128, 213, 213, 125, 220, - 170, 125, 159, 159, 123, 123, 214, 125, 125, 125, - 125, 159, 213, 213, 159, 125, 125 + 215, 215, 215, 215, 215, 215, 215, 215, 215, 127, + 214, 216, 152, 125, 127, 125, 125, 216, 158, 172, + 127, 161, 128, 161, 127, 117, 127, 117, 215, 110, + 127, 130, 214, 214, 127, 221, 172, 127, 161, 161, + 125, 125, 215, 127, 127, 127, 127, 161, 214, 214, + 161, 127, 127 }; #define yyerrok (yyerrstatus = 0) @@ -3329,7 +3348,7 @@ yyreduce: { case 3: /* Line 1792 of yacc.c */ -#line 386 "dtool/src/cppparser/cppBison.yxx" +#line 388 "dtool/src/cppparser/cppBison.yxx" { current_expr = (yyvsp[(2) - (2)].u.expr); } @@ -3337,7 +3356,7 @@ yyreduce: case 4: /* Line 1792 of yacc.c */ -#line 390 "dtool/src/cppparser/cppBison.yxx" +#line 392 "dtool/src/cppparser/cppBison.yxx" { current_type = (yyvsp[(2) - (2)].u.type); } @@ -3345,7 +3364,7 @@ yyreduce: case 10: /* Line 1792 of yacc.c */ -#line 408 "dtool/src/cppparser/cppBison.yxx" +#line 410 "dtool/src/cppparser/cppBison.yxx" { delete (yyvsp[(3) - (4)].u.expr); } @@ -3353,7 +3372,7 @@ yyreduce: case 11: /* Line 1792 of yacc.c */ -#line 420 "dtool/src/cppparser/cppBison.yxx" +#line 422 "dtool/src/cppparser/cppBison.yxx" { push_storage_class((current_storage_class & ~CPPInstance::SC_c_binding) | ((yyvsp[(1) - (2)].u.integer) & CPPInstance::SC_c_binding)); @@ -3362,7 +3381,7 @@ yyreduce: case 12: /* Line 1792 of yacc.c */ -#line 425 "dtool/src/cppparser/cppBison.yxx" +#line 427 "dtool/src/cppparser/cppBison.yxx" { pop_storage_class(); } @@ -3370,7 +3389,7 @@ yyreduce: case 20: /* Line 1792 of yacc.c */ -#line 439 "dtool/src/cppparser/cppBison.yxx" +#line 441 "dtool/src/cppparser/cppBison.yxx" { if (publish_nest_level != 0) { yyerror("Unclosed __begin_publish", publish_loc); @@ -3387,7 +3406,7 @@ yyreduce: case 21: /* Line 1792 of yacc.c */ -#line 452 "dtool/src/cppparser/cppBison.yxx" +#line 454 "dtool/src/cppparser/cppBison.yxx" { if (publish_nest_level != 1) { yyerror("Unmatched __end_publish", (yylsp[(1) - (1)])); @@ -3400,7 +3419,7 @@ yyreduce: case 22: /* Line 1792 of yacc.c */ -#line 461 "dtool/src/cppparser/cppBison.yxx" +#line 463 "dtool/src/cppparser/cppBison.yxx" { current_scope->set_current_vis(V_published); } @@ -3408,7 +3427,7 @@ yyreduce: case 23: /* Line 1792 of yacc.c */ -#line 465 "dtool/src/cppparser/cppBison.yxx" +#line 467 "dtool/src/cppparser/cppBison.yxx" { if (publish_nest_level > 0) { current_scope->set_current_vis(V_published); @@ -3420,7 +3439,7 @@ yyreduce: case 24: /* Line 1792 of yacc.c */ -#line 473 "dtool/src/cppparser/cppBison.yxx" +#line 475 "dtool/src/cppparser/cppBison.yxx" { current_scope->set_current_vis(V_protected); } @@ -3428,7 +3447,7 @@ yyreduce: case 25: /* Line 1792 of yacc.c */ -#line 477 "dtool/src/cppparser/cppBison.yxx" +#line 479 "dtool/src/cppparser/cppBison.yxx" { current_scope->set_current_vis(V_private); } @@ -3436,7 +3455,7 @@ yyreduce: case 26: /* Line 1792 of yacc.c */ -#line 481 "dtool/src/cppparser/cppBison.yxx" +#line 483 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *getter = (yyvsp[(5) - (7)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); @@ -3451,28 +3470,32 @@ yyreduce: case 27: /* Line 1792 of yacc.c */ -#line 492 "dtool/src/cppparser/cppBison.yxx" +#line 494 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *getter = (yyvsp[(5) - (9)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("Reference to non-existent or invalid getter: " + (yyvsp[(5) - (9)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (9)])); - } - CPPDeclaration *setter = (yyvsp[(7) - (9)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (setter == (CPPDeclaration *)NULL || setter->get_subtype() != CPPDeclaration::ST_function_group) { - yyerror("Reference to non-existent or invalid setter: " + (yyvsp[(7) - (9)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (9)])); - } + } else { + CPPDeclaration *setter = (yyvsp[(7) - (9)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); + CPPFunctionGroup *setter_func = NULL; - CPPMakeProperty *make_property = new CPPMakeProperty((yyvsp[(3) - (9)].u.identifier), getter->as_function_group(), - setter->as_function_group(), - current_scope, (yylsp[(1) - (9)]).file); - current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[(1) - (9)])); + if (setter == (CPPDeclaration *)NULL || setter->get_subtype() != CPPDeclaration::ST_function_group) { + yyerror("Reference to non-existent or invalid setter: " + (yyvsp[(7) - (9)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (9)])); + } else { + setter_func = setter->as_function_group(); + } + + CPPMakeProperty *make_property = new CPPMakeProperty((yyvsp[(3) - (9)].u.identifier), getter->as_function_group(), + setter_func, current_scope, (yylsp[(1) - (9)]).file); + current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[(1) - (9)])); + } } break; case 28: /* Line 1792 of yacc.c */ -#line 509 "dtool/src/cppparser/cppBison.yxx" +#line 515 "dtool/src/cppparser/cppBison.yxx" { CPPMakeSeq *make_seq = new CPPMakeSeq((yyvsp[(3) - (9)].u.identifier)->get_simple_name(), (yyvsp[(5) - (9)].u.identifier)->get_simple_name(), (yyvsp[(7) - (9)].u.identifier)->get_simple_name(), (yylsp[(1) - (9)]).file); current_scope->add_declaration(make_seq, global_scope, current_lexer, (yylsp[(1) - (9)])); @@ -3481,7 +3504,7 @@ yyreduce: case 29: /* Line 1792 of yacc.c */ -#line 517 "dtool/src/cppparser/cppBison.yxx" +#line 523 "dtool/src/cppparser/cppBison.yxx" { CPPScope *new_scope = new CPPScope(current_scope, CPPNameComponent("temp"), V_public); @@ -3491,7 +3514,7 @@ yyreduce: case 30: /* Line 1792 of yacc.c */ -#line 523 "dtool/src/cppparser/cppBison.yxx" +#line 529 "dtool/src/cppparser/cppBison.yxx" { delete current_scope; pop_scope(); @@ -3500,7 +3523,7 @@ yyreduce: case 31: /* Line 1792 of yacc.c */ -#line 532 "dtool/src/cppparser/cppBison.yxx" +#line 538 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = 0; } @@ -3508,7 +3531,7 @@ yyreduce: case 32: /* Line 1792 of yacc.c */ -#line 536 "dtool/src/cppparser/cppBison.yxx" +#line 542 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_extern; } @@ -3516,7 +3539,7 @@ yyreduce: case 33: /* Line 1792 of yacc.c */ -#line 540 "dtool/src/cppparser/cppBison.yxx" +#line 546 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (3)].u.integer) | (int)CPPInstance::SC_extern; if ((yyvsp[(3) - (3)].str) == "C") { @@ -3531,7 +3554,7 @@ yyreduce: case 34: /* Line 1792 of yacc.c */ -#line 551 "dtool/src/cppparser/cppBison.yxx" +#line 557 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_static; } @@ -3539,7 +3562,7 @@ yyreduce: case 35: /* Line 1792 of yacc.c */ -#line 555 "dtool/src/cppparser/cppBison.yxx" +#line 561 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_inline; } @@ -3547,7 +3570,7 @@ yyreduce: case 36: /* Line 1792 of yacc.c */ -#line 559 "dtool/src/cppparser/cppBison.yxx" +#line 565 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_virtual; } @@ -3555,7 +3578,7 @@ yyreduce: case 37: /* Line 1792 of yacc.c */ -#line 563 "dtool/src/cppparser/cppBison.yxx" +#line 569 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_explicit; } @@ -3563,7 +3586,7 @@ yyreduce: case 38: /* Line 1792 of yacc.c */ -#line 567 "dtool/src/cppparser/cppBison.yxx" +#line 573 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_volatile; } @@ -3571,7 +3594,7 @@ yyreduce: case 39: /* Line 1792 of yacc.c */ -#line 571 "dtool/src/cppparser/cppBison.yxx" +#line 577 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_mutable; } @@ -3579,7 +3602,7 @@ yyreduce: case 40: /* Line 1792 of yacc.c */ -#line 575 "dtool/src/cppparser/cppBison.yxx" +#line 581 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_register; } @@ -3587,7 +3610,7 @@ yyreduce: case 41: /* Line 1792 of yacc.c */ -#line 579 "dtool/src/cppparser/cppBison.yxx" +#line 585 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_blocking; } @@ -3595,7 +3618,7 @@ yyreduce: case 42: /* Line 1792 of yacc.c */ -#line 583 "dtool/src/cppparser/cppBison.yxx" +#line 589 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (2)].u.integer) | (int)CPPInstance::SC_extension; } @@ -3603,7 +3626,7 @@ yyreduce: case 43: /* Line 1792 of yacc.c */ -#line 590 "dtool/src/cppparser/cppBison.yxx" +#line 596 "dtool/src/cppparser/cppBison.yxx" { /* multiple_var_declaration adds itself to the scope. */ } @@ -3611,7 +3634,7 @@ yyreduce: case 44: /* Line 1792 of yacc.c */ -#line 594 "dtool/src/cppparser/cppBison.yxx" +#line 600 "dtool/src/cppparser/cppBison.yxx" { // We don't really care about the storage class here. In fact, it's // not actually legal to define a class or struct using a particular @@ -3624,7 +3647,7 @@ yyreduce: case 45: /* Line 1792 of yacc.c */ -#line 603 "dtool/src/cppparser/cppBison.yxx" +#line 609 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(2) - (3)].u.instance) != (CPPInstance *)NULL) { (yyvsp[(2) - (3)].u.instance)->_storage_class |= (current_storage_class | (yyvsp[(1) - (3)].u.integer)); @@ -3636,7 +3659,7 @@ yyreduce: case 46: /* Line 1792 of yacc.c */ -#line 614 "dtool/src/cppparser/cppBison.yxx" +#line 620 "dtool/src/cppparser/cppBison.yxx" { // We don't need to push/pop type, because we can't nest // multiple_var_declarations. @@ -3651,7 +3674,7 @@ yyreduce: case 47: /* Line 1792 of yacc.c */ -#line 625 "dtool/src/cppparser/cppBison.yxx" +#line 631 "dtool/src/cppparser/cppBison.yxx" { pop_storage_class(); } @@ -3659,7 +3682,7 @@ yyreduce: case 48: /* Line 1792 of yacc.c */ -#line 629 "dtool/src/cppparser/cppBison.yxx" +#line 635 "dtool/src/cppparser/cppBison.yxx" { // We don't need to push/pop type, because we can't nest // multiple_var_declarations. @@ -3670,7 +3693,7 @@ yyreduce: case 49: /* Line 1792 of yacc.c */ -#line 636 "dtool/src/cppparser/cppBison.yxx" +#line 642 "dtool/src/cppparser/cppBison.yxx" { pop_storage_class(); } @@ -3678,7 +3701,7 @@ yyreduce: case 50: /* Line 1792 of yacc.c */ -#line 647 "dtool/src/cppparser/cppBison.yxx" +#line 653 "dtool/src/cppparser/cppBison.yxx" { CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (2)].u.inst_ident), current_storage_class, @@ -3690,7 +3713,7 @@ yyreduce: case 51: /* Line 1792 of yacc.c */ -#line 655 "dtool/src/cppparser/cppBison.yxx" +#line 661 "dtool/src/cppparser/cppBison.yxx" { CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (4)].u.inst_ident), current_storage_class, @@ -3702,7 +3725,7 @@ yyreduce: case 52: /* Line 1792 of yacc.c */ -#line 666 "dtool/src/cppparser/cppBison.yxx" +#line 672 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(1) - (2)].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (2)].u.inst_ident), @@ -3715,7 +3738,7 @@ yyreduce: case 53: /* Line 1792 of yacc.c */ -#line 675 "dtool/src/cppparser/cppBison.yxx" +#line 681 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(1) - (4)].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (4)].u.inst_ident), @@ -3728,7 +3751,7 @@ yyreduce: case 54: /* Line 1792 of yacc.c */ -#line 688 "dtool/src/cppparser/cppBison.yxx" +#line 694 "dtool/src/cppparser/cppBison.yxx" { // We don't need to push/pop type, because we can't nest // multiple_var_declarations. @@ -3743,7 +3766,7 @@ yyreduce: case 55: /* Line 1792 of yacc.c */ -#line 699 "dtool/src/cppparser/cppBison.yxx" +#line 705 "dtool/src/cppparser/cppBison.yxx" { pop_storage_class(); } @@ -3751,7 +3774,7 @@ yyreduce: case 56: /* Line 1792 of yacc.c */ -#line 703 "dtool/src/cppparser/cppBison.yxx" +#line 709 "dtool/src/cppparser/cppBison.yxx" { // We don't need to push/pop type, because we can't nest // multiple_var_declarations. @@ -3762,7 +3785,7 @@ yyreduce: case 57: /* Line 1792 of yacc.c */ -#line 710 "dtool/src/cppparser/cppBison.yxx" +#line 716 "dtool/src/cppparser/cppBison.yxx" { pop_storage_class(); } @@ -3770,14 +3793,15 @@ yyreduce: case 58: /* Line 1792 of yacc.c */ -#line 714 "dtool/src/cppparser/cppBison.yxx" +#line 720 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(2) - (3)].u.instance) != (CPPDeclaration *)NULL) { CPPInstance *inst = (yyvsp[(2) - (3)].u.instance)->as_instance(); if (inst != (CPPInstance *)NULL) { inst->_storage_class |= (current_storage_class | (yyvsp[(1) - (3)].u.integer)); current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(2) - (3)])); - current_scope->add_declaration(new CPPTypedef(inst, current_scope == global_scope), global_scope, current_lexer, (yylsp[(2) - (3)])); + CPPTypedefType *typedef_type = new CPPTypedefType(inst->_type, inst->_ident, current_scope); + current_scope->add_declaration(typedef_type, global_scope, current_lexer, (yylsp[(2) - (3)])); } } } @@ -3785,57 +3809,49 @@ yyreduce: case 59: /* Line 1792 of yacc.c */ -#line 728 "dtool/src/cppparser/cppBison.yxx" +#line 735 "dtool/src/cppparser/cppBison.yxx" { - CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (2)].u.inst_ident), - current_storage_class, - (yylsp[(1) - (2)]).file); - inst->set_initializer((yyvsp[(2) - (2)].u.expr)); - current_scope->add_declaration(new CPPTypedef(inst, current_scope == global_scope), global_scope, current_lexer, (yylsp[(1) - (2)])); + CPPType *target_type = current_type; + CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[(1) - (2)].u.inst_ident), current_scope, (yylsp[(1) - (2)]).file); + current_scope->add_declaration(typedef_type, global_scope, current_lexer, (yylsp[(1) - (2)])); } break; case 60: /* Line 1792 of yacc.c */ -#line 736 "dtool/src/cppparser/cppBison.yxx" +#line 741 "dtool/src/cppparser/cppBison.yxx" { - CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (4)].u.inst_ident), - current_storage_class, - (yylsp[(1) - (4)]).file); - inst->set_initializer((yyvsp[(2) - (4)].u.expr)); - current_scope->add_declaration(new CPPTypedef(inst, current_scope == global_scope), global_scope, current_lexer, (yylsp[(1) - (4)])); + CPPType *target_type = current_type; + CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[(1) - (4)].u.inst_ident), current_scope, (yylsp[(1) - (4)]).file); + current_scope->add_declaration(typedef_type, global_scope, current_lexer, (yylsp[(1) - (4)])); } break; case 61: /* Line 1792 of yacc.c */ -#line 747 "dtool/src/cppparser/cppBison.yxx" +#line 750 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(1) - (2)].u.inst_ident)->add_modifier(IIT_const); - CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (2)].u.inst_ident), - current_storage_class, - (yylsp[(1) - (2)]).file); - inst->set_initializer((yyvsp[(2) - (2)].u.expr)); - current_scope->add_declaration(new CPPTypedef(inst, current_scope == global_scope), global_scope, current_lexer, (yylsp[(1) - (2)])); + CPPType *target_type = current_type; + CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[(1) - (2)].u.inst_ident), current_scope, (yylsp[(1) - (2)]).file); + current_scope->add_declaration(typedef_type, global_scope, current_lexer, (yylsp[(1) - (2)])); } break; case 62: /* Line 1792 of yacc.c */ -#line 756 "dtool/src/cppparser/cppBison.yxx" +#line 757 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(1) - (4)].u.inst_ident)->add_modifier(IIT_const); - CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (4)].u.inst_ident), - current_storage_class, - (yylsp[(1) - (4)]).file); - inst->set_initializer((yyvsp[(2) - (4)].u.expr)); - current_scope->add_declaration(new CPPTypedef(inst, current_scope == global_scope), global_scope, current_lexer, (yylsp[(1) - (4)])); + CPPType *target_type = current_type; + CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[(1) - (4)].u.inst_ident), current_scope, (yylsp[(1) - (4)]).file); + current_scope->add_declaration(typedef_type, global_scope, current_lexer, (yylsp[(1) - (4)])); } break; case 63: /* Line 1792 of yacc.c */ -#line 770 "dtool/src/cppparser/cppBison.yxx" +#line 769 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(1) - (2)].u.identifier)->get_scope(current_scope, global_scope)); } @@ -3843,7 +3859,7 @@ yyreduce: case 64: /* Line 1792 of yacc.c */ -#line 774 "dtool/src/cppparser/cppBison.yxx" +#line 773 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); CPPType *type; @@ -3865,7 +3881,7 @@ yyreduce: case 65: /* Line 1792 of yacc.c */ -#line 792 "dtool/src/cppparser/cppBison.yxx" +#line 791 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(1) - (2)].u.identifier)->get_scope(current_scope, global_scope)); } @@ -3873,7 +3889,7 @@ yyreduce: case 66: /* Line 1792 of yacc.c */ -#line 796 "dtool/src/cppparser/cppBison.yxx" +#line 795 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); CPPType *type; @@ -3895,7 +3911,7 @@ yyreduce: case 67: /* Line 1792 of yacc.c */ -#line 816 "dtool/src/cppparser/cppBison.yxx" +#line 815 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(2) - (3)].u.identifier)->get_scope(current_scope, global_scope)); } @@ -3903,7 +3919,7 @@ yyreduce: case 68: /* Line 1792 of yacc.c */ -#line 820 "dtool/src/cppparser/cppBison.yxx" +#line 819 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); if ((yyvsp[(2) - (7)].u.identifier)->is_scoped()) { @@ -3926,7 +3942,7 @@ yyreduce: case 69: /* Line 1792 of yacc.c */ -#line 846 "dtool/src/cppparser/cppBison.yxx" +#line 845 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(4) - (6)].u.inst_ident)->get_scope(current_scope, global_scope)); } @@ -3934,7 +3950,7 @@ yyreduce: case 70: /* Line 1792 of yacc.c */ -#line 850 "dtool/src/cppparser/cppBison.yxx" +#line 849 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); CPPType *type = (yyvsp[(1) - (10)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); @@ -3949,7 +3965,7 @@ yyreduce: case 71: /* Line 1792 of yacc.c */ -#line 861 "dtool/src/cppparser/cppBison.yxx" +#line 860 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(5) - (7)].u.inst_ident)->get_scope(current_scope, global_scope)); } @@ -3957,7 +3973,7 @@ yyreduce: case 72: /* Line 1792 of yacc.c */ -#line 865 "dtool/src/cppparser/cppBison.yxx" +#line 864 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); CPPType *type = (yyvsp[(1) - (11)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); @@ -3972,7 +3988,7 @@ yyreduce: case 73: /* Line 1792 of yacc.c */ -#line 878 "dtool/src/cppparser/cppBison.yxx" +#line 877 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(1) - (4)].u.identifier) != NULL) { push_scope((yyvsp[(1) - (4)].u.identifier)->get_scope(current_scope, global_scope)); @@ -3982,7 +3998,7 @@ yyreduce: case 74: /* Line 1792 of yacc.c */ -#line 884 "dtool/src/cppparser/cppBison.yxx" +#line 883 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(1) - (8)].u.identifier) != NULL) { pop_scope(); @@ -4011,7 +4027,7 @@ yyreduce: case 75: /* Line 1792 of yacc.c */ -#line 909 "dtool/src/cppparser/cppBison.yxx" +#line 908 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(1) - (5)].u.identifier) != NULL) { push_scope((yyvsp[(1) - (5)].u.identifier)->get_scope(current_scope, global_scope)); @@ -4021,7 +4037,7 @@ yyreduce: case 76: /* Line 1792 of yacc.c */ -#line 915 "dtool/src/cppparser/cppBison.yxx" +#line 914 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(1) - (9)].u.identifier) != NULL) { pop_scope(); @@ -4041,7 +4057,7 @@ yyreduce: case 77: /* Line 1792 of yacc.c */ -#line 935 "dtool/src/cppparser/cppBison.yxx" +#line 934 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *decl = (yyvsp[(1) - (1)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); @@ -4055,7 +4071,7 @@ yyreduce: case 78: /* Line 1792 of yacc.c */ -#line 948 "dtool/src/cppparser/cppBison.yxx" +#line 947 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = 0; } @@ -4063,7 +4079,7 @@ yyreduce: case 79: /* Line 1792 of yacc.c */ -#line 952 "dtool/src/cppparser/cppBison.yxx" +#line 951 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (int)CPPFunctionType::F_const_method; } @@ -4071,7 +4087,7 @@ yyreduce: case 80: /* Line 1792 of yacc.c */ -#line 956 "dtool/src/cppparser/cppBison.yxx" +#line 955 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (int)CPPFunctionType::F_noexcept; } @@ -4079,7 +4095,7 @@ yyreduce: case 81: /* Line 1792 of yacc.c */ -#line 960 "dtool/src/cppparser/cppBison.yxx" +#line 959 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (4)].u.integer); } @@ -4087,7 +4103,7 @@ yyreduce: case 82: /* Line 1792 of yacc.c */ -#line 964 "dtool/src/cppparser/cppBison.yxx" +#line 963 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(1) - (5)].u.integer); } @@ -4095,7 +4111,7 @@ yyreduce: case 83: /* Line 1792 of yacc.c */ -#line 971 "dtool/src/cppparser/cppBison.yxx" +#line 970 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "!"; } @@ -4103,7 +4119,7 @@ yyreduce: case 84: /* Line 1792 of yacc.c */ -#line 975 "dtool/src/cppparser/cppBison.yxx" +#line 974 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "~"; } @@ -4111,7 +4127,7 @@ yyreduce: case 85: /* Line 1792 of yacc.c */ -#line 979 "dtool/src/cppparser/cppBison.yxx" +#line 978 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "*"; } @@ -4119,7 +4135,7 @@ yyreduce: case 86: /* Line 1792 of yacc.c */ -#line 983 "dtool/src/cppparser/cppBison.yxx" +#line 982 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "/"; } @@ -4127,7 +4143,7 @@ yyreduce: case 87: /* Line 1792 of yacc.c */ -#line 987 "dtool/src/cppparser/cppBison.yxx" +#line 986 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "%"; } @@ -4135,7 +4151,7 @@ yyreduce: case 88: /* Line 1792 of yacc.c */ -#line 991 "dtool/src/cppparser/cppBison.yxx" +#line 990 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "+"; } @@ -4143,7 +4159,7 @@ yyreduce: case 89: /* Line 1792 of yacc.c */ -#line 995 "dtool/src/cppparser/cppBison.yxx" +#line 994 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "-"; } @@ -4151,7 +4167,7 @@ yyreduce: case 90: /* Line 1792 of yacc.c */ -#line 999 "dtool/src/cppparser/cppBison.yxx" +#line 998 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "|"; } @@ -4159,7 +4175,7 @@ yyreduce: case 91: /* Line 1792 of yacc.c */ -#line 1003 "dtool/src/cppparser/cppBison.yxx" +#line 1002 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "&"; } @@ -4167,7 +4183,7 @@ yyreduce: case 92: /* Line 1792 of yacc.c */ -#line 1007 "dtool/src/cppparser/cppBison.yxx" +#line 1006 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "^"; } @@ -4175,7 +4191,7 @@ yyreduce: case 93: /* Line 1792 of yacc.c */ -#line 1011 "dtool/src/cppparser/cppBison.yxx" +#line 1010 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "||"; } @@ -4183,7 +4199,7 @@ yyreduce: case 94: /* Line 1792 of yacc.c */ -#line 1015 "dtool/src/cppparser/cppBison.yxx" +#line 1014 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "&&"; } @@ -4191,7 +4207,7 @@ yyreduce: case 95: /* Line 1792 of yacc.c */ -#line 1019 "dtool/src/cppparser/cppBison.yxx" +#line 1018 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "=="; } @@ -4199,7 +4215,7 @@ yyreduce: case 96: /* Line 1792 of yacc.c */ -#line 1023 "dtool/src/cppparser/cppBison.yxx" +#line 1022 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "!="; } @@ -4207,7 +4223,7 @@ yyreduce: case 97: /* Line 1792 of yacc.c */ -#line 1027 "dtool/src/cppparser/cppBison.yxx" +#line 1026 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "<="; } @@ -4215,7 +4231,7 @@ yyreduce: case 98: /* Line 1792 of yacc.c */ -#line 1031 "dtool/src/cppparser/cppBison.yxx" +#line 1030 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = ">="; } @@ -4223,7 +4239,7 @@ yyreduce: case 99: /* Line 1792 of yacc.c */ -#line 1035 "dtool/src/cppparser/cppBison.yxx" +#line 1034 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "<"; } @@ -4231,7 +4247,7 @@ yyreduce: case 100: /* Line 1792 of yacc.c */ -#line 1039 "dtool/src/cppparser/cppBison.yxx" +#line 1038 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = ">"; } @@ -4239,7 +4255,7 @@ yyreduce: case 101: /* Line 1792 of yacc.c */ -#line 1043 "dtool/src/cppparser/cppBison.yxx" +#line 1042 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "<<"; } @@ -4247,7 +4263,7 @@ yyreduce: case 102: /* Line 1792 of yacc.c */ -#line 1047 "dtool/src/cppparser/cppBison.yxx" +#line 1046 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = ">>"; } @@ -4255,7 +4271,7 @@ yyreduce: case 103: /* Line 1792 of yacc.c */ -#line 1051 "dtool/src/cppparser/cppBison.yxx" +#line 1050 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "="; } @@ -4263,7 +4279,7 @@ yyreduce: case 104: /* Line 1792 of yacc.c */ -#line 1055 "dtool/src/cppparser/cppBison.yxx" +#line 1054 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = ","; } @@ -4271,7 +4287,7 @@ yyreduce: case 105: /* Line 1792 of yacc.c */ -#line 1059 "dtool/src/cppparser/cppBison.yxx" +#line 1058 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "++"; } @@ -4279,7 +4295,7 @@ yyreduce: case 106: /* Line 1792 of yacc.c */ -#line 1063 "dtool/src/cppparser/cppBison.yxx" +#line 1062 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "--"; } @@ -4287,7 +4303,7 @@ yyreduce: case 107: /* Line 1792 of yacc.c */ -#line 1067 "dtool/src/cppparser/cppBison.yxx" +#line 1066 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "*="; } @@ -4295,7 +4311,7 @@ yyreduce: case 108: /* Line 1792 of yacc.c */ -#line 1071 "dtool/src/cppparser/cppBison.yxx" +#line 1070 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "/="; } @@ -4303,7 +4319,7 @@ yyreduce: case 109: /* Line 1792 of yacc.c */ -#line 1075 "dtool/src/cppparser/cppBison.yxx" +#line 1074 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "%="; } @@ -4311,7 +4327,7 @@ yyreduce: case 110: /* Line 1792 of yacc.c */ -#line 1079 "dtool/src/cppparser/cppBison.yxx" +#line 1078 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "+="; } @@ -4319,7 +4335,7 @@ yyreduce: case 111: /* Line 1792 of yacc.c */ -#line 1083 "dtool/src/cppparser/cppBison.yxx" +#line 1082 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "-="; } @@ -4327,7 +4343,7 @@ yyreduce: case 112: /* Line 1792 of yacc.c */ -#line 1087 "dtool/src/cppparser/cppBison.yxx" +#line 1086 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "|="; } @@ -4335,7 +4351,7 @@ yyreduce: case 113: /* Line 1792 of yacc.c */ -#line 1091 "dtool/src/cppparser/cppBison.yxx" +#line 1090 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "&="; } @@ -4343,7 +4359,7 @@ yyreduce: case 114: /* Line 1792 of yacc.c */ -#line 1095 "dtool/src/cppparser/cppBison.yxx" +#line 1094 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "^="; } @@ -4351,7 +4367,7 @@ yyreduce: case 115: /* Line 1792 of yacc.c */ -#line 1099 "dtool/src/cppparser/cppBison.yxx" +#line 1098 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "<<="; } @@ -4359,7 +4375,7 @@ yyreduce: case 116: /* Line 1792 of yacc.c */ -#line 1103 "dtool/src/cppparser/cppBison.yxx" +#line 1102 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = ">>="; } @@ -4367,7 +4383,7 @@ yyreduce: case 117: /* Line 1792 of yacc.c */ -#line 1107 "dtool/src/cppparser/cppBison.yxx" +#line 1106 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "->"; } @@ -4375,7 +4391,7 @@ yyreduce: case 118: /* Line 1792 of yacc.c */ -#line 1111 "dtool/src/cppparser/cppBison.yxx" +#line 1110 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "[]"; } @@ -4383,7 +4399,7 @@ yyreduce: case 119: /* Line 1792 of yacc.c */ -#line 1115 "dtool/src/cppparser/cppBison.yxx" +#line 1114 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "()"; } @@ -4391,7 +4407,7 @@ yyreduce: case 120: /* Line 1792 of yacc.c */ -#line 1119 "dtool/src/cppparser/cppBison.yxx" +#line 1118 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "new"; } @@ -4399,7 +4415,7 @@ yyreduce: case 121: /* Line 1792 of yacc.c */ -#line 1123 "dtool/src/cppparser/cppBison.yxx" +#line 1122 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = "delete"; } @@ -4407,7 +4423,7 @@ yyreduce: case 124: /* Line 1792 of yacc.c */ -#line 1135 "dtool/src/cppparser/cppBison.yxx" +#line 1134 "dtool/src/cppparser/cppBison.yxx" { push_scope(new CPPTemplateScope(current_scope)); } @@ -4415,7 +4431,7 @@ yyreduce: case 125: /* Line 1792 of yacc.c */ -#line 1139 "dtool/src/cppparser/cppBison.yxx" +#line 1138 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); } @@ -4423,7 +4439,7 @@ yyreduce: case 128: /* Line 1792 of yacc.c */ -#line 1151 "dtool/src/cppparser/cppBison.yxx" +#line 1150 "dtool/src/cppparser/cppBison.yxx" { CPPTemplateScope *ts = current_scope->as_template_scope(); assert(ts != NULL); @@ -4433,7 +4449,7 @@ yyreduce: case 129: /* Line 1792 of yacc.c */ -#line 1157 "dtool/src/cppparser/cppBison.yxx" +#line 1156 "dtool/src/cppparser/cppBison.yxx" { CPPTemplateScope *ts = current_scope->as_template_scope(); assert(ts != NULL); @@ -4443,7 +4459,7 @@ yyreduce: case 130: /* Line 1792 of yacc.c */ -#line 1166 "dtool/src/cppparser/cppBison.yxx" +#line 1165 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[(2) - (2)].u.identifier))); } @@ -4451,7 +4467,7 @@ yyreduce: case 131: /* Line 1792 of yacc.c */ -#line 1170 "dtool/src/cppparser/cppBison.yxx" +#line 1169 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[(2) - (4)].u.identifier), (yyvsp[(4) - (4)].u.type))); } @@ -4459,7 +4475,7 @@ yyreduce: case 132: /* Line 1792 of yacc.c */ -#line 1174 "dtool/src/cppparser/cppBison.yxx" +#line 1173 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[(2) - (2)].u.identifier))); } @@ -4467,7 +4483,7 @@ yyreduce: case 133: /* Line 1792 of yacc.c */ -#line 1178 "dtool/src/cppparser/cppBison.yxx" +#line 1177 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[(2) - (4)].u.identifier), (yyvsp[(4) - (4)].u.type))); } @@ -4475,7 +4491,7 @@ yyreduce: case 134: /* Line 1792 of yacc.c */ -#line 1182 "dtool/src/cppparser/cppBison.yxx" +#line 1181 "dtool/src/cppparser/cppBison.yxx" { CPPInstance *inst = new CPPInstance((yyvsp[(1) - (3)].u.type), (yyvsp[(2) - (3)].u.inst_ident), 0, (yylsp[(2) - (3)]).file); inst->set_initializer((yyvsp[(3) - (3)].u.expr)); @@ -4485,7 +4501,7 @@ yyreduce: case 135: /* Line 1792 of yacc.c */ -#line 1188 "dtool/src/cppparser/cppBison.yxx" +#line 1187 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(3) - (4)].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance((yyvsp[(2) - (4)].u.type), (yyvsp[(3) - (4)].u.inst_ident), 0, (yylsp[(3) - (4)]).file); @@ -4496,7 +4512,7 @@ yyreduce: case 136: /* Line 1792 of yacc.c */ -#line 1198 "dtool/src/cppparser/cppBison.yxx" +#line 1197 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); } @@ -4504,7 +4520,7 @@ yyreduce: case 137: /* Line 1792 of yacc.c */ -#line 1202 "dtool/src/cppparser/cppBison.yxx" +#line 1201 "dtool/src/cppparser/cppBison.yxx" { yywarning("Not a type: " + (yyvsp[(1) - (1)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (1)])); (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_unknown)); @@ -4513,7 +4529,7 @@ yyreduce: case 138: /* Line 1792 of yacc.c */ -#line 1207 "dtool/src/cppparser/cppBison.yxx" +#line 1206 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); assert((yyval.u.type) != NULL); @@ -4522,7 +4538,7 @@ yyreduce: case 139: /* Line 1792 of yacc.c */ -#line 1216 "dtool/src/cppparser/cppBison.yxx" +#line 1215 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); } @@ -4530,7 +4546,7 @@ yyreduce: case 140: /* Line 1792 of yacc.c */ -#line 1220 "dtool/src/cppparser/cppBison.yxx" +#line 1219 "dtool/src/cppparser/cppBison.yxx" { // For an operator function. We implement this simply by building a // ficticious name for the function; in other respects it's just @@ -4548,7 +4564,7 @@ yyreduce: case 141: /* Line 1792 of yacc.c */ -#line 1234 "dtool/src/cppparser/cppBison.yxx" +#line 1233 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); @@ -4557,7 +4573,7 @@ yyreduce: case 142: /* Line 1792 of yacc.c */ -#line 1239 "dtool/src/cppparser/cppBison.yxx" +#line 1238 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); @@ -4566,7 +4582,7 @@ yyreduce: case 143: /* Line 1792 of yacc.c */ -#line 1244 "dtool/src/cppparser/cppBison.yxx" +#line 1243 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); @@ -4575,7 +4591,7 @@ yyreduce: case 144: /* Line 1792 of yacc.c */ -#line 1249 "dtool/src/cppparser/cppBison.yxx" +#line 1248 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); @@ -4584,7 +4600,7 @@ yyreduce: case 145: /* Line 1792 of yacc.c */ -#line 1254 "dtool/src/cppparser/cppBison.yxx" +#line 1253 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); @@ -4593,7 +4609,7 @@ yyreduce: case 146: /* Line 1792 of yacc.c */ -#line 1259 "dtool/src/cppparser/cppBison.yxx" +#line 1258 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); @@ -4602,7 +4618,7 @@ yyreduce: case 147: /* Line 1792 of yacc.c */ -#line 1264 "dtool/src/cppparser/cppBison.yxx" +#line 1263 "dtool/src/cppparser/cppBison.yxx" { // bitfield definition. We ignore the bitfield for now. (yyval.u.inst_ident) = (yyvsp[(1) - (3)].u.inst_ident); @@ -4611,7 +4627,7 @@ yyreduce: case 148: /* Line 1792 of yacc.c */ -#line 1269 "dtool/src/cppparser/cppBison.yxx" +#line 1268 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); @@ -4620,7 +4636,7 @@ yyreduce: case 149: /* Line 1792 of yacc.c */ -#line 1274 "dtool/src/cppparser/cppBison.yxx" +#line 1273 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(1) - (2)].u.inst_ident)->get_scope(current_scope, global_scope)); } @@ -4628,7 +4644,7 @@ yyreduce: case 150: /* Line 1792 of yacc.c */ -#line 1278 "dtool/src/cppparser/cppBison.yxx" +#line 1277 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); (yyval.u.inst_ident) = (yyvsp[(1) - (6)].u.inst_ident); @@ -4646,7 +4662,7 @@ yyreduce: case 151: /* Line 1792 of yacc.c */ -#line 1296 "dtool/src/cppparser/cppBison.yxx" +#line 1295 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = new CPPParameterList; } @@ -4654,7 +4670,7 @@ yyreduce: case 152: /* Line 1792 of yacc.c */ -#line 1300 "dtool/src/cppparser/cppBison.yxx" +#line 1299 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_includes_ellipsis = true; @@ -4663,7 +4679,7 @@ yyreduce: case 153: /* Line 1792 of yacc.c */ -#line 1305 "dtool/src/cppparser/cppBison.yxx" +#line 1304 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = (yyvsp[(1) - (1)].u.param_list); } @@ -4671,7 +4687,7 @@ yyreduce: case 154: /* Line 1792 of yacc.c */ -#line 1309 "dtool/src/cppparser/cppBison.yxx" +#line 1308 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = (yyvsp[(1) - (3)].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; @@ -4680,7 +4696,7 @@ yyreduce: case 155: /* Line 1792 of yacc.c */ -#line 1314 "dtool/src/cppparser/cppBison.yxx" +#line 1313 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = (yyvsp[(1) - (2)].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; @@ -4689,7 +4705,7 @@ yyreduce: case 156: /* Line 1792 of yacc.c */ -#line 1322 "dtool/src/cppparser/cppBison.yxx" +#line 1321 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_parameters.push_back((yyvsp[(1) - (1)].u.instance)); @@ -4698,7 +4714,7 @@ yyreduce: case 157: /* Line 1792 of yacc.c */ -#line 1327 "dtool/src/cppparser/cppBison.yxx" +#line 1326 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = (yyvsp[(1) - (3)].u.param_list); (yyval.u.param_list)->_parameters.push_back((yyvsp[(3) - (3)].u.instance)); @@ -4707,7 +4723,7 @@ yyreduce: case 158: /* Line 1792 of yacc.c */ -#line 1335 "dtool/src/cppparser/cppBison.yxx" +#line 1334 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (CPPExpression *)NULL; } @@ -4715,7 +4731,7 @@ yyreduce: case 159: /* Line 1792 of yacc.c */ -#line 1339 "dtool/src/cppparser/cppBison.yxx" +#line 1338 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); } @@ -4723,7 +4739,7 @@ yyreduce: case 160: /* Line 1792 of yacc.c */ -#line 1346 "dtool/src/cppparser/cppBison.yxx" +#line 1345 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (CPPExpression *)NULL; } @@ -4731,7 +4747,7 @@ yyreduce: case 161: /* Line 1792 of yacc.c */ -#line 1350 "dtool/src/cppparser/cppBison.yxx" +#line 1349 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); } @@ -4739,7 +4755,7 @@ yyreduce: case 162: /* Line 1792 of yacc.c */ -#line 1357 "dtool/src/cppparser/cppBison.yxx" +#line 1356 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (CPPExpression *)NULL; } @@ -4747,7 +4763,7 @@ yyreduce: case 163: /* Line 1792 of yacc.c */ -#line 1361 "dtool/src/cppparser/cppBison.yxx" +#line 1360 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (CPPExpression *)NULL; } @@ -4755,7 +4771,7 @@ yyreduce: case 164: /* Line 1792 of yacc.c */ -#line 1365 "dtool/src/cppparser/cppBison.yxx" +#line 1364 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (CPPExpression *)NULL; } @@ -4763,7 +4779,7 @@ yyreduce: case 165: /* Line 1792 of yacc.c */ -#line 1369 "dtool/src/cppparser/cppBison.yxx" +#line 1368 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); } @@ -4771,7 +4787,7 @@ yyreduce: case 166: /* Line 1792 of yacc.c */ -#line 1373 "dtool/src/cppparser/cppBison.yxx" +#line 1372 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (CPPExpression *)NULL; } @@ -4779,14 +4795,14 @@ yyreduce: case 170: /* Line 1792 of yacc.c */ -#line 1386 "dtool/src/cppparser/cppBison.yxx" +#line 1385 "dtool/src/cppparser/cppBison.yxx" { } break; case 174: /* Line 1792 of yacc.c */ -#line 1395 "dtool/src/cppparser/cppBison.yxx" +#line 1394 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.instance) = new CPPInstance((yyvsp[(1) - (3)].u.type), (yyvsp[(2) - (3)].u.inst_ident), 0, (yylsp[(2) - (3)]).file); (yyval.u.instance)->set_initializer((yyvsp[(3) - (3)].u.expr)); @@ -4795,7 +4811,7 @@ yyreduce: case 175: /* Line 1792 of yacc.c */ -#line 1400 "dtool/src/cppparser/cppBison.yxx" +#line 1399 "dtool/src/cppparser/cppBison.yxx" { yywarning("Not a type: " + (yyvsp[(1) - (3)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (3)])); CPPType *type = @@ -4807,7 +4823,7 @@ yyreduce: case 176: /* Line 1792 of yacc.c */ -#line 1408 "dtool/src/cppparser/cppBison.yxx" +#line 1407 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(3) - (4)].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[(2) - (4)].u.type), (yyvsp[(3) - (4)].u.inst_ident), 0, (yylsp[(3) - (4)]).file); @@ -4817,7 +4833,7 @@ yyreduce: case 177: /* Line 1792 of yacc.c */ -#line 1414 "dtool/src/cppparser/cppBison.yxx" +#line 1413 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_parameter)); @@ -4828,7 +4844,7 @@ yyreduce: case 178: /* Line 1792 of yacc.c */ -#line 1424 "dtool/src/cppparser/cppBison.yxx" +#line 1423 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } @@ -4836,7 +4852,7 @@ yyreduce: case 179: /* Line 1792 of yacc.c */ -#line 1428 "dtool/src/cppparser/cppBison.yxx" +#line 1427 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); } @@ -4844,7 +4860,7 @@ yyreduce: case 180: /* Line 1792 of yacc.c */ -#line 1432 "dtool/src/cppparser/cppBison.yxx" +#line 1431 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); } @@ -4852,7 +4868,7 @@ yyreduce: case 181: /* Line 1792 of yacc.c */ -#line 1436 "dtool/src/cppparser/cppBison.yxx" +#line 1435 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); @@ -4861,7 +4877,7 @@ yyreduce: case 182: /* Line 1792 of yacc.c */ -#line 1441 "dtool/src/cppparser/cppBison.yxx" +#line 1440 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); @@ -4870,7 +4886,7 @@ yyreduce: case 183: /* Line 1792 of yacc.c */ -#line 1446 "dtool/src/cppparser/cppBison.yxx" +#line 1445 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); @@ -4879,7 +4895,7 @@ yyreduce: case 184: /* Line 1792 of yacc.c */ -#line 1451 "dtool/src/cppparser/cppBison.yxx" +#line 1450 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); @@ -4888,7 +4904,7 @@ yyreduce: case 185: /* Line 1792 of yacc.c */ -#line 1456 "dtool/src/cppparser/cppBison.yxx" +#line 1455 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); @@ -4897,7 +4913,7 @@ yyreduce: case 186: /* Line 1792 of yacc.c */ -#line 1461 "dtool/src/cppparser/cppBison.yxx" +#line 1460 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); @@ -4906,7 +4922,7 @@ yyreduce: case 187: /* Line 1792 of yacc.c */ -#line 1469 "dtool/src/cppparser/cppBison.yxx" +#line 1468 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } @@ -4914,7 +4930,7 @@ yyreduce: case 188: /* Line 1792 of yacc.c */ -#line 1473 "dtool/src/cppparser/cppBison.yxx" +#line 1472 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); } @@ -4922,7 +4938,7 @@ yyreduce: case 189: /* Line 1792 of yacc.c */ -#line 1477 "dtool/src/cppparser/cppBison.yxx" +#line 1476 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); } @@ -4930,7 +4946,7 @@ yyreduce: case 190: /* Line 1792 of yacc.c */ -#line 1481 "dtool/src/cppparser/cppBison.yxx" +#line 1480 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); @@ -4939,7 +4955,7 @@ yyreduce: case 191: /* Line 1792 of yacc.c */ -#line 1486 "dtool/src/cppparser/cppBison.yxx" +#line 1485 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); @@ -4948,7 +4964,7 @@ yyreduce: case 192: /* Line 1792 of yacc.c */ -#line 1491 "dtool/src/cppparser/cppBison.yxx" +#line 1490 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); @@ -4957,7 +4973,7 @@ yyreduce: case 193: /* Line 1792 of yacc.c */ -#line 1496 "dtool/src/cppparser/cppBison.yxx" +#line 1495 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); @@ -4966,7 +4982,7 @@ yyreduce: case 194: /* Line 1792 of yacc.c */ -#line 1501 "dtool/src/cppparser/cppBison.yxx" +#line 1500 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); @@ -4975,7 +4991,7 @@ yyreduce: case 195: /* Line 1792 of yacc.c */ -#line 1506 "dtool/src/cppparser/cppBison.yxx" +#line 1505 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); @@ -4984,7 +5000,7 @@ yyreduce: case 196: /* Line 1792 of yacc.c */ -#line 1511 "dtool/src/cppparser/cppBison.yxx" +#line 1510 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (7)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); @@ -4994,7 +5010,7 @@ yyreduce: case 197: /* Line 1792 of yacc.c */ -#line 1517 "dtool/src/cppparser/cppBison.yxx" +#line 1516 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); @@ -5003,7 +5019,7 @@ yyreduce: case 198: /* Line 1792 of yacc.c */ -#line 1525 "dtool/src/cppparser/cppBison.yxx" +#line 1524 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } @@ -5011,7 +5027,7 @@ yyreduce: case 199: /* Line 1792 of yacc.c */ -#line 1529 "dtool/src/cppparser/cppBison.yxx" +#line 1528 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); @@ -5020,7 +5036,7 @@ yyreduce: case 200: /* Line 1792 of yacc.c */ -#line 1534 "dtool/src/cppparser/cppBison.yxx" +#line 1533 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); @@ -5029,7 +5045,7 @@ yyreduce: case 201: /* Line 1792 of yacc.c */ -#line 1539 "dtool/src/cppparser/cppBison.yxx" +#line 1538 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); @@ -5038,7 +5054,7 @@ yyreduce: case 202: /* Line 1792 of yacc.c */ -#line 1544 "dtool/src/cppparser/cppBison.yxx" +#line 1543 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); @@ -5047,7 +5063,7 @@ yyreduce: case 203: /* Line 1792 of yacc.c */ -#line 1549 "dtool/src/cppparser/cppBison.yxx" +#line 1548 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); @@ -5056,7 +5072,7 @@ yyreduce: case 204: /* Line 1792 of yacc.c */ -#line 1554 "dtool/src/cppparser/cppBison.yxx" +#line 1553 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); @@ -5065,7 +5081,7 @@ yyreduce: case 205: /* Line 1792 of yacc.c */ -#line 1559 "dtool/src/cppparser/cppBison.yxx" +#line 1558 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (7)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); @@ -5075,7 +5091,7 @@ yyreduce: case 206: /* Line 1792 of yacc.c */ -#line 1568 "dtool/src/cppparser/cppBison.yxx" +#line 1567 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); } @@ -5083,7 +5099,7 @@ yyreduce: case 207: /* Line 1792 of yacc.c */ -#line 1572 "dtool/src/cppparser/cppBison.yxx" +#line 1571 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); assert((yyval.u.type) != NULL); @@ -5092,7 +5108,7 @@ yyreduce: case 208: /* Line 1792 of yacc.c */ -#line 1577 "dtool/src/cppparser/cppBison.yxx" +#line 1576 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); } @@ -5100,7 +5116,7 @@ yyreduce: case 209: /* Line 1792 of yacc.c */ -#line 1581 "dtool/src/cppparser/cppBison.yxx" +#line 1580 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.struct_type)); } @@ -5108,7 +5124,7 @@ yyreduce: case 210: /* Line 1792 of yacc.c */ -#line 1585 "dtool/src/cppparser/cppBison.yxx" +#line 1584 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.struct_type)); } @@ -5116,7 +5132,7 @@ yyreduce: case 211: /* Line 1792 of yacc.c */ -#line 1589 "dtool/src/cppparser/cppBison.yxx" +#line 1588 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.enum_type)); } @@ -5124,15 +5140,7 @@ yyreduce: case 212: /* Line 1792 of yacc.c */ -#line 1593 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.enum_type)); -} - break; - - case 213: -/* Line 1792 of yacc.c */ -#line 1597 "dtool/src/cppparser/cppBison.yxx" +#line 1592 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -5150,13 +5158,82 @@ yyreduce: } break; + case 213: +/* Line 1792 of yacc.c */ +#line 1608 "dtool/src/cppparser/cppBison.yxx" + { + CPPType *type = (yyvsp[(2) - (4)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); + if (type != NULL) { + (yyval.u.type) = type; + } else { + CPPExtensionType *et = + CPPType::new_type(new CPPExtensionType((yyvsp[(1) - (4)].u.extension_enum), (yyvsp[(2) - (4)].u.identifier), current_scope, (yylsp[(1) - (4)]).file)) + ->as_extension_type(); + CPPScope *scope = (yyvsp[(2) - (4)].u.identifier)->get_scope(current_scope, global_scope); + if (scope != NULL) { + scope->define_extension_type(et); + } + (yyval.u.type) = et; + } +} + break; + case 214: /* Line 1792 of yacc.c */ -#line 1613 "dtool/src/cppparser/cppBison.yxx" +#line 1627 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.decl) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); +} + break; + + case 215: +/* Line 1792 of yacc.c */ +#line 1631 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.decl) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); + assert((yyval.u.decl) != NULL); +} + break; + + case 216: +/* Line 1792 of yacc.c */ +#line 1636 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.decl) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); +} + break; + + case 217: +/* Line 1792 of yacc.c */ +#line 1640 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.decl) = CPPType::new_type((yyvsp[(1) - (1)].u.struct_type)); +} + break; + + case 218: +/* Line 1792 of yacc.c */ +#line 1644 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[(1) - (1)].u.struct_type))); +} + break; + + case 219: +/* Line 1792 of yacc.c */ +#line 1648 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[(1) - (1)].u.enum_type))); +} + break; + + case 220: +/* Line 1792 of yacc.c */ +#line 1652 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { - (yyval.u.type) = type; + (yyval.u.decl) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[(1) - (2)].u.extension_enum), (yyvsp[(2) - (2)].u.identifier), current_scope, (yylsp[(1) - (2)]).file)) @@ -5165,72 +5242,37 @@ yyreduce: if (scope != NULL) { scope->define_extension_type(et); } - (yyval.u.type) = et; + (yyval.u.decl) = et; } } break; - case 215: -/* Line 1792 of yacc.c */ -#line 1632 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.decl) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); -} - break; - - case 216: -/* Line 1792 of yacc.c */ -#line 1636 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.decl) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - assert((yyval.u.decl) != NULL); -} - break; - - case 217: -/* Line 1792 of yacc.c */ -#line 1641 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.decl) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); -} - break; - - case 218: -/* Line 1792 of yacc.c */ -#line 1645 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.decl) = CPPType::new_type((yyvsp[(1) - (1)].u.struct_type)); -} - break; - - case 219: -/* Line 1792 of yacc.c */ -#line 1649 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[(1) - (1)].u.struct_type))); -} - break; - - case 220: -/* Line 1792 of yacc.c */ -#line 1653 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.decl) = CPPType::new_type((yyvsp[(1) - (1)].u.enum_type)); -} - break; - case 221: /* Line 1792 of yacc.c */ -#line 1657 "dtool/src/cppparser/cppBison.yxx" +#line 1668 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[(1) - (1)].u.enum_type))); + CPPType *type = (yyvsp[(2) - (4)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); + if (type != NULL) { + (yyval.u.decl) = type; + } else { + CPPExtensionType *et = + CPPType::new_type(new CPPExtensionType((yyvsp[(1) - (4)].u.extension_enum), (yyvsp[(2) - (4)].u.identifier), current_scope, (yylsp[(1) - (4)]).file)) + ->as_extension_type(); + CPPScope *scope = (yyvsp[(2) - (4)].u.identifier)->get_scope(current_scope, global_scope); + if (scope != NULL) { + scope->define_extension_type(et); + } + (yyval.u.decl) = et; + } } break; case 222: /* Line 1792 of yacc.c */ -#line 1661 "dtool/src/cppparser/cppBison.yxx" +#line 1684 "dtool/src/cppparser/cppBison.yxx" { + yywarning(string("C++ does not permit forward declaration of untyped enum ") + (yyvsp[(2) - (2)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (2)])); + CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { (yyval.u.decl) = type; @@ -5249,11 +5291,36 @@ yyreduce: case 223: /* Line 1792 of yacc.c */ -#line 1677 "dtool/src/cppparser/cppBison.yxx" +#line 1705 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); +} + break; + + case 224: +/* Line 1792 of yacc.c */ +#line 1709 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); + assert((yyval.u.type) != NULL); +} + break; + + case 225: +/* Line 1792 of yacc.c */ +#line 1714 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); +} + break; + + case 226: +/* Line 1792 of yacc.c */ +#line 1718 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { - (yyval.u.decl) = type; + (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[(1) - (2)].u.extension_enum), (yyvsp[(2) - (2)].u.identifier), current_scope, (yylsp[(1) - (2)]).file)) @@ -5262,39 +5329,14 @@ yyreduce: if (scope != NULL) { scope->define_extension_type(et); } - (yyval.u.decl) = et; + (yyval.u.type) = et; } } break; - case 224: -/* Line 1792 of yacc.c */ -#line 1696 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); -} - break; - - case 225: -/* Line 1792 of yacc.c */ -#line 1700 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - assert((yyval.u.type) != NULL); -} - break; - - case 226: -/* Line 1792 of yacc.c */ -#line 1705 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); -} - break; - case 227: /* Line 1792 of yacc.c */ -#line 1709 "dtool/src/cppparser/cppBison.yxx" +#line 1734 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -5314,27 +5356,7 @@ yyreduce: case 228: /* Line 1792 of yacc.c */ -#line 1725 "dtool/src/cppparser/cppBison.yxx" - { - CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { - (yyval.u.type) = type; - } else { - CPPExtensionType *et = - CPPType::new_type(new CPPExtensionType((yyvsp[(1) - (2)].u.extension_enum), (yyvsp[(2) - (2)].u.identifier), current_scope, (yylsp[(1) - (2)]).file)) - ->as_extension_type(); - CPPScope *scope = (yyvsp[(2) - (2)].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { - scope->define_extension_type(et); - } - (yyval.u.type) = et; - } -} - break; - - case 229: -/* Line 1792 of yacc.c */ -#line 1744 "dtool/src/cppparser/cppBison.yxx" +#line 1753 "dtool/src/cppparser/cppBison.yxx" { CPPInstance *inst = new CPPInstance((yyvsp[(1) - (2)].u.type), (yyvsp[(2) - (2)].u.inst_ident), 0, (yylsp[(1) - (2)]).file); (yyval.u.type) = inst->_type; @@ -5342,9 +5364,9 @@ yyreduce: } break; - case 230: + case 229: /* Line 1792 of yacc.c */ -#line 1750 "dtool/src/cppparser/cppBison.yxx" +#line 1759 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(3) - (3)].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance((yyvsp[(2) - (3)].u.type), (yyvsp[(3) - (3)].u.inst_ident), 0, (yylsp[(1) - (3)]).file); @@ -5353,9 +5375,9 @@ yyreduce: } break; - case 231: + case 230: /* Line 1792 of yacc.c */ -#line 1760 "dtool/src/cppparser/cppBison.yxx" +#line 1769 "dtool/src/cppparser/cppBison.yxx" { CPPVisibility starting_vis = ((yyvsp[(1) - (2)].u.extension_enum) == CPPExtensionType::T_class) ? V_private : V_public; @@ -5371,9 +5393,9 @@ yyreduce: } break; - case 232: + case 231: /* Line 1792 of yacc.c */ -#line 1774 "dtool/src/cppparser/cppBison.yxx" +#line 1783 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.struct_type) = current_struct; current_struct->_incomplete = false; @@ -5382,9 +5404,9 @@ yyreduce: } break; - case 233: + case 232: /* Line 1792 of yacc.c */ -#line 1784 "dtool/src/cppparser/cppBison.yxx" +#line 1793 "dtool/src/cppparser/cppBison.yxx" { CPPVisibility starting_vis = ((yyvsp[(1) - (2)].u.extension_enum) == CPPExtensionType::T_class) ? V_private : V_public; @@ -5406,9 +5428,9 @@ yyreduce: } break; - case 234: + case 233: /* Line 1792 of yacc.c */ -#line 1804 "dtool/src/cppparser/cppBison.yxx" +#line 1813 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.struct_type) = current_struct; current_struct->_incomplete = false; @@ -5417,115 +5439,138 @@ yyreduce: } break; - case 239: + case 238: /* Line 1792 of yacc.c */ -#line 1824 "dtool/src/cppparser/cppBison.yxx" +#line 1833 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(2) - (2)].u.type), V_public, false); } break; - case 240: + case 239: /* Line 1792 of yacc.c */ -#line 1828 "dtool/src/cppparser/cppBison.yxx" +#line 1837 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(2) - (2)].u.type), V_protected, false); } break; - case 241: + case 240: /* Line 1792 of yacc.c */ -#line 1832 "dtool/src/cppparser/cppBison.yxx" +#line 1841 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(2) - (2)].u.type), V_private, false); } break; - case 242: + case 241: /* Line 1792 of yacc.c */ -#line 1836 "dtool/src/cppparser/cppBison.yxx" +#line 1845 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_public, true); } break; + case 242: +/* Line 1792 of yacc.c */ +#line 1849 "dtool/src/cppparser/cppBison.yxx" + { + current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_protected, true); +} + break; + case 243: /* Line 1792 of yacc.c */ -#line 1840 "dtool/src/cppparser/cppBison.yxx" +#line 1853 "dtool/src/cppparser/cppBison.yxx" { - current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_protected, true); + current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_private, true); } break; case 244: /* Line 1792 of yacc.c */ -#line 1844 "dtool/src/cppparser/cppBison.yxx" - { - current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_private, true); -} - break; - - case 245: -/* Line 1792 of yacc.c */ -#line 1848 "dtool/src/cppparser/cppBison.yxx" +#line 1857 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_public, true); } break; - case 246: + case 245: /* Line 1792 of yacc.c */ -#line 1852 "dtool/src/cppparser/cppBison.yxx" +#line 1861 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_protected, true); } break; - case 247: + case 246: /* Line 1792 of yacc.c */ -#line 1856 "dtool/src/cppparser/cppBison.yxx" +#line 1865 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_private, true); } break; + case 247: +/* Line 1792 of yacc.c */ +#line 1872 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.enum_type) = current_enum; + current_enum = NULL; +} + break; + case 248: /* Line 1792 of yacc.c */ -#line 1863 "dtool/src/cppparser/cppBison.yxx" +#line 1880 "dtool/src/cppparser/cppBison.yxx" { - current_enum = new CPPEnumType(NULL, current_scope, (yylsp[(1) - (2)]).file); + current_enum = new CPPEnumType((yyvsp[(2) - (4)].u.identifier), (yyvsp[(4) - (4)].u.type), current_scope, (yylsp[(1) - (4)]).file); } break; case 249: /* Line 1792 of yacc.c */ -#line 1867 "dtool/src/cppparser/cppBison.yxx" +#line 1884 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.enum_type) = current_enum; - current_enum = NULL; + current_enum = new CPPEnumType((yyvsp[(2) - (2)].u.identifier), current_scope, (yylsp[(1) - (2)]).file); } break; case 250: /* Line 1792 of yacc.c */ -#line 1875 "dtool/src/cppparser/cppBison.yxx" +#line 1888 "dtool/src/cppparser/cppBison.yxx" { - current_enum = new CPPEnumType((yyvsp[(2) - (3)].u.identifier), current_scope, (yylsp[(1) - (3)]).file); + current_enum = new CPPEnumType(NULL, (yyvsp[(3) - (3)].u.type), current_scope, (yylsp[(1) - (3)]).file); } break; case 251: /* Line 1792 of yacc.c */ -#line 1879 "dtool/src/cppparser/cppBison.yxx" +#line 1892 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.enum_type) = current_enum; - current_enum = NULL; + current_enum = new CPPEnumType(NULL, current_scope, (yylsp[(1) - (1)]).file); +} + break; + + case 252: +/* Line 1792 of yacc.c */ +#line 1899 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); } break; case 253: /* Line 1792 of yacc.c */ -#line 1888 "dtool/src/cppparser/cppBison.yxx" +#line 1903 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); +} + break; + + case 255: +/* Line 1792 of yacc.c */ +#line 1911 "dtool/src/cppparser/cppBison.yxx" { assert(current_enum != NULL); CPPInstance *inst = current_enum->add_element((yyvsp[(2) - (3)].u.identifier)->get_simple_name()); @@ -5533,9 +5578,9 @@ yyreduce: } break; - case 254: + case 256: /* Line 1792 of yacc.c */ -#line 1894 "dtool/src/cppparser/cppBison.yxx" +#line 1917 "dtool/src/cppparser/cppBison.yxx" { assert(current_enum != NULL); CPPInstance *inst = current_enum->add_element((yyvsp[(2) - (5)].u.identifier)->get_simple_name(), (yyvsp[(4) - (5)].u.expr)); @@ -5543,9 +5588,9 @@ yyreduce: } break; - case 256: + case 258: /* Line 1792 of yacc.c */ -#line 1903 "dtool/src/cppparser/cppBison.yxx" +#line 1926 "dtool/src/cppparser/cppBison.yxx" { assert(current_enum != NULL); CPPInstance *inst = current_enum->add_element((yyvsp[(2) - (2)].u.identifier)->get_simple_name()); @@ -5553,9 +5598,9 @@ yyreduce: } break; - case 257: + case 259: /* Line 1792 of yacc.c */ -#line 1909 "dtool/src/cppparser/cppBison.yxx" +#line 1932 "dtool/src/cppparser/cppBison.yxx" { assert(current_enum != NULL); CPPInstance *inst = current_enum->add_element((yyvsp[(2) - (4)].u.identifier)->get_simple_name(), (yyvsp[(4) - (4)].u.expr)); @@ -5563,41 +5608,41 @@ yyreduce: } break; - case 258: + case 260: /* Line 1792 of yacc.c */ -#line 1918 "dtool/src/cppparser/cppBison.yxx" +#line 1941 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.extension_enum) = CPPExtensionType::T_enum; } break; - case 259: + case 261: /* Line 1792 of yacc.c */ -#line 1925 "dtool/src/cppparser/cppBison.yxx" +#line 1948 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.extension_enum) = CPPExtensionType::T_class; } break; - case 260: + case 262: /* Line 1792 of yacc.c */ -#line 1929 "dtool/src/cppparser/cppBison.yxx" +#line 1952 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.extension_enum) = CPPExtensionType::T_struct; } break; - case 261: + case 263: /* Line 1792 of yacc.c */ -#line 1933 "dtool/src/cppparser/cppBison.yxx" +#line 1956 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.extension_enum) = CPPExtensionType::T_union; } break; - case 262: + case 264: /* Line 1792 of yacc.c */ -#line 1940 "dtool/src/cppparser/cppBison.yxx" +#line 1963 "dtool/src/cppparser/cppBison.yxx" { CPPScope *scope = (yyvsp[(2) - (3)].u.identifier)->find_scope(current_scope, global_scope, current_lexer); if (scope == NULL) { @@ -5617,17 +5662,17 @@ yyreduce: } break; - case 263: + case 265: /* Line 1792 of yacc.c */ -#line 1958 "dtool/src/cppparser/cppBison.yxx" +#line 1981 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); } break; - case 265: + case 267: /* Line 1792 of yacc.c */ -#line 1966 "dtool/src/cppparser/cppBison.yxx" +#line 1989 "dtool/src/cppparser/cppBison.yxx" { CPPUsing *using_decl = new CPPUsing((yyvsp[(2) - (2)].u.identifier), false, (yylsp[(1) - (2)]).file); current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[(1) - (2)])); @@ -5635,9 +5680,9 @@ yyreduce: } break; - case 266: + case 268: /* Line 1792 of yacc.c */ -#line 1972 "dtool/src/cppparser/cppBison.yxx" +#line 1995 "dtool/src/cppparser/cppBison.yxx" { CPPUsing *using_decl = new CPPUsing((yyvsp[(3) - (3)].u.identifier), true, (yylsp[(1) - (3)]).file); current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[(1) - (3)])); @@ -5645,95 +5690,111 @@ yyreduce: } break; - case 270: + case 272: /* Line 1792 of yacc.c */ -#line 1987 "dtool/src/cppparser/cppBison.yxx" +#line 2010 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_bool); } break; - case 271: + case 273: /* Line 1792 of yacc.c */ -#line 1991 "dtool/src/cppparser/cppBison.yxx" +#line 2014 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char); } break; - case 272: + case 274: /* Line 1792 of yacc.c */ -#line 1995 "dtool/src/cppparser/cppBison.yxx" +#line 2018 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_wchar_t); } break; - case 273: + case 275: /* Line 1792 of yacc.c */ -#line 1999 "dtool/src/cppparser/cppBison.yxx" +#line 2022 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char16_t); +} + break; + + case 276: +/* Line 1792 of yacc.c */ +#line 2026 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char32_t); +} + break; + + case 277: +/* Line 1792 of yacc.c */ +#line 2030 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_short); } break; - case 274: + case 278: /* Line 1792 of yacc.c */ -#line 2004 "dtool/src/cppparser/cppBison.yxx" +#line 2035 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_long); } break; - case 275: + case 279: /* Line 1792 of yacc.c */ -#line 2009 "dtool/src/cppparser/cppBison.yxx" +#line 2040 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_longlong); } break; - case 276: + case 280: /* Line 1792 of yacc.c */ -#line 2014 "dtool/src/cppparser/cppBison.yxx" +#line 2045 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_unsigned); } break; - case 277: + case 281: /* Line 1792 of yacc.c */ -#line 2019 "dtool/src/cppparser/cppBison.yxx" +#line 2050 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_signed); } break; - case 278: + case 282: /* Line 1792 of yacc.c */ -#line 2024 "dtool/src/cppparser/cppBison.yxx" +#line 2055 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int); } break; - case 279: + case 283: /* Line 1792 of yacc.c */ -#line 2028 "dtool/src/cppparser/cppBison.yxx" +#line 2059 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = (yyvsp[(2) - (2)].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_short; } break; - case 280: + case 284: /* Line 1792 of yacc.c */ -#line 2033 "dtool/src/cppparser/cppBison.yxx" +#line 2064 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = (yyvsp[(2) - (2)].u.simple_type); if ((yyval.u.simple_type)->_flags & CPPSimpleType::F_long) { @@ -5744,261 +5805,261 @@ yyreduce: } break; - case 281: + case 285: /* Line 1792 of yacc.c */ -#line 2042 "dtool/src/cppparser/cppBison.yxx" +#line 2073 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = (yyvsp[(2) - (2)].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_unsigned; } break; - case 282: + case 286: /* Line 1792 of yacc.c */ -#line 2047 "dtool/src/cppparser/cppBison.yxx" +#line 2078 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = (yyvsp[(2) - (2)].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_signed; } break; - case 283: + case 287: /* Line 1792 of yacc.c */ -#line 2055 "dtool/src/cppparser/cppBison.yxx" +#line 2086 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_float); } break; - case 284: + case 288: /* Line 1792 of yacc.c */ -#line 2059 "dtool/src/cppparser/cppBison.yxx" +#line 2090 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_float, CPPSimpleType::F_long); } break; - case 285: + case 289: /* Line 1792 of yacc.c */ -#line 2064 "dtool/src/cppparser/cppBison.yxx" +#line 2095 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_double); } break; - case 286: + case 290: /* Line 1792 of yacc.c */ -#line 2068 "dtool/src/cppparser/cppBison.yxx" +#line 2099 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_float, CPPSimpleType::F_longlong); } break; - case 287: + case 291: /* Line 1792 of yacc.c */ -#line 2073 "dtool/src/cppparser/cppBison.yxx" +#line 2104 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_double, CPPSimpleType::F_long); } break; - case 288: + case 292: /* Line 1792 of yacc.c */ -#line 2081 "dtool/src/cppparser/cppBison.yxx" +#line 2112 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_void); } break; - case 289: + case 293: /* Line 1792 of yacc.c */ -#line 2090 "dtool/src/cppparser/cppBison.yxx" +#line 2121 "dtool/src/cppparser/cppBison.yxx" { current_lexer->_resolve_identifiers = false; } break; - case 290: + case 294: /* Line 1792 of yacc.c */ -#line 2094 "dtool/src/cppparser/cppBison.yxx" +#line 2125 "dtool/src/cppparser/cppBison.yxx" { current_lexer->_resolve_identifiers = true; } break; - case 293: -/* Line 1792 of yacc.c */ -#line 2106 "dtool/src/cppparser/cppBison.yxx" - { -} - break; - - case 294: -/* Line 1792 of yacc.c */ -#line 2109 "dtool/src/cppparser/cppBison.yxx" - { -} - break; - - case 295: -/* Line 1792 of yacc.c */ -#line 2112 "dtool/src/cppparser/cppBison.yxx" - { -} - break; - - case 296: -/* Line 1792 of yacc.c */ -#line 2115 "dtool/src/cppparser/cppBison.yxx" - { -} - break; - case 297: /* Line 1792 of yacc.c */ -#line 2118 "dtool/src/cppparser/cppBison.yxx" +#line 2137 "dtool/src/cppparser/cppBison.yxx" { } break; case 298: /* Line 1792 of yacc.c */ -#line 2121 "dtool/src/cppparser/cppBison.yxx" +#line 2140 "dtool/src/cppparser/cppBison.yxx" { } break; case 299: /* Line 1792 of yacc.c */ -#line 2124 "dtool/src/cppparser/cppBison.yxx" +#line 2143 "dtool/src/cppparser/cppBison.yxx" { } break; case 300: /* Line 1792 of yacc.c */ -#line 2127 "dtool/src/cppparser/cppBison.yxx" +#line 2146 "dtool/src/cppparser/cppBison.yxx" { } break; - case 373: + case 301: /* Line 1792 of yacc.c */ -#line 2147 "dtool/src/cppparser/cppBison.yxx" +#line 2149 "dtool/src/cppparser/cppBison.yxx" { } break; - case 397: + case 302: /* Line 1792 of yacc.c */ -#line 2156 "dtool/src/cppparser/cppBison.yxx" +#line 2152 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (CPPExpression *)NULL; } break; - case 398: + case 303: /* Line 1792 of yacc.c */ -#line 2160 "dtool/src/cppparser/cppBison.yxx" +#line 2155 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; - case 399: + case 304: /* Line 1792 of yacc.c */ -#line 2167 "dtool/src/cppparser/cppBison.yxx" +#line 2158 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (CPPExpression *)NULL; } break; - case 400: + case 379: /* Line 1792 of yacc.c */ -#line 2171 "dtool/src/cppparser/cppBison.yxx" +#line 2179 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); -} - break; - - case 401: -/* Line 1792 of yacc.c */ -#line 2178 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); -} - break; - - case 402: -/* Line 1792 of yacc.c */ -#line 2182 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(',', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 403: /* Line 1792 of yacc.c */ -#line 2189 "dtool/src/cppparser/cppBison.yxx" +#line 2188 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); + (yyval.u.expr) = (CPPExpression *)NULL; } break; case 404: /* Line 1792 of yacc.c */ -#line 2193 "dtool/src/cppparser/cppBison.yxx" +#line 2192 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; case 405: /* Line 1792 of yacc.c */ -#line 2197 "dtool/src/cppparser/cppBison.yxx" +#line 2199 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); + (yyval.u.expr) = (CPPExpression *)NULL; } break; case 406: /* Line 1792 of yacc.c */ -#line 2201 "dtool/src/cppparser/cppBison.yxx" +#line 2203 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; case 407: /* Line 1792 of yacc.c */ -#line 2205 "dtool/src/cppparser/cppBison.yxx" +#line 2210 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; case 408: /* Line 1792 of yacc.c */ -#line 2209 "dtool/src/cppparser/cppBison.yxx" +#line 2214 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); + (yyval.u.expr) = new CPPExpression(',', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 409: /* Line 1792 of yacc.c */ -#line 2213 "dtool/src/cppparser/cppBison.yxx" +#line 2221 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; case 410: /* Line 1792 of yacc.c */ -#line 2217 "dtool/src/cppparser/cppBison.yxx" +#line 2225 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); +} + break; + + case 411: +/* Line 1792 of yacc.c */ +#line 2229 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); +} + break; + + case 412: +/* Line 1792 of yacc.c */ +#line 2233 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); +} + break; + + case 413: +/* Line 1792 of yacc.c */ +#line 2237 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); +} + break; + + case 414: +/* Line 1792 of yacc.c */ +#line 2241 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 415: +/* Line 1792 of yacc.c */ +#line 2245 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 416: +/* Line 1792 of yacc.c */ +#line 2249 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(2) - (2)].u.expr)->_type == CPPExpression::T_integer) { (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); @@ -6012,241 +6073,241 @@ yyreduce: } break; - case 411: + case 417: /* Line 1792 of yacc.c */ -#line 2229 "dtool/src/cppparser/cppBison.yxx" +#line 2261 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[(2) - (2)].u.expr)); } break; - case 412: + case 418: /* Line 1792 of yacc.c */ -#line 2233 "dtool/src/cppparser/cppBison.yxx" +#line 2265 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); } break; - case 413: + case 419: /* Line 1792 of yacc.c */ -#line 2237 "dtool/src/cppparser/cppBison.yxx" +#line 2269 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 414: + case 420: /* Line 1792 of yacc.c */ -#line 2241 "dtool/src/cppparser/cppBison.yxx" +#line 2273 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 415: + case 421: /* Line 1792 of yacc.c */ -#line 2245 "dtool/src/cppparser/cppBison.yxx" +#line 2277 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 416: + case 422: /* Line 1792 of yacc.c */ -#line 2249 "dtool/src/cppparser/cppBison.yxx" +#line 2281 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 417: + case 423: /* Line 1792 of yacc.c */ -#line 2253 "dtool/src/cppparser/cppBison.yxx" +#line 2285 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 418: + case 424: /* Line 1792 of yacc.c */ -#line 2257 "dtool/src/cppparser/cppBison.yxx" +#line 2289 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 419: + case 425: /* Line 1792 of yacc.c */ -#line 2261 "dtool/src/cppparser/cppBison.yxx" +#line 2293 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 420: + case 426: /* Line 1792 of yacc.c */ -#line 2265 "dtool/src/cppparser/cppBison.yxx" +#line 2297 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 421: + case 427: /* Line 1792 of yacc.c */ -#line 2269 "dtool/src/cppparser/cppBison.yxx" +#line 2301 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 422: + case 428: /* Line 1792 of yacc.c */ -#line 2273 "dtool/src/cppparser/cppBison.yxx" +#line 2305 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 423: + case 429: /* Line 1792 of yacc.c */ -#line 2277 "dtool/src/cppparser/cppBison.yxx" +#line 2309 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 424: + case 430: /* Line 1792 of yacc.c */ -#line 2281 "dtool/src/cppparser/cppBison.yxx" +#line 2313 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 425: + case 431: /* Line 1792 of yacc.c */ -#line 2285 "dtool/src/cppparser/cppBison.yxx" +#line 2317 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 426: + case 432: /* Line 1792 of yacc.c */ -#line 2289 "dtool/src/cppparser/cppBison.yxx" +#line 2321 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 427: + case 433: /* Line 1792 of yacc.c */ -#line 2293 "dtool/src/cppparser/cppBison.yxx" +#line 2325 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 428: + case 434: /* Line 1792 of yacc.c */ -#line 2297 "dtool/src/cppparser/cppBison.yxx" +#line 2329 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 429: + case 435: /* Line 1792 of yacc.c */ -#line 2301 "dtool/src/cppparser/cppBison.yxx" +#line 2333 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); } break; - case 430: + case 436: /* Line 1792 of yacc.c */ -#line 2305 "dtool/src/cppparser/cppBison.yxx" +#line 2337 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); } break; - case 431: + case 437: /* Line 1792 of yacc.c */ -#line 2309 "dtool/src/cppparser/cppBison.yxx" +#line 2341 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); } break; - case 432: + case 438: /* Line 1792 of yacc.c */ -#line 2313 "dtool/src/cppparser/cppBison.yxx" +#line 2345 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); } break; - case 433: + case 439: /* Line 1792 of yacc.c */ -#line 2317 "dtool/src/cppparser/cppBison.yxx" +#line 2349 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 434: + case 440: /* Line 1792 of yacc.c */ -#line 2321 "dtool/src/cppparser/cppBison.yxx" +#line 2353 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 435: + case 441: /* Line 1792 of yacc.c */ -#line 2325 "dtool/src/cppparser/cppBison.yxx" +#line 2357 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); } break; - case 436: + case 442: /* Line 1792 of yacc.c */ -#line 2333 "dtool/src/cppparser/cppBison.yxx" +#line 2365 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; - case 437: + case 443: /* Line 1792 of yacc.c */ -#line 2337 "dtool/src/cppparser/cppBison.yxx" +#line 2369 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); } break; - case 438: + case 444: /* Line 1792 of yacc.c */ -#line 2341 "dtool/src/cppparser/cppBison.yxx" +#line 2373 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); } break; - case 439: + case 445: /* Line 1792 of yacc.c */ -#line 2345 "dtool/src/cppparser/cppBison.yxx" +#line 2377 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); } break; - case 440: + case 446: /* Line 1792 of yacc.c */ -#line 2349 "dtool/src/cppparser/cppBison.yxx" +#line 2381 "dtool/src/cppparser/cppBison.yxx" { // A constructor call. CPPType *type = (yyvsp[(1) - (4)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); @@ -6255,9 +6316,9 @@ yyreduce: } break; - case 441: + case 447: /* Line 1792 of yacc.c */ -#line 2356 "dtool/src/cppparser/cppBison.yxx" +#line 2388 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int)); @@ -6265,9 +6326,9 @@ yyreduce: } break; - case 442: + case 448: /* Line 1792 of yacc.c */ -#line 2362 "dtool/src/cppparser/cppBison.yxx" +#line 2394 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char)); @@ -6275,9 +6336,9 @@ yyreduce: } break; - case 443: + case 449: /* Line 1792 of yacc.c */ -#line 2368 "dtool/src/cppparser/cppBison.yxx" +#line 2400 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_wchar_t)); @@ -6285,9 +6346,29 @@ yyreduce: } break; - case 444: + case 450: /* Line 1792 of yacc.c */ -#line 2374 "dtool/src/cppparser/cppBison.yxx" +#line 2406 "dtool/src/cppparser/cppBison.yxx" + { + CPPType *type = + CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char16_t)); + (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[(3) - (4)].u.expr))); +} + break; + + case 451: +/* Line 1792 of yacc.c */ +#line 2412 "dtool/src/cppparser/cppBison.yxx" + { + CPPType *type = + CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char32_t)); + (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[(3) - (4)].u.expr))); +} + break; + + case 452: +/* Line 1792 of yacc.c */ +#line 2418 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_bool)); @@ -6295,9 +6376,9 @@ yyreduce: } break; - case 445: + case 453: /* Line 1792 of yacc.c */ -#line 2380 "dtool/src/cppparser/cppBison.yxx" +#line 2424 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, @@ -6306,9 +6387,9 @@ yyreduce: } break; - case 446: + case 454: /* Line 1792 of yacc.c */ -#line 2387 "dtool/src/cppparser/cppBison.yxx" +#line 2431 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, @@ -6317,9 +6398,9 @@ yyreduce: } break; - case 447: + case 455: /* Line 1792 of yacc.c */ -#line 2394 "dtool/src/cppparser/cppBison.yxx" +#line 2438 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, @@ -6328,9 +6409,9 @@ yyreduce: } break; - case 448: + case 456: /* Line 1792 of yacc.c */ -#line 2401 "dtool/src/cppparser/cppBison.yxx" +#line 2445 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, @@ -6339,9 +6420,9 @@ yyreduce: } break; - case 449: + case 457: /* Line 1792 of yacc.c */ -#line 2408 "dtool/src/cppparser/cppBison.yxx" +#line 2452 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_float)); @@ -6349,9 +6430,9 @@ yyreduce: } break; - case 450: + case 458: /* Line 1792 of yacc.c */ -#line 2414 "dtool/src/cppparser/cppBison.yxx" +#line 2458 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_double)); @@ -6359,409 +6440,49 @@ yyreduce: } break; - case 451: -/* Line 1792 of yacc.c */ -#line 2420 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); -} - break; - - case 452: -/* Line 1792 of yacc.c */ -#line 2424 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (2)].u.type))); -} - break; - - case 453: -/* Line 1792 of yacc.c */ -#line 2428 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (5)].u.type), (yyvsp[(4) - (5)].u.expr))); -} - break; - - case 454: -/* Line 1792 of yacc.c */ -#line 2432 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); -} - break; - - case 455: -/* Line 1792 of yacc.c */ -#line 2436 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); -} - break; - - case 456: -/* Line 1792 of yacc.c */ -#line 2440 "dtool/src/cppparser/cppBison.yxx" - { - if ((yyvsp[(2) - (2)].u.expr)->_type == CPPExpression::T_integer) { - (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); - (yyval.u.expr)->_u._integer = -(yyval.u.expr)->_u._integer; - } else if ((yyvsp[(2) - (2)].u.expr)->_type == CPPExpression::T_real) { - (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); - (yyval.u.expr)->_u._real = -(yyval.u.expr)->_u._real; - } else { - (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[(2) - (2)].u.expr)); - } -} - break; - - case 457: -/* Line 1792 of yacc.c */ -#line 2452 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[(2) - (2)].u.expr)); -} - break; - - case 458: -/* Line 1792 of yacc.c */ -#line 2456 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); -} - break; - case 459: /* Line 1792 of yacc.c */ -#line 2460 "dtool/src/cppparser/cppBison.yxx" +#line 2464 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); } break; case 460: /* Line 1792 of yacc.c */ -#line 2464 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 461: -/* Line 1792 of yacc.c */ #line 2468 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 462: -/* Line 1792 of yacc.c */ -#line 2472 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 463: -/* Line 1792 of yacc.c */ -#line 2476 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 464: -/* Line 1792 of yacc.c */ -#line 2480 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 465: -/* Line 1792 of yacc.c */ -#line 2484 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 466: -/* Line 1792 of yacc.c */ -#line 2488 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 467: -/* Line 1792 of yacc.c */ -#line 2492 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 468: -/* Line 1792 of yacc.c */ -#line 2496 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 469: -/* Line 1792 of yacc.c */ -#line 2500 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 470: -/* Line 1792 of yacc.c */ -#line 2504 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 471: -/* Line 1792 of yacc.c */ -#line 2508 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 472: -/* Line 1792 of yacc.c */ -#line 2512 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 473: -/* Line 1792 of yacc.c */ -#line 2516 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('<', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 474: -/* Line 1792 of yacc.c */ -#line 2520 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('>', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 475: -/* Line 1792 of yacc.c */ -#line 2524 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 476: -/* Line 1792 of yacc.c */ -#line 2528 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 477: -/* Line 1792 of yacc.c */ -#line 2532 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); -} - break; - - case 478: -/* Line 1792 of yacc.c */ -#line 2536 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); -} - break; - - case 479: -/* Line 1792 of yacc.c */ -#line 2540 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); -} - break; - - case 480: -/* Line 1792 of yacc.c */ -#line 2544 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); -} - break; - - case 481: -/* Line 1792 of yacc.c */ -#line 2548 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 482: -/* Line 1792 of yacc.c */ -#line 2552 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 483: -/* Line 1792 of yacc.c */ -#line 2556 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); -} - break; - - case 484: -/* Line 1792 of yacc.c */ -#line 2563 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); -} - break; - - case 485: -/* Line 1792 of yacc.c */ -#line 2567 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(true); -} - break; - - case 486: -/* Line 1792 of yacc.c */ -#line 2571 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(false); -} - break; - - case 487: -/* Line 1792 of yacc.c */ -#line 2575 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); -} - break; - - case 488: -/* Line 1792 of yacc.c */ -#line 2579 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.real)); -} - break; - - case 489: -/* Line 1792 of yacc.c */ -#line 2583 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].str)); -} - break; - - case 490: -/* Line 1792 of yacc.c */ -#line 2587 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.identifier), current_scope, global_scope, current_lexer); -} - break; - - case 491: -/* Line 1792 of yacc.c */ -#line 2601 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); -} - break; - - case 492: -/* Line 1792 of yacc.c */ -#line 2605 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); -} - break; - - case 493: -/* Line 1792 of yacc.c */ -#line 2609 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); -} - break; - - case 494: -/* Line 1792 of yacc.c */ -#line 2613 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); -} - break; - - case 495: -/* Line 1792 of yacc.c */ -#line 2617 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); -} - break; - - case 496: -/* Line 1792 of yacc.c */ -#line 2621 "dtool/src/cppparser/cppBison.yxx" - { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (2)].u.type))); } break; - case 497: + case 461: /* Line 1792 of yacc.c */ -#line 2625 "dtool/src/cppparser/cppBison.yxx" +#line 2472 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (5)].u.type), (yyvsp[(4) - (5)].u.expr))); } break; - case 498: + case 462: /* Line 1792 of yacc.c */ -#line 2629 "dtool/src/cppparser/cppBison.yxx" +#line 2476 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); } break; - case 499: + case 463: /* Line 1792 of yacc.c */ -#line 2633 "dtool/src/cppparser/cppBison.yxx" +#line 2480 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); } break; - case 500: + case 464: /* Line 1792 of yacc.c */ -#line 2637 "dtool/src/cppparser/cppBison.yxx" +#line 2484 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(2) - (2)].u.expr)->_type == CPPExpression::T_integer) { (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); @@ -6775,265 +6496,625 @@ yyreduce: } break; - case 501: + case 465: /* Line 1792 of yacc.c */ -#line 2649 "dtool/src/cppparser/cppBison.yxx" +#line 2496 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 466: +/* Line 1792 of yacc.c */ +#line 2500 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); } break; - case 502: + case 467: /* Line 1792 of yacc.c */ -#line 2653 "dtool/src/cppparser/cppBison.yxx" +#line 2504 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 503: + case 468: /* Line 1792 of yacc.c */ -#line 2657 "dtool/src/cppparser/cppBison.yxx" +#line 2508 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 504: + case 469: /* Line 1792 of yacc.c */ -#line 2661 "dtool/src/cppparser/cppBison.yxx" +#line 2512 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 505: + case 470: /* Line 1792 of yacc.c */ -#line 2665 "dtool/src/cppparser/cppBison.yxx" +#line 2516 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 506: + case 471: /* Line 1792 of yacc.c */ -#line 2669 "dtool/src/cppparser/cppBison.yxx" +#line 2520 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 507: + case 472: /* Line 1792 of yacc.c */ -#line 2673 "dtool/src/cppparser/cppBison.yxx" +#line 2524 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 508: + case 473: /* Line 1792 of yacc.c */ -#line 2677 "dtool/src/cppparser/cppBison.yxx" +#line 2528 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 509: + case 474: /* Line 1792 of yacc.c */ -#line 2681 "dtool/src/cppparser/cppBison.yxx" +#line 2532 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 510: + case 475: /* Line 1792 of yacc.c */ -#line 2685 "dtool/src/cppparser/cppBison.yxx" +#line 2536 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 511: + case 476: /* Line 1792 of yacc.c */ -#line 2689 "dtool/src/cppparser/cppBison.yxx" +#line 2540 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 512: + case 477: /* Line 1792 of yacc.c */ -#line 2693 "dtool/src/cppparser/cppBison.yxx" +#line 2544 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 513: + case 478: /* Line 1792 of yacc.c */ -#line 2697 "dtool/src/cppparser/cppBison.yxx" +#line 2548 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 514: + case 479: /* Line 1792 of yacc.c */ -#line 2701 "dtool/src/cppparser/cppBison.yxx" +#line 2552 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 515: + case 480: /* Line 1792 of yacc.c */ -#line 2705 "dtool/src/cppparser/cppBison.yxx" +#line 2556 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 516: + case 481: /* Line 1792 of yacc.c */ -#line 2709 "dtool/src/cppparser/cppBison.yxx" +#line 2560 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('<', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 517: + case 482: /* Line 1792 of yacc.c */ -#line 2713 "dtool/src/cppparser/cppBison.yxx" +#line 2564 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('>', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 518: + case 483: /* Line 1792 of yacc.c */ -#line 2717 "dtool/src/cppparser/cppBison.yxx" +#line 2568 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 519: + case 484: /* Line 1792 of yacc.c */ -#line 2721 "dtool/src/cppparser/cppBison.yxx" +#line 2572 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 520: + case 485: /* Line 1792 of yacc.c */ -#line 2725 "dtool/src/cppparser/cppBison.yxx" +#line 2576 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); } break; - case 521: + case 486: /* Line 1792 of yacc.c */ -#line 2729 "dtool/src/cppparser/cppBison.yxx" +#line 2580 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); } break; - case 522: + case 487: /* Line 1792 of yacc.c */ -#line 2733 "dtool/src/cppparser/cppBison.yxx" +#line 2584 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); } break; - case 523: + case 488: /* Line 1792 of yacc.c */ -#line 2737 "dtool/src/cppparser/cppBison.yxx" +#line 2588 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); } break; - case 524: + case 489: /* Line 1792 of yacc.c */ -#line 2741 "dtool/src/cppparser/cppBison.yxx" +#line 2592 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 525: + case 490: /* Line 1792 of yacc.c */ -#line 2745 "dtool/src/cppparser/cppBison.yxx" +#line 2596 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 526: + case 491: /* Line 1792 of yacc.c */ -#line 2749 "dtool/src/cppparser/cppBison.yxx" +#line 2600 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); } break; - case 527: + case 492: /* Line 1792 of yacc.c */ -#line 2756 "dtool/src/cppparser/cppBison.yxx" +#line 2607 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); } break; - case 528: + case 493: /* Line 1792 of yacc.c */ -#line 2760 "dtool/src/cppparser/cppBison.yxx" +#line 2611 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(true); } break; - case 529: + case 494: /* Line 1792 of yacc.c */ -#line 2764 "dtool/src/cppparser/cppBison.yxx" +#line 2615 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(false); } break; - case 530: + case 495: /* Line 1792 of yacc.c */ -#line 2768 "dtool/src/cppparser/cppBison.yxx" +#line 2619 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); } break; - case 531: + case 496: /* Line 1792 of yacc.c */ -#line 2772 "dtool/src/cppparser/cppBison.yxx" +#line 2623 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.real)); } break; - case 532: + case 497: /* Line 1792 of yacc.c */ -#line 2776 "dtool/src/cppparser/cppBison.yxx" +#line 2627 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].str)); } break; + case 498: +/* Line 1792 of yacc.c */ +#line 2631 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.identifier), current_scope, global_scope, current_lexer); +} + break; + + case 499: +/* Line 1792 of yacc.c */ +#line 2645 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); +} + break; + + case 500: +/* Line 1792 of yacc.c */ +#line 2649 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); +} + break; + + case 501: +/* Line 1792 of yacc.c */ +#line 2653 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); +} + break; + + case 502: +/* Line 1792 of yacc.c */ +#line 2657 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); +} + break; + + case 503: +/* Line 1792 of yacc.c */ +#line 2661 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); +} + break; + + case 504: +/* Line 1792 of yacc.c */ +#line 2665 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (2)].u.type))); +} + break; + + case 505: +/* Line 1792 of yacc.c */ +#line 2669 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (5)].u.type), (yyvsp[(4) - (5)].u.expr))); +} + break; + + case 506: +/* Line 1792 of yacc.c */ +#line 2673 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 507: +/* Line 1792 of yacc.c */ +#line 2677 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 508: +/* Line 1792 of yacc.c */ +#line 2681 "dtool/src/cppparser/cppBison.yxx" + { + if ((yyvsp[(2) - (2)].u.expr)->_type == CPPExpression::T_integer) { + (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); + (yyval.u.expr)->_u._integer = -(yyval.u.expr)->_u._integer; + } else if ((yyvsp[(2) - (2)].u.expr)->_type == CPPExpression::T_real) { + (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); + (yyval.u.expr)->_u._real = -(yyval.u.expr)->_u._real; + } else { + (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[(2) - (2)].u.expr)); + } +} + break; + + case 509: +/* Line 1792 of yacc.c */ +#line 2693 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 510: +/* Line 1792 of yacc.c */ +#line 2697 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 511: +/* Line 1792 of yacc.c */ +#line 2701 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 512: +/* Line 1792 of yacc.c */ +#line 2705 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 513: +/* Line 1792 of yacc.c */ +#line 2709 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 514: +/* Line 1792 of yacc.c */ +#line 2713 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 515: +/* Line 1792 of yacc.c */ +#line 2717 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 516: +/* Line 1792 of yacc.c */ +#line 2721 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 517: +/* Line 1792 of yacc.c */ +#line 2725 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 518: +/* Line 1792 of yacc.c */ +#line 2729 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 519: +/* Line 1792 of yacc.c */ +#line 2733 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 520: +/* Line 1792 of yacc.c */ +#line 2737 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 521: +/* Line 1792 of yacc.c */ +#line 2741 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 522: +/* Line 1792 of yacc.c */ +#line 2745 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 523: +/* Line 1792 of yacc.c */ +#line 2749 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 524: +/* Line 1792 of yacc.c */ +#line 2753 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('<', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 525: +/* Line 1792 of yacc.c */ +#line 2757 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('>', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 526: +/* Line 1792 of yacc.c */ +#line 2761 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 527: +/* Line 1792 of yacc.c */ +#line 2765 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 528: +/* Line 1792 of yacc.c */ +#line 2769 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); +} + break; + + case 529: +/* Line 1792 of yacc.c */ +#line 2773 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); +} + break; + + case 530: +/* Line 1792 of yacc.c */ +#line 2777 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); +} + break; + + case 531: +/* Line 1792 of yacc.c */ +#line 2781 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); +} + break; + + case 532: +/* Line 1792 of yacc.c */ +#line 2785 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + case 533: /* Line 1792 of yacc.c */ -#line 2783 "dtool/src/cppparser/cppBison.yxx" +#line 2789 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 534: +/* Line 1792 of yacc.c */ +#line 2793 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); +} + break; + + case 535: +/* Line 1792 of yacc.c */ +#line 2800 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); +} + break; + + case 536: +/* Line 1792 of yacc.c */ +#line 2804 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(true); +} + break; + + case 537: +/* Line 1792 of yacc.c */ +#line 2808 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(false); +} + break; + + case 538: +/* Line 1792 of yacc.c */ +#line 2812 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); +} + break; + + case 539: +/* Line 1792 of yacc.c */ +#line 2816 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.real)); +} + break; + + case 540: +/* Line 1792 of yacc.c */ +#line 2820 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].str)); +} + break; + + case 541: +/* Line 1792 of yacc.c */ +#line 2827 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, true); if (type == NULL) { @@ -7043,9 +7124,9 @@ yyreduce: } break; - case 534: + case 542: /* Line 1792 of yacc.c */ -#line 2791 "dtool/src/cppparser/cppBison.yxx" +#line 2835 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, true, current_lexer); if (type == NULL) { @@ -7055,41 +7136,41 @@ yyreduce: } break; - case 535: + case 543: /* Line 1792 of yacc.c */ -#line 2799 "dtool/src/cppparser/cppBison.yxx" +#line 2843 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); } break; - case 536: + case 544: /* Line 1792 of yacc.c */ -#line 2822 "dtool/src/cppparser/cppBison.yxx" +#line 2866 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.identifier) = (yyvsp[(1) - (1)].u.identifier); } break; - case 537: + case 545: /* Line 1792 of yacc.c */ -#line 2826 "dtool/src/cppparser/cppBison.yxx" +#line 2870 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.identifier) = (yyvsp[(1) - (1)].u.identifier); } break; - case 538: + case 546: /* Line 1792 of yacc.c */ -#line 2833 "dtool/src/cppparser/cppBison.yxx" +#line 2877 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; - case 539: + case 547: /* Line 1792 of yacc.c */ -#line 2837 "dtool/src/cppparser/cppBison.yxx" +#line 2881 "dtool/src/cppparser/cppBison.yxx" { (yyval.str) = (yyvsp[(1) - (2)].str) + (yyvsp[(2) - (2)].str); } @@ -7097,7 +7178,7 @@ yyreduce: /* Line 1792 of yacc.c */ -#line 7101 "built/tmp/cppBison.yxx.c" +#line 7182 "built/tmp/cppBison.yxx.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires diff --git a/dtool/src/cppparser/cppBison.h.prebuilt b/dtool/src/cppparser/cppBison.h.prebuilt index 76c7a5223f..491ce5dc46 100644 --- a/dtool/src/cppparser/cppBison.h.prebuilt +++ b/dtool/src/cppparser/cppBison.h.prebuilt @@ -91,63 +91,65 @@ extern int cppyydebug; KW_BOOL = 300, KW_CATCH = 301, KW_CHAR = 302, - KW_WCHAR_T = 303, - KW_CLASS = 304, - KW_CONST = 305, - KW_DELETE = 306, - KW_DOUBLE = 307, - KW_DYNAMIC_CAST = 308, - KW_ELSE = 309, - KW_END_PUBLISH = 310, - KW_ENUM = 311, - KW_EXTENSION = 312, - KW_EXTERN = 313, - KW_EXPLICIT = 314, - KW_PUBLISHED = 315, - KW_FALSE = 316, - KW_FLOAT = 317, - KW_FRIEND = 318, - KW_FOR = 319, - KW_GOTO = 320, - KW_IF = 321, - KW_INLINE = 322, - KW_INT = 323, - KW_LONG = 324, - KW_LONGLONG = 325, - KW_MAKE_PROPERTY = 326, - KW_MAKE_SEQ = 327, - KW_MUTABLE = 328, - KW_NAMESPACE = 329, - KW_NEW = 330, - KW_NOEXCEPT = 331, - KW_OPERATOR = 332, - KW_PRIVATE = 333, - KW_PROTECTED = 334, - KW_PUBLIC = 335, - KW_REGISTER = 336, - KW_RETURN = 337, - KW_SHORT = 338, - KW_SIGNED = 339, - KW_SIZEOF = 340, - KW_STATIC = 341, - KW_STATIC_CAST = 342, - KW_STRUCT = 343, - KW_TEMPLATE = 344, - KW_THROW = 345, - KW_TRUE = 346, - KW_TRY = 347, - KW_TYPEDEF = 348, - KW_TYPENAME = 349, - KW_UNION = 350, - KW_UNSIGNED = 351, - KW_USING = 352, - KW_VIRTUAL = 353, - KW_VOID = 354, - KW_VOLATILE = 355, - KW_WHILE = 356, - START_CPP = 357, - START_CONST_EXPR = 358, - START_TYPE = 359 + KW_CHAR16_T = 303, + KW_CHAR32_T = 304, + KW_CLASS = 305, + KW_CONST = 306, + KW_DELETE = 307, + KW_DOUBLE = 308, + KW_DYNAMIC_CAST = 309, + KW_ELSE = 310, + KW_END_PUBLISH = 311, + KW_ENUM = 312, + KW_EXTENSION = 313, + KW_EXTERN = 314, + KW_EXPLICIT = 315, + KW_PUBLISHED = 316, + KW_FALSE = 317, + KW_FLOAT = 318, + KW_FRIEND = 319, + KW_FOR = 320, + KW_GOTO = 321, + KW_IF = 322, + KW_INLINE = 323, + KW_INT = 324, + KW_LONG = 325, + KW_LONGLONG = 326, + KW_MAKE_PROPERTY = 327, + KW_MAKE_SEQ = 328, + KW_MUTABLE = 329, + KW_NAMESPACE = 330, + KW_NEW = 331, + KW_NOEXCEPT = 332, + KW_OPERATOR = 333, + KW_PRIVATE = 334, + KW_PROTECTED = 335, + KW_PUBLIC = 336, + KW_REGISTER = 337, + KW_RETURN = 338, + KW_SHORT = 339, + KW_SIGNED = 340, + KW_SIZEOF = 341, + KW_STATIC = 342, + KW_STATIC_CAST = 343, + KW_STRUCT = 344, + KW_TEMPLATE = 345, + KW_THROW = 346, + KW_TRUE = 347, + KW_TRY = 348, + KW_TYPEDEF = 349, + KW_TYPENAME = 350, + KW_UNION = 351, + KW_UNSIGNED = 352, + KW_USING = 353, + KW_VIRTUAL = 354, + KW_VOID = 355, + KW_VOLATILE = 356, + KW_WCHAR_T = 357, + KW_WHILE = 358, + START_CPP = 359, + START_CONST_EXPR = 360, + START_TYPE = 361 }; #endif /* Tokens. */ @@ -196,63 +198,65 @@ extern int cppyydebug; #define KW_BOOL 300 #define KW_CATCH 301 #define KW_CHAR 302 -#define KW_WCHAR_T 303 -#define KW_CLASS 304 -#define KW_CONST 305 -#define KW_DELETE 306 -#define KW_DOUBLE 307 -#define KW_DYNAMIC_CAST 308 -#define KW_ELSE 309 -#define KW_END_PUBLISH 310 -#define KW_ENUM 311 -#define KW_EXTENSION 312 -#define KW_EXTERN 313 -#define KW_EXPLICIT 314 -#define KW_PUBLISHED 315 -#define KW_FALSE 316 -#define KW_FLOAT 317 -#define KW_FRIEND 318 -#define KW_FOR 319 -#define KW_GOTO 320 -#define KW_IF 321 -#define KW_INLINE 322 -#define KW_INT 323 -#define KW_LONG 324 -#define KW_LONGLONG 325 -#define KW_MAKE_PROPERTY 326 -#define KW_MAKE_SEQ 327 -#define KW_MUTABLE 328 -#define KW_NAMESPACE 329 -#define KW_NEW 330 -#define KW_NOEXCEPT 331 -#define KW_OPERATOR 332 -#define KW_PRIVATE 333 -#define KW_PROTECTED 334 -#define KW_PUBLIC 335 -#define KW_REGISTER 336 -#define KW_RETURN 337 -#define KW_SHORT 338 -#define KW_SIGNED 339 -#define KW_SIZEOF 340 -#define KW_STATIC 341 -#define KW_STATIC_CAST 342 -#define KW_STRUCT 343 -#define KW_TEMPLATE 344 -#define KW_THROW 345 -#define KW_TRUE 346 -#define KW_TRY 347 -#define KW_TYPEDEF 348 -#define KW_TYPENAME 349 -#define KW_UNION 350 -#define KW_UNSIGNED 351 -#define KW_USING 352 -#define KW_VIRTUAL 353 -#define KW_VOID 354 -#define KW_VOLATILE 355 -#define KW_WHILE 356 -#define START_CPP 357 -#define START_CONST_EXPR 358 -#define START_TYPE 359 +#define KW_CHAR16_T 303 +#define KW_CHAR32_T 304 +#define KW_CLASS 305 +#define KW_CONST 306 +#define KW_DELETE 307 +#define KW_DOUBLE 308 +#define KW_DYNAMIC_CAST 309 +#define KW_ELSE 310 +#define KW_END_PUBLISH 311 +#define KW_ENUM 312 +#define KW_EXTENSION 313 +#define KW_EXTERN 314 +#define KW_EXPLICIT 315 +#define KW_PUBLISHED 316 +#define KW_FALSE 317 +#define KW_FLOAT 318 +#define KW_FRIEND 319 +#define KW_FOR 320 +#define KW_GOTO 321 +#define KW_IF 322 +#define KW_INLINE 323 +#define KW_INT 324 +#define KW_LONG 325 +#define KW_LONGLONG 326 +#define KW_MAKE_PROPERTY 327 +#define KW_MAKE_SEQ 328 +#define KW_MUTABLE 329 +#define KW_NAMESPACE 330 +#define KW_NEW 331 +#define KW_NOEXCEPT 332 +#define KW_OPERATOR 333 +#define KW_PRIVATE 334 +#define KW_PROTECTED 335 +#define KW_PUBLIC 336 +#define KW_REGISTER 337 +#define KW_RETURN 338 +#define KW_SHORT 339 +#define KW_SIGNED 340 +#define KW_SIZEOF 341 +#define KW_STATIC 342 +#define KW_STATIC_CAST 343 +#define KW_STRUCT 344 +#define KW_TEMPLATE 345 +#define KW_THROW 346 +#define KW_TRUE 347 +#define KW_TRY 348 +#define KW_TYPEDEF 349 +#define KW_TYPENAME 350 +#define KW_UNION 351 +#define KW_UNSIGNED 352 +#define KW_USING 353 +#define KW_VIRTUAL 354 +#define KW_VOID 355 +#define KW_VOLATILE 356 +#define KW_WCHAR_T 357 +#define KW_WHILE 358 +#define START_CPP 359 +#define START_CONST_EXPR 360 +#define START_TYPE 361 diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index 87c4f5cd17..644fcac1de 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -724,7 +724,7 @@ typedef_declaration: inst->_storage_class |= (current_storage_class | $1); current_scope->add_declaration(inst, global_scope, current_lexer, @2); CPPTypedefType *typedef_type = new CPPTypedefType(inst->_type, inst->_ident, current_scope); - current_scope->add_declaration(typedef_type, global_scope, current_lexer, @2); + current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, @2); } } } @@ -735,13 +735,13 @@ typedef_instance_identifiers: { CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, $1, current_scope, @1.file); - current_scope->add_declaration(typedef_type, global_scope, current_lexer, @1); + current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, @1); } | instance_identifier maybe_initialize ',' typedef_instance_identifiers { CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, $1, current_scope, @1.file); - current_scope->add_declaration(typedef_type, global_scope, current_lexer, @1); + current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, @1); } ; @@ -751,14 +751,14 @@ typedef_const_instance_identifiers: $1->add_modifier(IIT_const); CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, $1, current_scope, @1.file); - current_scope->add_declaration(typedef_type, global_scope, current_lexer, @1); + current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, @1); } | instance_identifier maybe_initialize ',' typedef_const_instance_identifiers { $1->add_modifier(IIT_const); CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, $1, current_scope, @1.file); - current_scope->add_declaration(typedef_type, global_scope, current_lexer, @1); + current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, @1); } ; diff --git a/dtool/src/cppparser/cppConstType.cxx b/dtool/src/cppparser/cppConstType.cxx index bf663b436c..503f1c0871 100644 --- a/dtool/src/cppparser/cppConstType.cxx +++ b/dtool/src/cppparser/cppConstType.cxx @@ -101,6 +101,17 @@ is_tbd() const { return _wrapped_around->is_tbd(); } +//////////////////////////////////////////////////////////////////// +// Function: CPPConstType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPConstType:: +is_trivial() const { + return _wrapped_around->is_trivial(); +} + //////////////////////////////////////////////////////////////////// // Function: CPPConstType::is_equivalent // Access: Public, Virtual diff --git a/dtool/src/cppparser/cppConstType.h b/dtool/src/cppparser/cppConstType.h index 2d6c552e1d..499b403a6e 100644 --- a/dtool/src/cppparser/cppConstType.h +++ b/dtool/src/cppparser/cppConstType.h @@ -38,6 +38,7 @@ public: CPPScope *global_scope); virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual bool is_equivalent(const CPPType &other) const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppExtensionType.cxx b/dtool/src/cppparser/cppExtensionType.cxx index 26022cf8bf..3056b8b6d4 100644 --- a/dtool/src/cppparser/cppExtensionType.cxx +++ b/dtool/src/cppparser/cppExtensionType.cxx @@ -102,6 +102,17 @@ is_tbd() const { return false; } +//////////////////////////////////////////////////////////////////// +// Function: CPPExtensionType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPExtensionType:: +is_trivial() const { + return (_type == T_enum); +} + //////////////////////////////////////////////////////////////////// // Function: CPPExtensionType::substitute_decl // Access: Public, Virtual diff --git a/dtool/src/cppparser/cppExtensionType.h b/dtool/src/cppparser/cppExtensionType.h index d1d810209c..d4201dc4e2 100644 --- a/dtool/src/cppparser/cppExtensionType.h +++ b/dtool/src/cppparser/cppExtensionType.h @@ -47,6 +47,7 @@ public: virtual bool is_incomplete() const; virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, CPPScope *current_scope, diff --git a/dtool/src/cppparser/cppFile.cxx b/dtool/src/cppparser/cppFile.cxx index 231c6dd104..4e8e8fba95 100644 --- a/dtool/src/cppparser/cppFile.cxx +++ b/dtool/src/cppparser/cppFile.cxx @@ -26,7 +26,8 @@ CPPFile:: CPPFile(const Filename &filename, const Filename &filename_as_referenced, Source source) : _filename(filename), _filename_as_referenced(filename_as_referenced), - _source(source) + _source(source), + _pragma_once(false) { _filename.set_text(); _filename_as_referenced.set_text(); @@ -42,7 +43,8 @@ CPPFile:: CPPFile(const CPPFile ©) : _filename(copy._filename), _filename_as_referenced(copy._filename_as_referenced), - _source(copy._source) + _source(copy._source), + _pragma_once(copy._pragma_once) { } @@ -56,6 +58,7 @@ operator = (const CPPFile ©) { _filename = copy._filename; _filename_as_referenced = copy._filename_as_referenced; _source = copy._source; + _pragma_once = copy._pragma_once; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/cppparser/cppFile.h b/dtool/src/cppparser/cppFile.h index f46d19f167..fde2209465 100644 --- a/dtool/src/cppparser/cppFile.h +++ b/dtool/src/cppparser/cppFile.h @@ -59,6 +59,7 @@ public: Filename _filename; Filename _filename_as_referenced; Source _source; + mutable bool _pragma_once; }; inline ostream &operator << (ostream &out, const CPPFile &file) { diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index 515729cf39..fa8cf3f291 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -159,6 +159,17 @@ is_tbd() const { return _parameters->is_tbd(); } +//////////////////////////////////////////////////////////////////// +// Function: CPPFunctionType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPFunctionType:: +is_trivial() const { + return false; +} + //////////////////////////////////////////////////////////////////// // Function: CPPFunctionType::output // Access: Public, Virtual diff --git a/dtool/src/cppparser/cppFunctionType.h b/dtool/src/cppparser/cppFunctionType.h index b728fa7b22..37360a80a7 100644 --- a/dtool/src/cppparser/cppFunctionType.h +++ b/dtool/src/cppparser/cppFunctionType.h @@ -29,14 +29,16 @@ class CPPIdentifier; class CPPFunctionType : public CPPType { public: enum Flags { - F_const_method = 0x01, - F_operator_typecast = 0x02, - F_constructor = 0x04, - F_destructor = 0x08, - F_method_pointer = 0x10, - F_unary_op = 0x20, - F_operator = 0x40, - F_noexcept = 0x80, + F_const_method = 0x001, + F_operator_typecast = 0x002, + F_constructor = 0x004, + F_destructor = 0x008, + F_method_pointer = 0x010, + F_unary_op = 0x020, + F_operator = 0x040, + F_noexcept = 0x080, + F_copy_constructor = 0x200, + F_move_constructor = 0x400, }; CPPFunctionType(CPPType *return_type, CPPParameterList *parameters, @@ -57,6 +59,7 @@ public: CPPScope *global_scope); virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual void output(ostream &out, int indent_level, CPPScope *scope, bool complete) const; diff --git a/dtool/src/cppparser/cppInstance.cxx b/dtool/src/cppparser/cppInstance.cxx index 94b0924460..32790e0cde 100644 --- a/dtool/src/cppparser/cppInstance.cxx +++ b/dtool/src/cppparser/cppInstance.cxx @@ -347,9 +347,33 @@ check_for_constructor(CPPScope *current_scope, CPPScope *global_scope) { CPPType *void_type = CPPType::new_type (new CPPSimpleType(CPPSimpleType::T_void)); + int flags = func->_flags | CPPFunctionType::F_constructor; + + // Check if it might be a copy or move constructor. + CPPParameterList *params = func->_parameters; + if (params->_parameters.size() == 1 && !params->_includes_ellipsis) { + CPPType *param_type = params->_parameters[0]->_type; + CPPReferenceType *ref_type = param_type->as_reference_type(); + + if (ref_type != NULL) { + param_type = ref_type->_pointing_at; + + if (param_type->get_subtype() == CPPDeclaration::ST_const) { + param_type = param_type->as_const_type()->_wrapped_around; + } + + if (class_name == param_type->get_simple_name()) { + if (ref_type->_value_category == CPPReferenceType::VC_rvalue) { + flags |= CPPFunctionType::F_move_constructor; + } else { + flags |= CPPFunctionType::F_copy_constructor; + } + } + } + } + _type = CPPType::new_type - (new CPPFunctionType(void_type, func->_parameters, - func->_flags | CPPFunctionType::F_constructor)); + (new CPPFunctionType(void_type, func->_parameters, flags)); } else if (method_name == "~" + class_name) { CPPType *void_type = CPPType::new_type diff --git a/dtool/src/cppparser/cppInstanceIdentifier.cxx b/dtool/src/cppparser/cppInstanceIdentifier.cxx index 7cd3c67283..45379e5f70 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.cxx +++ b/dtool/src/cppparser/cppInstanceIdentifier.cxx @@ -166,7 +166,16 @@ add_scoped_pointer_modifier(CPPIdentifier *scoping) { //////////////////////////////////////////////////////////////////// void CPPInstanceIdentifier:: add_array_modifier(CPPExpression *expr) { - _modifiers.push_back(Modifier::array_type(expr)); + // Special case for operator new[] and delete[]. We're not really + // adding an array modifier to them, but appending [] to the + // identifier. This is to work around a parser ambiguity. + if (_ident != NULL && (_ident->get_simple_name() == "operator delete" || + _ident->get_simple_name() == "operator new")) { + + _ident->_names.back().append_name("[]"); + } else { + _modifiers.push_back(Modifier::array_type(expr)); + } } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/cppparser/cppPointerType.cxx b/dtool/src/cppparser/cppPointerType.cxx index 22dd91b268..baa8a62ff8 100644 --- a/dtool/src/cppparser/cppPointerType.cxx +++ b/dtool/src/cppparser/cppPointerType.cxx @@ -103,6 +103,17 @@ is_tbd() const { return _pointing_at->is_tbd(); } +//////////////////////////////////////////////////////////////////// +// Function: CPPPointerType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPPointerType:: +is_trivial() const { + return true; +} + //////////////////////////////////////////////////////////////////// // Function: CPPPointerType::is_equivalent // Access: Public, Virtual diff --git a/dtool/src/cppparser/cppPointerType.h b/dtool/src/cppparser/cppPointerType.h index 6a7349343f..6f9c2b1b75 100644 --- a/dtool/src/cppparser/cppPointerType.h +++ b/dtool/src/cppparser/cppPointerType.h @@ -38,6 +38,7 @@ public: CPPScope *global_scope); virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual bool is_equivalent(const CPPType &other) const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 482a8cbabe..52c758acd6 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -620,6 +620,7 @@ push_file(const CPPFile &file) { indent(cerr, _files.size() * 2) << "Reading " << file << "\n"; } + _files.push_back(InputFile()); InputFile &infile = _files.back(); @@ -1158,7 +1159,7 @@ process_directive(int c) { } else if (command == "include") { handle_include_directive(args, first_line, first_col, first_file); } else if (command == "pragma") { - // Quietly ignore pragmas. + handle_pragma_directive(args, first_line, first_col, first_file); } else if (command == "ident") { // Quietly ignore idents. } else if (command == "error") { @@ -1462,7 +1463,16 @@ handle_include_directive(const string &args, int first_line, first_line, first_col, first_file); } else { _last_c = '\0'; - if (!push_file(CPPFile(filename, filename_as_referenced, source))) { + + CPPFile file(filename, filename_as_referenced, source); + + // Don't include it if we included it before and it had #pragma once. + ParsedFiles::const_iterator it = _parsed_files.find(file); + if (it->_pragma_once) { + return; + } + + if (!push_file(file)) { warning("Unable to read " + filename.get_fullpath(), first_line, first_col, first_file); } @@ -1473,6 +1483,21 @@ handle_include_directive(const string &args, int first_line, } } +//////////////////////////////////////////////////////////////////// +// Function: CPPPreprocessor::handle_pragma_directive +// Access: Private +// Description: +//////////////////////////////////////////////////////////////////// +void CPPPreprocessor:: +handle_pragma_directive(const string &args, int first_line, + int first_col, const CPPFile &first_file) { + if (args == "once") { + ParsedFiles::iterator it = _parsed_files.find(first_file); + assert(it != _parsed_files.end()); + it->_pragma_once = true; + } +} + //////////////////////////////////////////////////////////////////// // Function: CPPPreprocessor::handle_error_directive // Access: Private diff --git a/dtool/src/cppparser/cppPreprocessor.h b/dtool/src/cppparser/cppPreprocessor.h index 6d86a06846..571ef0598b 100644 --- a/dtool/src/cppparser/cppPreprocessor.h +++ b/dtool/src/cppparser/cppPreprocessor.h @@ -133,6 +133,8 @@ private: int first_col, const CPPFile &first_file); void handle_include_directive(const string &args, int first_line, int first_col, const CPPFile &first_file); + void handle_pragma_directive(const string &args, int first_line, + int first_col, const CPPFile &first_file); void handle_error_directive(const string &args, int first_line, int first_col, const CPPFile &first_file); diff --git a/dtool/src/cppparser/cppReferenceType.cxx b/dtool/src/cppparser/cppReferenceType.cxx index 40d6e987da..5b5d85fd3b 100644 --- a/dtool/src/cppparser/cppReferenceType.cxx +++ b/dtool/src/cppparser/cppReferenceType.cxx @@ -102,6 +102,17 @@ is_tbd() const { return _pointing_at->is_tbd(); } +//////////////////////////////////////////////////////////////////// +// Function: CPPReferenceType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPReferenceType:: +is_trivial() const { + return false; +} + //////////////////////////////////////////////////////////////////// // Function: CPPReferenceType::is_equivalent // Access: Public, Virtual diff --git a/dtool/src/cppparser/cppReferenceType.h b/dtool/src/cppparser/cppReferenceType.h index 3bf292841e..713a6abd6c 100644 --- a/dtool/src/cppparser/cppReferenceType.h +++ b/dtool/src/cppparser/cppReferenceType.h @@ -35,9 +35,6 @@ public: CPPType *_pointing_at; ValueCategory _value_category; - inline bool is_lvalue() const; - inline bool is_rvalue() const; - virtual bool is_fully_specified() const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, CPPScope *current_scope, @@ -47,6 +44,7 @@ public: CPPScope *global_scope); virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual bool is_equivalent(const CPPType &other) const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppSimpleType.cxx b/dtool/src/cppparser/cppSimpleType.cxx index 7ce7048848..ac4e633d6d 100644 --- a/dtool/src/cppparser/cppSimpleType.cxx +++ b/dtool/src/cppparser/cppSimpleType.cxx @@ -40,6 +40,17 @@ is_tbd() const { return (_type == T_unknown); } +//////////////////////////////////////////////////////////////////// +// Function: CPPSimpleType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPSimpleType:: +is_trivial() const { + return true; +} + //////////////////////////////////////////////////////////////////// // Function: CPPSimpleType::is_parameter_expr // Access: Public, Virtual diff --git a/dtool/src/cppparser/cppSimpleType.h b/dtool/src/cppparser/cppSimpleType.h index 6ac032456b..27a1b89206 100644 --- a/dtool/src/cppparser/cppSimpleType.h +++ b/dtool/src/cppparser/cppSimpleType.h @@ -66,6 +66,7 @@ public: int _flags; virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual bool is_parameter_expr() const; virtual string get_preferred_name() const; diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index 0c138f586d..c0a8aa7448 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -20,6 +20,7 @@ #include "cppTemplateScope.h" #include "cppFunctionGroup.h" #include "cppFunctionType.h" +#include "cppParameterList.h" #include "cppTBDType.h" #include "indent.h" #include "cppParser.h" @@ -131,6 +132,97 @@ is_abstract() const { return !funcs.empty(); } +//////////////////////////////////////////////////////////////////// +// Function: CPPStructType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPStructType:: +is_trivial() const { + // Make sure all base classes are trivial. + Derivation::const_iterator di; + for (di = _derivation.begin(); di != _derivation.end(); ++di) { + CPPStructType *base = (*di)._base->as_struct_type(); + if (base != NULL && !base->is_trivial()) { + return false; + } + } + + assert(_scope != NULL); + + // Make sure all members are trivial. + CPPScope::Variables::const_iterator vi; + for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { + CPPInstance *instance = (*vi).second; + assert(instance != NULL); + + if (instance->_storage_class & CPPInstance::SC_static) { + // Static members don't count. + continue; + } + + if (instance->_initializer != NULL) { + // A member with an initializer means the default constructor would + // assign a value. This means the type can't be trivial. + return false; + } + + // Finally, check if the data member itself is non-trivial. + assert(instance->_type != NULL); + if (!instance->_type->is_trivial()) { + return false; + } + } + + // Now look for functions that are virtual or con/destructors. + bool is_default_constructible = true; + CPPScope::Functions::const_iterator fi; + for (fi = _scope->_functions.begin(); fi != _scope->_functions.end(); ++fi) { + CPPFunctionGroup *fgroup = (*fi).second; + + CPPFunctionGroup::Instances::const_iterator ii; + for (ii = fgroup->_instances.begin(); ii != fgroup->_instances.end(); ++ii) { + CPPInstance *inst = (*ii); + + if (inst->_storage_class & CPPInstance::SC_virtual) { + // Virtual functions are banned right off the bat. + return false; + } + + assert(inst->_type != (CPPType *)NULL); + CPPFunctionType *ftype = inst->_type->as_function_type(); + assert(ftype != (CPPFunctionType *)NULL); + + if (ftype->_flags & (CPPFunctionType::F_destructor | + CPPFunctionType::F_move_constructor | + CPPFunctionType::F_copy_constructor)) { + // User-provided destructors and copy/move constructors are not trivial. + return false; + } + + if ((ftype->_flags & CPPFunctionType::F_constructor) != 0) { + if (ftype->_parameters->_parameters.size() == 0 && + !ftype->_parameters->_includes_ellipsis) { + // Same for the default constructor. + return false; + } + // The presence of a non-default constructor makes the class not + // default-constructible. + is_default_constructible = false; + } + + if (fgroup->_name == "operator =") { + // Or assignment operators. + return false; + } + } + } + + // Finally, the class must be default-constructible. + return is_default_constructible; +} + //////////////////////////////////////////////////////////////////// // Function: CPPStructType::check_virtual // Access: Public diff --git a/dtool/src/cppparser/cppStructType.h b/dtool/src/cppparser/cppStructType.h index 1e0c74a02f..9a650320d2 100644 --- a/dtool/src/cppparser/cppStructType.h +++ b/dtool/src/cppparser/cppStructType.h @@ -47,6 +47,7 @@ public: bool check_virtual(); virtual bool is_fully_specified() const; virtual bool is_incomplete() const; + virtual bool is_trivial() const; CPPInstance *get_destructor() const; diff --git a/dtool/src/cppparser/cppType.cxx b/dtool/src/cppparser/cppType.cxx index bad935dba6..c94cfbd759 100644 --- a/dtool/src/cppparser/cppType.cxx +++ b/dtool/src/cppparser/cppType.cxx @@ -68,6 +68,17 @@ is_tbd() const { return false; } +//////////////////////////////////////////////////////////////////// +// Function: CPPType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPType:: +is_trivial() const { + return false; +} + //////////////////////////////////////////////////////////////////// // Function: CPPType::is_parameter_expr // Access: Public, Virtual @@ -312,6 +323,12 @@ new_type(CPPType *type) { return type; } + // If this triggers, we probably messed up by defining is_less() + // incorrectly; they provide a relative ordering even though they + // are equal to each other. Or, we provided an is_equal() that + // gives false negatives. + assert(**result.first == *type); + // The insertion has not taken place; thus, there was previously // another equivalent type declared. if (*result.first != type) { diff --git a/dtool/src/cppparser/cppType.h b/dtool/src/cppparser/cppType.h index 1d962e8d69..824a71e3c4 100644 --- a/dtool/src/cppparser/cppType.h +++ b/dtool/src/cppparser/cppType.h @@ -48,6 +48,7 @@ public: CPPScope *global_scope); virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual bool is_parameter_expr() const; bool has_typedef_name() const; diff --git a/dtool/src/cppparser/cppTypedefType.cxx b/dtool/src/cppparser/cppTypedefType.cxx index ceedd35f33..1cc31e4b4e 100644 --- a/dtool/src/cppparser/cppTypedefType.cxx +++ b/dtool/src/cppparser/cppTypedefType.cxx @@ -178,6 +178,17 @@ is_tbd() const { return _type->is_tbd(); } +//////////////////////////////////////////////////////////////////// +// Function: CPPTypedefType::is_trivial +// Access: Public, Virtual +// Description: Returns true if the type is considered a Plain Old +// Data (POD) type. +//////////////////////////////////////////////////////////////////// +bool CPPTypedefType:: +is_trivial() const { + return _type->is_trivial(); +} + //////////////////////////////////////////////////////////////////// // Function: CPPTypedefType::is_fully_specified // Access: Public, Virtual @@ -370,7 +381,7 @@ is_equal(const CPPDeclaration *other) const { const CPPTypedefType *ot = ((CPPDeclaration *)other)->as_typedef_type(); assert(ot != NULL); - return (_type == ot->_type) && (*_ident == *ot->_ident); + return (*_type == *ot->_type) && (*_ident == *ot->_ident); } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/cppparser/cppTypedefType.h b/dtool/src/cppparser/cppTypedefType.h index ad6c33ffa2..030da91c18 100644 --- a/dtool/src/cppparser/cppTypedefType.h +++ b/dtool/src/cppparser/cppTypedefType.h @@ -42,6 +42,7 @@ public: virtual bool is_incomplete() const; virtual bool is_tbd() const; + virtual bool is_trivial() const; virtual bool is_fully_specified() const; diff --git a/dtool/src/dtoolbase/Sources.pp b/dtool/src/dtoolbase/Sources.pp index e6387f27e7..c44e2d7de0 100644 --- a/dtool/src/dtoolbase/Sources.pp +++ b/dtool/src/dtoolbase/Sources.pp @@ -10,6 +10,7 @@ addHash.I addHash.h \ atomicAdjust.h \ atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I \ + atomicAdjustGccImpl.h atomicAdjustGccImpl.I \ atomicAdjustI386Impl.h atomicAdjustI386Impl.I \ atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ @@ -30,7 +31,7 @@ nearly_zero.h \ neverFreeMemory.h neverFreeMemory.I \ numeric_types.h \ - pstrtod.h \ + pdtoa.h pstrtod.h \ register_type.I register_type.h \ selectThreadImpl.h \ stl_compares.I stl_compares.h \ @@ -47,6 +48,7 @@ #define INCLUDED_SOURCES \ addHash.cxx \ atomicAdjustDummyImpl.cxx \ + atomicAdjustGccImpl.cxx \ atomicAdjustI386Impl.cxx \ atomicAdjustPosixImpl.cxx \ atomicAdjustWin32Impl.cxx \ @@ -59,6 +61,7 @@ mutexWin32Impl.cxx \ mutexSpinlockImpl.cxx \ neverFreeMemory.cxx \ + pdtoa.cxx \ pstrtod.cxx \ register_type.cxx \ typeHandle.cxx \ @@ -69,6 +72,7 @@ addHash.I addHash.h \ atomicAdjust.h \ atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I \ + atomicAdjustGccImpl.h atomicAdjustGccImpl.I \ atomicAdjustI386Impl.h atomicAdjustI386Impl.I \ atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ @@ -89,7 +93,7 @@ nearly_zero.h \ neverFreeMemory.h neverFreeMemory.I \ numeric_types.h \ - pstrtod.h \ + pdtoa.h pstrtod.h \ register_type.I register_type.h \ selectThreadImpl.h \ stl_compares.I stl_compares.h \ diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 7a4fb2445b..4398036e3a 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -427,9 +427,28 @@ #define EXTEND #endif +/* These symbols are used in dtoolsymbols.h and pandasymbols.h. */ +#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) +#define EXPORT_CLASS __declspec(dllexport) +#define IMPORT_CLASS __declspec(dllimport) +#elif __GNUC__ >= 4 && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) +#define EXPORT_CLASS __attribute__((visibility("default"))) +#define IMPORT_CLASS +#else +#define EXPORT_CLASS +#define IMPORT_CLASS +#endif +/* "extern template" is now part of the C++11 standard. */ +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) +#define EXPORT_TEMPL +#define IMPORT_TEMPL extern +#else +#define EXPORT_TEMPL +#define IMPORT_TEMPL +#endif + #ifdef __cplusplus #include "dtoolbase_cc.h" #endif #endif - diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index cb6f1db130..efefd36e9e 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -174,7 +174,7 @@ typedef ios::seekdir ios_seekdir; # define MOVE(x) x #endif -#if defined(WIN32_VC) && !defined(LINK_ALL_STATIC) && defined(EXPORT_TEMPLATES) +#if !defined(LINK_ALL_STATIC) && defined(EXPORT_TEMPLATES) // This macro must be used to export an instantiated template class // from a DLL. If the template class name itself contains commas, it // may be necessary to first define a macro for the class name, to diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index d30f74ed08..cb4cd7993e 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -70,49 +70,47 @@ #define EXPCL_EMPTY -#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) - #ifdef BUILDING_DTOOL - #define EXPCL_DTOOL __declspec(dllexport) - #define EXPTP_DTOOL + #define EXPCL_DTOOL EXPORT_CLASS + #define EXPTP_DTOOL EXPORT_TEMPL #else - #define EXPCL_DTOOL __declspec(dllimport) - #define EXPTP_DTOOL extern + #define EXPCL_DTOOL IMPORT_CLASS + #define EXPTP_DTOOL IMPORT_TEMPL #endif #ifdef BUILDING_DTOOLCONFIG - #define EXPCL_DTOOLCONFIG __declspec(dllexport) - #define EXPTP_DTOOLCONFIG + #define EXPCL_DTOOLCONFIG EXPORT_CLASS + #define EXPTP_DTOOLCONFIG EXPORT_TEMPL #else - #define EXPCL_DTOOLCONFIG __declspec(dllimport) - #define EXPTP_DTOOLCONFIG extern + #define EXPCL_DTOOLCONFIG IMPORT_CLASS + #define EXPTP_DTOOLCONFIG IMPORT_TEMPL +#endif + +#ifdef BUILDING_INTERROGATEDB + #define EXPCL_INTERROGATEDB EXPORT_CLASS + #define EXPTP_INTERROGATEDB EXPORT_TEMPL +#else + #define EXPCL_INTERROGATEDB IMPORT_CLASS + #define EXPTP_INTERROGATEDB IMPORT_TEMPL #endif #ifdef BUILDING_MISC - #define EXPCL_MISC __declspec(dllexport) - #define EXPTP_MISC + #define EXPCL_MISC EXPORT_CLASS + #define EXPTP_MISC EXPORT_TEMPL #else /* BUILDING_MISC */ - #define EXPCL_MISC __declspec(dllimport) - #define EXPTP_MISC extern + #define EXPCL_MISC IMPORT_CLASS + #define EXPTP_MISC IMPORT_TEMPL #endif /* BUILDING_MISC */ -#else /* !WIN32_VC */ - -#define EXPCL_DTOOL -#define EXPTP_DTOOL - -#define EXPCL_DTOOLCONFIG -#define EXPTP_DTOOLCONFIG - -#define EXPCL_MISC -#define EXPTP_MISC - -#endif /* WIN32_VC */ - /* These two are always defined empty, because pystub is statically built. But we leave the symbol around in case we change our minds to make pystub once again be a dynamic library. */ +#if __GNUC__ >= 4 +/* In GCC, though, we still need to mark the symbols as visible. */ +#define EXPCL_PYSTUB __attribute__((visibility("default"))) +#else #define EXPCL_PYSTUB +#endif #define EXPTP_PYSTUB #endif diff --git a/dtool/src/dtoolbase/epvector.h b/dtool/src/dtoolbase/epvector.h index a6baad77af..2359400fd6 100644 --- a/dtool/src/dtoolbase/epvector.h +++ b/dtool/src/dtoolbase/epvector.h @@ -17,7 +17,7 @@ #include "pvector.h" -#if defined(HAVE_EIGEN) && defined(_WIN32) && !defined(CPPPARSER) +#if defined(HAVE_EIGEN) && defined(_WIN32) && !defined(_WIN64) && !defined(CPPPARSER) #include diff --git a/dtool/src/dtoolbase/pdtoa.cxx b/dtool/src/dtoolbase/pdtoa.cxx index 949e070b63..a2778dc962 100644 --- a/dtool/src/dtoolbase/pdtoa.cxx +++ b/dtool/src/dtoolbase/pdtoa.cxx @@ -30,6 +30,8 @@ THE SOFTWARE. #if defined(_MSC_VER) #include +#include +#define copysign _copysign #endif #define UINT64_C2(h, l) ((static_cast(h) << 32) | static_cast(l)) diff --git a/dtool/src/dtoolbase/pdtoa.h b/dtool/src/dtoolbase/pdtoa.h index b7f9b39f72..a3d3e46147 100644 --- a/dtool/src/dtoolbase/pdtoa.h +++ b/dtool/src/dtoolbase/pdtoa.h @@ -9,7 +9,7 @@ #ifndef PDTOA_H #define PDTOA_H -#include "dtoolsymbols.h" +#include "dtoolbase.h" #ifdef __cplusplus extern "C" { diff --git a/dtool/src/dtoolbase/typeHandle.I b/dtool/src/dtoolbase/typeHandle.I index 482d0996db..e489fd4099 100644 --- a/dtool/src/dtoolbase/typeHandle.I +++ b/dtool/src/dtoolbase/typeHandle.I @@ -13,28 +13,6 @@ //////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::Constructor -// Access: Published -// Description: The default constructor must do nothing, because we -// can't guarantee ordering of static initializers. If -// the constructor tried to initialize its value, it -// might happen after the value had already been set -// previously by another static initializer! -//////////////////////////////////////////////////////////////////// -INLINE TypeHandle:: -TypeHandle() { -} - -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE TypeHandle:: -TypeHandle(const TypeHandle ©) : _index(copy._index) { -} - //////////////////////////////////////////////////////////////////// // Function: TypeHandle::Equality Operator // Access: Published diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index 9573cb2ffb..c669fa8084 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -94,8 +94,10 @@ PUBLISHED: // enum value. }; - INLINE TypeHandle(); - INLINE TypeHandle(const TypeHandle ©); + // The default constructor must do nothing, because we can't + // guarantee ordering of static initializers. If the constructor + // tried to initialize its value, it might happen after the value + // had already been set previously by another static initializer! EXTENSION(static TypeHandle make(PyTypeObject *classobj)); diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index 3e1543ba4d..8c67ace1c8 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -66,10 +66,6 @@ extern char **environ; #include #endif -#ifdef HAVE_PYTHON -#include "Python.h" -#endif - // We define the symbol PREREAD_ENVIRONMENT if we cannot rely on // getenv() to read environment variables at static init time. In // this case, we must read all of the environment variables directly @@ -265,56 +261,9 @@ ns_get_environment_variable(const string &var) const { } else if (var == "COMMON_APPDATA") { return Filename::get_common_appdata_directory().to_os_specific(); } else if (var == "MAIN_DIR") { -#ifdef HAVE_PYTHON - // If we're running from Python code, read out sys.argv. - if (!ns_has_environment_variable("PANDA_INCOMPATIBLE_PYTHON") && Py_IsInitialized()) { - // Since we might have gotten to this point from a function call - // marked BLOCKING, which releases the Python thread state, we - // have to temporarily re-establish our thread state in the - // Python interpreter. - PyGILState_STATE state = PyGILState_Ensure(); - - Filename main_dir; - PyObject *obj = PySys_GetObject((char*) "argv"); // borrowed reference - if (obj != NULL && PyList_Check(obj)) { - PyObject *item = PyList_GetItem(obj, 0); // borrowed reference - if (item != NULL) { - if (PyUnicode_Check(item)) { - Py_ssize_t size = PyUnicode_GetSize(item); - wchar_t *data = new wchar_t[size + 1]; -#if PY_MAJOR_VERSION >= 3 - if (PyUnicode_AsWideChar(item, data, size) != -1) { -#else - if (PyUnicode_AsWideChar((PyUnicodeObject*) item, data, size) != -1) { -#endif - wstring wstr (data, size); - main_dir = Filename::from_os_specific_w(wstr); - } - delete data; - } -#if PY_MAJOR_VERSION < 3 - else if (PyString_Check(item)) { - char *str = PyString_AsString(item); - if (str != (char *)NULL) { - main_dir = Filename::from_os_specific(str); - } - } -#endif - } - } - - PyGILState_Release(state); - - if (main_dir.empty()) { - // We must be running in the Python interpreter directly, so return the CWD. - return get_cwd().to_os_specific(); - } - main_dir.make_absolute(); - return Filename(main_dir.get_dirname()).to_os_specific(); - } -#endif - - // Otherwise, Return the binary name's parent directory. + // Return the binary name's parent directory. If we're running + // inside the Python interpreter, this will be overridden by + // a setting from panda3d/core.py. if (!_binary_name.empty()) { Filename main_dir (_binary_name); main_dir.make_absolute(); diff --git a/dtool/src/dtoolutil/p3dtoolutil_composite2.cxx b/dtool/src/dtoolutil/p3dtoolutil_composite2.cxx index 289ce8f1e9..2adf532173 100644 --- a/dtool/src/dtoolutil/p3dtoolutil_composite2.cxx +++ b/dtool/src/dtoolutil/p3dtoolutil_composite2.cxx @@ -8,5 +8,6 @@ #include "stringDecoder.cxx" #include "textEncoder.cxx" #include "unicodeLatinMap.cxx" +#include "vector_int.cxx" #include "vector_string.cxx" #include "win32ArgParser.cxx" diff --git a/dtool/src/dtoolutil/string_utils.I b/dtool/src/dtoolutil/string_utils.I index abbfbbfd94..a69497c97f 100644 --- a/dtool/src/dtoolutil/string_utils.I +++ b/dtool/src/dtoolutil/string_utils.I @@ -26,6 +26,11 @@ format_string(const string &value) { return value; } +INLINE string +format_string(bool value) { + return string(value ? "true" : "false"); +} + INLINE string format_string(float value) { char buffer[32]; diff --git a/dtool/src/dtoolutil/string_utils.h b/dtool/src/dtoolutil/string_utils.h index afeb91c422..10ebad4720 100644 --- a/dtool/src/dtoolutil/string_utils.h +++ b/dtool/src/dtoolutil/string_utils.h @@ -69,6 +69,7 @@ INLINE string format_string(const Thing &thing); // Fast specializations for some primitive types. INLINE string format_string(const string &value); +INLINE string format_string(bool value); INLINE string format_string(float value); INLINE string format_string(double value); INLINE string format_string(unsigned int value); diff --git a/dtool/src/interrogatedb/vector_int.cxx b/dtool/src/dtoolutil/vector_int.cxx similarity index 91% rename from dtool/src/interrogatedb/vector_int.cxx rename to dtool/src/dtoolutil/vector_int.cxx index 6e829fcd63..4ec1769281 100644 --- a/dtool/src/interrogatedb/vector_int.cxx +++ b/dtool/src/dtoolutil/vector_int.cxx @@ -14,8 +14,8 @@ #include "vector_int.h" -#define EXPCL EXPCL_DTOOLCONFIG -#define EXPTP EXPTP_DTOOLCONFIG +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE int #define NAME vector_int diff --git a/dtool/src/interrogatedb/vector_int.h b/dtool/src/dtoolutil/vector_int.h similarity index 95% rename from dtool/src/interrogatedb/vector_int.h rename to dtool/src/dtoolutil/vector_int.h index 65ee50a4a5..af0a7dd981 100644 --- a/dtool/src/interrogatedb/vector_int.h +++ b/dtool/src/dtoolutil/vector_int.h @@ -26,8 +26,8 @@ // rather than defining the vector again. //////////////////////////////////////////////////////////////////// -#define EXPCL EXPCL_DTOOLCONFIG -#define EXPTP EXPTP_DTOOLCONFIG +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE int #define NAME vector_int diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index b2f703c926..5e602a7553 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -22,7 +22,9 @@ #include "interrogateBuilder.h" #include "interrogateDatabase.h" +#include "cppExpression.h" #include "cppInstance.h" +#include "cppArrayType.h" #include "cppConstType.h" #include "cppFunctionType.h" #include "cppParameterList.h" @@ -30,8 +32,6 @@ #include "interrogateType.h" #include "pnotify.h" -extern bool inside_python_native; - //////////////////////////////////////////////////////////////////// // Function: FunctionRemap::Constructor // Access: Public @@ -96,9 +96,29 @@ get_parameter_name(int n) const { // Access: Public // Description: Writes a sequence of commands to the given output // stream to call the wrapped function. The parameter -// values are taken from pexprs, if it is nonempty, or -// are assumed to be simply the names of the parameters, -// if it is empty. +// values are assumed to be simply the names of the +// parameters. +// +// The return value is the expression to return, if we +// are returning a value, or the empty string if we +// return nothing. +//////////////////////////////////////////////////////////////////// +string FunctionRemap:: +call_function(ostream &out, int indent_level, bool convert_result, + const string &container) const { + vector_string pexprs; + for (int i = 0; i < _parameters.size(); ++i) { + pexprs.push_back(get_parameter_name(i)); + } + return call_function(out, indent_level, convert_result, container, pexprs); +} + +//////////////////////////////////////////////////////////////////// +// Function: FunctionRemap::call_function +// Access: Public +// Description: Writes a sequence of commands to the given output +// stream to call the wrapped function. The parameter +// values are taken from pexprs. // // The return value is the expression to return, if we // are returning a value, or the empty string if we @@ -120,11 +140,7 @@ call_function(ostream &out, int indent_level, bool convert_result, InterfaceMaker::indent(out, indent_level) << "unref_delete(" << container << ");\n"; } else { - if (inside_python_native) { - InterfaceMaker::indent(out, indent_level) << "Dtool_Py_Delete(self);\n"; - } else { - InterfaceMaker::indent(out, indent_level) << "delete " << container << ";\n"; - } + InterfaceMaker::indent(out, indent_level) << "delete " << container << ";\n"; } } else if (_type == T_typecast_method) { @@ -225,7 +241,7 @@ call_function(ostream &out, int indent_level, bool convert_result, string call = get_call_str(container, pexprs); if (!convert_result) { - return_expr = get_call_str(container, pexprs); + return_expr = call; } else { //if (_return_type->return_value_should_be_simple()) { @@ -377,23 +393,35 @@ get_call_str(const string &container, const vector_string &pexprs) const { // Getters and setters are a special case. if (_type == T_getter) { - if (!container.empty()) { + if (_has_this && !container.empty()) { call << "(" << container << ")->" << _expression; } else { call << _expression; } } else if (_type == T_setter) { - if (!container.empty()) { - call << "(" << container << ")->" << _expression; + string expr; + if (_has_this && !container.empty()) { + expr = "(" + container + ")->" + _expression; } else { - call << _expression; + expr = _expression; + } + + // It's not possible to assign arrays in C++, we have to copy them. + CPPArrayType *array_type = _parameters[_first_true_parameter]._remap->get_orig_type()->as_array_type(); + if (array_type != NULL) { + call << "std::copy(" << expr << ", " << expr << " + " << *array_type->_bounds << ", "; + } else { + call << expr << " = "; } - call << " = "; _parameters[_first_true_parameter]._remap->pass_parameter(call, get_parameter_expr(_first_true_parameter, pexprs)); + if (array_type != NULL) { + call << ')'; + } + } else { const char *separator = ""; @@ -866,13 +894,12 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak break; case T_constructor: - if (!_has_this && _parameters.size() == 1 && - TypeManager::unwrap(_parameters[0]._remap->get_orig_type()) == - TypeManager::unwrap(_return_type->get_orig_type())) { - // If this is the only parameter, and it's the same as the - // "this" type, this is a copy constructor. + if (_ftype->_flags & CPPFunctionType::F_copy_constructor) { + // It's a copy constructor. _flags |= F_copy_constructor; + } else if (_ftype->_flags & CPPFunctionType::F_move_constructor) { + } else if (!_has_this && _parameters.size() > 0 && (_cppfunc->_storage_class & CPPInstance::SC_explicit) == 0) { // A non-explicit non-copy constructor might be eligible for coercion. diff --git a/dtool/src/interrogate/functionRemap.h b/dtool/src/interrogate/functionRemap.h index 969aa3b969..6a4477ba56 100644 --- a/dtool/src/interrogate/functionRemap.h +++ b/dtool/src/interrogate/functionRemap.h @@ -52,9 +52,11 @@ public: ~FunctionRemap(); string get_parameter_name(int n) const; + string call_function(ostream &out, int indent_level, + bool convert_result, const string &container) const; string call_function(ostream &out, int indent_level, bool convert_result, const string &container, - const vector_string &pexprs = vector_string()) const; + const vector_string &pexprs) const; void write_orig_prototype(ostream &out, int indent_level, bool local=false, int num_default_args=0) const; diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index 03398895b8..b8ec0c7c7f 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -442,8 +442,8 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { return new ParameterRemapEnumToInt(param_type); */ - } else if (TypeManager::is_const_simple(param_type)) { - return new ParameterRemapConstToNonConst(param_type); + //} else if (TypeManager::is_const_simple(param_type)) { + // return new ParameterRemapConstToNonConst(param_type); } else if (TypeManager::is_const_ref_to_simple(param_type)) { return new ParameterRemapReferenceToConcrete(param_type); @@ -833,9 +833,9 @@ manage_return_value(ostream &out, int indent_level, indent(out, indent_level) << "if (" << return_expr << " != (" - << remap->_return_type->get_new_type()->get_local_name(&parser) << ")0) {\n"; + << remap->_return_type->get_new_type()->get_local_name(&parser) << ")NULL) {\n"; indent(out, indent_level + 2) - << return_expr << "->ref();\n"; + << "(" << return_expr << ")->ref();\n"; indent(out, indent_level) << "}\n"; output_ref(out, indent_level, remap, "refcount"); diff --git a/dtool/src/interrogate/interfaceMakerC.cxx b/dtool/src/interrogate/interfaceMakerC.cxx index a1019241ed..c693bf7689 100644 --- a/dtool/src/interrogate/interfaceMakerC.cxx +++ b/dtool/src/interrogate/interfaceMakerC.cxx @@ -173,13 +173,17 @@ write_function_for(ostream &out, InterfaceMaker::Function *func) { void InterfaceMakerC:: write_function_instance(ostream &out, InterfaceMaker::Function *func, FunctionRemap *remap) { + if (remap->_extension || (remap->_flags & FunctionRemap::F_explicit_self)) { + return; + } + out << "/*\n" << " * C wrapper for\n" << " * "; remap->write_orig_prototype(out, 0); out << "\n" << " */\n"; - + if (!output_function_names) { // If we're not saving the function names, don't export it from // the library. @@ -192,17 +196,17 @@ write_function_instance(ostream &out, InterfaceMaker::Function *func, if (generate_spam) { write_spam_message(out, remap); } - - string return_expr = + + string return_expr = remap->call_function(out, 2, true, "param0"); return_expr = manage_return_value(out, 2, remap, return_expr); if (!return_expr.empty()) { out << " return " << return_expr << ";\n"; } - + out << "}\n\n"; } - + //////////////////////////////////////////////////////////////////// // Function: InterfaceMakerC::write_function_header // Access: Private @@ -212,6 +216,10 @@ write_function_instance(ostream &out, InterfaceMaker::Function *func, void InterfaceMakerC:: write_function_header(ostream &out, InterfaceMaker::Function *func, FunctionRemap *remap, bool newline) { + if (remap->_extension || (remap->_flags & FunctionRemap::F_explicit_self)) { + return; + } + if (remap->_void_return) { out << "void"; } else { diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index ecd2460d7c..a6daee775b 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -40,7 +40,6 @@ #include #include -extern bool inside_python_native; extern InterrogateType dummy_type; extern std::string EXPORT_IMPORT_PREFIX; @@ -720,11 +719,16 @@ get_valid_child_classes(std::map &answer, CPPStructTyp /////////////////////////////////////////////////////////////////////////////// void InterfaceMakerPythonNative:: write_python_instance(ostream &out, int indent_level, const string &return_expr, - bool owns_memory, const string &class_name, - CPPType *ctype, bool is_const) { + bool owns_memory, const InterrogateType &itype, bool is_const) { out << boolalpha; - if (IsPandaTypedObject(ctype->as_struct_type())) { + if (!isExportThisRun(itype._cpptype)) { + _external_imports.insert(TypeManager::resolve_type(itype._cpptype)); + } + + string class_name = itype.get_scoped_name(); + + if (IsPandaTypedObject(itype._cpptype->as_struct_type())) { // We can't let DTool_CreatePyInstanceTyped do the NULL check since we // will be grabbing the type index (which would obviously crash when called // on a NULL pointer), so we do it here. @@ -738,7 +742,7 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr, << "} else {\n"; indent(out, indent_level) << " return DTool_CreatePyInstanceTyped((void *)" << return_expr - << ", " << CLASS_PREFIX << make_safe_name(class_name) << ", " + << ", *Dtool_Ptr_" << make_safe_name(class_name) << ", " << owns_memory << ", " << is_const << ", " << return_expr << "->as_typed_object()->get_type_index());\n"; indent(out, indent_level) @@ -748,7 +752,7 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr, indent(out, indent_level) << "return " << "DTool_CreatePyInstance((void *)" << return_expr << ", " - << CLASS_PREFIX << make_safe_name(class_name) << ", " + << "*Dtool_Ptr_" << make_safe_name(class_name) << ", " << owns_memory << ", " << is_const << ");\n"; } } @@ -782,8 +786,6 @@ InterfaceMakerPythonNative:: //////////////////////////////////////////////////////////////////// void InterfaceMakerPythonNative:: write_prototypes(ostream &out_code, ostream *out_h) { - inside_python_native = true; - Functions::iterator fi; if (out_h != NULL) { @@ -812,7 +814,7 @@ write_prototypes(ostream &out_code, ostream *out_h) { write_prototypes_class(out_code, out_h, object); } else { //write_prototypes_class_external(out_code, object); - _external_imports.insert(object->_itype._cpptype); + //_external_imports.insert(object->_itype._cpptype); } } } @@ -827,28 +829,86 @@ write_prototypes(ostream &out_code, ostream *out_h) { string class_name = type->get_local_name(&parser); string safe_name = make_safe_name(class_name); - out_code << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << safe_name << ";\n"; - out_code << "IMPORT_THIS void Dtool_PyModuleClassInit_" << safe_name << "(PyObject *module);\n"; + out_code << "// " << class_name << "\n"; + out_code << "#ifndef LINK_ALL_STATIC\n"; + //out_code << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << safe_name << ";\n"; + out_code << "static struct Dtool_PyTypedObject *Dtool_Ptr_" << safe_name << ";\n"; + //out_code << "#define Dtool_Ptr_" << safe_name << " &Dtool_" << safe_name << "\n"; + //out_code << "IMPORT_THIS void Dtool_PyModuleClassInit_" << safe_name << "(PyObject *module);\n"; + + // This is some really ugly code, because we have to store a pointer with a + // function of a signature that differs from class to class. If someone can + // think of an elegant way to do this without sacrificing perf, let me know. int has_coerce = has_coerce_constructor(type->as_struct_type()); - if (TypeManager::is_reference_count(type)) { - if (has_coerce > 0) { - out_code << "IMPORT_THIS bool Dtool_Coerce_" << safe_name << "(PyObject *args, CPT(" << class_name << ") &coerced);\n"; + if (has_coerce > 0) { + if (TypeManager::is_reference_count(type)) { + out_code + << "inline static bool Dtool_ConstCoerce_" << safe_name << "(PyObject *args, CPT(" << class_name << ") &coerced) {\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce != NULL, false);\n" + << " return ((bool (*)(PyObject *, CPT(" << class_name << ") &))Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce)(args, coerced);\n" + << "}\n"; + if (has_coerce > 1) { - out_code << "IMPORT_THIS bool Dtool_Coerce_" << safe_name << "(PyObject *args, PT(" << class_name << ") &coerced);\n"; + out_code + << "inline static bool Dtool_Coerce_" << safe_name << "(PyObject *args, PT(" << class_name << ") &coerced) {\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != NULL, false);\n" + << " return ((bool (*)(PyObject *, PT(" << class_name << ") &))Dtool_Ptr_" << safe_name << "->_Dtool_Coerce)(args, coerced);\n" + << "}\n"; } - } - } else { - if (has_coerce > 0) { - out_code << "IMPORT_THIS bool Dtool_Coerce_" << safe_name << "(PyObject *args, " << class_name << " const *&coerced, bool &manage);\n"; + + } else if (TypeManager::is_trivial(type)) { + out_code + << "inline static " << class_name << " *Dtool_Coerce_" << safe_name << "(PyObject *args, " << class_name << " &coerced) {\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, NULL);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != NULL, NULL);\n" + << " return ((" << class_name << " *(*)(PyObject *, " << class_name << " &))Dtool_Ptr_" << safe_name << "->_Dtool_Coerce)(args, coerced);\n" + << "}\n"; + + } else { + out_code + << "inline static bool Dtool_ConstCoerce_" << safe_name << "(PyObject *args, " << class_name << " const *&coerced, bool &manage) {\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce != NULL, false);\n" + << " return ((bool (*)(PyObject *, " << class_name << " const *&, bool&))Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce)(args, coerced, manage);\n" + << "}\n"; + if (has_coerce > 1) { - out_code << "IMPORT_THIS bool Dtool_Coerce_" << safe_name << "(PyObject *args, " << class_name << " *&coerced, bool &manage);\n"; + out_code + << "inline static bool Dtool_Coerce_" << safe_name << "(PyObject *args, " << class_name << " *&coerced, bool &manage) {\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != NULL, false);\n" + << " return ((bool (*)(PyObject *, " << class_name << " *&, bool&))Dtool_Ptr_" << safe_name << "->_Dtool_Coerce)(args, coerced, manage);\n" + << "}\n"; } } } - } + out_code << "#else\n"; + out_code << "extern struct Dtool_PyTypedObject Dtool_" << safe_name << ";\n"; + out_code << "static struct Dtool_PyTypedObject *const Dtool_Ptr_" << safe_name << " = &Dtool_" << safe_name << ";\n"; - inside_python_native = false; + if (has_coerce > 0) { + if (TypeManager::is_reference_count(type)) { + assert(!type->is_trivial()); + out_code << "extern bool Dtool_ConstCoerce_" << safe_name << "(PyObject *args, CPT(" << class_name << ") &coerced);\n"; + if (has_coerce > 1) { + out_code << "extern bool Dtool_Coerce_" << safe_name << "(PyObject *args, PT(" << class_name << ") &coerced);\n"; + } + + } else if (TypeManager::is_trivial(type)) { + out_code << "extern " << class_name << " *Dtool_Coerce_" << safe_name << "(PyObject *args, " << class_name << " &coerced);\n"; + + } else { + out_code << "extern bool Dtool_ConstCoerce_" << safe_name << "(PyObject *args, " << class_name << " const *&coerced, bool &manage);\n"; + if (has_coerce > 1) { + out_code << "extern bool Dtool_Coerce_" << safe_name << "(PyObject *args, " << class_name << " *&coerced, bool &manage);\n"; + } + } + } + out_code << "#endif\n"; + } } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -914,8 +974,6 @@ write_prototypes_class(ostream &out_code, ostream *out_h, Object *obj) { //////////////////////////////////////////////////////////////////// void InterfaceMakerPythonNative:: write_functions(ostream &out) { - inside_python_native = true; - out << "//********************************************************************\n"; out << "//*** Functions for .. Global\n" ; out << "//********************************************************************\n"; @@ -952,8 +1010,6 @@ write_functions(ostream &out) { } } } - - inside_python_native = true; } //////////////////////////////////////////////////////////////////// @@ -1010,7 +1066,7 @@ write_class_details(ostream &out, Object *obj) { // Write the constructors. if (obj->_constructors.size() == 0) { // There is no constructor - write one that simply outputs an error. - out << "int Dtool_Init_" + ClassName + "(PyObject *, PyObject *, PyObject *) {\n" + out << "static int Dtool_Init_" + ClassName + "(PyObject *, PyObject *, PyObject *) {\n" << "#ifdef NDEBUG\n" << " Dtool_Raise_TypeError(\"cannot init constant class\");\n" << "#else\n" @@ -1022,7 +1078,7 @@ write_class_details(ostream &out, Object *obj) { } else { for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { Function *func = (*fi); - std::string fname = "int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)"; + std::string fname = "static int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)"; string expected_params; write_function_for_name(out, obj, func->_remaps, fname, expected_params, true, AT_keyword_args, RF_int); @@ -1035,7 +1091,7 @@ write_class_details(ostream &out, Object *obj) { int has_coerce = has_coerce_constructor(cpptype->as_struct_type()); if (has_coerce > 0) { write_coerce_constructor(out, obj, true); - if (has_coerce > 1) { + if (has_coerce > 1 && !TypeManager::is_trivial(obj->_itype._cpptype)) { write_coerce_constructor(out, obj, false); } } @@ -1054,28 +1110,28 @@ write_class_details(ostream &out, Object *obj) { for (di = details.begin(); di != details.end(); di++) { //InterrogateType ptype =idb->get_type(di->first); if (di->second._is_legal_py_class && !isExportThisRun(di->second._structType)) { - _external_imports.insert(di->second._structType); + _external_imports.insert(TypeManager::resolve_type(di->second._structType)); } //out << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << make_safe_name(di->second._to_class_name) << ";\n"; } // Write support methods to cast from and to pointers of this type. { - out << "inline void *Dtool_UpcastInterface_" << ClassName << "(PyObject *self, Dtool_PyTypedObject *requested_type) {\n"; + out << "static void *Dtool_UpcastInterface_" << ClassName << "(PyObject *self, Dtool_PyTypedObject *requested_type) {\n"; out << " Dtool_PyTypedObject *SelfType = ((Dtool_PyInstDef *)self)->_My_Type;\n"; - out << " if (SelfType != &Dtool_" << ClassName << ") {\n"; + out << " if (SelfType != Dtool_Ptr_" << ClassName << ") {\n"; out << " printf(\"" << ClassName << " ** Bad Source Type-- Requesting Conversion from %s to %s\\n\", Py_TYPE(self)->tp_name, requested_type->_PyType.tp_name); fflush(NULL);\n";; out << " return NULL;\n"; out << " }\n"; out << "\n"; out << " " << cClassName << " *local_this = (" << cClassName << " *)((Dtool_PyInstDef *)self)->_ptr_to_object;\n"; - out << " if (requested_type == &Dtool_" << ClassName << ") {\n"; + out << " if (requested_type == Dtool_Ptr_" << ClassName << ") {\n"; out << " return local_this;\n"; out << " }\n"; for (di = details.begin(); di != details.end(); di++) { if (di->second._is_legal_py_class) { - out << " if (requested_type == &Dtool_" << make_safe_name(di->second._to_class_name) << ") {\n"; + out << " if (requested_type == Dtool_Ptr_" << make_safe_name(di->second._to_class_name) << ") {\n"; out << " return " << di->second._up_cast_string << " local_this;\n"; out << " }\n"; } @@ -1084,16 +1140,16 @@ write_class_details(ostream &out, Object *obj) { out << " return NULL;\n"; out << "}\n\n"; - out << "inline void *Dtool_DowncastInterface_" << ClassName << "(void *from_this, Dtool_PyTypedObject *from_type) {\n"; + out << "static void *Dtool_DowncastInterface_" << ClassName << "(void *from_this, Dtool_PyTypedObject *from_type) {\n"; out << " if (from_this == NULL || from_type == NULL) {\n"; out << " return NULL;\n"; out << " }\n"; - out << " if (from_type == &Dtool_" << ClassName << ") {\n"; + out << " if (from_type == Dtool_Ptr_" << ClassName << ") {\n"; out << " return from_this;\n"; out << " }\n"; for (di = details.begin(); di != details.end(); di++) { if (di->second._can_downcast && di->second._is_legal_py_class) { - out << " if (from_type == &Dtool_" << make_safe_name(di->second._to_class_name) << ") {\n"; + out << " if (from_type == Dtool_Ptr_" << make_safe_name(di->second._to_class_name) << ") {\n"; out << " " << di->second._to_class_name << "* other_this = (" << di->second._to_class_name << "*)from_this;\n" ; out << " return (" << cClassName << "*)other_this;\n"; out << " }\n"; @@ -1139,21 +1195,25 @@ write_class_declarations(ostream &out, ostream *out_h, Object *obj) { } out << "(" << _def->module_name << ", " << class_name << ", " << class_name << "_localtype, " << classNameFromCppName(preferred_name, false) << ");\n"; - out << "EXPORT_THIS void Dtool_PyModuleClassInit_" << class_name << "(PyObject *module);\n"; + out << "static struct Dtool_PyTypedObject *const Dtool_Ptr_" << class_name << " = &Dtool_" << class_name << ";\n"; + out << "static void Dtool_PyModuleClassInit_" << class_name << "(PyObject *module);\n"; int has_coerce = has_coerce_constructor(type->as_struct_type()); - if (TypeManager::is_reference_count(type)) { - if (has_coerce > 0) { - out << "EXPORT_THIS bool Dtool_Coerce_" << class_name << "(PyObject *args, CPT(" << c_class_name << ") &coerced);\n"; + if (has_coerce > 0) { + if (TypeManager::is_reference_count(type)) { + assert(!type->is_trivial()); + out << "bool Dtool_ConstCoerce_" << class_name << "(PyObject *args, CPT(" << c_class_name << ") &coerced);\n"; if (has_coerce > 1) { - out << "EXPORT_THIS bool Dtool_Coerce_" << class_name << "(PyObject *args, PT(" << c_class_name << ") &coerced);\n"; + out << "bool Dtool_Coerce_" << class_name << "(PyObject *args, PT(" << c_class_name << ") &coerced);\n"; } - } - } else { - if (has_coerce > 0) { - out << "EXPORT_THIS bool Dtool_Coerce_" << class_name << "(PyObject *args, " << c_class_name << " const *&coerced, bool &manage);\n"; + + } else if (TypeManager::is_trivial(type)) { + out << "" << c_class_name << " *Dtool_Coerce_" << class_name << "(PyObject *args, " << c_class_name << " &coerced);\n"; + + } else { + out << "bool Dtool_ConstCoerce_" << class_name << "(PyObject *args, " << c_class_name << " const *&coerced, bool &manage);\n"; if (has_coerce > 1) { - out << "EXPORT_THIS bool Dtool_Coerce_" << class_name << "(PyObject *args, " << c_class_name << " *&coerced, bool &manage);\n"; + out << "bool Dtool_Coerce_" << class_name << "(PyObject *args, " << c_class_name << " *&coerced, bool &manage);\n"; } } } @@ -1197,17 +1257,23 @@ write_sub_module(ostream &out, Object *obj) { << " " << *(obj->_itype._cpptype) << "\n"; if (!isExportThisRun(wrapped_itype._cpptype)) { - _external_imports.insert(wrapped_itype._cpptype); + _external_imports.insert(TypeManager::resolve_type(wrapped_itype._cpptype)); } } std::string export_class_name = classNameFromCppName(obj->_itype.get_name(), false); std::string export_class_name2 = classNameFromCppName(obj->_itype.get_name(), true); -// out << " Py_INCREF(&Dtool_" << class_name << ".As_PyTypeObject());\n"; - out << " PyModule_AddObject(module, \"" << export_class_name << "\", (PyObject *)&Dtool_" << class_name << ".As_PyTypeObject());\n"; + // Note: PyModule_AddObject steals a reference, so we have to call Py_INCREF + // for every but the first time we add it to the module. + if (obj->_itype.is_typedef()) { + out << " Py_INCREF((PyObject *)&Dtool_" << class_name << ");\n"; + } + + out << " PyModule_AddObject(module, \"" << export_class_name << "\", (PyObject *)&Dtool_" << class_name << ");\n"; if (export_class_name != export_class_name2) { - out << " PyModule_AddObject(module, \"" << export_class_name2 << "\", (PyObject *)&Dtool_" << class_name << ".As_PyTypeObject());\n"; + out << " Py_INCREF((PyObject *)&Dtool_" << class_name << ");\n"; + out << " PyModule_AddObject(module, \"" << export_class_name2 << "\", (PyObject *)&Dtool_" << class_name << ");\n"; } } @@ -1220,19 +1286,65 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << "//*** Module Object Linker ..\n"; out << "//********************************************************************\n"; - out << "static void BuildInstants(PyObject *module) {\n"; - out << " (void) module; // Unused\n"; - Objects::iterator oi; + + out << "void Dtool_" << def->library_name << "_RegisterTypes() {\n"; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { Object *object = (*oi).second; - if (object->_itype.is_enum() && !object->_itype.is_nested()) { - int enum_count = object->_itype.number_of_enum_values(); - if (enum_count > 0) { - out << "//********************************************************************\n"; - out << "//*** Module Enums .." << object->_itype.get_scoped_name() << "\n"; - out << "//********************************************************************\n"; + if (object->_itype.is_class() || + object->_itype.is_struct()) { + if (is_cpp_type_legal(object->_itype._cpptype) && + isExportThisRun(object->_itype._cpptype)) { + string class_name = make_safe_name(object->_itype.get_scoped_name()); + bool is_typed = HasAGetClassTypeFunction(object->_itype._cpptype); + + if (is_typed) { + out << " Dtool_" << class_name << "._type = " + << object->_itype._cpptype->get_local_name(&parser) + << "::get_class_type();\n" + << " RegisterRuntimeTypedClass(Dtool_" << class_name << ");\n"; + + } else { + out << "#ifndef LINK_ALL_STATIC\n" + << " RegisterNamedClass(\"" << object->_itype.get_scoped_name() + << "\", Dtool_" << class_name << ");\n" + << "#endif\n"; + + if (IsPandaTypedObject(object->_itype._cpptype->as_struct_type())) { + nout << object->_itype.get_scoped_name() << " derives from TypedObject, " + << "but does not define a get_class_type() function.\n"; + } + } } + } + } + out << "}\n\n"; + + out << "void Dtool_" << def->library_name << "_ResolveExternals() {\n"; + out << "#ifndef LINK_ALL_STATIC\n"; + out << " // Resolve externally imported types.\n"; + + for (std::set::iterator ii = _external_imports.begin(); ii != _external_imports.end(); ++ii) { + string class_name = (*ii)->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + + if (HasAGetClassTypeFunction(*ii)) { + out << " Dtool_Ptr_" << safe_name << " = LookupRuntimeTypedClass(" << class_name << "::get_class_type());\n"; + } else { + out << " Dtool_Ptr_" << safe_name << " = LookupNamedClass(\"" << class_name << "\");\n"; + } + } + out << "#endif\n"; + out << "}\n\n"; + + out << "void Dtool_" << def->library_name << "_BuildInstants(PyObject *module) {\n"; + out << " (void) module;\n"; + + for (oi = _objects.begin(); oi != _objects.end(); ++oi) { + Object *object = (*oi).second; + if (object->_itype.is_enum() && !object->_itype.is_nested() && + isExportThisRun(object->_itype._cpptype)) { + int enum_count = object->_itype.number_of_enum_values(); for (int xx = 0; xx < enum_count; xx++) { string name1 = classNameFromCppName(object->_itype.get_enum_value_name(xx), false); string name2 = classNameFromCppName(object->_itype.get_enum_value_name(xx), true); @@ -1308,9 +1420,11 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { string name2 = methodNameFromCppName(func, "", true); string flags; + string fptr = "&" + func->_name; switch (func->_args_type) { case AT_keyword_args: flags = "METH_VARARGS | METH_KEYWORDS"; + fptr = "(PyCFunction) " + fptr; break; case AT_varargs: @@ -1329,11 +1443,11 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { // Note: we shouldn't add METH_STATIC here, since both METH_STATIC // and METH_CLASS are illegal for module-level functions. - out << " { \"" << name1 << "\", (PyCFunction) &" - << func->_name << ", " << flags << ", (const char *)" << func->_name << "_comment},\n"; + out << " {\"" << name1 << "\", " << fptr + << ", " << flags << ", (const char *)" << func->_name << "_comment},\n"; if (name1 != name2) { - out << " { \"" << name2 << "\", (PyCFunction) &" - << func->_name << ", " << flags << ", (const char *)" << func->_name << "_comment},\n"; + out << " {\"" << name2 << "\", " << fptr + << ", " << flags << ", (const char *)" << func->_name << "_comment},\n"; } } } @@ -1346,7 +1460,7 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << " {NULL, NULL, 0, NULL}\n" << "};\n\n"; - out << "EXPORT_THIS struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, BuildInstants};\n"; + out << "struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs};\n"; if (out_h != NULL) { *out_h << "extern struct LibraryDef " << def->library_name << "_moddef;\n"; } @@ -1435,6 +1549,11 @@ write_module_class(ostream &out, Object *obj) { std::string cClassName = obj->_itype.get_true_name(); std::string export_class_name = classNameFromCppName(obj->_itype.get_name(), false); + bool is_runtime_typed = IsPandaTypedObject(obj->_itype._cpptype->as_struct_type()); + if (!is_runtime_typed && HasAGetClassTypeFunction(obj->_itype._cpptype)) { + is_runtime_typed = true; + } + Functions::iterator fi; out << "//********************************************************************\n"; out << "//*** Py Init Code For .. " << ClassName << " | " << export_class_name << "\n" ; @@ -1458,9 +1577,11 @@ write_module_class(ostream &out, Object *obj) { string name2 = methodNameFromCppName(func, export_class_name, true); string flags; + string fptr = "&" + func->_name; switch (func->_args_type) { case AT_keyword_args: flags = "METH_VARARGS | METH_KEYWORDS"; + fptr = "(PyCFunction) " + fptr; break; case AT_varargs: @@ -1550,48 +1671,54 @@ write_module_class(ostream &out, Object *obj) { } // This method has non-slotted remaps, so write it out into the function table. - out << " { \"" << name1 << "\", (PyCFunction) &" - << func->_name << ", " << flags << ", (char *) " << func->_name << "_comment},\n"; + out << " {\"" << name1 << "\", " << fptr + << ", " << flags << ", (const char *)" << func->_name << "_comment},\n"; if (name1 != name2) { - out << " { \"" << name2 << "\", (PyCFunction) &" - << func->_name << ", " << flags << ", (char *) " << func->_name << "_comment},\n"; + out << " {\"" << name2 << "\", " << fptr + << ", " << flags << ", (const char *)" << func->_name << "_comment},\n"; } } } if (obj->_protocol_types & Object::PT_make_copy) { if (!got_copy) { - out << " { \"__copy__\", (PyCFunction) ©_from_make_copy, METH_NOARGS, NULL},\n"; + out << " {\"__copy__\", ©_from_make_copy, METH_NOARGS, NULL},\n"; got_copy = true; } } else if (obj->_protocol_types & Object::PT_copy_constructor) { if (!got_copy) { - out << " { \"__copy__\", (PyCFunction) ©_from_copy_constructor, METH_NOARGS, NULL},\n"; + out << " {\"__copy__\", ©_from_copy_constructor, METH_NOARGS, NULL},\n"; got_copy = true; } } if (got_copy && !got_deepcopy) { - out << " { \"__deepcopy__\", (PyCFunction) &map_deepcopy_to_copy, METH_VARARGS, NULL},\n"; + out << " {\"__deepcopy__\", &map_deepcopy_to_copy, METH_VARARGS, NULL},\n"; } MakeSeqs::iterator msi; for (msi = obj->_make_seqs.begin(); msi != obj->_make_seqs.end(); ++msi) { - string flags = "METH_NOARGS"; - if (obj->is_static_method((*msi)->_element_name)) { - flags += " | METH_CLASS"; - } - string name1 = methodNameFromCppName((*msi)->_seq_name, export_class_name, false); - string name2 = methodNameFromCppName((*msi)->_seq_name, export_class_name, true); - out << " { \"" << name1 - << "\", (PyCFunction) &" << (*msi)->_name << ", " << flags << ", NULL},\n"; - if (name1 != name2) { - out << " { \"" << name2 + const string &seq_name = (*msi)->_seq_name; + + if ((seq_name.size() > 4 && seq_name.substr(0, 4) == "get_") || + (seq_name.size() > 7 && seq_name.substr(0, 7) == "modify_")) { + + string flags = "METH_NOARGS"; + if (obj->is_static_method((*msi)->_element_name)) { + flags += " | METH_CLASS"; + } + string name1 = methodNameFromCppName((*msi)->_seq_name, export_class_name, false); + string name2 = methodNameFromCppName((*msi)->_seq_name, export_class_name, true); + out << " {\"" << name1 << "\", (PyCFunction) &" << (*msi)->_name << ", " << flags << ", NULL},\n"; + if (name1 != name2) { + out << " { \"" << name2 + << "\", (PyCFunction) &" << (*msi)->_name << ", " << flags << ", NULL},\n"; + } } } - out << " { NULL, NULL, 0, NULL }\n" + out << " {NULL, NULL, 0, NULL}\n" << "};\n\n"; int num_derivations = obj->_itype.number_of_derivations(); @@ -1602,7 +1729,7 @@ write_module_class(ostream &out, Object *obj) { const InterrogateType &d_itype = idb->get_type(d_type_Index); if (is_cpp_type_legal(d_itype._cpptype)) { if (!isExportThisRun(d_itype._cpptype)) { - _external_imports.insert(d_itype._cpptype); + _external_imports.insert(TypeManager::resolve_type(d_itype._cpptype)); //out << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << make_safe_name(d_itype.get_scoped_name().c_str()) << ";\n"; } @@ -1813,7 +1940,7 @@ write_module_class(ostream &out, Object *obj) { out << " if (res != NULL) {\n"; out << " return res;\n"; out << " }\n"; - out << " if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {\n"; + out << " if (_PyErr_OCCURRED() != PyExc_AttributeError) {\n"; out << " return NULL;\n"; out << " }\n"; out << " PyErr_Clear();\n\n"; @@ -2644,7 +2771,7 @@ write_module_class(ostream &out, Object *obj) { } // Output the actual PyTypeObject definition. - out << "EXPORT_THIS Dtool_PyTypedObject Dtool_" << ClassName << " = {\n"; + out << "struct Dtool_PyTypedObject Dtool_" << ClassName << " = {\n"; out << " {\n"; out << " PyVarObject_HEAD_INIT(NULL, 0)\n"; // const char *tp_name; @@ -2843,12 +2970,36 @@ write_module_class(ostream &out, Object *obj) { out << " 0, // tp_version_tag\n"; out << "#endif\n"; out << " },\n"; + + // It's tempting to initialize the type handle here, but this causes static + // init ordering issues; this may run before init_type is called. + out << " TypeHandle::none(),\n"; + out << " Dtool_PyModuleClassInit_" << ClassName << ",\n"; out << " Dtool_UpcastInterface_" << ClassName << ",\n"; out << " Dtool_DowncastInterface_" << ClassName << ",\n"; - out << " TypeHandle::none(),\n"; + + int has_coerce = has_coerce_constructor(obj->_itype._cpptype->as_struct_type()); + if (has_coerce > 0) { + if (TypeManager::is_reference_count(obj->_itype._cpptype) || + !TypeManager::is_trivial(obj->_itype._cpptype)) { + out << " (CoerceFunction)Dtool_ConstCoerce_" << ClassName << ",\n"; + if (has_coerce > 1) { + out << " (CoerceFunction)Dtool_Coerce_" << ClassName << ",\n"; + } else { + out << " (CoerceFunction)0,\n"; + } + } else { + out << " (CoerceFunction)0,\n"; + out << " (CoerceFunction)Dtool_Coerce_" << ClassName << ",\n"; + } + } else { + out << " (CoerceFunction)0,\n"; + out << " (CoerceFunction)0,\n"; + } + out << "};\n\n"; - out << "void Dtool_PyModuleClassInit_" << ClassName << "(PyObject *module) {\n"; + out << "static void Dtool_PyModuleClassInit_" << ClassName << "(PyObject *module) {\n"; out << " (void) module; // Unused\n"; out << " static bool initdone = false;\n"; out << " if (!initdone) {\n"; @@ -2859,11 +3010,14 @@ write_module_class(ostream &out, Object *obj) { out << " // Dependent objects\n"; string baseargs; for (vector::iterator bi = bases.begin(); bi != bases.end(); ++bi) { - baseargs += ", &Dtool_" + *bi + ".As_PyTypeObject()"; - out << " Dtool_PyModuleClassInit_" << make_safe_name(*bi) << "(NULL);\n"; + baseargs += ", (PyTypeObject *)Dtool_Ptr_" + *bi; + string safe_name = make_safe_name(*bi); + + out << " assert(Dtool_Ptr_" << safe_name << " != NULL);\n" + << " Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit(NULL);\n"; } - out << " Dtool_" << ClassName << ".As_PyTypeObject().tp_bases = PyTuple_Pack(" << bases.size() << baseargs << ");\n"; + out << " Dtool_" << ClassName << "._PyType.tp_bases = PyTuple_Pack(" << bases.size() << baseargs << ");\n"; } int num_nested = obj->_itype.number_of_nested_types(); @@ -2896,7 +3050,7 @@ write_module_class(ostream &out, Object *obj) { } else { out << " PyObject *dict = PyDict_New();\n"; } - out << " Dtool_" << ClassName << ".As_PyTypeObject().tp_dict = dict;\n"; + out << " Dtool_" << ClassName << "._PyType.tp_dict = dict;\n"; out << " PyDict_SetItemString(dict, \"DtoolClassDict\", dict);\n"; // Now go through the nested types again to actually add the dict items. @@ -2917,9 +3071,9 @@ write_module_class(ostream &out, Object *obj) { out << " Dtool_PyModuleClassInit_" << ClassName1 << "(NULL);\n"; string name1 = classNameFromCppName(ClassName2, false); string name2 = classNameFromCppName(ClassName2, true); - out << " PyDict_SetItemString(dict, \"" << name1 << "\", (PyObject *)&Dtool_" << ClassName1 << ".As_PyTypeObject());\n"; + out << " PyDict_SetItemString(dict, \"" << name1 << "\", (PyObject *)&Dtool_" << ClassName1 << ");\n"; if (name1 != name2) { - out << " PyDict_SetItemString(dict, \"" << name2 << "\", (PyObject *)&Dtool_" << ClassName1 << ".As_PyTypeObject());\n"; + out << " PyDict_SetItemString(dict, \"" << name2 << "\", (PyObject *)&Dtool_" << ClassName1 << ");\n"; } } else if (nested_obj->_itype.is_typedef()) { @@ -2938,7 +3092,7 @@ write_module_class(ostream &out, Object *obj) { string ClassName2 = make_safe_name(interrogate_type_name(wrapped)); string name1 = classNameFromCppName(ClassName2, false); - out << " PyDict_SetItemString(dict, \"" << name1 << "\", (PyObject *)&Dtool_" << ClassName1 << ".As_PyTypeObject());\n"; + out << " PyDict_SetItemString(dict, \"" << name1 << "\", (PyObject *)&Dtool_" << ClassName1 << ");\n"; // No need to support mangled names for nested typedefs; we only added support recently. } else if (nested_obj->_itype.is_enum()) { @@ -2964,28 +3118,12 @@ write_module_class(ostream &out, Object *obj) { } } - out << " if (PyType_Ready(&Dtool_" << ClassName << ".As_PyTypeObject()) < 0) {\n"; - out << " Dtool_Raise_TypeError(\"PyType_Ready(" << ClassName << ")\");\n"; - out << " return;\n"; - out << " }\n"; - - out << " Py_INCREF(&Dtool_" << ClassName << ".As_PyTypeObject());\n"; - - // Why make the class a member of itself? - //out << " PyDict_SetItemString(Dtool_" <_itype._cpptype->as_struct_type()); - if (HasAGetClassTypeFunction(obj->_itype)) { - is_runtime_typed = true; - } - - if (is_runtime_typed) { - out << " RegisterRuntimeClass(&Dtool_" << ClassName << ", " << cClassName << "::get_class_type().get_index());\n"; - } else { - out << " RegisterRuntimeClass(&Dtool_" << ClassName << ", -1);\n"; - } - - out << " }\n"; + out << " if (PyType_Ready((PyTypeObject *)&Dtool_" << ClassName << ") < 0) {\n" + " Dtool_Raise_TypeError(\"PyType_Ready(" << ClassName << ")\");\n" + " return;\n" + " }\n" + " Py_INCREF((PyTypeObject *)&Dtool_" << ClassName << ");\n" + " }\n"; // Also write out the explicit alternate names. //int num_alt_names = obj->_itype.get_num_alt_names(); @@ -3170,6 +3308,7 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker break; default: + prototype += ", PyObject *"; break; } prototype += ")"; @@ -3620,12 +3759,14 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { std::string ClassName = make_safe_name(obj->_itype.get_scoped_name()); std::string cClassName = obj->_itype.get_true_name(); + int return_flags = RF_coerced; + if (TypeManager::is_reference_count(obj->_itype._cpptype)) { // The coercion works slightly different for reference counted types, since // we can handle those a bit more nicely by taking advantage of the refcount // instead of having to use a boolean to indicate that it should be managed. if (is_const) { - out << "bool Dtool_Coerce_" << ClassName << "(PyObject *args, CPT(" << cClassName << ") &coerced) {\n"; + out << "bool Dtool_ConstCoerce_" << ClassName << "(PyObject *args, CPT(" << cClassName << ") &coerced) {\n"; } else { out << "bool Dtool_Coerce_" << ClassName << "(PyObject *args, PT(" << cClassName << ") &coerced) {\n"; } @@ -3645,9 +3786,26 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { out << " coerced->ref();\n"; out << " return true;\n"; } + return_flags |= RF_err_false; + + } else if (TypeManager::is_trivial(obj->_itype._cpptype)) { + out << cClassName << " *Dtool_Coerce_" << ClassName << "(PyObject *args, " << cClassName << " &coerced) {\n"; + + out << " " << cClassName << " *local_this;\n"; + out << " DTOOL_Call_ExtractThisPointerForType(args, &Dtool_" << ClassName << ", (void**)&local_this);\n"; + out << " if (local_this != NULL) {\n"; + out << " if (((Dtool_PyInstDef *)args)->_is_const) {\n"; + out << " // This is a const object. Make a copy.\n"; + out << " coerced = *(const " << cClassName << " *)local_this;\n"; + out << " return &coerced;\n"; + out << " }\n"; + out << " return local_this;\n"; + + return_flags |= RF_err_null; + } else { if (is_const) { - out << "bool Dtool_Coerce_" << ClassName << "(PyObject *args, " << cClassName << " const *&coerced, bool &manage) {\n"; + out << "bool Dtool_ConstCoerce_" << ClassName << "(PyObject *args, " << cClassName << " const *&coerced, bool &manage) {\n"; } else { out << "bool Dtool_Coerce_" << ClassName << "(PyObject *args, " << cClassName << " *&coerced, bool &manage) {\n"; } @@ -3662,12 +3820,14 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { } else { out << " return true;\n"; } + + return_flags |= RF_err_false; } out << " }\n\n"; if (map_sets.empty()) { - error_return(out, 2, RF_coerced | RF_err_false); + error_return(out, 2, return_flags); out << "}\n\n"; return; } @@ -3682,12 +3842,12 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { out << " PyObject *arg = args;\n"; write_function_forset(out, mii->second, mii->first, mii->first, expected_params, 4, false, false, - AT_single_arg, RF_coerced | RF_err_false, true, false); + AT_single_arg, return_flags, true, false); if (map_sets.size() == 1) { out << " }\n"; //out << " PyErr_Clear();\n"; - error_return(out, 2, RF_coerced | RF_err_false); + error_return(out, 2, return_flags); out << "}\n\n"; return; } @@ -3725,7 +3885,7 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { indent(out, 6) << "case " << max_args << ": {\n"; write_function_forset(out, mii->second, min_args, max_args, expected_params, 8, false, false, - AT_varargs, RF_coerced | RF_err_false, true, false); + AT_varargs, return_flags, true, false); indent(out, 8) << "break;\n"; indent(out, 6) << "}\n"; @@ -3755,13 +3915,13 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { } write_function_forset(out, mii->second, min_args, max_args, expected_params, 6, false, false, - AT_varargs, RF_coerced | RF_err_false, true, false); + AT_varargs, return_flags, true, false); indent(out, 4) << "}\n"; } out << " }\n\n"; //out << " PyErr_Clear();\n"; - error_return(out, 2, RF_coerced | RF_err_false); + error_return(out, 2, return_flags); out << "}\n\n"; } @@ -4588,8 +4748,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" << "#endif\n"; - pexpr_string = "std::wstring(" + - param_name + "_str, " + param_name + "_len)"; + pexpr_string = param_name + "_str, " + param_name + "_len"; extra_cleanup << "#if PY_VERSION_HEX >= 0x03030000\n" @@ -4614,8 +4773,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" << "#endif\n"; - pexpr_string = "&std::wstring(" + - param_name + "_str, " + param_name + "_len)"; + pexpr_string = param_name + "_str, " + param_name + "_len"; extra_cleanup << "#if PY_VERSION_HEX >= 0x03030000\n" @@ -4662,13 +4820,12 @@ write_function_instance(ostream &out, FunctionRemap *remap, + "_str, &" + param_name + "_len"; } - if (TypeManager::is_const_ptr_to_basic_string_char(orig_type)) { - pexpr_string = "&std::string(" + - param_name + "_str, " + param_name + "_len)"; - } else { - pexpr_string = "std::string(" + - param_name + "_str, " + param_name + "_len)"; - } +// if (TypeManager::is_const_ptr_to_basic_string_char(orig_type)) { +// pexpr_string = "&std::string(" + +// param_name + "_str, " + param_name + "_len)"; +// } else { + pexpr_string = param_name + "_str, " + param_name + "_len"; +// } expected_params += "str"; } // Remember to clear the TypeError that any of the above methods raise. @@ -4772,12 +4929,13 @@ write_function_instance(ostream &out, FunctionRemap *remap, expected_params += "long"; only_pyobjects = false; - } else if (TypeManager::is_unsigned_short(type)) { + } else if (TypeManager::is_unsigned_short(type) || + TypeManager::is_unsigned_char(type) || TypeManager::is_signed_char(type)) { + if (args_type == AT_single_arg) { - // This is defined to PyLong_Check for Python 3 by py_panda.h. - type_check = "PyInt_Check(arg)"; + type_check = "PyLongOrInt_Check(arg)"; extra_convert - << "long " << param_name << " = PyInt_AS_LONG(arg);\n"; + << "long " << param_name << " = PyLongOrInt_AS_LONG(arg);\n"; pexpr_string = "(" + type->get_local_name(&parser) + ")" + param_name; } else { @@ -4789,12 +4947,25 @@ write_function_instance(ostream &out, FunctionRemap *remap, // The "H" format code, unlike "h", does not do overflow checking, so // we have to do it ourselves (except in release builds). extra_convert - << "#ifndef NDEBUG\n" - << "if (" << param_name << " < 0 || " << param_name << " > USHRT_MAX) {\n"; + << "#ifndef NDEBUG\n"; + + if (TypeManager::is_unsigned_short(type)) { + extra_convert << "if (" << param_name << " < 0 || " << param_name << " > USHRT_MAX) {\n"; + error_raise_return(extra_convert, 2, return_flags, "OverflowError", + "value %ld out of range for unsigned short integer", + param_name); + } else if (TypeManager::is_unsigned_char(type)) { + extra_convert << "if (" << param_name << " < 0 || " << param_name << " > UCHAR_MAX) {\n"; + error_raise_return(extra_convert, 2, return_flags, "OverflowError", + "value %ld out of range for unsigned byte", + param_name); + } else { + extra_convert << "if (" << param_name << " < CHAR_MIN || " << param_name << " > CHAR_MAX) {\n"; + error_raise_return(extra_convert, 2, return_flags, "OverflowError", + "value %ld out of range for signed byte", + param_name); + } - error_raise_return(extra_convert, 2, return_flags, "OverflowError", - "value %ld out of range for unsigned short integer", - param_name); extra_convert << "}\n" << "#endif\n"; @@ -4804,12 +4975,11 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else if (TypeManager::is_short(type)) { if (args_type == AT_single_arg) { - // This is defined to PyLong_Check for Python 3 by py_panda.h. - type_check = "PyInt_Check(arg)"; + type_check = "PyLongOrInt_Check(arg)"; // Perform overflow checking in debug builds. extra_convert - << "long arg_val = PyInt_AS_LONG(arg);\n" + << "long arg_val = PyLongOrInt_AS_LONG(arg);\n" << "#ifndef NDEBUG\n" << "if (arg_val < SHRT_MIN || arg_val > SHRT_MAX) {\n"; @@ -4867,14 +5037,13 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else if (TypeManager::is_integer(type)) { if (args_type == AT_single_arg) { - // This is defined to PyLong_Check for Python 3 by py_panda.h. - type_check = "PyInt_Check(arg)"; + type_check = "PyLongOrInt_Check(arg)"; // Perform overflow checking in debug builds. Note that Python 2 // stores longs internally, for ints, so we don't do it on Windows, // where longs are the same size as ints. extra_convert - << "long arg_val = PyInt_AS_LONG(arg);\n" + << "long arg_val = PyLongOrInt_AS_LONG(arg);\n" << "#if (SIZEOF_LONG > SIZEOF_INT) && !defined(NDEBUG)\n" << "if (arg_val < INT_MIN || arg_val > INT_MAX) {\n"; @@ -5158,7 +5327,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // need to a forward scope for this class.. if (!isExportThisRun(obj_type)) { - _external_imports.insert(obj_type); + _external_imports.insert(TypeManager::resolve_type(obj_type)); } string this_class_name; @@ -5178,19 +5347,50 @@ write_function_instance(ostream &out, FunctionRemap *remap, // We use a PointerTo to handle the management here. It's cleaner // that way. if (TypeManager::is_const_pointer_to_anything(type)) { - extra_convert << 'C'; - } - extra_convert - << "PT(" << class_name << ") " << param_name << "_this" - << default_expr << ";\n"; + extra_convert + << "CPT(" << class_name << ") " << param_name << "_this" + << default_expr << ";\n"; - coerce_call = "Dtool_Coerce_" + make_safe_name(class_name) + - "(" + param_name + ", " + param_name + "_this)"; + coerce_call = "Dtool_ConstCoerce_" + make_safe_name(class_name) + + "(" + param_name + ", " + param_name + "_this)"; + } else { + extra_convert + << "PT(" << class_name << ") " << param_name << "_this" + << default_expr << ";\n"; + + coerce_call = "Dtool_Coerce_" + make_safe_name(class_name) + + "(" + param_name + ", " + param_name + "_this)"; + } // Use move constructor when available for functions that take // an actual PointerTo. This eliminates an unref()/ref() pair. pexpr_string = "MOVE(" + param_name + "_this)"; + } else if (TypeManager::is_trivial(obj_type)) { + // This is a trivial type, such as TypeHandle or LVecBase4. + obj_type->output_instance(extra_convert, param_name + "_local", &parser); + extra_convert << ";\n"; + + type->output_instance(extra_convert, param_name + "_this", &parser); + + if (is_optional) { + extra_convert + << default_expr << ";\n" + << "if (" << param_name << " != NULL) {\n" + << " " << param_name << "_this"; + } + + extra_convert << " = Dtool_Coerce_" + make_safe_name(class_name) + + "(" + param_name + ", " + param_name + "_local);\n"; + + if (is_optional) { + extra_convert << "}\n"; + } + + coerce_call = "(" + param_name + "_this != NULL)"; + + pexpr_string = param_name + "_this"; + } else { // This is a bit less elegant: we use a bool to store whether // we're supposed to clean up the reference afterward. @@ -5199,8 +5399,13 @@ write_function_instance(ostream &out, FunctionRemap *remap, << default_expr << ";\n" << "bool " << param_name << "_manage = false;\n"; - coerce_call = "Dtool_Coerce_" + make_safe_name(class_name) + - "(" + param_name + ", " + param_name + "_this, " + param_name + "_manage)"; + if (TypeManager::is_const_pointer_or_ref(orig_type)) { + coerce_call = "Dtool_ConstCoerce_" + make_safe_name(class_name) + + "(" + param_name + ", " + param_name + "_this, " + param_name + "_manage)"; + } else { + coerce_call = "Dtool_Coerce_" + make_safe_name(class_name) + + "(" + param_name + ", " + param_name + "_this, " + param_name + "_manage)"; + } extra_cleanup << "if (" << param_name << "_manage) {\n" @@ -5261,13 +5466,13 @@ write_function_instance(ostream &out, FunctionRemap *remap, } extra_convert << "DTOOL_Call_ExtractThisPointerForType(" << param_name - << ", &Dtool_" << make_safe_name(class_name) + << ", Dtool_Ptr_" << make_safe_name(class_name) << ", (void **)&" << param_name << "_this);\n"; } else { extra_convert << boolalpha << " = (" << class_name << " *)" << "DTOOL_Call_GetPointerThisClass(" << param_name - << ", &Dtool_" << make_safe_name(class_name) + << ", Dtool_Ptr_" << make_safe_name(class_name) << ", " << pn << ", \"" << method_prefix << methodNameFromCppName(remap, this_class_name, false) << "\", " << const_ok << ", " << report_errors << ");\n"; @@ -5457,6 +5662,20 @@ write_function_instance(ostream &out, FunctionRemap *remap, manage_return = remap->_return_value_needs_management; return_expr = "return_value"; + } else if ((return_flags & RF_coerced) != 0 && TypeManager::is_trivial(remap->_cpptype)) { + // Another special case is the coerce constructor for a trivial type. + // We don't want to invoke "operator new" unnecessarily. + if (is_constructor && remap->_extension) { + // Extension constructors are a special case, as usual. + indent(out, indent_level) + << remap->get_call_str("&coerced", pexprs) << ";\n"; + + } else { + indent(out, indent_level) + << "coerced = " << remap->get_call_str(container, pexprs) << ";\n"; + } + return_expr = "&coerced"; + } else { // The general case; an ordinary constructor or function. return_expr = remap->call_function(out, indent_level, true, container, pexprs); @@ -5561,6 +5780,11 @@ write_function_instance(ostream &out, FunctionRemap *remap, << "return Dtool_Return_Bool(" << return_expr << ");\n"; return_flags &= ~RF_pyobject; + } else if (return_null && TypeManager::is_pointer_to_PyObject(remap->_return_type->get_new_type())) { + indent(out, indent_level) + << "return Dtool_Return(" << return_expr << ");\n"; + return_flags &= ~RF_pyobject; + } else { indent(out, indent_level) << "if (Dtool_CheckErrorOccurred()) {\n"; @@ -5621,7 +5845,10 @@ write_function_instance(ostream &out, FunctionRemap *remap, // the C++ code was executing, and report this failure back to Python. // Don't do this for coercion constructors since they are called by // other wrapper functions which already check this on their own. - if (watch_asserts && (return_flags & RF_coerced) == 0) { + // Generated getters obviously can't raise asserts. + if (watch_asserts && (return_flags & RF_coerced) == 0 && + remap->_type != FunctionRemap::T_getter && + remap->_type != FunctionRemap::T_setter) { out << "#ifndef NDEBUG\n"; indent(out, indent_level) << "Notify *notify = Notify::ptr();\n"; @@ -5658,10 +5885,10 @@ write_function_instance(ostream &out, FunctionRemap *remap, TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)), false); const InterrogateType &itype = idb->get_type(type_index); indent(out, indent_level) - << "return DTool_PyInit_Finalize(self, " << return_expr << ", &" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) << ", true, false);\n"; + << "return DTool_PyInit_Finalize(self, (void *)" << return_expr << ", &" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) << ", true, false);\n"; } else if (TypeManager::is_integer(orig_type)) { - if (return_flags & RF_compare) { + if ((return_flags & RF_compare) == RF_compare) { // Make sure it returns -1, 0, or 1, or Python complains with: // RuntimeWarning: tp_compare didn't return -1, 0 or 1 indent(out, indent_level) << "return (int)(" << return_expr << " > 0) - (int)(" << return_expr << " < 0);\n"; @@ -5673,7 +5900,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << "return 0;\n"; } else { - cerr << "Warning: function has return type " << *orig_type + nout << "Warning: function has return type " << *orig_type << ", expected int or void:\n" << expected_params << "\n"; indent(out, indent_level) << "// Don't know what to do with return type " << *orig_type << ".\n"; @@ -5723,16 +5950,20 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (return_expr == "coerced") { // We already did this earlier... + indent(out, indent_level) << "return true;\n"; } else if (TypeManager::is_reference_count(remap->_cpptype)) { indent(out, indent_level) << "coerced = MOVE(" << return_expr << ");\n"; + indent(out, indent_level) << "return true;\n"; + + } else if (TypeManager::is_trivial(remap->_cpptype)) { + indent(out, indent_level) << "return &coerced;\n"; } else { indent(out, indent_level) << "coerced = " << return_expr << ";\n"; indent(out, indent_level) << "manage = true;\n"; + indent(out, indent_level) << "return true;\n"; } - - indent(out, indent_level) << "return true;\n"; } // Close the extra braces opened earlier. @@ -5822,7 +6053,8 @@ error_raise_return(ostream &out, int indent_level, int return_flags, out << ");\n"; } - } else if ((return_flags & RF_err_null) != 0) { + } else if ((return_flags & RF_err_null) != 0 && + (return_flags & RF_pyobject) != 0) { // PyErr_Format always returns NULL. Passing it on directly allows // the compiler to make a tiny optimization, so why not. indent(out, indent_level) << "return PyErr_Format(PyExc_" << exc_type << ",\n"; @@ -6046,31 +6278,19 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(type)),false); const InterrogateType &itype = idb->get_type(type_index); - if (!isExportThisRun(itype._cpptype)) { - _external_imports.insert(itype._cpptype); - } - - write_python_instance(out, indent_level, return_expr, owns_memory, itype.get_scoped_name(), itype._cpptype, is_const); + write_python_instance(out, indent_level, return_expr, owns_memory, itype, is_const); } else { TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)),false); const InterrogateType &itype = idb->get_type(type_index); - if (!isExportThisRun(itype._cpptype)) { - _external_imports.insert(itype._cpptype); - } - - write_python_instance(out, indent_level, return_expr, owns_memory, itype.get_scoped_name(), itype._cpptype, is_const); + write_python_instance(out, indent_level, return_expr, owns_memory, itype, is_const); } } else if (TypeManager::is_struct(orig_type->as_pointer_type()->_pointing_at)) { TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)),false); const InterrogateType &itype = idb->get_type(type_index); - if (!isExportThisRun(itype._cpptype)) { - _external_imports.insert(itype._cpptype); - } - - write_python_instance(out, indent_level, return_expr, owns_memory, itype.get_scoped_name(), itype._cpptype, is_const); + write_python_instance(out, indent_level, return_expr, owns_memory, itype, is_const); } else { indent(out, indent_level) << "Should Never Reach This InterfaceMakerPythonNative::pack_python_value"; @@ -6108,7 +6328,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, << " return NULL;\n" << " }\n" << "\n" - << " PyObject *getter = PyObject_GetAttrString(self, \"" << element_name << "\");\n" + << " PyObject *getter = PyDict_GetItemString(Dtool_" << ClassName << "._PyType.tp_dict, \"" << element_name << "\");\n" << " if (getter == (PyObject *)NULL) {\n" << " return NULL;\n" << " }\n" @@ -6122,7 +6342,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, << "#else\n" << " PyObject *index = PyInt_FromSsize_t(i);\n" << "#endif\n" - << " PyObject *value = PyObject_CallFunctionObjArgs(getter, index, NULL);\n" + << " PyObject *value = PyObject_CallFunctionObjArgs(getter, self, index, NULL);\n" << " PyTuple_SET_ITEM(tuple, i, value);\n" << " Py_DECREF(index);\n" << " }\n" @@ -6272,7 +6492,6 @@ record_object(TypeIndex type_index) { //////////////////////////////////////////////////////////////////// void InterfaceMakerPythonNative:: generate_wrappers() { - inside_python_native = true; InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); // We use a while loop rather than a simple for loop, because we @@ -6321,7 +6540,6 @@ generate_wrappers() { record_function(dummy_type, func_index); } } - inside_python_native = false; } ////////////////////////////////////////////// @@ -6497,9 +6715,9 @@ has_coerce_constructor(CPPStructType *type) { } if (ftype->_flags & CPPFunctionType::F_constructor) { - if (params.size() == 1 && - TypeManager::unwrap(params[0]->_type) == type) { - // Skip a copy constructor. + if (ftype->_flags & (CPPFunctionType::F_copy_constructor | + CPPFunctionType::F_move_constructor)) { + // Skip a copy and move constructor. continue; } else { return 2; @@ -6633,36 +6851,19 @@ DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { // does the class have a supportable GetClassType which returns a TypeHandle. ////////////////////////////////////////////////////////////////////////////////////////// bool InterfaceMakerPythonNative:: -HasAGetClassTypeFunction(const InterrogateType &itype_class) { - InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - - int num_methods = itype_class.number_of_methods(); - int mi; - for (mi = 0; mi < num_methods; mi++) { - FunctionIndex func_index = itype_class.get_method(mi); - const InterrogateFunction &ifunc = idb->get_function(func_index); - if (ifunc.get_name() == "get_class_type") { - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { - InterrogateFunction::Instances::const_iterator ii; - for (ii = ifunc._instances->begin();ii != ifunc._instances->end();++ii) { - CPPInstance *cppinst = (*ii).second; - CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - - if (cppfunc != NULL && cppfunc->_return_type != NULL && - cppfunc->_parameters != NULL) { - CPPType *ret_type = TypeManager::unwrap(cppfunc->_return_type); - if (TypeManager::is_struct(ret_type) && - ret_type->get_simple_name() == "TypeHandle") { - if (cppfunc->_parameters->_parameters.size() == 0) { - return true; - } - } - } - } - } - } +HasAGetClassTypeFunction(CPPType *type) { + while (type->get_subtype() == CPPDeclaration::ST_typedef) { + type = type->as_typedef_type()->_type; } - return false; + + CPPStructType *struct_type = type->as_struct_type(); + if (struct_type == NULL) { + return false; + } + + CPPScope *scope = struct_type->get_scope(); + + return scope->_functions.find("get_class_type") != scope->_functions.end(); } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.h b/dtool/src/interrogate/interfaceMakerPythonNative.h index aa3aa5071c..ae62cfc72b 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.h +++ b/dtool/src/interrogate/interfaceMakerPythonNative.h @@ -198,8 +198,8 @@ public: void get_valid_child_classes(std::map &answer, CPPStructType *inclass, const std::string &upcast_seed = "", bool can_downcast = true); bool DoesInheritFromIsClass(const CPPStructType * inclass, const std::string &name); bool IsPandaTypedObject(CPPStructType * inclass) { return DoesInheritFromIsClass(inclass,"TypedObject"); }; - void write_python_instance(ostream &out, int indent_level, const std::string &return_expr, bool owns_memory, const std::string &class_name, CPPType *ctype, bool is_const); - bool HasAGetClassTypeFunction(const InterrogateType &itype_class); + void write_python_instance(ostream &out, int indent_level, const std::string &return_expr, bool owns_memory, const InterrogateType &itype, bool is_const); + bool HasAGetClassTypeFunction(CPPType *type); int NeedsAStrFunction(const InterrogateType &itype_class); int NeedsAReprFunction(const InterrogateType &itype_class); bool NeedsARichCompareFunction(const InterrogateType &itype_class); diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 15abba6ac2..7e7e6e8280 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -550,7 +550,7 @@ main(int argc, char **argv) { output_include << "/*\n" - << " * This file generated by:\n" + << " * This file was generated by:\n" << " * " << command_line << "\n" << " *\n" << " */\n\n"; @@ -572,7 +572,7 @@ main(int argc, char **argv) { output_code << "/*\n" - << " * This file generated by:\n" + << " * This file was generated by:\n" << " * " << command_line << "\n" << " *\n" << " */\n\n"; diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 6e874462f8..e6babb17f7 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -53,7 +53,6 @@ InterrogateBuilder builder; std::string EXPORT_IMPORT_PREFIX; -bool inside_python_native = false; //////////////////////////////////////////////////////////////////// // Function: InterrogateBuilder::add_source_file @@ -1538,6 +1537,12 @@ get_getter(CPPType *expr_type, string expression, assert(expr_type != (CPPType *)NULL); } + // We can't return an array from a function, but we can decay it + // into a pointer. + while (expr_type->get_subtype() == CPPDeclaration::ST_array) { + expr_type = CPPType::new_type(new CPPPointerType(expr_type->as_array_type()->_element_type)); + } + // Make up a CPPFunctionType. CPPParameterList *params = new CPPParameterList; CPPFunctionType *ftype = new CPPFunctionType(expr_type, params, 0); @@ -1912,27 +1917,29 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type) { CPPType *return_type = NULL; CPPFunctionGroup *fgroup = make_property->_getter; - CPPFunctionGroup::Instances::const_iterator fi; - for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { - CPPInstance *function = (*fi); - CPPFunctionType *ftype = - function->_type->as_function_type(); - if (ftype != NULL && ftype->_parameters->_parameters.size() == 0) { - getter = function; - return_type = ftype->_return_type; + if (fgroup != NULL) { + CPPFunctionGroup::Instances::const_iterator fi; + for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { + CPPInstance *function = (*fi); + CPPFunctionType *ftype = + function->_type->as_function_type(); + if (ftype != NULL && ftype->_parameters->_parameters.size() == 0) { + getter = function; + return_type = ftype->_return_type; - // The return type of the non-const method probably better represents - // the type of the property we are creating. - if ((ftype->_flags & CPPFunctionType::F_const_method) == 0) { - break; + // The return type of the non-const method probably better represents + // the type of the property we are creating. + if ((ftype->_flags & CPPFunctionType::F_const_method) == 0) { + break; + } } } - } - if (getter == NULL || return_type == NULL) { - cerr << "No instance of getter '" - << make_property->_getter->_name << "' is suitable!\n"; - return 0; + if (getter == NULL || return_type == NULL) { + cerr << "No instance of getter '" + << fgroup->_name << "' is suitable!\n"; + return 0; + } } InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); @@ -1944,11 +1951,17 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type) { iproperty._name = make_property->get_simple_name(); iproperty._scoped_name = descope(make_property->get_local_name(&parser)); - iproperty._type = get_type(return_type, false); + if (return_type != NULL) { + iproperty._type = get_type(return_type, false); + } else { + iproperty._type = 0; + } - iproperty._flags |= InterrogateElement::F_has_getter; - iproperty._getter = get_function(getter, "", struct_type, - struct_type->get_scope(), 0); + if (getter != NULL) { + iproperty._flags |= InterrogateElement::F_has_getter; + iproperty._getter = get_function(getter, "", struct_type, + struct_type->get_scope(), 0); + } // See if there happens to be a comment before the MAKE_PROPERTY macro. if (make_property->_leading_comment != (CPPCommentBlock *)NULL) { @@ -1958,6 +1971,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type) { // Now look for setters. fgroup = make_property->_setter; if (fgroup != NULL) { + CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); iproperty._flags |= InterrogateElement::F_has_setter; diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 9292f04b02..8f5b39591e 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -25,6 +25,7 @@ #include "panda_getopt_long.h" #include "preprocess_argv.h" #include "pset.h" +#include "vector_string.h" Filename output_code_filename; string module_name; @@ -33,6 +34,7 @@ bool build_c_wrappers = false; bool build_python_wrappers = false; bool build_python_native_wrappers = false; bool track_interpreter = false; +vector_string imports; // Short command-line options. static const char *short_options = ""; @@ -46,6 +48,7 @@ enum CommandOptions { CO_python, CO_python_native, CO_track_interpreter, + CO_import, }; static struct option long_options[] = { @@ -56,6 +59,7 @@ static struct option long_options[] = { { "python", no_argument, NULL, CO_python }, { "python-native", no_argument, NULL, CO_python_native }, { "track-interpreter", no_argument, NULL, CO_track_interpreter }, + { "import", required_argument, NULL, CO_import }, { NULL } }; @@ -91,13 +95,13 @@ int write_python_table_native(ostream &out) { FunctionIndex function_index = interrogate_get_function(fi); // Consider only those that belong in the module we asked for. - if (interrogate_function_has_module_name(function_index) && - module_name == interrogate_function_module_name(function_index)) { + //if (interrogate_function_has_module_name(function_index) && + // module_name == interrogate_function_module_name(function_index)) { // if it has a library name add it to set of libraries if (interrogate_function_has_library_name(function_index)) { libraries.insert(interrogate_function_library_name(function_index)); } - } + //} } for (int ti = 0; ti < interrogate_number_of_types(); ti++) { @@ -113,6 +117,9 @@ int write_python_table_native(ostream &out) { for(ii = libraries.begin(); ii != libraries.end(); ii++) { printf("Referencing Library %s\n", (*ii).c_str()); out << "extern LibraryDef " << *ii << "_moddef;\n"; + out << "extern void Dtool_" << *ii << "_RegisterTypes();\n"; + out << "extern void Dtool_" << *ii << "_ResolveExternals();\n"; + out << "extern void Dtool_" << *ii << "_BuildInstants(PyObject *module);\n"; } out << "\n" @@ -128,6 +135,8 @@ int write_python_table_native(ostream &out) { << "\n" << "#ifdef _WIN32\n" << "extern \"C\" __declspec(dllexport) PyObject *PyInit_" << library_name << "();\n" + << "#elif __GNUC__ >= 4\n" + << "extern \"C\" __attribute__((visibility(\"default\"))) PyObject *PyInit_" << library_name << "();\n" << "#else\n" << "extern \"C\" PyObject *PyInit_" << library_name << "();\n" << "#endif\n" @@ -138,6 +147,19 @@ int write_python_table_native(ostream &out) { out << " in_interpreter = 1;\n"; } + vector_string::const_iterator si; + for (si = imports.begin(); si != imports.end(); ++si) { + out << " PyImport_Import(PyUnicode_FromString(\"" << *si << "\"));\n"; + } + + for (ii = libraries.begin(); ii != libraries.end(); ii++) { + out << " Dtool_" << *ii << "_RegisterTypes();\n"; + } + for (ii = libraries.begin(); ii != libraries.end(); ii++) { + out << " Dtool_" << *ii << "_ResolveExternals();\n"; + } + out << "\n"; + out << " LibraryDef *defs[] = {"; for(ii = libraries.begin(); ii != libraries.end(); ii++) { out << "&" << *ii << "_moddef, "; @@ -145,13 +167,23 @@ int write_python_table_native(ostream &out) { out << "NULL};\n" << "\n" - << " return Dtool_PyModuleInitHelper(defs, &py_" << library_name << "_module);\n" + << " PyObject *module = Dtool_PyModuleInitHelper(defs, &py_" << library_name << "_module);\n" + << " if (module != NULL) {\n"; + + for (ii = libraries.begin(); ii != libraries.end(); ii++) { + out << " Dtool_" << *ii << "_BuildInstants(module);\n"; + } + + out << " }\n" + << " return module;\n" << "}\n" << "\n" << "#else // Python 2 case\n" << "\n" << "#ifdef _WIN32\n" << "extern \"C\" __declspec(dllexport) void init" << library_name << "();\n" + << "#elif __GNUC__ >= 4\n" + << "extern \"C\" __attribute__((visibility(\"default\"))) void init" << library_name << "();\n" << "#else\n" << "extern \"C\" void init" << library_name << "();\n" << "#endif\n" @@ -162,6 +194,18 @@ int write_python_table_native(ostream &out) { out << " in_interpreter = 1;\n"; } + for (si = imports.begin(); si != imports.end(); ++si) { + out << " PyImport_Import(PyUnicode_FromString(\"" << *si << "\"));\n"; + } + + for (ii = libraries.begin(); ii != libraries.end(); ii++) { + out << " Dtool_" << *ii << "_RegisterTypes();\n"; + } + for (ii = libraries.begin(); ii != libraries.end(); ii++) { + out << " Dtool_" << *ii << "_ResolveExternals();\n"; + } + out << "\n"; + out << " LibraryDef *defs[] = {"; for(ii = libraries.begin(); ii != libraries.end(); ii++) { out << "&" << *ii << "_moddef, "; @@ -169,7 +213,14 @@ int write_python_table_native(ostream &out) { out << "NULL};\n" << "\n" - << " Dtool_PyModuleInitHelper(defs, \"" << library_name << "\");\n" + << " PyObject *module = Dtool_PyModuleInitHelper(defs, \"" << module_name << "\");\n" + << " if (module != NULL) {\n"; + + for (ii = libraries.begin(); ii != libraries.end(); ii++) { + out << " Dtool_" << *ii << "_BuildInstants(module);\n"; + } + + out << " }\n" << "}\n" << "#endif\n" << "\n"; @@ -335,6 +386,10 @@ int main(int argc, char *argv[]) { track_interpreter = true; break; + case CO_import: + imports.push_back(optarg); + break; + default: exit(1); } diff --git a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx index bb111935b2..03bb183a0e 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx @@ -13,6 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "parameterRemapBasicStringPtrToString.h" +#include "interrogate.h" //////////////////////////////////////////////////////////////////// // Function: ParameterRemapBasicStringPtrToString::Constructor @@ -23,6 +24,12 @@ ParameterRemapBasicStringPtrToString:: ParameterRemapBasicStringPtrToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { + static CPPType *const_char_star_type = (CPPType *)NULL; + if (const_char_star_type == (CPPType *)NULL) { + const_char_star_type = parser.parse_type("const char *"); + } + + _new_type = const_char_star_type; } //////////////////////////////////////////////////////////////////// @@ -34,7 +41,7 @@ ParameterRemapBasicStringPtrToString(CPPType *orig_type) : //////////////////////////////////////////////////////////////////// void ParameterRemapBasicStringPtrToString:: pass_parameter(ostream &out, const string &variable_name) { - out << "&" << variable_name; + out << "&std::string(" << variable_name << ")"; } //////////////////////////////////////////////////////////////////// @@ -58,6 +65,12 @@ ParameterRemapBasicWStringPtrToWString:: ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) { + static CPPType *const_wchar_star_type = (CPPType *)NULL; + if (const_wchar_star_type == (CPPType *)NULL) { + const_wchar_star_type = parser.parse_type("const wchar_t *"); + } + + _new_type = const_wchar_star_type; } //////////////////////////////////////////////////////////////////// @@ -69,7 +82,7 @@ ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) : //////////////////////////////////////////////////////////////////// void ParameterRemapBasicWStringPtrToWString:: pass_parameter(ostream &out, const string &variable_name) { - out << "&" << variable_name; + out << "&std::wstring(" << variable_name << ")"; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx index 6025d395c6..84962d4bf6 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx @@ -13,6 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "parameterRemapBasicStringRefToString.h" +#include "interrogate.h" //////////////////////////////////////////////////////////////////// // Function: ParameterRemapBasicStringRefToString::Constructor @@ -23,6 +24,12 @@ ParameterRemapBasicStringRefToString:: ParameterRemapBasicStringRefToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { + static CPPType *const_char_star_type = (CPPType *)NULL; + if (const_char_star_type == (CPPType *)NULL) { + const_char_star_type = parser.parse_type("const char *"); + } + + _new_type = const_char_star_type; } //////////////////////////////////////////////////////////////////// @@ -34,7 +41,7 @@ ParameterRemapBasicStringRefToString(CPPType *orig_type) : //////////////////////////////////////////////////////////////////// void ParameterRemapBasicStringRefToString:: pass_parameter(ostream &out, const string &variable_name) { - out << variable_name; + out << "std::string(" << variable_name << ")"; } //////////////////////////////////////////////////////////////////// @@ -58,6 +65,12 @@ ParameterRemapBasicWStringRefToWString:: ParameterRemapBasicWStringRefToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) { + static CPPType *const_wchar_star_type = (CPPType *)NULL; + if (const_wchar_star_type == (CPPType *)NULL) { + const_wchar_star_type = parser.parse_type("const wchar_t *"); + } + + _new_type = const_wchar_star_type; } //////////////////////////////////////////////////////////////////// @@ -69,7 +82,7 @@ ParameterRemapBasicWStringRefToWString(CPPType *orig_type) : //////////////////////////////////////////////////////////////////// void ParameterRemapBasicWStringRefToWString:: pass_parameter(ostream &out, const string &variable_name) { - out << variable_name; + out << "std::wstring(" << variable_name << ")"; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx index 3fdcc44042..8a23083953 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx @@ -14,6 +14,7 @@ #include "parameterRemapBasicStringToString.h" #include "interfaceMaker.h" +#include "interrogate.h" //////////////////////////////////////////////////////////////////// // Function: ParameterRemapBasicStringToString::Constructor @@ -24,6 +25,12 @@ ParameterRemapBasicStringToString:: ParameterRemapBasicStringToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { + static CPPType *const_char_star_type = (CPPType *)NULL; + if (const_char_star_type == (CPPType *)NULL) { + const_char_star_type = parser.parse_type("const char *"); + } + + _new_type = const_char_star_type; } //////////////////////////////////////////////////////////////////// @@ -35,7 +42,7 @@ ParameterRemapBasicStringToString(CPPType *orig_type) : //////////////////////////////////////////////////////////////////// void ParameterRemapBasicStringToString:: pass_parameter(ostream &out, const string &variable_name) { - out << variable_name; + out << "std::string(" << variable_name << ")"; } //////////////////////////////////////////////////////////////////// @@ -73,8 +80,14 @@ get_return_expr(const string &expression) { //////////////////////////////////////////////////////////////////// ParameterRemapBasicWStringToWString:: ParameterRemapBasicWStringToWString(CPPType *orig_type) : - ParameterRemapToString(orig_type) + ParameterRemapToWString(orig_type) { + static CPPType *const_wchar_star_type = (CPPType *)NULL; + if (const_wchar_star_type == (CPPType *)NULL) { + const_wchar_star_type = parser.parse_type("const wchar_t *"); + } + + _new_type = const_wchar_star_type; } //////////////////////////////////////////////////////////////////// @@ -86,7 +99,7 @@ ParameterRemapBasicWStringToWString(CPPType *orig_type) : //////////////////////////////////////////////////////////////////// void ParameterRemapBasicWStringToWString:: pass_parameter(ostream &out, const string &variable_name) { - out << variable_name; + out << "std::wstring(" << variable_name << ")"; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.h b/dtool/src/interrogate/parameterRemapBasicStringToString.h index 877ebad035..63678a8354 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.h +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.h @@ -39,7 +39,7 @@ public: // Description : Maps a concrete basic_string to an atomic // string. //////////////////////////////////////////////////////////////////// -class ParameterRemapBasicWStringToWString : public ParameterRemapToString { +class ParameterRemapBasicWStringToWString : public ParameterRemapToWString { public: ParameterRemapBasicWStringToWString(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapToString.cxx b/dtool/src/interrogate/parameterRemapToString.cxx index 362cd89691..fd41c9bbe3 100644 --- a/dtool/src/interrogate/parameterRemapToString.cxx +++ b/dtool/src/interrogate/parameterRemapToString.cxx @@ -35,7 +35,7 @@ ParameterRemapToString(CPPType *orig_type) : const_char_star_type = parser.parse_type("const char *"); } - if (TypeManager::is_const(orig_type)) { + if (TypeManager::is_const_char_pointer(orig_type) || TypeManager::is_string(orig_type)) { _new_type = const_char_star_type; } else { _new_type = char_star_type; diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index fa78d89664..c8e6dce9c7 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -638,6 +638,40 @@ is_unsigned_char(CPPType *type) { return false; } +//////////////////////////////////////////////////////////////////// +// Function: TypeManager::is_signed_char +// Access: Public, Static +// Description: Returns true if the indicated type is signed char, +// but not unsigned or 'plain' char. +//////////////////////////////////////////////////////////////////// +bool TypeManager:: +is_signed_char(CPPType *type) { + switch (type->get_subtype()) { + case CPPDeclaration::ST_const: + return is_signed_char(type->as_const_type()->_wrapped_around); + + case CPPDeclaration::ST_simple: + { + CPPSimpleType *simple_type = type->as_simple_type(); + + if (simple_type != (CPPSimpleType *)NULL) { + return + (simple_type->_type == CPPSimpleType::T_char) && + (simple_type->_flags & CPPSimpleType::F_signed) != 0; + } + } + break; + + case CPPDeclaration::ST_typedef: + return is_signed_char(type->as_typedef_type()->_type); + + default: + break; + } + + return false; +} + //////////////////////////////////////////////////////////////////// // Function: TypeManager::is_char_pointer // Access: Public, Static @@ -2570,4 +2604,59 @@ is_local(CPPType *source_type) { return false; */ -}; +} + +//////////////////////////////////////////////////////////////////// +// Function: TypeManager::is_trivial +// Access: Public, Static +// Description: Returns true if the type is trivial (or trivial +// enough for our purposes). +//////////////////////////////////////////////////////////////////// +bool TypeManager:: +is_trivial(CPPType *source_type) { + switch (source_type->get_subtype()) { + case CPPDeclaration::ST_const: + return is_trivial(source_type->as_const_type()->_wrapped_around); + + case CPPDeclaration::ST_reference: + return false; + + case CPPDeclaration::ST_pointer: + return true; + + case CPPDeclaration::ST_simple: + return true; + + case CPPDeclaration::ST_typedef: + return is_trivial(source_type->as_typedef_type()->_type); + + default: + if (source_type->is_trivial()) { + return true; + } else { + // This is a bit of a hack. is_trivial() returns false for types that + // have an empty constructor (since we can't use =default yet). + // For the other classes, it's just convenient to consider them trivial + // even if they aren't, since they are simple enough. + string name = source_type->get_simple_name(); + return (name == "ButtonHandle" || name == "DatagramIterator" || + name == "BitMask" || name == "Filename" || name == "pixel" || + name == "NodePath" || name == "LoaderOptions" || + name == "PointerToArray" || name == "ConstPointerToArray" || + name == "PStatThread" || + (name.size() >= 6 && name.substr(0, 6) == "LPlane") || + (name.size() > 6 && name.substr(0, 6) == "LPoint") || + (name.size() > 7 && name.substr(0, 7) == "LVector") || + (name.size() > 7 && name.substr(0, 7) == "LMatrix") || + (name.size() > 8 && name.substr(0, 8) == "LVecBase") || + (name.size() >= 9 && name.substr(0, 9) == "LParabola") || + (name.size() >= 9 && name.substr(0, 9) == "LRotation") || + (name.size() >= 11 && name.substr(0, 11) == "LQuaternion") || + (name.size() >= 12 && name.substr(0, 12) == "LOrientation") || + (name.size() > 16 && name.substr(0, 16) == "UnalignedLMatrix") || + (name.size() > 17 && name.substr(0, 17) == "UnalignedLVecBase")); + } + } + + return false; +} diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index 16b9dfda22..29b29eb2c7 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/dtool/src/interrogate/typeManager.h @@ -67,6 +67,7 @@ public: static bool is_pointable(CPPType *type); static bool is_char(CPPType *type); static bool is_unsigned_char(CPPType *type); + static bool is_signed_char(CPPType *type); static bool is_char_pointer(CPPType *type); static bool is_const_char_pointer(CPPType *type); static bool is_unsigned_char_pointer(CPPType *type); @@ -146,7 +147,7 @@ public: static bool is_exported(CPPType *type); static bool is_local(CPPType *type); - + static bool is_trivial(CPPType *type); }; #endif diff --git a/dtool/src/interrogatedb/config_interrogatedb.h b/dtool/src/interrogatedb/config_interrogatedb.h index e088787b9d..6dd0995532 100644 --- a/dtool/src/interrogatedb/config_interrogatedb.h +++ b/dtool/src/interrogatedb/config_interrogatedb.h @@ -19,7 +19,7 @@ #include "notifyCategoryProxy.h" #include "configVariableSearchPath.h" -NotifyCategoryDecl(interrogatedb, EXPCL_DTOOLCONFIG, EXPTP_DTOOLCONFIG); +NotifyCategoryDecl(interrogatedb, EXPCL_INTERROGATEDB, EXPTP_INTERROGATEDB); extern ConfigVariableSearchPath interrogatedb_path; diff --git a/dtool/src/interrogatedb/dtool_super_base.cxx b/dtool/src/interrogatedb/dtool_super_base.cxx index d695fb5ef5..7cdcd21221 100644 --- a/dtool/src/interrogatedb/dtool_super_base.cxx +++ b/dtool/src/interrogatedb/dtool_super_base.cxx @@ -21,7 +21,7 @@ class EmptyClass { Define_Module_Class_Private(dtoolconfig, DTOOL_SUPER_BASE, EmptyClass, DTOOL_SUPER_BASE111); static PyObject *GetSuperBase(PyObject *self) { - Py_INCREF(&(Dtool_DTOOL_SUPER_BASE.As_PyTypeObject())); // order is important .. this is used for static functions + Py_INCREF((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE); // order is important .. this is used for static functions return (PyObject *) &Dtool_DTOOL_SUPER_BASE; }; @@ -30,26 +30,26 @@ PyMethodDef Dtool_Methods_DTOOL_SUPER_BASE[] = { { NULL, NULL } }; -EXPCL_DTOOLCONFIG void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module) { +EXPCL_INTERROGATEDB void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module) { static bool initdone = false; if (!initdone) { initdone = true; - Dtool_DTOOL_SUPER_BASE.As_PyTypeObject().tp_dict = PyDict_New(); - PyDict_SetItemString(Dtool_DTOOL_SUPER_BASE.As_PyTypeObject().tp_dict, "DtoolClassDict", Dtool_DTOOL_SUPER_BASE.As_PyTypeObject().tp_dict); + Dtool_DTOOL_SUPER_BASE._PyType.tp_dict = PyDict_New(); + PyDict_SetItemString(Dtool_DTOOL_SUPER_BASE._PyType.tp_dict, "DtoolClassDict", Dtool_DTOOL_SUPER_BASE._PyType.tp_dict); - if (PyType_Ready(&Dtool_DTOOL_SUPER_BASE.As_PyTypeObject()) < 0) { + if (PyType_Ready((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE) < 0) { PyErr_SetString(PyExc_TypeError, "PyType_Ready(Dtool_DTOOL_SUPER_BASE)"); return; } - Py_INCREF(&Dtool_DTOOL_SUPER_BASE.As_PyTypeObject()); + Py_INCREF((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE); - PyDict_SetItemString(Dtool_DTOOL_SUPER_BASE.As_PyTypeObject().tp_dict, "DtoolGetSuperBase", PyCFunction_New(&Dtool_Methods_DTOOL_SUPER_BASE[0], &Dtool_DTOOL_SUPER_BASE.As_PyObject())); + PyDict_SetItemString(Dtool_DTOOL_SUPER_BASE._PyType.tp_dict, "DtoolGetSuperBase", PyCFunction_New(&Dtool_Methods_DTOOL_SUPER_BASE[0], (PyObject *)&Dtool_DTOOL_SUPER_BASE)); } if (module != NULL) { - Py_INCREF(&Dtool_DTOOL_SUPER_BASE.As_PyTypeObject()); - PyModule_AddObject(module, "DTOOL_SUPER_BASE", (PyObject *)&Dtool_DTOOL_SUPER_BASE.As_PyTypeObject()); + Py_INCREF((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE); + PyModule_AddObject(module, "DTOOL_SUPER_BASE", (PyObject *)&Dtool_DTOOL_SUPER_BASE); } } @@ -123,9 +123,12 @@ EXPORT_THIS Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE = { 0, 0, }, + TypeHandle::none(), + Dtool_PyModuleClassInit_DTOOL_SUPER_BASE, Dtool_UpcastInterface_DTOOL_SUPER_BASE, Dtool_DowncastInterface_DTOOL_SUPER_BASE, - TypeHandle::none(), + NULL, + NULL, }; #endif // HAVE_PYTHON diff --git a/dtool/src/interrogatedb/extension.h b/dtool/src/interrogatedb/extension.h index 0d41ef2c60..57728f98bf 100644 --- a/dtool/src/interrogatedb/extension.h +++ b/dtool/src/interrogatedb/extension.h @@ -24,7 +24,7 @@ // be used from the extension method. //////////////////////////////////////////////////////////////////// template -class EXPCL_DTOOLCONFIG ExtensionBase { +class EXPCL_INTERROGATEDB ExtensionBase { public: T * _this; }; @@ -36,7 +36,7 @@ public: // a specialization of this class template. //////////////////////////////////////////////////////////////////// template -class EXPCL_DTOOLCONFIG Extension : public ExtensionBase { +class EXPCL_INTERROGATEDB Extension : public ExtensionBase { }; //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/interrogatedb/indexRemapper.h b/dtool/src/interrogatedb/indexRemapper.h index da2efc023f..61aa67ccc5 100644 --- a/dtool/src/interrogatedb/indexRemapper.h +++ b/dtool/src/interrogatedb/indexRemapper.h @@ -30,7 +30,7 @@ // only reason it exists is because Microsoft can't // export STL map outside of the DLL. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG IndexRemapper { +class EXPCL_INTERROGATEDB IndexRemapper { public: IndexRemapper(); ~IndexRemapper(); diff --git a/dtool/src/interrogatedb/interrogateComponent.h b/dtool/src/interrogatedb/interrogateComponent.h index 6ad6bcd806..e1820806d3 100644 --- a/dtool/src/interrogatedb/interrogateComponent.h +++ b/dtool/src/interrogatedb/interrogateComponent.h @@ -30,7 +30,7 @@ class IndexRemapper; // interrogate database. This includes types, // functions, and function wrappers. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG InterrogateComponent { +class EXPCL_INTERROGATEDB InterrogateComponent { public: INLINE InterrogateComponent(InterrogateModuleDef *def = NULL); INLINE InterrogateComponent(const InterrogateComponent ©); diff --git a/dtool/src/interrogatedb/interrogateDatabase.h b/dtool/src/interrogatedb/interrogateDatabase.h index 8a6a313802..893fa23ba4 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.h +++ b/dtool/src/interrogatedb/interrogateDatabase.h @@ -35,7 +35,7 @@ class IndexRemapper; // Description : This stores all of the interrogate data and handles // reading the data from a disk file when necessary. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG InterrogateDatabase { +class EXPCL_INTERROGATEDB InterrogateDatabase { private: InterrogateDatabase(); diff --git a/dtool/src/interrogatedb/interrogateElement.h b/dtool/src/interrogatedb/interrogateElement.h index 863e502545..52d4f25b28 100644 --- a/dtool/src/interrogatedb/interrogateElement.h +++ b/dtool/src/interrogatedb/interrogateElement.h @@ -26,7 +26,7 @@ class IndexRemapper; // Description : An internal representation of a data element, like a // data member or a global variable. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG InterrogateElement : public InterrogateComponent { +class EXPCL_INTERROGATEDB InterrogateElement : public InterrogateComponent { public: INLINE InterrogateElement(InterrogateModuleDef *def = NULL); INLINE InterrogateElement(const InterrogateElement ©); diff --git a/dtool/src/interrogatedb/interrogateFunction.h b/dtool/src/interrogatedb/interrogateFunction.h index 676eb53cf7..04132814f8 100644 --- a/dtool/src/interrogatedb/interrogateFunction.h +++ b/dtool/src/interrogatedb/interrogateFunction.h @@ -29,7 +29,7 @@ class CPPInstance; // Class : InterrogateFunction // Description : An internal representation of a function. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG InterrogateFunction : public InterrogateComponent { +class EXPCL_INTERROGATEDB InterrogateFunction : public InterrogateComponent { public: InterrogateFunction(InterrogateModuleDef *def = NULL); InterrogateFunction(const InterrogateFunction ©); diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.h b/dtool/src/interrogatedb/interrogateFunctionWrapper.h index 4eeae4d600..282b989961 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.h +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.h @@ -27,7 +27,7 @@ class IndexRemapper; // Class : InterrogateFunctionWrapper // Description : An internal representation of a callable function. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG InterrogateFunctionWrapper : public InterrogateComponent { +class EXPCL_INTERROGATEDB InterrogateFunctionWrapper : public InterrogateComponent { public: INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = NULL); INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper ©); diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.h b/dtool/src/interrogatedb/interrogateMakeSeq.h index 5ce472d4bf..bd991f71ca 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.h +++ b/dtool/src/interrogatedb/interrogateMakeSeq.h @@ -26,7 +26,7 @@ class IndexRemapper; // Description : Represents a synthetic method created via the // MAKE_SEQ() macro. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG InterrogateMakeSeq : public InterrogateComponent { +class EXPCL_INTERROGATEDB InterrogateMakeSeq : public InterrogateComponent { public: INLINE InterrogateMakeSeq(InterrogateModuleDef *def = NULL); INLINE InterrogateMakeSeq(const InterrogateMakeSeq ©); diff --git a/dtool/src/interrogatedb/interrogateManifest.h b/dtool/src/interrogatedb/interrogateManifest.h index d6d5d00192..4011868953 100644 --- a/dtool/src/interrogatedb/interrogateManifest.h +++ b/dtool/src/interrogatedb/interrogateManifest.h @@ -25,7 +25,7 @@ class IndexRemapper; // Class : InterrogateManifest // Description : An internal representation of a manifest constant. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG InterrogateManifest : public InterrogateComponent { +class EXPCL_INTERROGATEDB InterrogateManifest : public InterrogateComponent { public: INLINE InterrogateManifest(InterrogateModuleDef *def = NULL); INLINE InterrogateManifest(const InterrogateManifest ©); diff --git a/dtool/src/interrogatedb/interrogateType.cxx b/dtool/src/interrogatedb/interrogateType.cxx index 3c69995c99..d0ce756fa4 100644 --- a/dtool/src/interrogatedb/interrogateType.cxx +++ b/dtool/src/interrogatedb/interrogateType.cxx @@ -269,23 +269,3 @@ remap_indices(const IndexRemapper &remap) { } } - - -//////////////////////////////////////////////////////////////////// -// Function: GetRunTimeDictionary -//////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG RunTimeTypeDictionary & GetRunTimeDictionary() -{ - static RunTimeTypeDictionary dict; - return dict; -}; - -//////////////////////////////////////////////////////////////////// -// Function: GetRunTimeTypeList -//////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG RunTimeTypeList & GetRunTimeTypeList() -{ - static RunTimeTypeList list; - return list; -}; - diff --git a/dtool/src/interrogatedb/interrogateType.h b/dtool/src/interrogatedb/interrogateType.h index 8abf807f02..5a6a88b311 100644 --- a/dtool/src/interrogatedb/interrogateType.h +++ b/dtool/src/interrogatedb/interrogateType.h @@ -29,7 +29,7 @@ class CPPScope; // Class : InterrogateType // Description : An internal representation of a type. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG InterrogateType : public InterrogateComponent { +class EXPCL_INTERROGATEDB InterrogateType : public InterrogateComponent { public: InterrogateType(InterrogateModuleDef *def = NULL); InterrogateType(const InterrogateType ©); @@ -231,14 +231,4 @@ INLINE istream &operator >> (istream &in, InterrogateType::EnumValue &d); #include "interrogateType.I" -#include -#include -struct Dtool_PyTypedObject; -typedef std::map< int , Dtool_PyTypedObject *> RunTimeTypeDictionary; -typedef std::set RunTimeTypeList; - -EXPCL_DTOOLCONFIG RunTimeTypeDictionary & GetRunTimeDictionary(); -EXPCL_DTOOLCONFIG RunTimeTypeList & GetRunTimeTypeList(); - - #endif diff --git a/dtool/src/interrogatedb/interrogate_interface.h b/dtool/src/interrogatedb/interrogate_interface.h index c1e615556f..9cbe879339 100644 --- a/dtool/src/interrogatedb/interrogate_interface.h +++ b/dtool/src/interrogatedb/interrogate_interface.h @@ -87,9 +87,9 @@ enum AtomicToken { AT_longlong = 8 }; -EXPCL_DTOOLCONFIG void interrogate_add_search_directory(const char *dirname); -EXPCL_DTOOLCONFIG void interrogate_add_search_path(const char *pathstring); -EXPCL_DTOOLCONFIG bool interrogate_error_flag(); +EXPCL_INTERROGATEDB void interrogate_add_search_directory(const char *dirname); +EXPCL_INTERROGATEDB void interrogate_add_search_path(const char *pathstring); +EXPCL_INTERROGATEDB bool interrogate_error_flag(); ////////////////////////////////////////////////////////////////////////// // @@ -107,23 +107,23 @@ EXPCL_DTOOLCONFIG bool interrogate_error_flag(); // (whatever type interrogate thinks it is), as returned by the getter // function given by interrogate_manifest_getter(). -EXPCL_DTOOLCONFIG int interrogate_number_of_manifests(); -EXPCL_DTOOLCONFIG ManifestIndex interrogate_get_manifest(int n); -EXPCL_DTOOLCONFIG ManifestIndex interrogate_get_manifest_by_name(const char *manifest_name); -EXPCL_DTOOLCONFIG const char *interrogate_manifest_name(ManifestIndex manifest); -EXPCL_DTOOLCONFIG const char *interrogate_manifest_definition(ManifestIndex manifest); -EXPCL_DTOOLCONFIG bool interrogate_manifest_has_type(ManifestIndex manifest); -EXPCL_DTOOLCONFIG TypeIndex interrogate_manifest_get_type(ManifestIndex manifest); -EXPCL_DTOOLCONFIG bool interrogate_manifest_has_getter(ManifestIndex manifest); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_manifest_getter(ManifestIndex manifest); +EXPCL_INTERROGATEDB int interrogate_number_of_manifests(); +EXPCL_INTERROGATEDB ManifestIndex interrogate_get_manifest(int n); +EXPCL_INTERROGATEDB ManifestIndex interrogate_get_manifest_by_name(const char *manifest_name); +EXPCL_INTERROGATEDB const char *interrogate_manifest_name(ManifestIndex manifest); +EXPCL_INTERROGATEDB const char *interrogate_manifest_definition(ManifestIndex manifest); +EXPCL_INTERROGATEDB bool interrogate_manifest_has_type(ManifestIndex manifest); +EXPCL_INTERROGATEDB TypeIndex interrogate_manifest_get_type(ManifestIndex manifest); +EXPCL_INTERROGATEDB bool interrogate_manifest_has_getter(ManifestIndex manifest); +EXPCL_INTERROGATEDB FunctionIndex interrogate_manifest_getter(ManifestIndex manifest); // An exception is made for manifest constants that have an integer // type value, since these are so common. The scripting language can // query these values directly, which saves having to generate a // wrapper function for each stupid little manifest. In this case, // there will be no getter function available. -EXPCL_DTOOLCONFIG bool interrogate_manifest_has_int_value(ManifestIndex manifest); -EXPCL_DTOOLCONFIG int interrogate_manifest_get_int_value(ManifestIndex manifest); +EXPCL_INTERROGATEDB bool interrogate_manifest_has_int_value(ManifestIndex manifest); +EXPCL_INTERROGATEDB int interrogate_manifest_get_int_value(ManifestIndex manifest); ////////////////////////////////////////////////////////////////////////// @@ -136,12 +136,12 @@ EXPCL_DTOOLCONFIG int interrogate_manifest_get_int_value(ManifestIndex manifest) // elements. Interrogate automatically generates a getter function // and, if possible, a setter function. -EXPCL_DTOOLCONFIG const char *interrogate_element_name(ElementIndex element); -EXPCL_DTOOLCONFIG const char *interrogate_element_scoped_name(ElementIndex element); -EXPCL_DTOOLCONFIG bool interrogate_element_has_comment(ElementIndex element); -EXPCL_DTOOLCONFIG const char *interrogate_element_comment(ElementIndex element); -EXPCL_DTOOLCONFIG ElementIndex interrogate_get_element_by_name(const char *element_name); -EXPCL_DTOOLCONFIG ElementIndex interrogate_get_element_by_scoped_name(const char *element_name); +EXPCL_INTERROGATEDB const char *interrogate_element_name(ElementIndex element); +EXPCL_INTERROGATEDB const char *interrogate_element_scoped_name(ElementIndex element); +EXPCL_INTERROGATEDB bool interrogate_element_has_comment(ElementIndex element); +EXPCL_INTERROGATEDB const char *interrogate_element_comment(ElementIndex element); +EXPCL_INTERROGATEDB ElementIndex interrogate_get_element_by_name(const char *element_name); +EXPCL_INTERROGATEDB ElementIndex interrogate_get_element_by_scoped_name(const char *element_name); // Be careful with this function. The element's bare type is not // likely to be directly useful to the scripting language. This is a @@ -151,12 +151,12 @@ EXPCL_DTOOLCONFIG ElementIndex interrogate_get_element_by_scoped_name(const char // scripting language can't handle directly, e.g. a Node, while the // getter will return (and the setter accept) a pointer to a Node, // which is what the scripting language actually works with. -EXPCL_DTOOLCONFIG TypeIndex interrogate_element_type(ElementIndex element); +EXPCL_INTERROGATEDB TypeIndex interrogate_element_type(ElementIndex element); -EXPCL_DTOOLCONFIG bool interrogate_element_has_getter(ElementIndex element); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_element_getter(ElementIndex element); -EXPCL_DTOOLCONFIG bool interrogate_element_has_setter(ElementIndex element); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_element_setter(ElementIndex element); +EXPCL_INTERROGATEDB bool interrogate_element_has_getter(ElementIndex element); +EXPCL_INTERROGATEDB FunctionIndex interrogate_element_getter(ElementIndex element); +EXPCL_INTERROGATEDB bool interrogate_element_has_setter(ElementIndex element); +EXPCL_INTERROGATEDB FunctionIndex interrogate_element_setter(ElementIndex element); ////////////////////////////////////////////////////////////////////////// // @@ -166,8 +166,8 @@ EXPCL_DTOOLCONFIG FunctionIndex interrogate_element_setter(ElementIndex element) // This is the list of global data elements. -EXPCL_DTOOLCONFIG int interrogate_number_of_globals(); -EXPCL_DTOOLCONFIG ElementIndex interrogate_get_global(int n); +EXPCL_INTERROGATEDB int interrogate_number_of_globals(); +EXPCL_INTERROGATEDB ElementIndex interrogate_get_global(int n); ////////////////////////////////////////////////////////////////////////// // @@ -183,16 +183,16 @@ EXPCL_DTOOLCONFIG ElementIndex interrogate_get_global(int n); // These are the global (nonmember) functions that appear outside of // any class definition. -EXPCL_DTOOLCONFIG int interrogate_number_of_global_functions(); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_get_global_function(int n); +EXPCL_INTERROGATEDB int interrogate_number_of_global_functions(); +EXPCL_INTERROGATEDB FunctionIndex interrogate_get_global_function(int n); // This can be used to traverse through *all* the functions known to // interrogate. It's usually not what you want, since this includes // global functions, class methods, and synthesized functions like // upcasts and downcasts. You probably want to use instead // interrogate_number_of_global_functions(), above. -EXPCL_DTOOLCONFIG int interrogate_number_of_functions(); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_get_function(int n); +EXPCL_INTERROGATEDB int interrogate_number_of_functions(); +EXPCL_INTERROGATEDB FunctionIndex interrogate_get_function(int n); // This is the function's name. It is not unique; it may be shared // between multiple different functions that have the same name but @@ -200,42 +200,42 @@ EXPCL_DTOOLCONFIG FunctionIndex interrogate_get_function(int n); // Two different classes might also have member functions that have // the same name, or the same name as a global function (but also see // the scoped_name, below). -EXPCL_DTOOLCONFIG const char *interrogate_function_name(FunctionIndex function); +EXPCL_INTERROGATEDB const char *interrogate_function_name(FunctionIndex function); // The scoped name is the function name prefixed with the name of the // class that includes the function, if the function is a class // method. If it is a global function, the scoped name is the same as // the name returned above. In the absence of C++ function // overloading, this name will be unique to each function. -EXPCL_DTOOLCONFIG const char *interrogate_function_scoped_name(FunctionIndex function); +EXPCL_INTERROGATEDB const char *interrogate_function_scoped_name(FunctionIndex function); // This returns the C++ comment written for the function, either in // the header file or in the .C file, or both. -EXPCL_DTOOLCONFIG bool interrogate_function_has_comment(FunctionIndex function); -EXPCL_DTOOLCONFIG const char *interrogate_function_comment(FunctionIndex function); +EXPCL_INTERROGATEDB bool interrogate_function_has_comment(FunctionIndex function); +EXPCL_INTERROGATEDB const char *interrogate_function_comment(FunctionIndex function); // This defines the function prototype as it appears in the C++ // source, useful primarily for documentation purposes. -EXPCL_DTOOLCONFIG const char *interrogate_function_prototype(FunctionIndex function); +EXPCL_INTERROGATEDB const char *interrogate_function_prototype(FunctionIndex function); // This can be used to determine the class that the function is a // method for, if the function is a class method. -EXPCL_DTOOLCONFIG bool interrogate_function_is_method(FunctionIndex function); -EXPCL_DTOOLCONFIG TypeIndex interrogate_function_class(FunctionIndex function); +EXPCL_INTERROGATEDB bool interrogate_function_is_method(FunctionIndex function); +EXPCL_INTERROGATEDB TypeIndex interrogate_function_class(FunctionIndex function); // This returns the module name reported for the function, if // available. -EXPCL_DTOOLCONFIG bool interrogate_function_has_module_name(FunctionIndex function); -EXPCL_DTOOLCONFIG const char *interrogate_function_module_name(FunctionIndex function); +EXPCL_INTERROGATEDB bool interrogate_function_has_module_name(FunctionIndex function); +EXPCL_INTERROGATEDB const char *interrogate_function_module_name(FunctionIndex function); // This returns the library name reported for the function, if // available. -EXPCL_DTOOLCONFIG bool interrogate_function_has_library_name(FunctionIndex function); -EXPCL_DTOOLCONFIG const char *interrogate_function_library_name(FunctionIndex function); +EXPCL_INTERROGATEDB bool interrogate_function_has_library_name(FunctionIndex function); +EXPCL_INTERROGATEDB const char *interrogate_function_library_name(FunctionIndex function); // This is true for virtual member functions. It's not likely that // this will be important to the scripting language. -EXPCL_DTOOLCONFIG bool interrogate_function_is_virtual(FunctionIndex function); +EXPCL_INTERROGATEDB bool interrogate_function_is_virtual(FunctionIndex function); // The actual callable function interface is defined via one or more @@ -246,11 +246,11 @@ EXPCL_DTOOLCONFIG bool interrogate_function_is_virtual(FunctionIndex function); // calling convention or the Python calling convention. The set of // wrappers that will actually be available depends on the parameters // passed to the interrogate command line. -EXPCL_DTOOLCONFIG int interrogate_function_number_of_c_wrappers(FunctionIndex function); -EXPCL_DTOOLCONFIG FunctionWrapperIndex interrogate_function_c_wrapper(FunctionIndex function, int n); +EXPCL_INTERROGATEDB int interrogate_function_number_of_c_wrappers(FunctionIndex function); +EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_c_wrapper(FunctionIndex function, int n); -EXPCL_DTOOLCONFIG int interrogate_function_number_of_python_wrappers(FunctionIndex function); -EXPCL_DTOOLCONFIG FunctionWrapperIndex interrogate_function_python_wrapper(FunctionIndex function, int n); +EXPCL_INTERROGATEDB int interrogate_function_number_of_python_wrappers(FunctionIndex function); +EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_python_wrapper(FunctionIndex function, int n); ////////////////////////////////////////////////////////////////////////// // @@ -273,17 +273,17 @@ EXPCL_DTOOLCONFIG FunctionWrapperIndex interrogate_function_python_wrapper(Funct // Don't confuse this with the unique_name, below. The two are // related, but not identical. -EXPCL_DTOOLCONFIG const char *interrogate_wrapper_name(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB const char *interrogate_wrapper_name(FunctionWrapperIndex wrapper); // This returns true if -fnames was given to interrogate, making the // wrapper function callable directly by its name. -EXPCL_DTOOLCONFIG bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper); // This returns the C++ comment written for the function wrapper, // usually from the .cpp file. There may be a different comment for // each overload of a given function. -EXPCL_DTOOLCONFIG bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper); -EXPCL_DTOOLCONFIG const char *interrogate_wrapper_comment(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB const char *interrogate_wrapper_comment(FunctionWrapperIndex wrapper); // Every function wrapper has zero or more parameters and may or may // not have a return value. Each parameter has a type and may or may @@ -293,8 +293,8 @@ EXPCL_DTOOLCONFIG const char *interrogate_wrapper_comment(FunctionWrapperIndex w // its first parameter, it is a static member function, also called a // class method.) -EXPCL_DTOOLCONFIG bool interrogate_wrapper_has_return_value(FunctionWrapperIndex wrapper); -EXPCL_DTOOLCONFIG TypeIndex interrogate_wrapper_return_type(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB bool interrogate_wrapper_has_return_value(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB TypeIndex interrogate_wrapper_return_type(FunctionWrapperIndex wrapper); // Sometimes interrogate must synthesize a wrapper that allocates its // return value from the free store. Other times (especially if @@ -309,15 +309,15 @@ EXPCL_DTOOLCONFIG TypeIndex interrogate_wrapper_return_type(FunctionWrapperIndex // that for the class). Otherwise, this function will return false, // and the scripting language should *not* call any destructor on this // value. -EXPCL_DTOOLCONFIG bool interrogate_wrapper_caller_manages_return_value(FunctionWrapperIndex wrapper); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_wrapper_return_value_destructor(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB bool interrogate_wrapper_caller_manages_return_value(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB FunctionIndex interrogate_wrapper_return_value_destructor(FunctionWrapperIndex wrapper); // These define the parameters of the function. -EXPCL_DTOOLCONFIG int interrogate_wrapper_number_of_parameters(FunctionWrapperIndex wrapper); -EXPCL_DTOOLCONFIG TypeIndex interrogate_wrapper_parameter_type(FunctionWrapperIndex wrapper, int n); -EXPCL_DTOOLCONFIG bool interrogate_wrapper_parameter_has_name(FunctionWrapperIndex wrapper, int n); -EXPCL_DTOOLCONFIG const char *interrogate_wrapper_parameter_name(FunctionWrapperIndex wrapper, int n); -EXPCL_DTOOLCONFIG bool interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n); +EXPCL_INTERROGATEDB int interrogate_wrapper_number_of_parameters(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB TypeIndex interrogate_wrapper_parameter_type(FunctionWrapperIndex wrapper, int n); +EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_has_name(FunctionWrapperIndex wrapper, int n); +EXPCL_INTERROGATEDB const char *interrogate_wrapper_parameter_name(FunctionWrapperIndex wrapper, int n); +EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n); // This returns a pointer to a function that may be called to invoke // the function, if the -fptrs option to return function pointers was @@ -327,8 +327,8 @@ EXPCL_DTOOLCONFIG bool interrogate_wrapper_parameter_is_this(FunctionWrapperInde // These two functions may be called without forcing a load of the // complete interrogate database. -EXPCL_DTOOLCONFIG bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper); -EXPCL_DTOOLCONFIG void *interrogate_wrapper_pointer(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB void *interrogate_wrapper_pointer(FunctionWrapperIndex wrapper); // This function will return a name that is guaranteed to be unique to // this particular function wrapper, and that will (usually) be @@ -339,7 +339,7 @@ EXPCL_DTOOLCONFIG void *interrogate_wrapper_pointer(FunctionWrapperIndex wrapper // The unique name is an ugly hashed name, not safe for human // consumption. Its sole purpose is to provide some consistent way to // identify function wrappers between sessions. -EXPCL_DTOOLCONFIG const char *interrogate_wrapper_unique_name(FunctionWrapperIndex wrapper); +EXPCL_INTERROGATEDB const char *interrogate_wrapper_unique_name(FunctionWrapperIndex wrapper); // This function provides a reverse-lookup on the above unique name, // returning the wrapper index corresponding to the given name. It @@ -349,7 +349,7 @@ EXPCL_DTOOLCONFIG const char *interrogate_wrapper_unique_name(FunctionWrapperInd // This function may be called without forcing a load of the complete // interrogate database. -EXPCL_DTOOLCONFIG FunctionWrapperIndex interrogate_get_wrapper_by_unique_name(const char *unique_name); +EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_get_wrapper_by_unique_name(const char *unique_name); ////////////////////////////////////////////////////////////////////////// // @@ -364,14 +364,14 @@ EXPCL_DTOOLCONFIG FunctionWrapperIndex interrogate_get_wrapper_by_unique_name(co // get_things(). // The class of which the make_seq is a method. -EXPCL_DTOOLCONFIG TypeIndex interrogate_make_seq_class(MakeSeqIndex make_seq); +EXPCL_INTERROGATEDB TypeIndex interrogate_make_seq_class(MakeSeqIndex make_seq); // The name of the syntheized method, e.g. "get_things" -EXPCL_DTOOLCONFIG const char *interrogate_make_seq_seq_name(MakeSeqIndex make_seq); +EXPCL_INTERROGATEDB const char *interrogate_make_seq_seq_name(MakeSeqIndex make_seq); // The name of the real method that returns the length, e.g. "get_num_things" -EXPCL_DTOOLCONFIG const char *interrogate_make_seq_num_name(MakeSeqIndex make_seq); +EXPCL_INTERROGATEDB const char *interrogate_make_seq_num_name(MakeSeqIndex make_seq); // The name of the real method that returns the nth element, e.g. "get_thing" -EXPCL_DTOOLCONFIG const char *interrogate_make_seq_element_name(MakeSeqIndex make_seq); +EXPCL_INTERROGATEDB const char *interrogate_make_seq_element_name(MakeSeqIndex make_seq); ////////////////////////////////////////////////////////////////////////// @@ -393,16 +393,16 @@ EXPCL_DTOOLCONFIG const char *interrogate_make_seq_element_name(MakeSeqIndex mak // classes. These types are necessary to fully define all of the // function parameters, but need not themselves be wrapped. -EXPCL_DTOOLCONFIG int interrogate_number_of_global_types(); -EXPCL_DTOOLCONFIG TypeIndex interrogate_get_global_type(int n); -EXPCL_DTOOLCONFIG int interrogate_number_of_types(); -EXPCL_DTOOLCONFIG TypeIndex interrogate_get_type(int n); -EXPCL_DTOOLCONFIG TypeIndex interrogate_get_type_by_name(const char *type_name); -EXPCL_DTOOLCONFIG TypeIndex interrogate_get_type_by_scoped_name(const char *type_name); -EXPCL_DTOOLCONFIG TypeIndex interrogate_get_type_by_true_name(const char *type_name); -EXPCL_DTOOLCONFIG const char *interrogate_type_name(TypeIndex type); -EXPCL_DTOOLCONFIG const char *interrogate_type_scoped_name(TypeIndex type); -EXPCL_DTOOLCONFIG const char *interrogate_type_true_name(TypeIndex type); +EXPCL_INTERROGATEDB int interrogate_number_of_global_types(); +EXPCL_INTERROGATEDB TypeIndex interrogate_get_global_type(int n); +EXPCL_INTERROGATEDB int interrogate_number_of_types(); +EXPCL_INTERROGATEDB TypeIndex interrogate_get_type(int n); +EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_name(const char *type_name); +EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_scoped_name(const char *type_name); +EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_true_name(const char *type_name); +EXPCL_INTERROGATEDB const char *interrogate_type_name(TypeIndex type); +EXPCL_INTERROGATEDB const char *interrogate_type_scoped_name(TypeIndex type); +EXPCL_INTERROGATEDB const char *interrogate_type_true_name(TypeIndex type); // A given type might be a nested type, meaning it is entirely defined // within (and scoped within) some different C++ class. In this case, @@ -410,32 +410,32 @@ EXPCL_DTOOLCONFIG const char *interrogate_type_true_name(TypeIndex type); // within the class, while the scoped_name() will return the // fully-qualified name of the type, and is_nested() and outer_class() // can be used to determine the class it is nested within. -EXPCL_DTOOLCONFIG bool interrogate_type_is_nested(TypeIndex type); -EXPCL_DTOOLCONFIG TypeIndex interrogate_type_outer_class(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_nested(TypeIndex type); +EXPCL_INTERROGATEDB TypeIndex interrogate_type_outer_class(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_has_comment(TypeIndex type); -EXPCL_DTOOLCONFIG const char *interrogate_type_comment(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_has_comment(TypeIndex type); +EXPCL_INTERROGATEDB const char *interrogate_type_comment(TypeIndex type); // This returns the module name reported for the type, if available. -EXPCL_DTOOLCONFIG bool interrogate_type_has_module_name(TypeIndex type); -EXPCL_DTOOLCONFIG const char *interrogate_type_module_name(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_has_module_name(TypeIndex type); +EXPCL_INTERROGATEDB const char *interrogate_type_module_name(TypeIndex type); // This returns the library name reported for the type, if available. -EXPCL_DTOOLCONFIG bool interrogate_type_has_library_name(TypeIndex type); -EXPCL_DTOOLCONFIG const char *interrogate_type_library_name(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_has_library_name(TypeIndex type); +EXPCL_INTERROGATEDB const char *interrogate_type_library_name(TypeIndex type); // If interrogate_type_is_atomic() returns true, the type is one of // the basic C types enumerated in AtomicToken, above. The type may // then be further modified by one or more of unsigned, signed, long, // longlong, or short. However, it will not be a pointer. -EXPCL_DTOOLCONFIG bool interrogate_type_is_atomic(TypeIndex type); -EXPCL_DTOOLCONFIG AtomicToken interrogate_type_atomic_token(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_unsigned(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_signed(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_long(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_longlong(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_short(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_atomic(TypeIndex type); +EXPCL_INTERROGATEDB AtomicToken interrogate_type_atomic_token(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_unsigned(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_signed(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_long(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_longlong(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_short(TypeIndex type); // If interrogate_type_is_wrapped() returns true, this is a composite // type "wrapped" around some simpler type, for instance a pointer to @@ -444,21 +444,21 @@ EXPCL_DTOOLCONFIG bool interrogate_type_is_short(TypeIndex type); // they use multiple wrappers. A const char pointer, for example, is // represented as a pointer wrapper around a const wrapper around an // atomic char.) -EXPCL_DTOOLCONFIG bool interrogate_type_is_wrapped(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_pointer(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_const(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_typedef(TypeIndex type); -EXPCL_DTOOLCONFIG TypeIndex interrogate_type_wrapped_type(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_wrapped(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_pointer(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_const(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_typedef(TypeIndex type); +EXPCL_INTERROGATEDB TypeIndex interrogate_type_wrapped_type(TypeIndex type); // If interrogate_type_is_enum() returns true, this is an enumerated // type, which means it may take any one of a number of named integer // values. -EXPCL_DTOOLCONFIG bool interrogate_type_is_enum(TypeIndex type); -EXPCL_DTOOLCONFIG int interrogate_type_number_of_enum_values(TypeIndex type); -EXPCL_DTOOLCONFIG const char *interrogate_type_enum_value_name(TypeIndex type, int n); -EXPCL_DTOOLCONFIG const char *interrogate_type_enum_value_scoped_name(TypeIndex type, int n); -EXPCL_DTOOLCONFIG const char *interrogate_type_enum_value_comment(TypeIndex type, int n); -EXPCL_DTOOLCONFIG int interrogate_type_enum_value(TypeIndex type, int n); +EXPCL_INTERROGATEDB bool interrogate_type_is_enum(TypeIndex type); +EXPCL_INTERROGATEDB int interrogate_type_number_of_enum_values(TypeIndex type); +EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_name(TypeIndex type, int n); +EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_scoped_name(TypeIndex type, int n); +EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_comment(TypeIndex type, int n); +EXPCL_INTERROGATEDB int interrogate_type_enum_value(TypeIndex type, int n); // If none of the above is true, the type is some extension type. It // may be a struct, class, or union (and the distinction between these @@ -466,19 +466,19 @@ EXPCL_DTOOLCONFIG int interrogate_type_enum_value(TypeIndex type, int n); // any case, it may contain zero or more constructors, zero or one // destructor, zero or more member functions, and zero or more data // members; all of the remaining type functions may apply. -EXPCL_DTOOLCONFIG bool interrogate_type_is_struct(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_class(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_is_union(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_struct(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_class(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_union(TypeIndex type); // If is_fully_defined() returns false, this class/struct was a // forward reference, and we really don't know anything about it. (In // this case, it will appear to have no methods or members.) -EXPCL_DTOOLCONFIG bool interrogate_type_is_fully_defined(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_fully_defined(TypeIndex type); // If is_unpublished() returns false, the class/struct is unknown // because it was not marked to be published (or, in promiscuous mode, // it is a protected or private nested class). -EXPCL_DTOOLCONFIG bool interrogate_type_is_unpublished(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_is_unpublished(TypeIndex type); // Otherwise, especially if the type is a struct or class, we may have // a number of member functions, including zero or more constructors @@ -499,36 +499,36 @@ EXPCL_DTOOLCONFIG bool interrogate_type_is_unpublished(TypeIndex type); // same function index as the one returned by the ancestor class, and // interrogate_type_destructor_is_inherited() will return true for // this class. -EXPCL_DTOOLCONFIG int interrogate_type_number_of_constructors(TypeIndex type); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_constructor(TypeIndex type, int n); -EXPCL_DTOOLCONFIG bool interrogate_type_has_destructor(TypeIndex type); -EXPCL_DTOOLCONFIG bool interrogate_type_destructor_is_inherited(TypeIndex type); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_destructor(TypeIndex type); +EXPCL_INTERROGATEDB int interrogate_type_number_of_constructors(TypeIndex type); +EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_constructor(TypeIndex type, int n); +EXPCL_INTERROGATEDB bool interrogate_type_has_destructor(TypeIndex type); +EXPCL_INTERROGATEDB bool interrogate_type_destructor_is_inherited(TypeIndex type); +EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_destructor(TypeIndex type); // This is the set of exposed data elements in the struct or class. -EXPCL_DTOOLCONFIG int interrogate_type_number_of_elements(TypeIndex type); -EXPCL_DTOOLCONFIG ElementIndex interrogate_type_get_element(TypeIndex type, int n); +EXPCL_INTERROGATEDB int interrogate_type_number_of_elements(TypeIndex type); +EXPCL_INTERROGATEDB ElementIndex interrogate_type_get_element(TypeIndex type, int n); // This is the set of exposed member functions in the struct or class. -EXPCL_DTOOLCONFIG int interrogate_type_number_of_methods(TypeIndex type); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_method(TypeIndex type, int n); +EXPCL_INTERROGATEDB int interrogate_type_number_of_methods(TypeIndex type); +EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_method(TypeIndex type, int n); // This is the set of MAKE_SEQ wrappers in the struct or class. -EXPCL_DTOOLCONFIG int interrogate_type_number_of_make_seqs(TypeIndex type); -EXPCL_DTOOLCONFIG MakeSeqIndex interrogate_type_get_make_seq(TypeIndex type, int n); +EXPCL_INTERROGATEDB int interrogate_type_number_of_make_seqs(TypeIndex type); +EXPCL_INTERROGATEDB MakeSeqIndex interrogate_type_get_make_seq(TypeIndex type, int n); // A C++ class may also define a number of explicit cast operators, // which define how to convert an object of this type to an object of // some other type (the type can be inferred by the return type of the // cast function). This is not related to upcast and downcast, // defined below. -EXPCL_DTOOLCONFIG int interrogate_type_number_of_casts(TypeIndex type); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_cast(TypeIndex type, int n); +EXPCL_INTERROGATEDB int interrogate_type_number_of_casts(TypeIndex type); +EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_cast(TypeIndex type, int n); // A C++ class may inherit from zero or more base classes. This // defines the list of base classes for this particular type. -EXPCL_DTOOLCONFIG int interrogate_type_number_of_derivations(TypeIndex type); -EXPCL_DTOOLCONFIG TypeIndex interrogate_type_get_derivation(TypeIndex type, int n); +EXPCL_INTERROGATEDB int interrogate_type_number_of_derivations(TypeIndex type); +EXPCL_INTERROGATEDB TypeIndex interrogate_type_get_derivation(TypeIndex type, int n); // For each base class, we might need to define an explicit upcast or // downcast operation to convert the pointer to the derived class to @@ -544,8 +544,8 @@ EXPCL_DTOOLCONFIG TypeIndex interrogate_type_get_derivation(TypeIndex type, int // class. If this returns false, you may simply use the same pointer // as either a derived class pointer or a base class pointer without // any extra step. -EXPCL_DTOOLCONFIG bool interrogate_type_derivation_has_upcast(TypeIndex type, int n); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_upcast(TypeIndex type, int n); +EXPCL_INTERROGATEDB bool interrogate_type_derivation_has_upcast(TypeIndex type, int n); +EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_upcast(TypeIndex type, int n); // Although it is always possible to upcast a pointer to a base class, // it is not always possible to downcast from a base class to the @@ -555,14 +555,14 @@ EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_upcast(TypeIndex type, int // way as upcasting. (Of course, it is the caller's responsibility to // guarantee that the pointer actually represents an object of the // type being downcast to.) -EXPCL_DTOOLCONFIG bool interrogate_type_derivation_downcast_is_impossible(TypeIndex type, int n); -EXPCL_DTOOLCONFIG bool interrogate_type_derivation_has_downcast(TypeIndex type, int n); -EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_downcast(TypeIndex type, int n); +EXPCL_INTERROGATEDB bool interrogate_type_derivation_downcast_is_impossible(TypeIndex type, int n); +EXPCL_INTERROGATEDB bool interrogate_type_derivation_has_downcast(TypeIndex type, int n); +EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_downcast(TypeIndex type, int n); // A C++ class may also define any number of nested types--classes or // enums defined within the scope of this class. -EXPCL_DTOOLCONFIG int interrogate_type_number_of_nested_types(TypeIndex type); -EXPCL_DTOOLCONFIG TypeIndex interrogate_type_get_nested_type(TypeIndex type, int n); +EXPCL_INTERROGATEDB int interrogate_type_number_of_nested_types(TypeIndex type); +EXPCL_INTERROGATEDB TypeIndex interrogate_type_get_nested_type(TypeIndex type, int n); #ifdef __cplusplus } diff --git a/dtool/src/interrogatedb/interrogate_request.h b/dtool/src/interrogatedb/interrogate_request.h index 063b04f2ec..06d8bfb1a4 100644 --- a/dtool/src/interrogatedb/interrogate_request.h +++ b/dtool/src/interrogatedb/interrogate_request.h @@ -39,7 +39,7 @@ extern "C" { * data available, but doesn't allow matching the database information * up with any compiled-in function wrappers or anything. */ -EXPCL_DTOOLCONFIG void interrogate_request_database(const char *database_filename); +EXPCL_INTERROGATEDB void interrogate_request_database(const char *database_filename); @@ -74,7 +74,7 @@ typedef struct { * This includes all of the function pointers and/or unique names that * might be compiled in. */ -EXPCL_DTOOLCONFIG void interrogate_request_module(InterrogateModuleDef *def); +EXPCL_INTERROGATEDB void interrogate_request_module(InterrogateModuleDef *def); #ifdef __cplusplus } diff --git a/dtool/src/interrogatedb/p3interrogatedb_composite2.cxx b/dtool/src/interrogatedb/p3interrogatedb_composite2.cxx index e56075e2d0..c6b6c61362 100644 --- a/dtool/src/interrogatedb/p3interrogatedb_composite2.cxx +++ b/dtool/src/interrogatedb/p3interrogatedb_composite2.cxx @@ -5,7 +5,6 @@ #include "interrogate_interface.cxx" #include "interrogate_request.cxx" #include "py_panda.cxx" -#include "vector_int.cxx" diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 11af0c1ace..0278a84ce1 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -26,6 +26,10 @@ PyMemberDef standard_type_members[] = { {NULL} /* Sentinel */ }; +static RuntimeTypeMap runtime_type_map; +static RuntimeTypeSet runtime_type_set; +static NamedTypeMap named_type_map; + //////////////////////////////////////////////////////////////////// // Function: DtoolCanThisBeAPandaInstance // Description: Given a valid (non-NULL) PyObject, does a simple @@ -273,6 +277,29 @@ PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *functio return NULL; } +//////////////////////////////////////////////////////////////////// +// Function: Dtool_Raise_AttributeError +// Description: Raises an AttributeError of the form: +// 'type' has no attribute 'attr' +// +// Always returns NULL so that it can be conveniently +// used as a return expression for wrapper functions +// that return a PyObject pointer. +//////////////////////////////////////////////////////////////////// +PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute) { +#if PY_MAJOR_VERSION >= 3 + PyObject *message = PyUnicode_FromFormat( +#else + PyObject *message = PyString_FromFormat( +#endif + "'%.100s' object has no attribute '%.200s'", + Py_TYPE(obj)->tp_name, attribute); + + Py_INCREF(PyExc_TypeError); + PyErr_Restore(PyExc_TypeError, message, (PyObject *)NULL); + return NULL; +} + //////////////////////////////////////////////////////////////////// // Function: Dtool_Raise_BadArgumentsError // Description: Raises a TypeError of the form: @@ -330,6 +357,24 @@ PyObject *Dtool_Return_Bool(bool value) { return result; } +//////////////////////////////////////////////////////////////////// +// Function: Dtool_Return +// Description: Convenience method that checks for exceptions, and +// if one occurred, returns NULL, otherwise the given +// return value. Its reference count is not increased. +//////////////////////////////////////////////////////////////////// +PyObject *_Dtool_Return(PyObject *value) { + if (_PyErr_OCCURRED()) { + return NULL; + } +#ifndef NDEBUG + if (Notify::ptr()->has_assert_failed()) { + return Dtool_Raise_AssertionError(); + } +#endif + return value; +} + //////////////////////////////////////////////////////////////////////// // Function : DTool_CreatePyInstanceTyped // @@ -360,7 +405,7 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & ///////////////////////////////////////////// // ask class to allocate an instance.. ///////////////////////////////////////////// - Dtool_PyInstDef *self = (Dtool_PyInstDef *) target_class->As_PyTypeObject().tp_new(&target_class->As_PyTypeObject(), NULL, NULL); + Dtool_PyInstDef *self = (Dtool_PyInstDef *) target_class->_PyType.tp_new(&target_class->_PyType, NULL, NULL); if (self != NULL) { self->_ptr_to_object = new_local_this; self->_memory_rules = memory_rules; @@ -377,7 +422,7 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // if we get this far .. just wrap the thing in the known type ?? // better than aborting...I guess.... ///////////////////////////////////////////////////// - Dtool_PyInstDef *self = (Dtool_PyInstDef *) known_class_type.As_PyTypeObject().tp_new(&known_class_type.As_PyTypeObject(), NULL, NULL); + Dtool_PyInstDef *self = (Dtool_PyInstDef *) known_class_type._PyType.tp_new(&known_class_type._PyType, NULL, NULL); if (self != NULL) { self->_ptr_to_object = local_this_in; self->_memory_rules = memory_rules; @@ -401,7 +446,7 @@ PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_class } Dtool_PyTypedObject *classdef = &in_classdef; - Dtool_PyInstDef *self = (Dtool_PyInstDef *) classdef->As_PyTypeObject().tp_new(&classdef->As_PyTypeObject(), NULL, NULL); + Dtool_PyInstDef *self = (Dtool_PyInstDef *) classdef->_PyType.tp_new(&classdef->_PyType, NULL, NULL); if (self != NULL) { self->_ptr_to_object = local_this; self->_memory_rules = memory_rules; @@ -446,42 +491,97 @@ void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { // /////////////////////////////////////////////////////////////////////////////// void -RegisterRuntimeClass(Dtool_PyTypedObject *otype, int class_id) { - if (class_id == 0) { +RegisterNamedClass(const string &name, Dtool_PyTypedObject &otype) { + pair result = + named_type_map.insert(NamedTypeMap::value_type(name, &otype)); + + if (!result.second) { + // There was already a class with this name in the dictionary. interrogatedb_cat.warning() - << "Class " << otype->_PyType.tp_name + << "Double definition for class " << name << "\n"; + } +} + +void +RegisterRuntimeTypedClass(Dtool_PyTypedObject &otype) { + int type_index = otype._type.get_index(); + + if (type_index == 0) { + interrogatedb_cat.warning() + << "Class " << otype._PyType.tp_name << " has a zero TypeHandle value; check that init_type() is called.\n"; - } else if (class_id > 0) { - RunTimeTypeDictionary &dict = GetRunTimeDictionary(); - pair result = - dict.insert(RunTimeTypeDictionary::value_type(class_id, otype)); + } else if (type_index < 0 || type_index >= TypeRegistry::ptr()->get_num_typehandles()) { + interrogatedb_cat.warning() + << "Class " << otype._PyType.tp_name + << " has an illegal TypeHandle value; check that init_type() is called.\n"; + + } else { + pair result = + runtime_type_map.insert(RuntimeTypeMap::value_type(type_index, &otype)); if (!result.second) { - // There was already an entry in the dictionary for class_id. + // There was already an entry in the dictionary for type_index. Dtool_PyTypedObject *other_type = (*result.first).second; interrogatedb_cat.warning() - << "Classes " << otype->_PyType.tp_name + << "Classes " << otype._PyType.tp_name << " and " << other_type->_PyType.tp_name - << " share the same TypeHandle value (" << class_id + << " share the same TypeHandle value (" << type_index << "); check class definitions.\n"; } else { - GetRunTimeTypeList().insert(class_id); - otype->_type = TypeRegistry::ptr()->find_type_by_id(class_id); + runtime_type_set.insert(type_index); } } } +Dtool_PyTypedObject * +LookupNamedClass(const string &name) { + NamedTypeMap::const_iterator it; + it = named_type_map.find(name); + + if (it == named_type_map.end()) { + // Find a type named like this in the type registry. + TypeHandle handle = TypeRegistry::ptr()->find_type(name); + if (handle.get_index() > 0) { + RuntimeTypeMap::const_iterator it2; + it2 = runtime_type_map.find(handle.get_index()); + if (it2 != runtime_type_map.end()) { + return it2->second; + } + } + + interrogatedb_cat.error() + << "Attempt to use type " << name << " which has not yet been defined!\n"; + return NULL; + } else { + return it->second; + } +} + +Dtool_PyTypedObject * +LookupRuntimeTypedClass(TypeHandle handle) { + RuntimeTypeMap::const_iterator it; + it = runtime_type_map.find(handle.get_index()); + + if (it == runtime_type_map.end()) { + interrogatedb_cat.error() + << "Attempt to use type " << handle << " which has not yet been defined!\n"; + return NULL; + } else { + return it->second; + } +} + /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type) { - RunTimeTypeDictionary::iterator di = GetRunTimeDictionary().find(type); - if (di != GetRunTimeDictionary().end()) { + RuntimeTypeMap::iterator di = runtime_type_map.find(type); + if (di != runtime_type_map.end()) { return di->second; } else { - int type2 = get_best_parent_from_Set(type, GetRunTimeTypeList()); - di = GetRunTimeDictionary().find(type2); - if (di != GetRunTimeDictionary().end()) { + int type2 = get_best_parent_from_Set(type, runtime_type_set); + di = runtime_type_map.find(type2); + if (di != runtime_type_map.end()) { return di->second; } } @@ -526,11 +626,6 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { #endif } - // the constant inits... enums, classes ... - for (int y = 0; defs[y] != NULL; y++) { - defs[y]->_constants(module); - } - PyModule_AddIntConstant(module, "Dtool_PyNativeInterface", 1); return module; } @@ -710,39 +805,12 @@ PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op) { return PyBool_FromLong(result); } -PyObject *make_list_for_item(PyObject *self, const char *num_name, - const char *element_name) { - PyObject *num_result = PyObject_CallMethod(self, (char *)num_name, (char *)"()"); - if (num_result == NULL) { - return NULL; - } - - Py_ssize_t num_elements; -#if PY_MAJOR_VERSION >= 3 - num_elements = PyLong_AsSsize_t(num_result); -#else - num_elements = PyInt_AsSsize_t(num_result); -#endif - Py_DECREF(num_result); - - PyObject *list = PyList_New(num_elements); - for (int i = 0; i < num_elements; ++i) { - PyObject *element = PyObject_CallMethod(self, (char *)element_name, (char *)"(i)", i); - if (element == NULL) { - Py_DECREF(list); - return NULL; - } - PyList_SET_ITEM(list, i, element); - } - return list; -} - //////////////////////////////////////////////////////////////////// // Function: copy_from_make_copy // Description: This is a support function for a synthesized // __copy__() method from a C++ make_copy() method. //////////////////////////////////////////////////////////////////// -PyObject *copy_from_make_copy(PyObject *self) { +PyObject *copy_from_make_copy(PyObject *self, PyObject *noargs) { return PyObject_CallMethod(self, (char *)"make_copy", (char *)"()"); } @@ -751,7 +819,7 @@ PyObject *copy_from_make_copy(PyObject *self) { // Description: This is a support function for a synthesized // __copy__() method from a C++ copy constructor. //////////////////////////////////////////////////////////////////// -PyObject *copy_from_copy_constructor(PyObject *self) { +PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) { PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { return NULL; @@ -780,7 +848,7 @@ PyObject *map_deepcopy_to_copy(PyObject *self, PyObject *args) { // to whether the indicated value will fit. //////////////////////////////////////////////////////////////////// #if PY_MAJOR_VERSION < 3 -EXPCL_DTOOLCONFIG PyObject * +EXPCL_INTERROGATEDB PyObject * PyLongOrInt_FromUnsignedLong(unsigned long value) { if ((long)value < 0) { return PyLong_FromUnsignedLong(value); diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index e6847359c3..2a26f347e1 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -114,6 +114,7 @@ inline PyObject* doPy_RETURN_FALSE() #define PyLongOrInt_FromSize_t PyLong_FromSize_t #define PyLongOrInt_FromLong PyLong_FromLong #define PyLongOrInt_FromUnsignedLong PyLong_FromUnsignedLong +#define PyLongOrInt_AS_LONG PyLong_AS_LONG #define PyInt_Check PyLong_Check #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG @@ -122,6 +123,7 @@ inline PyObject* doPy_RETURN_FALSE() // PyInt_FromSize_t automatically picks the right type. #define PyLongOrInt_FromSize_t PyInt_FromSize_t #define PyLongOrInt_FromLong PyInt_FromLong +#define PyLongOrInt_AS_LONG PyInt_AsLong // For more portably defining hash functions. typedef long Py_hash_t; @@ -143,17 +145,17 @@ using namespace std; /////////////////////////////////////////////////////////////////////////////////// struct Dtool_PyTypedObject; -typedef std::map RunTimeTypeDictionary; -typedef std::set RunTimeTypeList; - -EXPCL_DTOOLCONFIG RunTimeTypeDictionary &GetRunTimeDictionary(); -EXPCL_DTOOLCONFIG RunTimeTypeList &GetRunTimeTypeList(); +typedef std::map RuntimeTypeMap; +typedef std::set RuntimeTypeSet; +typedef std::map NamedTypeMap; ////////////////////////////////////////////////////////// // used to stamp dtool instance.. #define PY_PANDA_SIGNATURE 0xbeaf typedef void *(*UpcastFunction)(PyObject *,Dtool_PyTypedObject *); typedef void *(*DowncastFunction)(void *, Dtool_PyTypedObject *); +typedef void *(*CoerceFunction)(PyObject *, void *); +typedef void (*ModuleClassInitFunction)(PyObject *module); //inline Dtool_PyTypedObject * Dtool_RuntimeTypeDtoolType(int type); //inline void Dtool_Deallocate_General(PyObject * self); @@ -187,7 +189,7 @@ struct Dtool_PyInstDef { //////////////////////////////////////////////////////////////////////// // A Offset Dictionary Defining How to read the Above Object.. //////////////////////////////////////////////////////////////////////// -extern EXPCL_DTOOLCONFIG PyMemberDef standard_type_members[]; +extern EXPCL_INTERROGATEDB PyMemberDef standard_type_members[]; //////////////////////////////////////////////////////////////////////// // The Class Definition Structor For a Dtool python type. @@ -196,16 +198,16 @@ struct Dtool_PyTypedObject { // Standard Python Features.. PyTypeObject _PyType; - // My Class Level Features.. - UpcastFunction _Dtool_UpcastInterface; // The Upcast Function By Slot - DowncastFunction _Dtool_DowncastInterface; // The Downcast Function By Slot - // May be TypeHandle::none() to indicate a non-TypedObject class. TypeHandle _type; - // some convenience functions.. - inline PyTypeObject &As_PyTypeObject() { return _PyType; }; - inline PyObject &As_PyObject() { return (PyObject &)_PyType; }; + ModuleClassInitFunction _Dtool_ModuleClassInit; + + UpcastFunction _Dtool_UpcastInterface; // The Upcast Function By Slot + DowncastFunction _Dtool_DowncastInterface; // The Downcast Function By Slot + + CoerceFunction _Dtool_ConstCoerce; + CoerceFunction _Dtool_Coerce; }; // This is now simply a forward declaration. The actual definition is created @@ -217,7 +219,7 @@ struct Dtool_PyTypedObject { // More Macro(s) to Implement class functions.. Usually used if C++ needs type information //////////////////////////////////////////////////////////////////////// #define Define_Dtool_new(CLASS_NAME,CNAME)\ -PyObject *Dtool_new_##CLASS_NAME(PyTypeObject *type, PyObject *args, PyObject *kwds) {\ +static PyObject *Dtool_new_##CLASS_NAME(PyTypeObject *type, PyObject *args, PyObject *kwds) {\ (void) args; (void) kwds;\ PyObject *self = type->tp_alloc(type, 0);\ ((Dtool_PyInstDef *)self)->_signature = PY_PANDA_SIGNATURE;\ @@ -281,7 +283,7 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ //////////////////////////////////////////////////////////////////////// /// Simple Recognition Functions.. //////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG bool DtoolCanThisBeAPandaInstance(PyObject *self); +EXPCL_INTERROGATEDB bool DtoolCanThisBeAPandaInstance(PyObject *self); /////////////////////////////////////////////////////////////////////////////// // ** HACK ** allert.. @@ -291,11 +293,15 @@ EXPCL_DTOOLCONFIG bool DtoolCanThisBeAPandaInstance(PyObject *self); // /////////////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG void RegisterRuntimeClass(Dtool_PyTypedObject *otype, int class_id); +EXPCL_INTERROGATEDB void RegisterNamedClass(const string &name, Dtool_PyTypedObject &otype); +EXPCL_INTERROGATEDB void RegisterRuntimeTypedClass(Dtool_PyTypedObject &otype); + +EXPCL_INTERROGATEDB Dtool_PyTypedObject *LookupNamedClass(const string &name); +EXPCL_INTERROGATEDB Dtool_PyTypedObject *LookupRuntimeTypedClass(TypeHandle handle); /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type); +EXPCL_INTERROGATEDB Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type); //////////////////////////////////////////////////////////////////////// // Function : DTOOL_Call_ExtractThisPointerForType @@ -305,15 +311,15 @@ EXPCL_DTOOLCONFIG Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type); // with these as the generated code depends on how this is set // up.. //////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject * classdef, void ** answer); +EXPCL_INTERROGATEDB void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *classdef, void **answer); -EXPCL_DTOOLCONFIG void *DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const string &function_name, bool const_ok, bool report_errors); +EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const string &function_name, bool const_ok, bool report_errors); -EXPCL_DTOOLCONFIG void *DTOOL_Call_GetPointerThis(PyObject *self); +EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThis(PyObject *self); -EXPCL_DTOOLCONFIG bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef, void **answer); +EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef, void **answer); -EXPCL_DTOOLCONFIG bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef, +EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef, void **answer, const char *method_name); template INLINE bool DTOOL_Call_ExtractThisPointer(PyObject *self, T *&into) { @@ -334,14 +340,15 @@ template INLINE bool DTOOL_Call_ExtractThisPointer(PyObject *self, T *& // _PyErr_OCCURRED is an undocumented inline version of PyErr_Occurred. #define Dtool_CheckErrorOccurred() (_PyErr_OCCURRED() != NULL) #else -EXPCL_DTOOLCONFIG bool Dtool_CheckErrorOccurred(); +EXPCL_INTERROGATEDB bool Dtool_CheckErrorOccurred(); #endif -EXPCL_DTOOLCONFIG PyObject *Dtool_Raise_AssertionError(); -EXPCL_DTOOLCONFIG PyObject *Dtool_Raise_TypeError(const char *message); -EXPCL_DTOOLCONFIG PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *function_name, const char *type_name); +EXPCL_INTERROGATEDB PyObject *Dtool_Raise_AssertionError(); +EXPCL_INTERROGATEDB PyObject *Dtool_Raise_TypeError(const char *message); +EXPCL_INTERROGATEDB PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *function_name, const char *type_name); +EXPCL_INTERROGATEDB PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute); -EXPCL_DTOOLCONFIG PyObject *_Dtool_Raise_BadArgumentsError(); +EXPCL_INTERROGATEDB PyObject *_Dtool_Raise_BadArgumentsError(); #ifdef NDEBUG // Define it to a function that just prints a generic message. #define Dtool_Raise_BadArgumentsError(x) _Dtool_Raise_BadArgumentsError() @@ -350,13 +357,16 @@ EXPCL_DTOOLCONFIG PyObject *_Dtool_Raise_BadArgumentsError(); #define Dtool_Raise_BadArgumentsError(x) Dtool_Raise_TypeError("Arguments must match:\n" x) #endif -EXPCL_DTOOLCONFIG PyObject *_Dtool_Return_None(); -EXPCL_DTOOLCONFIG PyObject *Dtool_Return_Bool(bool value); +EXPCL_INTERROGATEDB PyObject *_Dtool_Return_None(); +EXPCL_INTERROGATEDB PyObject *Dtool_Return_Bool(bool value); +EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value); #ifdef NDEBUG #define Dtool_Return_None() (_PyErr_OCCURRED() != NULL ? NULL : (Py_INCREF(Py_None), Py_None)) +#define Dtool_Return(value) (_PyErr_OCCURRED() != NULL ? NULL : value) #else #define Dtool_Return_None() _Dtool_Return_None() +#define Dtool_Return(value) _Dtool_Return(value) #endif //////////////////////////////////////////////////////////////////////// @@ -365,13 +375,13 @@ EXPCL_DTOOLCONFIG PyObject *Dtool_Return_Bool(bool value); // this function relies on the behavior of typed objects in the panda system. // //////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject &known_class_type, bool memory_rules, bool is_const, int RunTimeType); +EXPCL_INTERROGATEDB PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject &known_class_type, bool memory_rules, bool is_const, int RunTimeType); //////////////////////////////////////////////////////////////////////// // DTool_CreatePyInstance .. wrapper function to finalize the existance of a general // dtool py instance.. //////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_classdef, bool memory_rules, bool is_const); +EXPCL_INTERROGATEDB PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_classdef, bool memory_rules, bool is_const); // These template methods allow use when the Dtool_PyTypedObject is not known. // They require a get_class_type() to be defined for the class. @@ -407,11 +417,9 @@ template INLINE PyObject *DTool_CreatePyInstanceTyped(T *obj, bool memo //struct Dtool_PyTypedObject Dtool_##CLASS_NAME; #define Define_Module_Class_Internal(MODULE_NAME,CLASS_NAME,CNAME)\ -extern EXPORT_THIS Dtool_PyTypedObject Dtool_##CLASS_NAME;\ -int Dtool_Init_##CLASS_NAME(PyObject *self, PyObject *args, PyObject *kwds);\ -PyObject * Dtool_new_##CLASS_NAME(PyTypeObject *type, PyObject *args, PyObject *kwds);\ -void * Dtool_UpcastInterface_##CLASS_NAME(PyObject *self, Dtool_PyTypedObject *requested_type);\ -void * Dtool_DowncastInterface_##CLASS_NAME(void *self, Dtool_PyTypedObject *requested_type); +extern struct Dtool_PyTypedObject Dtool_##CLASS_NAME;\ +static int Dtool_Init_##CLASS_NAME(PyObject *self, PyObject *args, PyObject *kwds);\ +static PyObject *Dtool_new_##CLASS_NAME(PyTypeObject *type, PyObject *args, PyObject *kwds); /////////////////////////////////////////////////////////////////////////////// #define Define_Module_Class(MODULE_NAME,CLASS_NAME,CNAME,PUBLIC_NAME)\ @@ -444,7 +452,7 @@ Define_Dtool_Class(MODULE_NAME,CLASS_NAME,PUBLIC_NAME) /////////////////////////////////////////////////////////////////////////////// /// Th Finalizer for simple instances.. /////////////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG int DTool_PyInit_Finalize(PyObject *self, void *This, Dtool_PyTypedObject *type, bool memory_rules, bool is_const); +EXPCL_INTERROGATEDB int DTool_PyInit_Finalize(PyObject *self, void *This, Dtool_PyTypedObject *type, bool memory_rules, bool is_const); /////////////////////////////////////////////////////////////////////////////// /// A heler function to glu methed definition together .. that can not be done at @@ -453,24 +461,21 @@ EXPCL_DTOOLCONFIG int DTool_PyInit_Finalize(PyObject *self, void *This, Dtool_Py /////////////////////////////////////////////////////////////////////////////// typedef std::map MethodDefmap; -EXPCL_DTOOLCONFIG void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap); +EXPCL_INTERROGATEDB void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap); /////////////////////////////////////////////////////////////////////////////// //// We need a way to runtime merge compile units into a python "Module" .. this is done with the /// fallowing structors and code.. along with the support of interigate_module /////////////////////////////////////////////////////////////////////////////// struct LibraryDef { - typedef void (*ConstantFunction)(PyObject *); - PyMethodDef *_methods; - ConstantFunction _constants; }; /////////////////////////////////////////////////////////////////////////////// #if PY_MAJOR_VERSION >= 3 -EXPCL_DTOOLCONFIG PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], PyModuleDef *module_def); +EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], PyModuleDef *module_def); #else -EXPCL_DTOOLCONFIG PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename); +EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename); #endif /////////////////////////////////////////////////////////////////////////////// @@ -481,16 +486,16 @@ EXPCL_DTOOLCONFIG PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const c // Required to support fom historical inharatence in the for of "is this instance of".. // /////////////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args); +EXPCL_INTERROGATEDB PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args); ////////////////////////////////////////////////////////////////////////////////////////////// // We do expose a dictionay for dtool classes .. this should be removed at some point.. ////////////////////////////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args); +EXPCL_INTERROGATEDB PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args); /////////////////////////////////////////////////////////////////////////////////// -EXPCL_DTOOLCONFIG Py_hash_t DTOOL_PyObject_HashPointer(PyObject *obj); +EXPCL_INTERROGATEDB Py_hash_t DTOOL_PyObject_HashPointer(PyObject *obj); /* Compare v to w. Return -1 if v < w or exception (PyErr_Occurred() true in latter case). @@ -500,32 +505,30 @@ EXPCL_DTOOLCONFIG Py_hash_t DTOOL_PyObject_HashPointer(PyObject *obj); XXX of error. */ -EXPCL_DTOOLCONFIG int DTOOL_PyObject_ComparePointers(PyObject *v1, PyObject *v2); -EXPCL_DTOOLCONFIG int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2); +EXPCL_INTERROGATEDB int DTOOL_PyObject_ComparePointers(PyObject *v1, PyObject *v2); +EXPCL_INTERROGATEDB int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2); -EXPCL_DTOOLCONFIG PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op); +EXPCL_INTERROGATEDB PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op); -EXPCL_DTOOLCONFIG PyObject * -make_list_for_item(PyObject *self, const char *num_name, - const char *element_name); +EXPCL_INTERROGATEDB PyObject * +copy_from_make_copy(PyObject *self, PyObject *noargs); -EXPCL_DTOOLCONFIG PyObject * -copy_from_make_copy(PyObject *self); +EXPCL_INTERROGATEDB PyObject * +copy_from_copy_constructor(PyObject *self, PyObject *noargs); -EXPCL_DTOOLCONFIG PyObject * -copy_from_copy_constructor(PyObject *self); - -EXPCL_DTOOLCONFIG PyObject * +EXPCL_INTERROGATEDB PyObject * map_deepcopy_to_copy(PyObject *self, PyObject *args); #if PY_MAJOR_VERSION < 3 // In the Python 3 case, it is defined as a macro, at the beginning of this file. -EXPCL_DTOOLCONFIG PyObject * +EXPCL_INTERROGATEDB PyObject * PyLongOrInt_FromUnsignedLong(unsigned long value); #endif -EXPCL_DTOOLCONFIG extern struct Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE; -EXPCL_DTOOLCONFIG extern void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module); +EXPCL_INTERROGATEDB extern struct Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE; +EXPCL_INTERROGATEDB extern void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module); + +#define Dtool_Ptr_DTOOL_SUPER_BASE (&Dtool_DTOOL_SUPER_BASE) #endif // HAVE_PYTHON && !CPPPARSER diff --git a/dtool/src/parser-inc/iostream b/dtool/src/parser-inc/iostream index 87fd92ebcd..5da002182a 100644 --- a/dtool/src/parser-inc/iostream +++ b/dtool/src/parser-inc/iostream @@ -43,6 +43,9 @@ __published: static const openmode in; static const openmode out; static const openmode trunc; +protected: + // Force this to be a non-trivial type. + ios_base() {}; }; class ios : public ios_base { __published: @@ -56,6 +59,10 @@ __published: bool bad() const; void clear(); }; + +// We actually want to wrap streampos as streamoff. +#define streampos streamoff + class ostream : virtual public ios { __published: void put(char c); @@ -101,6 +108,6 @@ extern istream cin; extern ostream cout; extern ostream cerr; -typedef int streampos; +typedef long streamoff; #endif diff --git a/dtool/src/parser-inc/stdint.h b/dtool/src/parser-inc/stdint.h index 060dbf82e7..11fba7a776 100644 --- a/dtool/src/parser-inc/stdint.h +++ b/dtool/src/parser-inc/stdint.h @@ -15,7 +15,7 @@ #ifndef _STDINT_H #define _STDINT_H -#ifdef _LP64 +#if defined(_LP64) || defined(_WIN64) #define __WORDSIZE 64 #else #define __WORDSIZE 32 diff --git a/dtool/src/parser-inc/stdtypedefs.h b/dtool/src/parser-inc/stdtypedefs.h index 34b9b0b4c6..345eda1fd0 100644 --- a/dtool/src/parser-inc/stdtypedefs.h +++ b/dtool/src/parser-inc/stdtypedefs.h @@ -20,8 +20,8 @@ #ifndef STDTYPEDEFS_H #define STDTYPEDEFS_H #ifndef __APPLE__ -typedef unsigned int size_t; -typedef int ssize_t; +typedef unsigned long size_t; +typedef long ssize_t; typedef int off_t; typedef unsigned int time_t; typedef int clock_t; @@ -44,7 +44,5 @@ typedef unsigned char uchar; #define NULL ((void *)0) #endif -typedef int fd_set; - #endif diff --git a/dtool/src/prc/notifyCategoryProxy.h b/dtool/src/prc/notifyCategoryProxy.h index 5a306497cd..9e3c239c5e 100644 --- a/dtool/src/prc/notifyCategoryProxy.h +++ b/dtool/src/prc/notifyCategoryProxy.h @@ -125,28 +125,28 @@ INLINE ostream &operator << (ostream &out, NotifyCategoryProxy &pro // appear in the config_*.h file. The proxy object will be named // basename_cat. -#if defined(WIN32_VC) && !defined(CPPPARSER) - +#ifdef CPPPARSER +#define NotifyCategoryDecl(basename, expcl, exptp) +#elif defined(WIN32_VC) +// MSVC's rules for extern template classes differ slightly. #define NotifyCategoryDecl(basename, expcl, exptp) \ class expcl NotifyCategoryGetCategory_ ## basename { \ public: \ NotifyCategoryGetCategory_ ## basename(); \ static NotifyCategory *get_category(); \ }; \ - exptp template class expcl NotifyCategoryProxy; \ + EXPORT_TEMPLATE_CLASS(expcl, exptp, NotifyCategoryProxy); \ extern expcl NotifyCategoryProxy basename ## _cat; - -#else // WIN32_VC - +#else #define NotifyCategoryDecl(basename, expcl, exptp) \ - class NotifyCategoryGetCategory_ ## basename { \ + class expcl NotifyCategoryGetCategory_ ## basename { \ public: \ NotifyCategoryGetCategory_ ## basename(); \ static NotifyCategory *get_category(); \ }; \ - extern NotifyCategoryProxy basename ## _cat; - -#endif // WIN32_VC + EXPORT_TEMPLATE_CLASS(expcl, extern, NotifyCategoryProxy); \ + extern expcl NotifyCategoryProxy basename ## _cat; +#endif // This macro is the same as the above, except that it declares a category // that is not intended to be exported from any DLL. @@ -171,6 +171,7 @@ INLINE ostream &operator << (ostream &out, NotifyCategoryProxy &pro #else #define NotifyCategoryDefName(basename, actual_name, parent_category) \ + template class NotifyCategoryProxy; \ NotifyCategoryProxy basename ## _cat; \ static NotifyCategoryGetCategory_ ## basename force_init_ ## basename ## _cat; \ NotifyCategoryGetCategory_ ## basename:: \ diff --git a/makepanda/.gitignore b/makepanda/.gitignore index 94487b9516..c3667923e0 100644 --- a/makepanda/.gitignore +++ b/makepanda/.gitignore @@ -1 +1,2 @@ *.pyc +*.pyo diff --git a/makepanda/installpanda.py b/makepanda/installpanda.py index 41e78bc85a..a84fb02ac6 100644 --- a/makepanda/installpanda.py +++ b/makepanda/installpanda.py @@ -127,7 +127,7 @@ def GetLibDir(): something like "lib" or "lib64" or in some cases, something similar to "lib/x86_64-linux-gnu". """ - if sys.platform == "darwin": + if sys.platform in ("darwin", "win32"): return "lib" # This one's a bit tricky. Some systems require us to install diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 487d964d8f..b7ac3cbc4a 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -30,11 +30,6 @@ import time import os import sys -## jGenPyCode tries to get the directory for Direct from the sys.path. This only works if you -## have installed the sdk using a installer. This would not work if the installer was -## never used and everything was grabbed into a virgin environment using cvs. -sys.path.append(os.getcwd()) - ######################################################################## ## ## PARSING THE COMMAND LINE OPTIONS @@ -87,7 +82,7 @@ PkgListSet(["PYTHON", "DIRECT", # Python support "ODE", "PHYSX", "BULLET", "PANDAPHYSICS", # Physics "SPEEDTREE", # SpeedTree "ZLIB", "PNG", "JPEG", "TIFF", "SQUISH", "FREETYPE", # 2D Formats support - ] + MAYAVERSIONS + MAXVERSIONS + [ "FCOLLADA", # 3D Formats support + ] + MAYAVERSIONS + MAXVERSIONS + [ "FCOLLADA", "ASSIMP", # 3D Formats support "VRPN", "OPENSSL", # Transport "FFTW", # Algorithm helpers "ARTOOLKIT", "OPENCV", "DIRECTCAM", "VISION", # Augmented Reality @@ -367,7 +362,7 @@ if RUNTIME or RTDIST: if DEBVERSION is None: DEBVERSION = VERSION -MAJOR_VERSION = VERSION[:3] +MAJOR_VERSION = '.'.join(VERSION.split('.')[:2]) if P3DSUFFIX is None: P3DSUFFIX = MAJOR_VERSION @@ -595,6 +590,7 @@ if (COMPILER == "MSVC"): if (PkgSkip("FFTW")==0): LibName("FFTW", GetThirdpartyDir() + "fftw/lib/fftw.lib") if (PkgSkip("ARTOOLKIT")==0):LibName("ARTOOLKIT",GetThirdpartyDir() + "artoolkit/lib/libAR.lib") if (PkgSkip("FCOLLADA")==0): LibName("FCOLLADA", GetThirdpartyDir() + "fcollada/lib/FCollada.lib") + if (PkgSkip("ASSIMP")==0): PkgDisable("ASSIMP") # Not yet supported if (PkgSkip("OPENCV")==0): LibName("OPENCV", GetThirdpartyDir() + "opencv/lib/cv.lib") if (PkgSkip("OPENCV")==0): LibName("OPENCV", GetThirdpartyDir() + "opencv/lib/highgui.lib") if (PkgSkip("OPENCV")==0): LibName("OPENCV", GetThirdpartyDir() + "opencv/lib/cvaux.lib") @@ -737,6 +733,7 @@ if (COMPILER=="GCC"): SmartPkgEnable("EIGEN", "eigen3", (), ("Eigen/Dense",), target_pkg = 'ALWAYS') SmartPkgEnable("ARTOOLKIT", "", ("AR"), "AR/ar.h") SmartPkgEnable("FCOLLADA", "", ChooseLib(fcollada_libs, "FCOLLADA"), ("FCollada", "FCollada/FCollada.h")) + SmartPkgEnable("ASSIMP", "assimp", ("assimp"), "assimp") SmartPkgEnable("FFMPEG", ffmpeg_libs, ffmpeg_libs, ffmpeg_libs) SmartPkgEnable("SWSCALE", "libswscale", "libswscale", ("libswscale", "libswscale/swscale.h"), target_pkg = "FFMPEG") SmartPkgEnable("SWRESAMPLE","libswresample", "libswresample", ("libswresample", "libswresample/swresample.h"), target_pkg = "FFMPEG") @@ -913,9 +910,19 @@ if (COMPILER=="GCC"): DefSymbol("WITHINPANDA", "WITHIN_PANDA", "1") if GetLinkAllStatic(): - DefSymbol("ALWAYS", "LINK_ALL_STATIC", "") + DefSymbol("ALWAYS", "LINK_ALL_STATIC") if GetTarget() == 'android': - DefSymbol("ALWAYS", "ANDROID", "") + DefSymbol("ALWAYS", "ANDROID") + +if not PkgSkip("EIGEN"): + DefSymbol("ALWAYS", "EIGEN_MPL2_ONLY") + if GetOptimize() >= 3: + DefSymbol("ALWAYS", "EIGEN_NO_DEBUG") + if COMPILER == "MSVC": + # Squeeze out a bit more performance on MSVC builds... + # Only do this if EIGEN_NO_DEBUG is also set, otherwise it + # will turn them into runtime assertions. + DefSymbol("ALWAYS", "EIGEN_NO_STATIC_ASSERT") ######################################################################## ## @@ -1018,10 +1025,10 @@ def CompileCxx(obj,src,opts): if (optlevel==1): cmd += " /MDd /Zi /RTCs /GS" if (optlevel==2): cmd += " /MDd /Zi" - if (optlevel==3): cmd += " /MD /Zi /O2 /Ob2 /Oi /Ot /fp:fast /DFORCE_INLINING" + if (optlevel==3): cmd += " /MD /Zi /GS- /O2 /Ob2 /Oi /Ot /fp:fast" if (optlevel==4): - cmd += " /MD /Zi /Ox /Ob2 /Oi /Ot /fp:fast /DFORCE_INLINING /DNDEBUG /GL" - cmd += " /Oy /Zp16" # jean-claude add /Zp16 insures correct static alignment for SSEx + cmd += " /MD /Zi /GS- /Ox /Ob2 /Oi /Ot /fp:fast /DFORCE_INLINING /DNDEBUG /GL" + cmd += " /Oy /Zp16" # jean-claude add /Zp16 insures correct static alignment for SSEx cmd += " /Fd" + os.path.splitext(obj)[0] + ".pdb" @@ -1036,7 +1043,7 @@ def CompileCxx(obj,src,opts): if 'EXCEPTIONS' in opts: cmd += " /EHsc" else: - cmd += " -D_HAS_EXCEPTIONS=0" + cmd += " /D_HAS_EXCEPTIONS=0" if 'RTTI' not in opts: cmd += " /GR-" @@ -1148,6 +1155,9 @@ def CompileCxx(obj,src,opts): if (opt=="ALWAYS") or (opt in opts): cmd += ' -D' + var + '=' + val for x in ipath: cmd += ' -I' + x + if not GetLinkAllStatic(): + cmd += ' -fvisibility=hidden' + # Mac-specific flags. if GetTarget() == "darwin": cmd += " -Wno-deprecated-declarations" @@ -1318,9 +1328,8 @@ def CompileIgate(woutd,wsrc,opts): if (PkgSkip("PYTHON")): WriteFile(woutc, "") WriteFile(woutd, "") - CompileCxx(wobj, woutc, opts) ConditionalWriteFile(woutd, "") - return + return (wobj, woutc, opts) if not CrossCompiling(): # If we're compiling for this platform, we can use the one we've built. @@ -1371,8 +1380,8 @@ def CompileIgate(woutd,wsrc,opts): else: cmd += ' ' + BracketNameWithQuotes(os.path.basename(x)) oscmd(cmd) - CompileCxx(wobj,woutc,opts) - return + + return (wobj, woutc, opts) ######################################################################## ## @@ -1399,7 +1408,10 @@ def CompileImod(wobj, wsrc, opts): # Assume that interrogate_module is on the PATH somewhere. cmd = 'interrogate_module' - cmd += ' -oc ' + woutc + ' -module ' + module + ' -library ' + library + ' -python-native ' + cmd += ' -oc ' + woutc + ' -module ' + module + ' -library ' + library + ' -python-native' + importmod = GetValueOption(opts, "IMPORT:") + if importmod: + cmd += ' -import ' + importmod for x in wsrc: cmd += ' ' + BracketNameWithQuotes(x) oscmd(cmd) CompileCxx(wobj,woutc,opts) @@ -1578,22 +1590,16 @@ def CompileLink(dll, obj, opts): else: if (GetTarget() == "darwin"): cmd = cxx + ' -undefined dynamic_lookup' - if ("BUNDLE" in opts): cmd += ' -bundle ' + if ("BUNDLE" in opts or GetOrigExt(dll) == ".pyd"): + cmd += ' -bundle ' else: - if GetOrigExt(dll) == ".pyd": - install_name = '@loader_path/../panda3d/' + os.path.basename(dll) - else: - install_name = os.path.basename(dll) + install_name = '@loader_path/../lib/' + os.path.basename(dll) cmd += ' -dynamiclib -install_name ' + install_name cmd += ' -compatibility_version ' + MAJOR_VERSION + ' -current_version ' + VERSION cmd += ' -o ' + dll + ' -L' + GetOutputDir() + '/lib -L' + GetOutputDir() + '/tmp' else: cmd = cxx + ' -shared' if ("MODULE" not in opts): cmd += " -Wl,-soname=" + os.path.basename(dll) - if GetOrigExt(dll) == ".pyd" and not os.path.basename(dll).startswith('core'): - # Tell the other libraries where to find core.so. - # Not sure if this is the best way to do that, but it works. - cmd += " -Wl,-rpath '-Wl,$ORIGIN'" cmd += ' -o ' + dll + ' -L' + GetOutputDir() + '/lib -L' + GetOutputDir() + '/tmp' for x in obj: @@ -1762,28 +1768,26 @@ def CompileRsrc(target, src, opts): ########################################################################################## # -# RunGenPyCode +# GenPyExtensions # ########################################################################################## -def RunGenPyCode(target, inputs, opts): - if (PkgSkip("PYTHON") != 0): - return +def GenPyExtensions(target, inputs, opts): + # Hopefully the need for this will soon go away as we migrate everything to + # C extensions. - cmdstr = BracketNameWithQuotes(SDK["PYTHONEXEC"]) + " " - if sys.version_info >= (2, 6): - cmdstr += "-B " + code = "# This file is automatically generated by makepanda.py. Do not modify.\n" + code += "from __future__ import absolute_import\n" - cmdstr += os.path.join(GetOutputDir(), "direct", "ffi", "jGenPyCode.py") - if (GENMAN): cmdstr += " -d" - cmdstr += " -r" for i in inputs: - if (GetOrigExt(i)==".pyd"): - cmdstr += " panda3d." + os.path.basename(os.path.splitext(i)[0]) - elif (GetOrigExt(i)==".dll"): - cmdstr += " " + os.path.basename(os.path.splitext(i)[0].replace("_d","")) + if GetOrigExt(i) == ".pyd": + code += "from .%s import *\n" % (os.path.splitext(os.path.basename(i))[0]) + elif GetOrigExt(i) == ".py": + code += "### BEGIN %s\n" % i + code += ReadFile(i) + code += "### END %s\n" % i - oscmd(cmdstr) + WriteFile(target, code) ########################################################################################## # @@ -1793,7 +1797,7 @@ def RunGenPyCode(target, inputs, opts): def FreezePy(target, inputs, opts): assert len(inputs) > 0 - # Make sure this function isn't called before genpycode is run. + cmdstr = BracketNameWithQuotes(SDK["PYTHONEXEC"]) + " " if sys.version_info >= (2, 6): cmdstr += "-B " @@ -1924,9 +1928,9 @@ def CompileAnything(target, inputs, opts, progress = None): if (origsuffix==".exe" and GetHost() != "windows"): os.system("chmod +x \"%s\"" % target) return - elif (target.endswith("pandac/PandaModules.py")): - ProgressOutput(progress, "Generating 'pandac' tree") - return RunGenPyCode(target, inputs, opts) + elif (target.endswith(".py")): + ProgressOutput(progress, "Generating", target) + return GenPyExtensions(target, inputs, opts) elif (infile.endswith(".py")): if (origsuffix==".exe"): ProgressOutput(progress, "Building frozen executable", target) @@ -1963,7 +1967,9 @@ def CompileAnything(target, inputs, opts, progress = None): return CompileLink(target, inputs, opts) elif (origsuffix==".in"): ProgressOutput(progress, "Building Interrogate database", target) - return CompileIgate(target, inputs, opts) + args = CompileIgate(target, inputs, opts) + ProgressOutput(progress, "Building C++ object", args[0]) + return CompileCxx(*args) elif (origsuffix==".plugin" and GetTarget() == "darwin"): ProgressOutput(progress, "Building plugin bundle", target) return CompileBundle(target, inputs, opts) @@ -2046,6 +2052,7 @@ DTOOL_CONFIG=[ ("DO_DCAST", 'UNDEF', 'UNDEF'), ("DO_COLLISION_RECORDING", 'UNDEF', 'UNDEF'), ("SUPPORT_IMMEDIATE_MODE", 'UNDEF', 'UNDEF'), + ("SUPPORT_FIXED_FUNCTION", '1', '1'), ("TRACK_IN_INTERPRETER", 'UNDEF', 'UNDEF'), ("DO_MEMORY_USAGE", 'UNDEF', 'UNDEF'), ("DO_PIPELINING", '1', '1'), @@ -2571,6 +2578,84 @@ if (PkgSkip("DIRECT")==0): if os.path.isfile(GetOutputDir() + '/direct/ffi/panda3d.pyc'): os.remove(GetOutputDir() + '/direct/ffi/panda3d.pyc') +# This used to exist; no longer. +if sys.platform == 'win32': + core_so = GetOutputDir() + '/panda3d/core.pyd' + direct_so = GetOutputDir() + '/panda3d/direct.pyd' + dtoolconfig_so = GetOutputDir() + '/panda3d/dtoolconfig.pyd' +else: + core_so = GetOutputDir() + '/panda3d/core.so' + direct_so = GetOutputDir() + '/panda3d/direct.so' + dtoolconfig_so = GetOutputDir() + '/panda3d/dtoolconfig.so' + +if os.path.isfile(core_so): + os.remove(core_so) +if os.path.isfile(direct_so): + os.remove(direct_so) +if os.path.isfile(dtoolconfig_so): + os.remove(dtoolconfig_so) + +# Write an appropriate panda3d/__init__.py +p3d_init = """"Python bindings for the Panda3D libraries" +""" + +if GetTarget() == 'windows': + p3d_init += """ +import os + +bindir = os.path.join(os.path.dirname(__file__), '..', 'bin') +if os.path.isfile(os.path.join(bindir, 'libpanda.dll')): + if not os.environ.get('PATH'): + os.environ['PATH'] = bindir + else: + os.environ['PATH'] = bindir + os.pathsep + os.environ['PATH'] + +del os, bindir +""" + +ConditionalWriteFile(GetOutputDir() + '/panda3d/__init__.py', p3d_init) + +# PandaModules is now deprecated; generate a shim for backward compatibility. +for fn in glob.glob(GetOutputDir() + '/pandac/*.py') + glob.glob(GetOutputDir() + '/pandac/*.py[co]'): + if os.path.basename(fn) not in ('PandaModules.py', '__init__.py'): + os.remove(fn) + +panda_modules = ['core'] +if not PkgSkip("PANDAPHYSICS"): + panda_modules.append('physics') +if not PkgSkip('PANDAFX'): + panda_modules.append('fx') +if not PkgSkip("DIRECT"): + panda_modules.append('direct') +if not PkgSkip("VISION"): + panda_modules.append('vision') +if not PkgSkip("SKEL"): + panda_modules.append('skel') +panda_modules.append('egg') +if not PkgSkip("AWESOMIUM"): + panda_modules.append('awesomium') +if not PkgSkip("ODE"): + panda_modules.append('ode') +if not PkgSkip("VRPN"): + panda_modules.append('vrpn') + +panda_modules_code = """ +"This module is deprecated. Import from panda3d.core and other panda3d.* modules instead." + +print("Warning: pandac.PandaModules is deprecated, import from panda3d.core instead") +""" + +for module in panda_modules: + panda_modules_code += """ +try: + from panda3d.%s import * +except ImportError, err: + if "No module named %s" not in str(err): + raise""" % (module, module) + +ConditionalWriteFile(GetOutputDir() + '/pandac/PandaModules.py', panda_modules_code) +ConditionalWriteFile(GetOutputDir() + '/pandac/__init__.py', '') + ########################################################################################## # # Generate the PRC files into the ETC directory. @@ -2612,6 +2697,12 @@ ConditionalWriteFile(GetOutputDir()+"/etc/Confauto.prc", confautoprc) tp_dir = GetThirdpartyDir() if tp_dir is not None: + dylibs = set() + + if GetTarget() == 'darwin': + for lib in glob.glob(tp_dir + "/*/lib/*.dylib"): + dylibs.add(os.path.basename(lib)) + for pkg in PkgListGet(): if PkgSkip(pkg): continue @@ -2631,12 +2722,36 @@ if tp_dir is not None: CopyFile(GetOutputDir() + "/lib/" + os.path.basename(tp_lib), tp_lib) if GetTarget() == 'darwin': - for tp_lib in glob.glob(tp_pkg + "/lib/*.dylib"): - CopyFile(GetOutputDir() + "/lib/" + os.path.basename(tp_lib), tp_lib) + tp_libs = glob.glob(tp_pkg + "/lib/*.dylib") if not PkgSkip("PYTHON"): - for tp_lib in glob.glob(os.path.join(tp_pkg, "lib", SDK["PYTHONVERSION"], "*.dylib")): - CopyFile(GetOutputDir() + "/lib/" + os.path.basename(tp_lib), tp_lib) + tp_libs += glob.glob(os.path.join(tp_pkg, "lib", SDK["PYTHONVERSION"], "*.dylib")) + + for tp_lib in tp_libs: + basename = os.path.basename(tp_lib) + target = GetOutputDir() + "/lib/" + basename + if not NeedsBuild([target], [tp_lib]): + continue + + CopyFile(target, tp_lib) + if os.path.islink(target): + continue + + # Correct the inter-library dependencies so that the build is relocatable. + oscmd('install_name_tool -id @loader_path/../lib/%s %s' % (basename, target)) + oscmd("otool -L %s | grep .dylib > %s/tmp/otool-libs.txt" % (target, GetOutputDir()), True) + + for line in open(GetOutputDir() + "/tmp/otool-libs.txt", "r"): + line = line.strip() + if not line or line.startswith('@loader_path/../lib/') or line.endswith(":"): + continue + + libdep = line.split(" ", 1)[0] + dep_basename = os.path.basename(libdep) + if dep_basename in dylibs: + oscmd("install_name_tool -change %s @loader_path/../lib/%s %s" % (libdep, dep_basename, target), True) + + JustBuilt([target], [tp_lib]) for fwx in glob.glob(tp_pkg + "/*.framework"): CopyTree(GetOutputDir() + "/Frameworks/" + os.path.basename(fwx), fwx) @@ -2650,6 +2765,10 @@ if tp_dir is not None: CopyFile(GetOutputDir() + "/bin" + pydll, SDK["PYTHON"] + pydll) if not RTDIST: CopyTree(GetOutputDir() + "/python", SDK["PYTHON"]) + if not os.path.isfile(SDK["PYTHON"] + "/ppython.exe") and os.path.isfile(SDK["PYTHON"] + "/python.exe"): + CopyFile(GetOutputDir() + "/python/ppython.exe", SDK["PYTHON"] + "/python.exe") + if not os.path.isfile(SDK["PYTHON"] + "/ppythonw.exe") and os.path.isfile(SDK["PYTHON"] + "/pythonw.exe"): + CopyFile(GetOutputDir() + "/python/ppythonw.exe", SDK["PYTHON"] + "/pythonw.exe") ConditionalWriteFile(GetOutputDir() + "/python/panda.pth", "..\n../bin\n") ######################################################################## @@ -3015,14 +3134,6 @@ TargetAdd('p3prc_composite2.obj', opts=OPTS, input='p3prc_composite2.cxx') OPTS=['DIR:dtool/src/dconfig', 'BUILDING:DTOOLCONFIG'] TargetAdd('p3dconfig_composite1.obj', opts=OPTS, input='p3dconfig_composite1.cxx') -# -# DIRECTORY: dtool/src/interrogatedb/ -# - -OPTS=['DIR:dtool/src/interrogatedb', 'BUILDING:DTOOLCONFIG'] -TargetAdd('p3interrogatedb_composite1.obj', opts=OPTS, input='p3interrogatedb_composite1.cxx') -TargetAdd('p3interrogatedb_composite2.obj', opts=OPTS, input='p3interrogatedb_composite2.cxx') - # # DIRECTORY: dtool/metalibs/dtoolconfig/ # @@ -3030,21 +3141,38 @@ TargetAdd('p3interrogatedb_composite2.obj', opts=OPTS, input='p3interrogatedb_co OPTS=['DIR:dtool/metalibs/dtoolconfig', 'BUILDING:DTOOLCONFIG'] TargetAdd('p3dtoolconfig_dtoolconfig.obj', opts=OPTS, input='dtoolconfig.cxx') TargetAdd('libp3dtoolconfig.dll', input='p3dtoolconfig_dtoolconfig.obj') -TargetAdd('libp3dtoolconfig.dll', input='p3interrogatedb_composite1.obj') -TargetAdd('libp3dtoolconfig.dll', input='p3interrogatedb_composite2.obj') TargetAdd('libp3dtoolconfig.dll', input='p3dconfig_composite1.obj') TargetAdd('libp3dtoolconfig.dll', input='p3prc_composite1.obj') TargetAdd('libp3dtoolconfig.dll', input='p3prc_composite2.obj') TargetAdd('libp3dtoolconfig.dll', input='libp3dtool.dll') TargetAdd('libp3dtoolconfig.dll', opts=['ADVAPI', 'OPENSSL', 'WINGDI', 'WINUSER']) +# +# DIRECTORY: dtool/src/interrogatedb/ +# + +OPTS=['DIR:dtool/src/interrogatedb', 'BUILDING:INTERROGATEDB'] +TargetAdd('p3interrogatedb_composite1.obj', opts=OPTS, input='p3interrogatedb_composite1.cxx') +TargetAdd('p3interrogatedb_composite2.obj', opts=OPTS, input='p3interrogatedb_composite2.cxx') +TargetAdd('libp3interrogatedb.dll', input='p3interrogatedb_composite1.obj') +TargetAdd('libp3interrogatedb.dll', input='p3interrogatedb_composite2.obj') +TargetAdd('libp3interrogatedb.dll', input='libp3dtool.dll') +TargetAdd('libp3interrogatedb.dll', input='libp3dtoolconfig.dll') +TargetAdd('libp3interrogatedb.dll', opts=['PYTHON']) + if not PkgSkip("PYTHON"): + # This used to be called dtoolconfig.pyd, but it just contains the interrogatedb + # stuff, so it has been renamed appropriately. OPTS=['DIR:dtool/metalibs/dtoolconfig'] - TargetAdd('dtoolconfig_pydtool.obj', opts=OPTS, input="pydtool.cxx") - TargetAdd('dtoolconfig.pyd', input='dtoolconfig_pydtool.obj') - TargetAdd('dtoolconfig.pyd', input='libp3dtoolconfig.dll') - TargetAdd('dtoolconfig.pyd', input='libp3dtool.dll') - TargetAdd('dtoolconfig.pyd', opts=['PYTHON']) + TargetAdd('interrogatedb_pydtool.obj', opts=OPTS, input="pydtool.cxx") + TargetAdd('interrogatedb.pyd', input='interrogatedb_pydtool.obj') + TargetAdd('interrogatedb.pyd', input='libp3dtool.dll') + TargetAdd('interrogatedb.pyd', input='libp3dtoolconfig.dll') + TargetAdd('interrogatedb.pyd', input='libp3interrogatedb.dll') + TargetAdd('interrogatedb.pyd', opts=['PYTHON']) + + # Make a stub file importing the new one for backward compatibility. + TargetAdd('panda3d/dtoolconfig.py', input='interrogatedb.pyd') # # DIRECTORY: dtool/src/pystub/ @@ -3068,12 +3196,14 @@ if (not RUNTIME): TargetAdd('interrogate.exe', input='interrogate_composite2.obj') TargetAdd('interrogate.exe', input='libp3cppParser.ilb') TargetAdd('interrogate.exe', input=COMMON_DTOOL_LIBS_PYSTUB) + TargetAdd('interrogate.exe', input='libp3interrogatedb.dll') TargetAdd('interrogate.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) TargetAdd('interrogate_module_interrogate_module.obj', opts=OPTS, input='interrogate_module.cxx') TargetAdd('interrogate_module.exe', input='interrogate_module_interrogate_module.obj') TargetAdd('interrogate_module.exe', input='libp3cppParser.ilb') TargetAdd('interrogate_module.exe', input=COMMON_DTOOL_LIBS_PYSTUB) + TargetAdd('interrogate_module.exe', input='libp3interrogatedb.dll') TargetAdd('interrogate_module.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) if (not RTDIST): @@ -3081,6 +3211,7 @@ if (not RUNTIME): TargetAdd('parse_file.exe', input='parse_file_parse_file.obj') TargetAdd('parse_file.exe', input='libp3cppParser.ilb') TargetAdd('parse_file.exe', input=COMMON_DTOOL_LIBS_PYSTUB) + TargetAdd('parse_file.exe', input='libp3interrogatedb.dll') TargetAdd('parse_file.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) # @@ -3102,6 +3233,7 @@ if (not RTDIST and not RUNTIME): OPTS=['DIR:dtool/src/test_interrogate'] TargetAdd('test_interrogate_test_interrogate.obj', opts=OPTS, input='test_interrogate.cxx') TargetAdd('test_interrogate.exe', input='test_interrogate_test_interrogate.obj') + TargetAdd('test_interrogate.exe', input='libp3interrogatedb.dll') TargetAdd('test_interrogate.exe', input=COMMON_DTOOL_LIBS_PYSTUB) TargetAdd('test_interrogate.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) @@ -3771,58 +3903,68 @@ if (not RUNTIME): if PkgSkip("FREETYPE")==0: TargetAdd('core_module.obj', input='libp3pnmtext.in') - TargetAdd('core_module.obj', opts=['IMOD:panda3d.core', 'ILIB:core']) + TargetAdd('core_module.obj', opts=['IMOD:panda3d._core', 'ILIB:_core']) - TargetAdd('core.pyd', input='libp3downloader_igate.obj') - TargetAdd('core.pyd', input='p3express_ext_composite.obj') - TargetAdd('core.pyd', input='libp3express_igate.obj') + TargetAdd('_core.pyd', input='libp3downloader_igate.obj') + TargetAdd('_core.pyd', input='p3express_ext_composite.obj') + TargetAdd('_core.pyd', input='libp3express_igate.obj') - TargetAdd('core.pyd', input='libp3recorder_igate.obj') - TargetAdd('core.pyd', input='libp3pgraphnodes_igate.obj') - TargetAdd('core.pyd', input='libp3pgraph_igate.obj') - TargetAdd('core.pyd', input='libp3movies_igate.obj') - TargetAdd('core.pyd', input='libp3grutil_igate.obj') - TargetAdd('core.pyd', input='libp3chan_igate.obj') - TargetAdd('core.pyd', input='libp3pstatclient_igate.obj') - TargetAdd('core.pyd', input='libp3char_igate.obj') - TargetAdd('core.pyd', input='libp3collide_igate.obj') - TargetAdd('core.pyd', input='libp3device_igate.obj') - TargetAdd('core.pyd', input='libp3dgraph_igate.obj') - TargetAdd('core.pyd', input='libp3display_igate.obj') - TargetAdd('core.pyd', input='libp3pipeline_igate.obj') - TargetAdd('core.pyd', input='libp3event_igate.obj') - TargetAdd('core.pyd', input='libp3gobj_igate.obj') - TargetAdd('core.pyd', input='libp3gsgbase_igate.obj') - TargetAdd('core.pyd', input='libp3linmath_igate.obj') - TargetAdd('core.pyd', input='libp3mathutil_igate.obj') - TargetAdd('core.pyd', input='libp3parametrics_igate.obj') - TargetAdd('core.pyd', input='libp3pnmimage_igate.obj') - TargetAdd('core.pyd', input='libp3text_igate.obj') - TargetAdd('core.pyd', input='libp3tform_igate.obj') - TargetAdd('core.pyd', input='libp3putil_igate.obj') - TargetAdd('core.pyd', input='libp3audio_igate.obj') - TargetAdd('core.pyd', input='libp3pgui_igate.obj') - TargetAdd('core.pyd', input='libp3net_igate.obj') - TargetAdd('core.pyd', input='libp3nativenet_igate.obj') - TargetAdd('core.pyd', input='libp3dxml_igate.obj') + TargetAdd('_core.pyd', input='libp3recorder_igate.obj') + TargetAdd('_core.pyd', input='libp3pgraphnodes_igate.obj') + TargetAdd('_core.pyd', input='libp3pgraph_igate.obj') + TargetAdd('_core.pyd', input='libp3movies_igate.obj') + TargetAdd('_core.pyd', input='libp3grutil_igate.obj') + TargetAdd('_core.pyd', input='libp3chan_igate.obj') + TargetAdd('_core.pyd', input='libp3pstatclient_igate.obj') + TargetAdd('_core.pyd', input='libp3char_igate.obj') + TargetAdd('_core.pyd', input='libp3collide_igate.obj') + TargetAdd('_core.pyd', input='libp3device_igate.obj') + TargetAdd('_core.pyd', input='libp3dgraph_igate.obj') + TargetAdd('_core.pyd', input='libp3display_igate.obj') + TargetAdd('_core.pyd', input='libp3pipeline_igate.obj') + TargetAdd('_core.pyd', input='libp3event_igate.obj') + TargetAdd('_core.pyd', input='libp3gobj_igate.obj') + TargetAdd('_core.pyd', input='libp3gsgbase_igate.obj') + TargetAdd('_core.pyd', input='libp3linmath_igate.obj') + TargetAdd('_core.pyd', input='libp3mathutil_igate.obj') + TargetAdd('_core.pyd', input='libp3parametrics_igate.obj') + TargetAdd('_core.pyd', input='libp3pnmimage_igate.obj') + TargetAdd('_core.pyd', input='libp3text_igate.obj') + TargetAdd('_core.pyd', input='libp3tform_igate.obj') + TargetAdd('_core.pyd', input='libp3putil_igate.obj') + TargetAdd('_core.pyd', input='libp3audio_igate.obj') + TargetAdd('_core.pyd', input='libp3pgui_igate.obj') + TargetAdd('_core.pyd', input='libp3net_igate.obj') + TargetAdd('_core.pyd', input='libp3nativenet_igate.obj') + TargetAdd('_core.pyd', input='libp3dxml_igate.obj') if PkgSkip("FREETYPE")==0: - TargetAdd('core.pyd', input="libp3pnmtext_igate.obj") + TargetAdd('_core.pyd', input="libp3pnmtext_igate.obj") - TargetAdd('core.pyd', input='p3putil_typedWritable_ext.obj') - TargetAdd('core.pyd', input='p3putil_pythonCallbackObject.obj') - TargetAdd('core.pyd', input='p3pnmimage_pfmFile_ext.obj') - TargetAdd('core.pyd', input='p3event_pythonTask.obj') - TargetAdd('core.pyd', input='p3gobj_ext_composite.obj') - TargetAdd('core.pyd', input='p3pgraph_ext_composite.obj') - TargetAdd('core.pyd', input='p3display_graphicsStateGuardian_ext.obj') - TargetAdd('core.pyd', input='p3display_graphicsWindow_ext.obj') - TargetAdd('core.pyd', input='p3display_pythonGraphicsWindowProc.obj') + TargetAdd('_core.pyd', input='p3putil_typedWritable_ext.obj') + TargetAdd('_core.pyd', input='p3putil_pythonCallbackObject.obj') + TargetAdd('_core.pyd', input='p3pnmimage_pfmFile_ext.obj') + TargetAdd('_core.pyd', input='p3event_pythonTask.obj') + TargetAdd('_core.pyd', input='p3gobj_ext_composite.obj') + TargetAdd('_core.pyd', input='p3pgraph_ext_composite.obj') + TargetAdd('_core.pyd', input='p3display_graphicsStateGuardian_ext.obj') + TargetAdd('_core.pyd', input='p3display_graphicsWindow_ext.obj') + TargetAdd('_core.pyd', input='p3display_pythonGraphicsWindowProc.obj') - TargetAdd('core.pyd', input='core_module.obj') - TargetAdd('core.pyd', input='libp3tinyxml.ilb') - TargetAdd('core.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('core.pyd', opts=['PYTHON', 'WINSOCK2']) + TargetAdd('_core.pyd', input='core_module.obj') + TargetAdd('_core.pyd', input='libp3tinyxml.ilb') + TargetAdd('_core.pyd', input='libp3interrogatedb.dll') + TargetAdd('_core.pyd', input=COMMON_PANDA_LIBS) + TargetAdd('_core.pyd', opts=['PYTHON', 'WINSOCK2']) + + OPTS=['DIR:direct/src/extensions_native'] + TargetAdd('panda3d/core.py', input='_core.pyd') + TargetAdd('panda3d/core.py', opts=OPTS, input='core_extensions.py') + TargetAdd('panda3d/core.py', opts=OPTS, input='NodePath_extensions.py') + TargetAdd('panda3d/core.py', opts=OPTS, input='Mat3_extensions.py') + TargetAdd('panda3d/core.py', opts=OPTS, input='VBase3_extensions.py') + TargetAdd('panda3d/core.py', opts=OPTS, input='VBase4_extensions.py') + TargetAdd('panda3d/core.py', opts=OPTS, input='HTTPChannel_extensions.py') # # DIRECTORY: panda/src/vision/ @@ -3844,12 +3986,12 @@ if (PkgSkip("VISION") == 0) and (not RUNTIME): TargetAdd('vision_module.obj', input='libp3vision.in') TargetAdd('vision_module.obj', opts=OPTS) - TargetAdd('vision_module.obj', opts=['IMOD:panda3d.vision', 'ILIB:vision']) + TargetAdd('vision_module.obj', opts=['IMOD:panda3d.vision', 'ILIB:vision', 'IMPORT:panda3d._core']) TargetAdd('vision.pyd', input='vision_module.obj') TargetAdd('vision.pyd', input='libp3vision_igate.obj') TargetAdd('vision.pyd', input='libp3vision.dll') - TargetAdd('vision.pyd', input='core.pyd') + TargetAdd('vision.pyd', input='libp3interrogatedb.dll') TargetAdd('vision.pyd', input=COMMON_PANDA_LIBS) TargetAdd('vision.pyd', opts=['PYTHON']) @@ -3875,13 +4017,13 @@ if (PkgSkip("ROCKET") == 0) and (not RUNTIME): TargetAdd('rocket_module.obj', input='libp3rocket.in') TargetAdd('rocket_module.obj', opts=OPTS) - TargetAdd('rocket_module.obj', opts=['IMOD:panda3d.rocket', 'ILIB:rocket']) + TargetAdd('rocket_module.obj', opts=['IMOD:panda3d.rocket', 'ILIB:rocket', 'IMPORT:panda3d._core']) TargetAdd('rocket.pyd', input='rocket_module.obj') TargetAdd('rocket.pyd', input='libp3rocket_igate.obj') TargetAdd('rocket.pyd', input='p3rocket_rocketRegion_ext.obj') TargetAdd('rocket.pyd', input='libp3rocket.dll') - TargetAdd('rocket.pyd', input='core.pyd') + TargetAdd('rocket.pyd', input='libp3interrogatedb.dll') TargetAdd('rocket.pyd', input=COMMON_PANDA_LIBS) TargetAdd('rocket.pyd', opts=['PYTHON', 'ROCKET']) @@ -3903,12 +4045,12 @@ if PkgSkip("AWESOMIUM") == 0 and not RUNTIME: TargetAdd('awesomium_module.obj', input='libp3awesomium.in') TargetAdd('awesomium_module.obj', opts=OPTS) - TargetAdd('awesomium_module.obj', opts=['IMOD:panda3d.awesomium', 'ILIB:awesomium']) + TargetAdd('awesomium_module.obj', opts=['IMOD:panda3d.awesomium', 'ILIB:awesomium', 'IMPORT:panda3d._core']) TargetAdd('awesomium.pyd', input='awesomium_module.obj') TargetAdd('awesomium.pyd', input='libp3awesomium_igate.obj') TargetAdd('awesomium.pyd', input='libp3awesomium.dll') - TargetAdd('awesomium.pyd', input='core.pyd') + TargetAdd('awesomium.pyd', input='libp3interrogatedb.dll') TargetAdd('awesomium.pyd', input=COMMON_PANDA_LIBS) TargetAdd('awesomium.pyd', opts=['PYTHON']) @@ -3937,12 +4079,12 @@ if (PkgSkip('SKEL')==0) and (not RUNTIME): TargetAdd('libpandaskel.dll', opts=OPTS) TargetAdd('skel_module.obj', input='libp3skel.in') - TargetAdd('skel_module.obj', opts=['IMOD:panda3d.skel', 'ILIB:skel']) + TargetAdd('skel_module.obj', opts=['IMOD:panda3d.skel', 'ILIB:skel', 'IMPORT:panda3d._core']) TargetAdd('skel.pyd', input='skel_module.obj') TargetAdd('skel.pyd', input='libp3skel_igate.obj') TargetAdd('skel.pyd', input='libpandaskel.dll') - TargetAdd('skel.pyd', input='core.pyd') + TargetAdd('skel.pyd', input='libp3interrogatedb.dll') TargetAdd('skel.pyd', input=COMMON_PANDA_LIBS) TargetAdd('skel.pyd', opts=['PYTHON']) @@ -3976,12 +4118,12 @@ if (PkgSkip('PANDAFX')==0) and (not RUNTIME): OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'NVIDIACG'] TargetAdd('fx_module.obj', input='libp3distort.in') TargetAdd('fx_module.obj', opts=OPTS) - TargetAdd('fx_module.obj', opts=['IMOD:panda3d.fx', 'ILIB:fx']) + TargetAdd('fx_module.obj', opts=['IMOD:panda3d.fx', 'ILIB:fx', 'IMPORT:panda3d._core']) TargetAdd('fx.pyd', input='fx_module.obj') TargetAdd('fx.pyd', input='libp3distort_igate.obj') TargetAdd('fx.pyd', input='libpandafx.dll') - TargetAdd('fx.pyd', input='core.pyd') + TargetAdd('fx.pyd', input='libp3interrogatedb.dll') TargetAdd('fx.pyd', input=COMMON_PANDA_LIBS) TargetAdd('fx.pyd', opts=['PYTHON']) @@ -4004,12 +4146,12 @@ if (PkgSkip("VRPN")==0 and not RUNTIME): TargetAdd('vrpn_module.obj', input='libp3vrpn.in') TargetAdd('vrpn_module.obj', opts=OPTS) - TargetAdd('vrpn_module.obj', opts=['IMOD:panda3d.vrpn', 'ILIB:vrpn']) + TargetAdd('vrpn_module.obj', opts=['IMOD:panda3d.vrpn', 'ILIB:vrpn', 'IMPORT:panda3d._core']) TargetAdd('vrpn.pyd', input='vrpn_module.obj') TargetAdd('vrpn.pyd', input='libp3vrpn_igate.obj') TargetAdd('vrpn.pyd', input='libp3vrpn.dll') - TargetAdd('vrpn.pyd', input='core.pyd') + TargetAdd('vrpn.pyd', input='libp3interrogatedb.dll') TargetAdd('vrpn.pyd', input=COMMON_PANDA_LIBS) TargetAdd('vrpn.pyd', opts=['PYTHON']) @@ -4237,14 +4379,14 @@ if (not RUNTIME): TargetAdd('egg_module.obj', input='libp3egg2pg.in') TargetAdd('egg_module.obj', input='libp3egg.in') TargetAdd('egg_module.obj', opts=OPTS) - TargetAdd('egg_module.obj', opts=['IMOD:panda3d.egg', 'ILIB:egg']) + TargetAdd('egg_module.obj', opts=['IMOD:panda3d.egg', 'ILIB:egg', 'IMPORT:panda3d._core']) TargetAdd('egg.pyd', input='egg_module.obj') TargetAdd('egg.pyd', input='p3egg_eggGroupNode_ext.obj') TargetAdd('egg.pyd', input='libp3egg_igate.obj') TargetAdd('egg.pyd', input='libp3egg2pg_igate.obj') TargetAdd('egg.pyd', input='libpandaegg.dll') - TargetAdd('egg.pyd', input='core.pyd') + TargetAdd('egg.pyd', input='libp3interrogatedb.dll') TargetAdd('egg.pyd', input=COMMON_PANDA_LIBS) TargetAdd('egg.pyd', opts=['PYTHON']) @@ -4404,13 +4546,13 @@ if (PkgSkip("ODE")==0 and not RUNTIME): OPTS=['DIR:panda/metalibs/pandaode', 'ODE'] TargetAdd('ode_module.obj', input='libpandaode.in') TargetAdd('ode_module.obj', opts=OPTS) - TargetAdd('ode_module.obj', opts=['IMOD:panda3d.ode', 'ILIB:ode']) + TargetAdd('ode_module.obj', opts=['IMOD:panda3d.ode', 'ILIB:ode', 'IMPORT:panda3d._core']) TargetAdd('ode.pyd', input='ode_module.obj') TargetAdd('ode.pyd', input='libpandaode_igate.obj') TargetAdd('ode.pyd', input='p3ode_ext_composite.obj') TargetAdd('ode.pyd', input='libpandaode.dll') - TargetAdd('ode.pyd', input='core.pyd') + TargetAdd('ode.pyd', input='libp3interrogatedb.dll') TargetAdd('ode.pyd', input=COMMON_PANDA_LIBS) TargetAdd('ode.pyd', opts=['PYTHON', 'WINUSER', 'ODE']) @@ -4442,12 +4584,12 @@ if (PkgSkip("BULLET")==0 and not RUNTIME): OPTS=['DIR:panda/metalibs/pandabullet', 'BULLET'] TargetAdd('bullet_module.obj', input='libpandabullet.in') TargetAdd('bullet_module.obj', opts=OPTS) - TargetAdd('bullet_module.obj', opts=['IMOD:panda3d.bullet', 'ILIB:bullet']) + TargetAdd('bullet_module.obj', opts=['IMOD:panda3d.bullet', 'ILIB:bullet', 'IMPORT:panda3d._core']) TargetAdd('bullet.pyd', input='bullet_module.obj') TargetAdd('bullet.pyd', input='libpandabullet_igate.obj') TargetAdd('bullet.pyd', input='libpandabullet.dll') - TargetAdd('bullet.pyd', input='core.pyd') + TargetAdd('bullet.pyd', input='libp3interrogatedb.dll') TargetAdd('bullet.pyd', input=COMMON_PANDA_LIBS) TargetAdd('bullet.pyd', opts=['PYTHON', 'WINUSER', 'BULLET']) @@ -4481,12 +4623,12 @@ if (PkgSkip("PHYSX")==0): OPTS=['DIR:panda/metalibs/pandaphysx', 'PHYSX', 'NOARCH:PPC'] TargetAdd('physx_module.obj', input='libpandaphysx.in') TargetAdd('physx_module.obj', opts=OPTS) - TargetAdd('physx_module.obj', opts=['IMOD:panda3d.physx', 'ILIB:physx']) + TargetAdd('physx_module.obj', opts=['IMOD:panda3d.physx', 'ILIB:physx', 'IMPORT:panda3d._core']) TargetAdd('physx.pyd', input='physx_module.obj') TargetAdd('physx.pyd', input='libpandaphysx_igate.obj') TargetAdd('physx.pyd', input='libpandaphysx.dll') - TargetAdd('physx.pyd', input='core.pyd') + TargetAdd('physx.pyd', input='libp3interrogatedb.dll') TargetAdd('physx.pyd', input=COMMON_PANDA_LIBS) TargetAdd('physx.pyd', opts=['PYTHON', 'WINUSER', 'PHYSX', 'NOARCH:PPC']) @@ -4547,14 +4689,14 @@ if (PkgSkip("PANDAPHYSICS")==0) and (not RUNTIME): if (PkgSkip("PANDAPARTICLESYSTEM")==0): TargetAdd('physics_module.obj', input='libp3particlesystem.in') TargetAdd('physics_module.obj', opts=OPTS) - TargetAdd('physics_module.obj', opts=['IMOD:panda3d.physics', 'ILIB:physics']) + TargetAdd('physics_module.obj', opts=['IMOD:panda3d.physics', 'ILIB:physics', 'IMPORT:panda3d._core']) TargetAdd('physics.pyd', input='physics_module.obj') TargetAdd('physics.pyd', input='libp3physics_igate.obj') if (PkgSkip("PANDAPARTICLESYSTEM")==0): TargetAdd('physics.pyd', input='libp3particlesystem_igate.obj') TargetAdd('physics.pyd', input='libpandaphysics.dll') - TargetAdd('physics.pyd', input='core.pyd') + TargetAdd('physics.pyd', input='libp3interrogatedb.dll') TargetAdd('physics.pyd', input=COMMON_PANDA_LIBS) TargetAdd('physics.pyd', opts=['PYTHON']) @@ -4804,19 +4946,23 @@ if (PkgSkip("DIRECT")==0): TargetAdd('direct_module.obj', input='libp3interval.in') TargetAdd('direct_module.obj', input='libp3distributed.in') TargetAdd('direct_module.obj', opts=OPTS) - TargetAdd('direct_module.obj', opts=['IMOD:panda3d.direct', 'ILIB:direct']) + TargetAdd('direct_module.obj', opts=['IMOD:panda3d._direct', 'ILIB:_direct', 'IMPORT:panda3d._core']) - TargetAdd('direct.pyd', input='libp3dcparser_igate.obj') - TargetAdd('direct.pyd', input='libp3showbase_igate.obj') - TargetAdd('direct.pyd', input='libp3deadrec_igate.obj') - TargetAdd('direct.pyd', input='libp3interval_igate.obj') - TargetAdd('direct.pyd', input='libp3distributed_igate.obj') + TargetAdd('_direct.pyd', input='libp3dcparser_igate.obj') + TargetAdd('_direct.pyd', input='libp3showbase_igate.obj') + TargetAdd('_direct.pyd', input='libp3deadrec_igate.obj') + TargetAdd('_direct.pyd', input='libp3interval_igate.obj') + TargetAdd('_direct.pyd', input='libp3distributed_igate.obj') - TargetAdd('direct.pyd', input='direct_module.obj') - TargetAdd('direct.pyd', input='libp3direct.dll') - TargetAdd('direct.pyd', input='core.pyd') - TargetAdd('direct.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('direct.pyd', opts=['PYTHON', 'OPENSSL', 'WINUSER', 'WINGDI']) + TargetAdd('_direct.pyd', input='direct_module.obj') + TargetAdd('_direct.pyd', input='libp3direct.dll') + TargetAdd('_direct.pyd', input='libp3interrogatedb.dll') + TargetAdd('_direct.pyd', input=COMMON_PANDA_LIBS) + TargetAdd('_direct.pyd', opts=['PYTHON', 'OPENSSL', 'WINUSER', 'WINGDI']) + + OPTS=['DIR:direct/src/extensions_native'] + TargetAdd('panda3d/direct.py', input='_direct.pyd') + TargetAdd('panda3d/direct.py', opts=OPTS, input='CInterval_extensions.py') # # DIRECTORY: direct/src/dcparse/ @@ -5207,6 +5353,16 @@ if (PkgSkip("PANDATOOL")==0 and PkgSkip("FCOLLADA")==0): TargetAdd('libp3daeegg.lib', input='p3daeegg_composite1.obj') TargetAdd('libp3daeegg.lib', opts=['FCOLLADA', 'CARBON']) +# +# DIRECTORY: pandatool/src/assimp +# +if (PkgSkip("PANDATOOL") == 0 and PkgSkip("ASSIMP")==0): + OPTS=['DIR:pandatool/src/assimp', 'BUILDING:ASSIMP', 'ASSIMP', 'MODULE'] + TargetAdd('p3assimp_composite1.obj', opts=OPTS, input='p3assimp_composite1.cxx') + TargetAdd('libp3assimp.dll', input='p3assimp_composite1.obj') + TargetAdd('libp3assimp.dll', input=COMMON_PANDA_LIBS) + TargetAdd('libp3assimp.dll', opts=OPTS) + # # DIRECTORY: pandatool/src/daeprogs/ # @@ -6004,44 +6160,15 @@ if (PkgSkip("CONTRIB")==0 and not RUNTIME): TargetAdd('ai_module.obj', input='libpandaai.in') TargetAdd('ai_module.obj', opts=OPTS) - TargetAdd('ai_module.obj', opts=['IMOD:panda3d.ai', 'ILIB:ai']) + TargetAdd('ai_module.obj', opts=['IMOD:panda3d.ai', 'ILIB:ai', 'IMPORT:panda3d._core']) TargetAdd('ai.pyd', input='ai_module.obj') TargetAdd('ai.pyd', input='libpandaai_igate.obj') TargetAdd('ai.pyd', input='libpandaai.dll') - TargetAdd('ai.pyd', input='core.pyd') + TargetAdd('ai.pyd', input='libp3interrogatedb.dll') TargetAdd('ai.pyd', input=COMMON_PANDA_LIBS) TargetAdd('ai.pyd', opts=['PYTHON']) -# -# Run genpycode -# - -if (PkgSkip("PYTHON")==0 and not RUNTIME): - # We're phasing out the concept of PandaModules, so do not - # add new libraries here. Only add new libraries when you've - # split them out of libpanda and need to maintain backward - # compatibility with old imports. See direct/src/ffi/panda3d.py - - TargetAdd('PandaModules.py', input='core.pyd') - if (PkgSkip("PANDAPHYSICS")==0): - TargetAdd('PandaModules.py', input='physics.pyd') - if (PkgSkip('PANDAFX')==0): - TargetAdd('PandaModules.py', input='fx.pyd') - if (PkgSkip("DIRECT")==0): - TargetAdd('PandaModules.py', input='direct.pyd') - if (PkgSkip("VISION")==0): - TargetAdd('PandaModules.py', input='vision.pyd') - if (PkgSkip("SKEL")==0): - TargetAdd('PandaModules.py', input='skel.pyd') - TargetAdd('PandaModules.py', input='egg.pyd') - if (PkgSkip("AWESOMIUM")==0): - TargetAdd('PandaModules.py', input='awesomium.pyd') - if (PkgSkip("ODE")==0): - TargetAdd('PandaModules.py', input='ode.pyd') - if (PkgSkip("VRPN")==0): - TargetAdd('PandaModules.py', input='vrpn.pyd') - # # Generate the models directory and samples directory # @@ -6289,7 +6416,7 @@ def MakeInstallerNSIS(file, title, installdir): shutil.move("direct\\src\\plugin_installer\\p3d-setup.exe", file) return - print("Building "+title+" installer. This can take up to an hour.") + print("Building "+title+" installer at %s" % (file)) if (COMPRESSOR != "lzma"): print("Note: you are using zlib, which is faster, but lzma gives better compression.") if (os.path.exists("nsis-output.exe")): @@ -6642,16 +6769,6 @@ def MakeInstallerOSX(): # On OSX, just specifying -P is not enough to do that. oscmd("cp -R -P " + GetOutputDir() + "/" + base + " " + libname) - # Execute install_name_tool to make them reference an absolute path - if (libname.endswith(".dylib") or libname.endswith(".so")) and not os.path.islink(libname): - oscmd("install_name_tool -id /Developer/Panda3D/%s %s" % (base, libname), True) - oscmd("otool -L %s | grep .dylib > %s/tmp/otool-libs.txt" % (libname, GetOutputDir()), True) - for line in open(GetOutputDir()+"/tmp/otool-libs.txt", "r"): - if len(line.strip()) > 0 and not line.strip().endswith(":"): - libdep = line.strip().split(" ", 1)[0] - if 'lib/' + os.path.basename(libdep) in install_libs: - oscmd("install_name_tool -change %s /Developer/Panda3D/lib/%s %s" % (libdep, os.path.basename(libdep), libname), True) - oscmd("mkdir -p dstroot/tools/Developer/Tools/Panda3D") oscmd("mkdir -p dstroot/tools/Developer/Panda3D") oscmd("mkdir -p dstroot/tools/etc/paths.d") @@ -6666,15 +6783,6 @@ def MakeInstallerOSX(): # OSX needs the -R argument to copy symbolic links correctly, it doesn't have -d. How weird. oscmd("cp -R " + GetOutputDir() + "/bin/" + base + " " + binname) - # Execute install_name_tool to make the binaries reference an absolute path - if (not os.path.islink(binname)): - oscmd("otool -L %s | grep .dylib > %s/tmp/otool-libs.txt" % (binname, GetOutputDir()), True) - for line in open(GetOutputDir()+"/tmp/otool-libs.txt", "r"): - if len(line.strip()) > 0 and not line.strip().endswith(":"): - libdep = line.strip().split(" ", 1)[0] - if 'lib/' + os.path.basename(libdep) in install_libs: - oscmd("install_name_tool -change %s /Developer/Panda3D/lib/%s %s" % (libdep, os.path.basename(libdep), binname), True) - if PkgSkip("PYTHON")==0: PV = SDK["PYTHONVERSION"].replace("python", "") oscmd("mkdir -p dstroot/pythoncode/usr/bin") @@ -6728,8 +6836,12 @@ def MakeInstallerOSX(): cmd = '/Developer/usr/bin/packagemaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg ' + target + ' --domain system --root dstroot/' + pkg + '/ --no-relocate' elif os.path.exists("/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"): cmd = '/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg ' + target + ' --domain system --root dstroot/' + pkg + '/ --no-relocate' + elif os.path.exists("/Developer/Tools/PackageMaker.app/Contents/MacOS/PackageMaker"): + cmd = '/Developer/Tools/PackageMaker.app/Contents/MacOS/PackageMaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg ' + target + ' --domain system --root dstroot/' + pkg + '/ --no-relocate' elif os.path.exists("/Developer/Tools/packagemaker"): cmd = '/Developer/Tools/packagemaker -build -f dstroot/' + pkg + '/ -p dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg -i /tmp/Info_plist' + elif os.path.exists("/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"): + cmd = '/Applications/PackageMaker.app/Contents/MacOS/PackageMaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg ' + target + ' --domain system --root dstroot/' + pkg + '/ --no-relocate' else: exit("PackageMaker could not be found!") oscmd(cmd) @@ -6846,19 +6958,29 @@ try: if INSTALLER: ProgressOutput(100.0, "Building installer") target = GetTarget() - if (target == 'windows'): - dbg = "" - if (GetOptimize() <= 2): dbg = "-dbg" - if GetTargetArch() == 'x64': - if (RUNTIME): - MakeInstallerNSIS("Panda3D-Runtime-"+VERSION+dbg+"-x64.exe", "Panda3D "+VERSION, "C:\\Panda3D-"+VERSION+"-x64") - else: - MakeInstallerNSIS("Panda3D-"+VERSION+dbg+"-x64.exe", "Panda3D SDK "+VERSION, "C:\\Panda3D-"+VERSION+"-x64") + if target == 'windows': + fn = "Panda3D-" + dir = "C:\\Panda3D-" + VERSION + + if RUNTIME: + fn += "Runtime-" + title = "Panda3D " + VERSION else: - if (RUNTIME): - MakeInstallerNSIS("Panda3D-Runtime-"+VERSION+dbg+".exe", "Panda3D "+VERSION, "C:\\Panda3D-"+VERSION) - else: - MakeInstallerNSIS("Panda3D-"+VERSION+dbg+".exe", "Panda3D SDK "+VERSION, "C:\\Panda3D-"+VERSION) + title = "Panda3D SDK " + VERSION + + fn += VERSION + + if SDK["PYTHONVERSION"] != "python2.7": + fn += '-py' + SDK["PYTHONVERSION"][6:] + + if GetOptimize() <= 2: + fn += "-dbg" + if GetTargetArch() == 'x64': + fn += '-x64' + dir += '-x64' + + fn += '.exe' + MakeInstallerNSIS(fn, title, dir) elif (target == 'linux'): MakeInstallerLinux() elif (target == 'darwin'): diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 899434d677..aa3207b806 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -79,6 +79,7 @@ MAYAVERSIONINFO = [("MAYA6", "6.0"), ("MAYA20135","2013.5"), ("MAYA2014","2014"), ("MAYA2015","2015"), + ("MAYA2016","2016"), ] MAXVERSIONINFO = [("MAX6", "SOFTWARE\\Autodesk\\3DSMAX\\6.0", "installdir", "maxsdk\\cssdk\\include"), @@ -1060,7 +1061,6 @@ def MakeBuildTree(): MakeDirectory(OUTPUTDIR + "/pandac") MakeDirectory(OUTPUTDIR + "/pandac/input") MakeDirectory(OUTPUTDIR + "/panda3d") - CreateFile(OUTPUTDIR + "/panda3d/__init__.py") if GetTarget() == 'darwin': MakeDirectory(OUTPUTDIR + "/Frameworks") @@ -1845,12 +1845,18 @@ def SdkLocatePython(prefer_thirdparty_python=False): return if GetTarget() == 'windows': - SDK["PYTHON"] = GetThirdpartyBase() + "/win-python" - if (GetOptimize() <= 2): - SDK["PYTHON"] += "-dbg" - if (GetTargetArch() == 'x64' and os.path.isdir(SDK["PYTHON"] + "-x64")): - SDK["PYTHON"] += "-x64" + sdkdir = GetThirdpartyBase() + "/win-python" + if sys.version_info >= (3, 0): + # Python 3 build... + sdkdir += "%d.%d" % sys.version_info[:2] + + if GetOptimize() <= 2: + sdkdir += "-dbg" + if GetTargetArch() == 'x64': + sdkdir += "-x64" + + SDK["PYTHON"] = sdkdir SDK["PYTHONEXEC"] = SDK["PYTHON"].replace('/', '\\') + "\\python" if (GetOptimize() <= 2): SDK["PYTHONEXEC"] += "_d.exe" @@ -1872,10 +1878,14 @@ def SdkLocatePython(prefer_thirdparty_python=False): exit("Found multiple Python dlls in %s." % (SDK["PYTHON"])) py_dll = os.path.basename(py_dlls[0]) - SDK["PYTHONVERSION"] = "python" + py_dll[6] + "." + py_dll[7] + ver = py_dll[6] + "." + py_dll[7] + SDK["PYTHONVERSION"] = "python" + ver os.environ["PYTHONHOME"] = SDK["PYTHON"] + if sys.version[:3] != ver: + print("Warning: running makepanda with Python %s, but building Panda3D with Python %s." % (sys.version[:3], ver)) + elif CrossCompiling() or (prefer_thirdparty_python and os.path.isdir(os.path.join(GetThirdpartyDir(), "python"))): tp_python = os.path.join(GetThirdpartyDir(), "python") @@ -1933,6 +1943,8 @@ def SdkLocatePython(prefer_thirdparty_python=False): if GetVerbose(): print("Using Python %s build located at %s" % (SDK["PYTHONVERSION"][6:9], SDK["PYTHON"])) + else: + print("Using Python %s" % (SDK["PYTHONVERSION"][6:9])) def SdkLocateVisualStudio(): if (GetHost() != "windows"): return @@ -2287,7 +2299,7 @@ def SetupBuildEnvironment(compiler): print("Host OS: %s" % GetHost()) print("Host arch: %s" % GetHostArch()) print("Target OS: %s" % GetTarget()) - print("Target arch: %s" % GetTargetArch()) + print("Target arch: %s" % GetTargetArch()) if compiler == "MSVC": # Add the visual studio tools to PATH et al. @@ -2693,17 +2705,20 @@ def SetOrigExt(x, v): ORIG_EXT[x] = v def CalcLocation(fn, ipath): + if fn.startswith("panda3d/") and fn.endswith(".py"): + return OUTPUTDIR + "/" + fn + if (fn.count("/")): return fn dllext = "" target = GetTarget() if (GetOptimize() <= 2 and target == 'windows'): dllext = "_d" - if (fn == "PandaModules.py"): return OUTPUTDIR+"/pandac/" + fn if (fn == "AndroidManifest.xml"): return OUTPUTDIR+"/"+fn if (fn.endswith(".cxx")): return CxxFindSource(fn, ipath) if (fn.endswith(".I")): return CxxFindSource(fn, ipath) if (fn.endswith(".h")): return CxxFindSource(fn, ipath) if (fn.endswith(".c")): return CxxFindSource(fn, ipath) + if (fn.endswith(".py")): return CxxFindSource(fn, ipath) if (fn.endswith(".yxx")): return CxxFindSource(fn, ipath) if (fn.endswith(".lxx")): return CxxFindSource(fn, ipath) if (fn.endswith(".pdef")):return CxxFindSource(fn, ipath) diff --git a/panda/.gitignore b/panda/.gitignore index 3fbb4b2955..ec20cdb1ee 100644 --- a/panda/.gitignore +++ b/panda/.gitignore @@ -1,4 +1,5 @@ *.pyc +*.pyo # These are files that are generated within the source tree by the # ppremake system. Makefile diff --git a/panda/src/bullet/bulletRigidBodyNode.h b/panda/src/bullet/bulletRigidBodyNode.h index 73ba5568a3..309e2386a1 100644 --- a/panda/src/bullet/bulletRigidBodyNode.h +++ b/panda/src/bullet/bulletRigidBodyNode.h @@ -33,7 +33,7 @@ class BulletShape; class EXPCL_PANDABULLET BulletRigidBodyNode : public BulletBodyNode { PUBLISHED: - BulletRigidBodyNode(const char *name="rigid"); + explicit BulletRigidBodyNode(const char *name="rigid"); INLINE ~BulletRigidBodyNode(); // Mass & inertia diff --git a/panda/src/chan/animChannelMatrixFixed.h b/panda/src/chan/animChannelMatrixFixed.h index b367df0105..a2a72889b5 100644 --- a/panda/src/chan/animChannelMatrixFixed.h +++ b/panda/src/chan/animChannelMatrixFixed.h @@ -20,8 +20,6 @@ #include "animChannel.h" #include "luse.h" -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_CHAN, EXPTP_PANDA_CHAN, AnimChannel); - //////////////////////////////////////////////////////////////////// // Class : AnimChannelMatrixFixed // Description : A specialization on AnimChannel to add all the diff --git a/panda/src/display/get_x11.h b/panda/src/display/get_x11.h index 7ea150a963..5e246e5ae0 100644 --- a/panda/src/display/get_x11.h +++ b/panda/src/display/get_x11.h @@ -52,7 +52,6 @@ struct XVisualInfo; #include #include #include -#include #ifdef HAVE_XRANDR #include @@ -63,7 +62,7 @@ struct XVisualInfo; #endif #ifdef HAVE_XF86DGA -#include +#include #endif #include "post_x11_include.h" diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 41cc8315ea..a3979a6c2c 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -814,17 +814,12 @@ dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) { //////////////////////////////////////////////////////////////////// PT(GeomMunger) GraphicsStateGuardian:: get_geom_munger(const RenderState *state, Thread *current_thread) { - // We can cast the RenderState to a non-const object because we are - // only updating a cache within the RenderState, not really changing - // any of its properties. - RenderState *nc_state = ((RenderState *)state); - // Before we even look up the map, see if the _last_mi value points // to this GSG. This is likely because we tend to visit the same // state multiple times during a frame. Also, this might well be // the only GSG in the world anyway. - if (!nc_state->_mungers.empty()) { - RenderState::Mungers::const_iterator mi = nc_state->_last_mi; + if (!state->_mungers.empty()) { + RenderState::Mungers::const_iterator mi = state->_last_mi; if (!(*mi).first.was_deleted() && (*mi).first == this) { if ((*mi).second->is_registered()) { return (*mi).second; @@ -833,23 +828,23 @@ get_geom_munger(const RenderState *state, Thread *current_thread) { } // Nope, we have to look it up in the map. - RenderState::Mungers::iterator mi = nc_state->_mungers.find(this); - if (mi != nc_state->_mungers.end() && !(*mi).first.was_deleted()) { + RenderState::Mungers::iterator mi = state->_mungers.find(this); + if (mi != state->_mungers.end() && !(*mi).first.was_deleted()) { if ((*mi).second->is_registered()) { - nc_state->_last_mi = mi; + state->_last_mi = mi; return (*mi).second; } // This GeomMunger is no longer registered. Remove it from the // map. - nc_state->_mungers.erase(mi); + state->_mungers.erase(mi); } // Nothing in the map; create a new entry. - PT(GeomMunger) munger = make_geom_munger(nc_state, current_thread); + PT(GeomMunger) munger = make_geom_munger(state, current_thread); nassertr(munger != (GeomMunger *)NULL && munger->is_registered(), munger); - mi = nc_state->_mungers.insert(RenderState::Mungers::value_type(this, munger)).first; - nc_state->_last_mi = mi; + mi = state->_mungers.insert(RenderState::Mungers::value_type(this, munger)).first; + state->_last_mi = mi; return munger; } @@ -1267,10 +1262,17 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, case Shader::SMO_model_to_view: { return &(get_external_transform()->get_mat()); } + case Shader::SMO_model_to_apiview: { + return &(get_internal_transform()->get_mat()); + } case Shader::SMO_view_to_model: { t = get_external_transform()->get_inverse()->get_mat(); return &t; } + case Shader::SMO_apiview_to_model: { + t = get_internal_transform()->get_inverse()->get_mat(); + return &t; + } case Shader::SMO_apiview_to_view: { return &(_inv_cs_transform->get_mat()); } @@ -1303,6 +1305,12 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, t = _cs_transform->get_mat() * _projection_mat->get_mat(); return &t; } + case Shader::SMO_apiclip_to_apiview: { + return &(_projection_mat_inv->get_mat()); + } + case Shader::SMO_apiview_to_apiclip: { + return &(_projection_mat->get_mat()); + } case Shader::SMO_view_x_to_view: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); nassertr(!np.is_empty(), &LMatrix4::ident_mat()); diff --git a/panda/src/display/pStatGPUTimer.I b/panda/src/display/pStatGPUTimer.I index 27f4938917..4493f4ab9b 100644 --- a/panda/src/display/pStatGPUTimer.I +++ b/panda/src/display/pStatGPUTimer.I @@ -25,7 +25,7 @@ PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector) : PStatTimer(collector), _gsg(gsg) { - if (gsg->get_timer_queries_active()) { + if (gsg->get_timer_queries_active() && collector.is_active()) { gsg->issue_timer_query(collector.get_index()); //cerr << "issuing " << collector << " active " << collector.is_active() << "\n"; } @@ -41,7 +41,7 @@ PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector, Thread *cur PStatTimer(collector, current_thread), _gsg(gsg) { - if (gsg->get_timer_queries_active()) { + if (gsg->get_timer_queries_active() && collector.is_active()) { gsg->issue_timer_query(collector.get_index()); } } @@ -53,7 +53,7 @@ PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector, Thread *cur //////////////////////////////////////////////////////////////////// INLINE PStatGPUTimer:: ~PStatGPUTimer() { - if (_gsg->get_timer_queries_active()) { + if (_gsg->get_timer_queries_active() && _collector.is_active()) { _gsg->issue_timer_query(_collector.get_index() | 0x8000); } } diff --git a/panda/src/display/standardMunger.cxx b/panda/src/display/standardMunger.cxx index 45fcc7feb1..85ddd0f3e1 100644 --- a/panda/src/display/standardMunger.cxx +++ b/panda/src/display/standardMunger.cxx @@ -37,14 +37,14 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, StateMunger(gsg), _num_components(num_components), _numeric_type(numeric_type), - _contents(contents) + _contents(contents), + _munge_color(false), + _munge_color_scale(false), + _auto_shader(false), + _shader_skinning(false) { _render_mode = DCAST(RenderModeAttrib, state->get_attrib(RenderModeAttrib::get_class_slot())); - _munge_color = false; - _munge_color_scale = false; - _auto_shader = false; - if (!get_gsg()->get_runtime_color_scale()) { // We might need to munge the colors. const ColorAttrib *color_attrib = (const ColorAttrib *) @@ -98,6 +98,9 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, if (shader_attrib->auto_shader()) { _auto_shader = true; } + if (shader_attrib->get_flag(ShaderAttrib::F_hardware_skinning)) { + _shader_skinning = true; + } } //////////////////////////////////////////////////////////////////// @@ -128,9 +131,13 @@ munge_data_impl(const GeomVertexData *data) { } GeomVertexAnimationSpec animation = new_data->get_format()->get_animation(); - if (hardware_animated_vertices && - animation.get_animation_type() == AT_panda && - new_data->get_slider_table() == (SliderTable *)NULL) { + if (_shader_skinning || (_auto_shader && hardware_animated_vertices && + !basic_shaders_only && animation.get_animation_type() == AT_panda)) { + animation.set_hardware(4, true); + + } else if (hardware_animated_vertices && + animation.get_animation_type() == AT_panda && + new_data->get_slider_table() == (SliderTable *)NULL) { // Maybe we can animate the vertices with hardware. const TransformBlendTable *table = new_data->get_transform_blend_table(); if (table != (TransformBlendTable *)NULL && @@ -161,7 +168,7 @@ munge_data_impl(const GeomVertexData *data) { } } } - + CPT(GeomVertexFormat) orig_format = new_data->get_format(); CPT(GeomVertexFormat) new_format = munge_format(orig_format, animation); @@ -306,7 +313,9 @@ compare_to_impl(const GeomMunger *other) const { return compare; } } - + if (_shader_skinning != om->_shader_skinning) { + return (int)_shader_skinning - (int)om->_shader_skinning; + } if (_auto_shader != om->_auto_shader) { return (int)_auto_shader - (int)om->_auto_shader; } @@ -345,6 +354,9 @@ geom_compare_to_impl(const GeomMunger *other) const { return compare; } } + if (_shader_skinning != om->_shader_skinning) { + return (int)_shader_skinning - (int)om->_shader_skinning; + } return StateMunger::geom_compare_to_impl(other); } @@ -376,7 +388,17 @@ munge_state_impl(const RenderState *state) { } if (shader_state->_generated_shader == NULL) { // Cache the generated ShaderAttrib on the shader state. - shader_state->_generated_shader = shader_generator->synthesize_shader(shader_state); + GeomVertexAnimationSpec spec; + + // Currently we overload this flag to request vertex animation + // for the shader generator. + const ShaderAttrib *sattr; + shader_state->get_attrib_def(sattr); + if (sattr->get_flag(ShaderAttrib::F_hardware_skinning)) { + spec.set_hardware(4, true); + } + + shader_state->_generated_shader = shader_generator->synthesize_shader(shader_state, spec); } munged_state = munged_state->set_attrib(shader_state->_generated_shader); } diff --git a/panda/src/display/standardMunger.h b/panda/src/display/standardMunger.h index 872d2d8403..515a1d1ace 100644 --- a/panda/src/display/standardMunger.h +++ b/panda/src/display/standardMunger.h @@ -60,6 +60,7 @@ private: bool _munge_color; bool _munge_color_scale; bool _auto_shader; + bool _shader_skinning; LColor _color; LVecBase4 _color_scale; diff --git a/panda/src/downloader/httpClient.h b/panda/src/downloader/httpClient.h index 5d6b0c8aea..cabc03c924 100644 --- a/panda/src/downloader/httpClient.h +++ b/panda/src/downloader/httpClient.h @@ -77,7 +77,6 @@ PUBLISHED: void clear_direct_host(); void add_direct_host(const string &hostname); - void get_proxies_for_url(const URLSpec &url, pvector &proxies) const; string get_proxies_for_url(const URLSpec &url) const; void set_username(const string &server, const string &realm, const string &username); @@ -134,6 +133,8 @@ PUBLISHED: static HTTPClient *get_global_ptr(); public: + void get_proxies_for_url(const URLSpec &url, pvector &proxies) const; + SSL_CTX *get_ssl_ctx(); private: diff --git a/panda/src/downloader/stringStream.h b/panda/src/downloader/stringStream.h index 366f0d1394..d90314c46e 100644 --- a/panda/src/downloader/stringStream.h +++ b/panda/src/downloader/stringStream.h @@ -34,6 +34,8 @@ PUBLISHED: INLINE string get_data(); INLINE void set_data(const string &data); + +public: INLINE void swap_data(pvector &data); private: diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index 886ffd2af5..70b5ff8f47 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -118,7 +118,7 @@ munge_format_impl(const GeomVertexFormat *orig, if (normal_type != (const GeomVertexColumn *)NULL) { new_array_format->add_column - (InternalName::get_normal(), 3, NT_float32, C_vector); + (InternalName::get_normal(), 3, NT_float32, C_normal); new_format->remove_column(normal_type->get_name()); } @@ -227,7 +227,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { if (normal_type != (const GeomVertexColumn *)NULL) { new_array_format->add_column - (InternalName::get_normal(), 3, NT_float32, C_vector); + (InternalName::get_normal(), 3, NT_float32, C_normal); new_format->remove_column(normal_type->get_name()); } diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index cafc199a95..c8d7833b4f 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -2316,8 +2316,6 @@ reset() { Geom::GR_triangle_strip | Geom::GR_triangle_fan | Geom::GR_flat_first_vertex; - _auto_rescale_normal = false; - // overwrite gsg defaults with these values HRESULT hr; @@ -2864,10 +2862,6 @@ do_issue_transform() { } _transform_stale = false; - - if (_auto_rescale_normal) { - do_auto_rescale_normal(); - } } //////////////////////////////////////////////////////////////////// @@ -3001,10 +2995,12 @@ do_issue_render_mode() { //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian9:: do_issue_rescale_normal() { - const RescaleNormalAttrib *target_rescale_normal = DCAST(RescaleNormalAttrib, _target_rs->get_attrib_def(RescaleNormalAttrib::get_class_slot())); - RescaleNormalAttrib::Mode mode = target_rescale_normal->get_mode(); + RescaleNormalAttrib::Mode mode = RescaleNormalAttrib::M_none; - _auto_rescale_normal = false; + const RescaleNormalAttrib *target_rescale_normal; + if (_target_rs->get_attrib(target_rescale_normal)) { + mode = target_rescale_normal->get_mode(); + } switch (mode) { case RescaleNormalAttrib::M_none: @@ -3016,11 +3012,6 @@ do_issue_rescale_normal() { set_render_state(D3DRS_NORMALIZENORMALS, true); break; - case RescaleNormalAttrib::M_auto: - _auto_rescale_normal = true; - do_auto_rescale_normal(); - break; - default: dxgsg9_cat.error() << "Unknown rescale_normal mode " << (int)mode << endl; @@ -4234,24 +4225,6 @@ set_read_buffer(const RenderBuffer &rb) { return; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_auto_rescale_normal -// Access: Protected -// Description: Issues the appropriate DX commands to either rescale -// or normalize the normals according to the current -// transform. -//////////////////////////////////////////////////////////////////// -void DXGraphicsStateGuardian9:: -do_auto_rescale_normal() { - if (_internal_transform->has_identity_scale()) { - // If there's no scale, don't normalize anything. - set_render_state(D3DRS_NORMALIZENORMALS, false); - } else { - // If there is a scale, turn on normalization. - set_render_state(D3DRS_NORMALIZENORMALS, true); - } -} - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian9::get_light_color // Access: Public diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index 6bc8af012d..b31e1940f4 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -208,8 +208,6 @@ protected: void set_draw_buffer(const RenderBuffer &rb); void set_read_buffer(const RenderBuffer &rb); - void do_auto_rescale_normal(); - void disable_standard_vertex_arrays(); bool update_standard_vertex_arrays(bool force); void disable_standard_texture_bindings(); @@ -277,7 +275,6 @@ protected: bool _supports_render_texture; RenderBuffer::Type _cur_read_pixel_buffer; // source for copy_pixel_buffer operation - bool _auto_rescale_normal; PN_stdfloat _material_ambient; PN_stdfloat _material_diffuse; diff --git a/panda/src/egg/eggGroup.I b/panda/src/egg/eggGroup.I index 64bc0c843d..f88d7c40c0 100644 --- a/panda/src/egg/eggGroup.I +++ b/panda/src/egg/eggGroup.I @@ -1018,7 +1018,7 @@ tag_end() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::tag_size -// Access: Published +// Access: Public // Description: Returns the number of elements between tag_begin() // and tag_end(). // diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index ffdfcb304c..b7c318941b 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -26,6 +26,7 @@ #include "luse.h" #include "globPattern.h" #include "plist.h" +#include "bamCacheRecord.h" class EggTextureCollection; class EggMaterialCollection; @@ -33,7 +34,6 @@ class EggPolygon; class EggVertex; class EggVertexPool; class DSearchPath; -class BamCacheRecord; //////////////////////////////////////////////////////////////////// // Class : EggGroupNode diff --git a/panda/src/egg/eggTexture.I b/panda/src/egg/eggTexture.I index 25f1bcfab4..a6b49f7bd2 100644 --- a/panda/src/egg/eggTexture.I +++ b/panda/src/egg/eggTexture.I @@ -1057,6 +1057,142 @@ get_read_mipmaps() const { return _read_mipmaps; } +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::set_min_lod +// Access: Published +// Description: Sets the minimum mipmap level that may be sampled. +//////////////////////////////////////////////////////////////////// +INLINE void EggTexture:: +set_min_lod(double min_lod) { + _min_lod = min_lod; + _flags |= F_has_min_lod; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::clear_min_lod +// Access: Published +// Description: Removes the specification of a minimum mipmap level +// from the texture. +//////////////////////////////////////////////////////////////////// +INLINE void EggTexture:: +clear_min_lod() { + _min_lod = -1000; + _flags &= ~F_has_min_lod; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::has_min_lod +// Access: Published +// Description: Returns true if a value for the minimum mipmap level +// has been specified for this texture, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool EggTexture:: +has_min_lod() const { + return (_flags & F_has_min_lod) != 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::get_min_lod +// Access: Published +// Description: Returns the minimum mipmap level that has been +// specified for this texture. +//////////////////////////////////////////////////////////////////// +INLINE double EggTexture:: +get_min_lod() const { + return _min_lod; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::set_max_lod +// Access: Published +// Description: Sets the maximum mipmap level that may be sampled. +//////////////////////////////////////////////////////////////////// +INLINE void EggTexture:: +set_max_lod(double max_lod) { + _max_lod = max_lod; + _flags |= F_has_max_lod; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::clear_max_lod +// Access: Published +// Description: Removes the specification of a maximum mipmap level +// from the texture. +//////////////////////////////////////////////////////////////////// +INLINE void EggTexture:: +clear_max_lod() { + _max_lod = 1000; + _flags &= ~F_has_max_lod; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::has_max_lod +// Access: Published +// Description: Returns true if a value for the maximum mipmap level +// has been specified for this texture, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool EggTexture:: +has_max_lod() const { + return (_flags & F_has_max_lod) != 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::get_max_lod +// Access: Published +// Description: Returns the maximum mipmap level that has been +// specified for this texture. +//////////////////////////////////////////////////////////////////// +INLINE double EggTexture:: +get_max_lod() const { + return _max_lod; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::set_lod_bias +// Access: Published +// Description: Sets the mipmap level bias that is added to the +// mipmap level to be sampled. +//////////////////////////////////////////////////////////////////// +INLINE void EggTexture:: +set_lod_bias(double lod_bias) { + _lod_bias = lod_bias; + _flags |= F_has_lod_bias; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::clear_lod_bias +// Access: Published +// Description: Removes the specification of a maximum mipmap level +// from the texture. +//////////////////////////////////////////////////////////////////// +INLINE void EggTexture:: +clear_lod_bias() { + _lod_bias = 1000; + _flags &= ~F_has_lod_bias; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::has_lod_bias +// Access: Published +// Description: Returns true if a value for the maximum mipmap level +// has been specified for this texture, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool EggTexture:: +has_lod_bias() const { + return (_flags & F_has_lod_bias) != 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggTexture::get_lod_bias +// Access: Published +// Description: Returns the maximum mipmap level that has been +// specified for this texture. +//////////////////////////////////////////////////////////////////// +INLINE double EggTexture:: +get_lod_bias() const { + return _lod_bias; +} + //////////////////////////////////////////////////////////////////// // Function: EggTexture::get_multitexture_sort // Access: Published diff --git a/panda/src/egg/eggTexture.h b/panda/src/egg/eggTexture.h index 3b68b640a7..575e243471 100644 --- a/panda/src/egg/eggTexture.h +++ b/panda/src/egg/eggTexture.h @@ -281,6 +281,20 @@ PUBLISHED: INLINE void set_read_mipmaps(bool read_mipmaps); INLINE bool get_read_mipmaps() const; + INLINE void set_min_lod(double min_lod); + INLINE void clear_min_lod(); + INLINE bool has_min_lod() const; + INLINE double get_min_lod() const; + + INLINE void set_max_lod(double max_lod); + INLINE void clear_max_lod(); + INLINE bool has_max_lod() const; + INLINE double get_max_lod() const; + + INLINE void set_lod_bias(double lod_bias); + INLINE void clear_lod_bias(); + INLINE bool has_lod_bias() const; + INLINE double get_lod_bias() const; void clear_multitexture(); bool multitexture_over(EggTexture *other); @@ -320,6 +334,9 @@ private: F_has_alpha_scale = 0x0200, F_has_border_color = 0x0400, F_has_num_views = 0x0800, + F_has_min_lod = 0x1000, + F_has_max_lod = 0x2000, + F_has_lod_bias = 0x4000, }; TextureType _texture_type; @@ -347,6 +364,9 @@ private: int _alpha_file_channel; bool _read_mipmaps; int _multitexture_sort; + double _min_lod; + double _max_lod; + double _lod_bias; class SourceAndOperand { public: diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index 9c828fec9e..57f9488ef9 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -699,6 +699,15 @@ texture_body: } else if (cmp_nocase_uh(name, "read_mipmaps") == 0) { texture->set_read_mipmaps(((int)value) != 0); + } else if (cmp_nocase_uh(name, "min_lod") == 0) { + texture->set_min_lod(value); + + } else if (cmp_nocase_uh(name, "max_lod") == 0) { + texture->set_max_lod(value); + + } else if (cmp_nocase_uh(name, "lod_bias") == 0) { + texture->set_lod_bias(value); + } else { eggyywarning("Unsupported texture scalar: " + name); } diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index b472a104b6..11d3e4f499 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -1088,36 +1088,38 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { tex->set_compression(convert_compression_mode(egg_tex->get_compression_mode())); } + SamplerState sampler; + EggTexture::WrapMode wrap_u = egg_tex->determine_wrap_u(); EggTexture::WrapMode wrap_v = egg_tex->determine_wrap_v(); EggTexture::WrapMode wrap_w = egg_tex->determine_wrap_w(); if (wrap_u != EggTexture::WM_unspecified) { - tex->set_wrap_u(convert_wrap_mode(wrap_u)); + sampler.set_wrap_u(convert_wrap_mode(wrap_u)); } if (wrap_v != EggTexture::WM_unspecified) { - tex->set_wrap_v(convert_wrap_mode(wrap_v)); + sampler.set_wrap_v(convert_wrap_mode(wrap_v)); } if (wrap_w != EggTexture::WM_unspecified) { - tex->set_wrap_w(convert_wrap_mode(wrap_w)); + sampler.set_wrap_w(convert_wrap_mode(wrap_w)); } if (egg_tex->has_border_color()) { - tex->set_border_color(egg_tex->get_border_color()); + sampler.set_border_color(egg_tex->get_border_color()); } switch (egg_tex->get_minfilter()) { case EggTexture::FT_nearest: - tex->set_minfilter(SamplerState::FT_nearest); + sampler.set_minfilter(SamplerState::FT_nearest); break; case EggTexture::FT_linear: if (egg_ignore_filters) { egg2pg_cat.warning() << "Ignoring minfilter request\n"; - tex->set_minfilter(SamplerState::FT_nearest); + sampler.set_minfilter(SamplerState::FT_nearest); } else { - tex->set_minfilter(SamplerState::FT_linear); + sampler.set_minfilter(SamplerState::FT_linear); } break; @@ -1125,13 +1127,13 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { if (egg_ignore_filters) { egg2pg_cat.warning() << "Ignoring minfilter request\n"; - tex->set_minfilter(SamplerState::FT_nearest); + sampler.set_minfilter(SamplerState::FT_nearest); } else if (egg_ignore_mipmaps) { egg2pg_cat.warning() << "Ignoring mipmap request\n"; - tex->set_minfilter(SamplerState::FT_nearest); + sampler.set_minfilter(SamplerState::FT_nearest); } else { - tex->set_minfilter(SamplerState::FT_nearest_mipmap_nearest); + sampler.set_minfilter(SamplerState::FT_nearest_mipmap_nearest); } break; @@ -1139,13 +1141,13 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { if (egg_ignore_filters) { egg2pg_cat.warning() << "Ignoring minfilter request\n"; - tex->set_minfilter(SamplerState::FT_nearest); + sampler.set_minfilter(SamplerState::FT_nearest); } else if (egg_ignore_mipmaps) { egg2pg_cat.warning() << "Ignoring mipmap request\n"; - tex->set_minfilter(SamplerState::FT_linear); + sampler.set_minfilter(SamplerState::FT_linear); } else { - tex->set_minfilter(SamplerState::FT_linear_mipmap_nearest); + sampler.set_minfilter(SamplerState::FT_linear_mipmap_nearest); } break; @@ -1153,13 +1155,13 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { if (egg_ignore_filters) { egg2pg_cat.warning() << "Ignoring minfilter request\n"; - tex->set_minfilter(SamplerState::FT_nearest); + sampler.set_minfilter(SamplerState::FT_nearest); } else if (egg_ignore_mipmaps) { egg2pg_cat.warning() << "Ignoring mipmap request\n"; - tex->set_minfilter(SamplerState::FT_nearest); + sampler.set_minfilter(SamplerState::FT_nearest); } else { - tex->set_minfilter(SamplerState::FT_nearest_mipmap_linear); + sampler.set_minfilter(SamplerState::FT_nearest_mipmap_linear); } break; @@ -1167,13 +1169,13 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { if (egg_ignore_filters) { egg2pg_cat.warning() << "Ignoring minfilter request\n"; - tex->set_minfilter(SamplerState::FT_nearest); + sampler.set_minfilter(SamplerState::FT_nearest); } else if (egg_ignore_mipmaps) { egg2pg_cat.warning() << "Ignoring mipmap request\n"; - tex->set_minfilter(SamplerState::FT_linear); + sampler.set_minfilter(SamplerState::FT_linear); } else { - tex->set_minfilter(SamplerState::FT_linear_mipmap_linear); + sampler.set_minfilter(SamplerState::FT_linear_mipmap_linear); } break; @@ -1185,7 +1187,7 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { case EggTexture::FT_nearest: case EggTexture::FT_nearest_mipmap_nearest: case EggTexture::FT_nearest_mipmap_linear: - tex->set_magfilter(SamplerState::FT_nearest); + sampler.set_magfilter(SamplerState::FT_nearest); break; case EggTexture::FT_linear: @@ -1194,9 +1196,9 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { if (egg_ignore_filters) { egg2pg_cat.warning() << "Ignoring magfilter request\n"; - tex->set_magfilter(SamplerState::FT_nearest); + sampler.set_magfilter(SamplerState::FT_nearest); } else { - tex->set_magfilter(SamplerState::FT_linear); + sampler.set_magfilter(SamplerState::FT_linear); } break; @@ -1205,9 +1207,23 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { } if (egg_tex->has_anisotropic_degree()) { - tex->set_anisotropic_degree(egg_tex->get_anisotropic_degree()); + sampler.set_anisotropic_degree(egg_tex->get_anisotropic_degree()); } + if (egg_tex->has_min_lod()) { + sampler.set_min_lod(egg_tex->get_min_lod()); + } + + if (egg_tex->has_max_lod()) { + sampler.set_max_lod(egg_tex->get_max_lod()); + } + + if (egg_tex->has_lod_bias()) { + sampler.set_lod_bias(egg_tex->get_lod_bias()); + } + + tex->set_default_sampler(sampler); + if (tex->get_num_components() == 1) { switch (egg_tex->get_format()) { case EggTexture::F_red: @@ -2240,7 +2256,7 @@ make_vertex_data(const EggRenderState *render_state, if (vertex_pool->has_normals()) { array_format->add_column (InternalName::get_normal(), 3, - Geom::NT_stdfloat, Geom::C_vector); + Geom::NT_stdfloat, Geom::C_normal); } if (!ignore_color) { diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index 051c3b6f54..ba4ee35d7f 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -431,7 +431,6 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, apply_node_properties(egg_group, node, false); // turn it into a collision node - egg_group->set_cs_type(EggGroup::CST_polyset); egg_group->set_collide_flags(EggGroup::CF_descend); NodePath np = node_path.get_node_path(); @@ -451,6 +450,8 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, for (int i = 0; i < num_solids; i++) { CPT(CollisionSolid) child = node->get_solid(i); if (child->is_of_type(CollisionPolygon::get_class_type())) { + egg_group->set_cs_type(EggGroup::CST_polyset); + EggPolygon *egg_poly = new EggPolygon; egg_group->add_child(egg_poly); @@ -464,10 +465,71 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, EggVertex *new_egg_vert = cvpool->create_unique_vertex(egg_vert); egg_poly->add_vertex(new_egg_vert); } - } else if (child->is_of_type(CollisionPlane::get_class_type())) { - nout << "Encountered unhandled collsion type: CollisionPlane" << "\n"; + } else if (child->is_of_type(CollisionSphere::get_class_type())) { - nout << "Encountered unhandled collsion type: CollisionSphere" << "\n"; + CPT(CollisionSphere) sphere = DCAST(CollisionSphere, child); + LPoint3 center = sphere->get_center(); + LVector3 offset(sphere->get_radius(), 0, 0); + + EggGroup *egg_sphere; + if (num_solids == 1) { + egg_sphere = egg_group; + } else { + egg_sphere = new EggGroup; + egg_sphere->set_collide_flags(EggGroup::CF_descend); + egg_group->add_child(egg_sphere); + } + egg_sphere->set_cs_type(EggGroup::CST_sphere); + + EggVertex ev1, ev2; + ev1.set_pos(LCAST(double, (center + offset) * net_mat)); + ev2.set_pos(LCAST(double, (center - offset) * net_mat)); + + EggPolygon *egg_poly = new EggPolygon; + egg_sphere->add_child(egg_poly); + + egg_poly->add_vertex(cvpool->create_unique_vertex(ev1)); + egg_poly->add_vertex(cvpool->create_unique_vertex(ev2)); + + } else if (child->is_of_type(CollisionPlane::get_class_type())) { + LPlane plane = DCAST(CollisionPlane, child)->get_plane(); + LPoint3 origin = plane.get_point(); + LVector3 normal = plane.get_normal(); + + // Get an arbitrary vector on the plane by taking the cross product + // with any vector, as long as it is different. + LVector3 vec1; + if (abs(normal[2]) > abs(normal[1])) { + vec1 = normal.cross(LVector3(0, 1, 0)); + } else { + vec1 = normal.cross(LVector3(0, 0, 1)); + } + + // Find a second vector perpendicular to the two. + LVector3 vec2 = normal.cross(vec1); + + EggGroup *egg_plane; + if (num_solids == 1) { + egg_plane = egg_group; + } else { + egg_plane = new EggGroup; + egg_plane->set_collide_flags(EggGroup::CF_descend); + egg_group->add_child(egg_plane); + } + egg_plane->set_cs_type(EggGroup::CST_plane); + + EggVertex ev0, ev1, ev2; + ev0.set_pos(LCAST(double, origin * net_mat)); + ev1.set_pos(LCAST(double, (origin + vec1) * net_mat)); + ev2.set_pos(LCAST(double, (origin + vec2) * net_mat)); + + EggPolygon *egg_poly = new EggPolygon; + egg_plane->add_child(egg_poly); + + egg_poly->add_vertex(cvpool->create_unique_vertex(ev0)); + egg_poly->add_vertex(cvpool->create_unique_vertex(ev1)); + egg_poly->add_vertex(cvpool->create_unique_vertex(ev2)); + } else if (child->is_of_type(CollisionBox::get_class_type())) { nout << "Encountered unhandled collsion type: CollisionBox" << "\n"; } else if (child->is_of_type(CollisionInvSphere::get_class_type())) { diff --git a/panda/src/express/Sources.pp b/panda/src/express/Sources.pp index dcec931471..150d0f421d 100644 --- a/panda/src/express/Sources.pp +++ b/panda/src/express/Sources.pp @@ -23,7 +23,9 @@ encrypt_string.h \ error_utils.h \ export_dtool.h \ + filename_ext.h \ fileReference.h fileReference.I \ + globPattern_ext.h \ hashGeneratorBase.I hashGeneratorBase.h \ hashVal.I hashVal.h \ indirectLess.I indirectLess.h \ @@ -45,6 +47,7 @@ patchfile.I patchfile.h \ pointerTo.I pointerTo.h \ pointerToArray.I pointerToArray.h \ + pointerToArray_ext.h \ pointerToArrayBase.I pointerToArrayBase.h \ pointerToBase.I pointerToBase.h \ pointerToVoid.I pointerToVoid.h \ @@ -61,6 +64,7 @@ threadSafePointerTo.I threadSafePointerTo.h \ threadSafePointerToBase.I threadSafePointerToBase.h \ trueClock.I trueClock.h \ + typeHandle_ext.h \ typedReferenceCount.I typedReferenceCount.h typedef.h \ vector_uchar.h vector_double.h vector_float.h \ vector_stdfloat.h \ diff --git a/panda/src/express/memoryUsagePointers.h b/panda/src/express/memoryUsagePointers.h index ceab784752..2512ea9f00 100644 --- a/panda/src/express/memoryUsagePointers.h +++ b/panda/src/express/memoryUsagePointers.h @@ -24,13 +24,6 @@ #include "referenceCount.h" #include "pvector.h" -#ifdef HAVE_PYTHON - -#undef _POSIX_C_SOURCE -#include - -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Class : MemoryUsagePointers // Description : This is a list of pointers returned by a MemoryUsage diff --git a/panda/src/express/memoryUsagePointers_ext.cxx b/panda/src/express/memoryUsagePointers_ext.cxx index eee3b5d0e6..63713cc907 100644 --- a/panda/src/express/memoryUsagePointers_ext.cxx +++ b/panda/src/express/memoryUsagePointers_ext.cxx @@ -17,9 +17,9 @@ #if defined(HAVE_PYTHON) && defined(DO_MEMORY_USAGE) #ifndef CPPPARSER -extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_TypedObject; -extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_TypedReferenceCount; -extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_ReferenceCount; +extern Dtool_PyTypedObject Dtool_TypedObject; +extern Dtool_PyTypedObject Dtool_TypedReferenceCount; +extern Dtool_PyTypedObject Dtool_ReferenceCount; #endif // CPPPARSER //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/namable.I b/panda/src/express/namable.I index adad9ec1e9..8d3e0b438d 100644 --- a/panda/src/express/namable.I +++ b/panda/src/express/namable.I @@ -45,6 +45,19 @@ operator = (const Namable &other) { return *this; } +#ifdef USE_MOVE_SEMANTICS +//////////////////////////////////////////////////////////////////// +// Function: Namable::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Namable &Namable:: +operator = (Namable &&other) NOEXCEPT { + _name = MOVE(other._name); + return *this; +} +#endif + //////////////////////////////////////////////////////////////////// // Function: Namable::set_name // Access: Public diff --git a/panda/src/express/namable.h b/panda/src/express/namable.h index 9c756827d2..84e01b0919 100644 --- a/panda/src/express/namable.h +++ b/panda/src/express/namable.h @@ -28,10 +28,14 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEXPRESS Namable : public MemoryBase { PUBLISHED: - INLINE Namable(const string &initial_name = ""); + INLINE explicit Namable(const string &initial_name = ""); INLINE Namable(const Namable ©); INLINE Namable &operator = (const Namable &other); +#ifdef USE_MOVE_SEMANTICS + INLINE Namable &operator = (Namable &&other) NOEXCEPT; +#endif + INLINE void set_name(const string &name); INLINE void clear_name(); INLINE bool has_name() const; diff --git a/panda/src/express/pta_uchar.h b/panda/src/express/pta_uchar.h index 40cc9763fe..1ba4dd4497 100644 --- a/panda/src/express/pta_uchar.h +++ b/panda/src/express/pta_uchar.h @@ -29,10 +29,14 @@ // rather than defining the pta again. //////////////////////////////////////////////////////////////////// +#if !defined(__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 +// GCC 4.6 has a weird bug related to this type. +#else EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToArrayBase) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToArray) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, ConstPointerToArray) +#endif typedef PointerToArray PTA_uchar; typedef ConstPointerToArray CPTA_uchar; diff --git a/panda/src/gles2gsg/gles2gsg.h b/panda/src/gles2gsg/gles2gsg.h index 71ac91e594..2582a2d5ed 100644 --- a/panda/src/gles2gsg/gles2gsg.h +++ b/panda/src/gles2gsg/gles2gsg.h @@ -49,6 +49,9 @@ #define OPENGLES_2 #endif +// OpenGL ES 2 has no fixed-function pipeline. +#undef SUPPORT_FIXED_FUNCTION + #ifdef IS_OSX #include // #include diff --git a/panda/src/glesgsg/glesgsg.h b/panda/src/glesgsg/glesgsg.h index 3282cd4536..6f13f9223c 100644 --- a/panda/src/glesgsg/glesgsg.h +++ b/panda/src/glesgsg/glesgsg.h @@ -49,6 +49,11 @@ #error OPENGLES_2 should not be defined! #endif +// OpenGL ES 1 has only the fixed-function pipeline. +#ifndef SUPPORT_FIXED_FUNCTION +#define SUPPORT_FIXED_FUNCTION +#endif + // This prevents glext.h from getting included by gl.h // That way, we can provide our own, better version. #define __glext_h_ diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 4afda4b921..d8db598182 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -41,6 +41,11 @@ CLP(CgShaderContext):: CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext(s) { _glgsg = glgsg; _cg_program = 0; + _glsl_program = 0; + _has_divisor = false; + _color_attrib_index = CA_color; + _transform_table_param = 0; + _slider_table_param = 0; nassertv(s->get_language() == Shader::SL_Cg); @@ -53,6 +58,21 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte return; } + _transform_table_param = cgGetNamedParameter(_cg_program, "tbl_transforms"); + if (_transform_table_param) { + _transform_table_size = cgGetArraySize(_transform_table_param, 0); + } + + _slider_table_param = cgGetNamedParameter(_cg_program, "tbl_sliders"); + if (_slider_table_param) { + _slider_table_size = cgGetArraySize(_slider_table_param, 0); + } + + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Loading Cg shader " << s->get_filename() << "\n"; + } + // Load the program. if (_cg_program == 0) { const char *str = cgGetErrorString(cgGetError()); @@ -73,6 +93,214 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte } } + if (_cg_program != 0) { + if (cgGetProgramProfile(_cg_program) == CG_PROFILE_GLSLC) { + _glsl_program = cgGLGetProgramID(_cg_program); + + // Sometimes it fails to link, and Cg fails to propagate the error. + GLint link_status; + _glgsg->_glGetProgramiv(_glsl_program, GL_LINK_STATUS, &link_status); + if (link_status != GL_TRUE) { + release_resources(); + } + } + } + + if (_cg_program == 0) { + return; + } + + // We don't use cgGLSetParameterPointer to set the vertex attributes any + // longer, since it is buggy on non-NVIDIA hardware and doesn't allow explicit + // control over some parameters. Instead, we have to figure out ourselves how + // to map the input varyings to OpenGL vertex attributes. + // + // We use positive indices to indicate generic vertex attributes, and negative + // indices to indicate conventional vertex attributes (ie. glVertexPointer). + int nvarying = _shader->_var_spec.size(); + for (int i = 0; i < nvarying; ++i) { + Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; + CGparameter p = _cg_parameter_map[i]; + if (p == 0) { + bind._id._seqno = CA_unknown; + continue; + } + + GLint loc = CA_unknown; + CGresource res = cgGetParameterResource(p); + + if (cgGetParameterBaseResource(p) == CG_ATTR0) { + // The Cg toolkit claims that it is bound to a generic vertex attribute. + if (_glsl_program != 0) { + // This is where the Cg glslv compiler lies, making the stupid assumption + // that we're using an NVIDIA card where generic attributes are aliased + // with conventional vertex attributes. Instead, it always uses + // conventional attributes in this case. Correct this. + int index = cgGetParameterResourceIndex(p); + switch (index) { + case 0: // gl_Vertex + loc = CA_vertex; + break; + case 2: // gl_Normal + loc = CA_normal; + break; + case 3: // gl_Color + loc = CA_color; + break; + case 4: // gl_SecondaryColor + loc = CA_secondary_color; + break; + case 1: // glWeightPointerARB? + case 5: // gl_FogCoord + case 6: // PSIZE? + case 7: // BLENDINDICES + GLCAT.error() + << "Cg varying " << cgGetParameterName(p) << " is bound to " + "unrecognized attribute " << index << "\n"; + loc = CA_unknown; + break; + default: + loc = CA_texcoord + (index - 8); + break; + } + } else { + loc = cgGetParameterResourceIndex(p); + + if (loc != 0 && bind._id._name == "vtx_position") { + // We really have to bind the vertex position to attribute 0, since + // OpenGL will hide the model if attribute 0 is not enabled, and we + // can only ever be sure that vtx_position is bound. + GLCAT.warning() + << "CG varying vtx_position is bound to generic attribute " << loc + << " instead of 0. Use ATTR0 semantic to prevent this.\n"; + } + } + + } else if (res == CG_GLSL_ATTRIB || _glsl_program != 0) { + // With cg-glsl-version 130 and higher, no conventional attributes are + // used, but it instead uses specially named variables. + // A bit of guesswork is involved here; Cg seems to mostly use the + // semantics as attribute names in GLSL, with a few exceptions. + const char *attribname = NULL; + switch (res) { + case CG_POSITION0: + attribname = "cg_Vertex"; + break; + case CG_NORMAL0: + attribname = "NORMAL"; + break; + case CG_COLOR0: + case CG_DIFFUSE0: + attribname = "COLOR"; + break; + case CG_COLOR1: + case CG_SPECULAR0: + attribname = "SPECULAR"; + break; + default: + // Everything else appears to be named after the semantic string. + attribname = cgGetParameterSemantic(p); + } + loc = _glgsg->_glGetAttribLocation(_glsl_program, attribname); + + if (bind._id._name == "vtx_color") { + _color_attrib_index = loc; + } + + if (loc == -1) { + const char *resource = cgGetParameterResourceName(p); + if (!resource) { + resource = "unknown"; + } + GLCAT.error() + << "Could not find Cg varying " << cgGetParameterName(p); + if (attribname) { + GLCAT.error(false) << " : " << attribname; + } + GLCAT.error(false) << " (" << resource << ") in the compiled GLSL program.\n"; + + } else if (loc != 0 && bind._id._name == "vtx_position") { + // We really have to bind the vertex position to attribute 0, since + // OpenGL will hide the model if attribute 0 is not enabled, and we + // can only ever be sure that vtx_position is bound. + GLCAT.warning() + << "CG varying vtx_position is bound to generic attribute " << loc + << "instead of 0. Use ATTR0 semantic to prevent this.\n"; + } + + } else if (cgGetParameterBaseResource(p) == CG_TEXCOORD0) { + // A conventional texture coordinate set. + loc = CA_texcoord + cgGetParameterResourceIndex(p); + + } else { + // Some other conventional vertex attribute. + switch (res) { + case CG_POSITION0: + loc = CA_vertex; + break; + case CG_NORMAL0: + loc = CA_normal; + break; + case CG_COLOR0: + case CG_DIFFUSE0: + loc = CA_color; + break; + case CG_COLOR1: + case CG_SPECULAR0: + loc = CA_secondary_color; + break; + default: + GLCAT.error() + << "Cg varying " << cgGetParameterName(p); + if (cgGetParameterSemantic(p)) { + GLCAT.error(false) << " : " << cgGetParameterSemantic(p); + } + GLCAT.error(false) << " has an unrecognized resource"; + if (cgGetParameterResourceName(p)) { + GLCAT.error(false) << " (" << cgGetParameterResourceName(p) << ")"; + } + GLCAT.error(false) << ".\n"; + loc = CA_unknown; + } + } + +#ifndef NDEBUG + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Cg varying " << cgGetParameterName(p); + + const char *semantic = cgGetParameterSemantic(p); + if (semantic) { + GLCAT.debug(false) << " : " << semantic; + } + + if (loc == CA_unknown) { + GLCAT.debug(false) + << " is not bound to a vertex attribute\n"; + + } else if (loc >= 0) { + GLCAT.debug(false) + << " is bound to generic attribute " << loc << "\n"; + + } else { + const char *resource = cgGetParameterResourceName(p); + if (!resource) { + resource = "unknown"; + } + GLCAT.debug(false) + << " is bound to a conventional attribute (" << resource << ")\n"; + } + } + if (loc == CA_unknown) { + // Suggest fix to developer. + GLCAT.error() << "Try using a different semantic.\n"; + } +#endif + + // Abuse the seqno field to store the GLSL attribute location. + bind._id._seqno = loc; + } + _glgsg->report_my_gl_errors(); } @@ -385,6 +613,58 @@ issue_parameters(int altered) { _glgsg->report_my_gl_errors(); } +//////////////////////////////////////////////////////////////////// +// Function: CgGLShaderContext::update_transform_table +// Access: Public +// Description: Changes the active transform table, used for hardware +// skinning. +//////////////////////////////////////////////////////////////////// +void CLP(CgShaderContext):: +update_transform_table(const TransformTable *table) { + LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); + + int i = 0; + if (table != NULL) { + int num_transforms = min(_transform_table_size, (long)table->get_num_transforms()); + for (; i < num_transforms; ++i) { +#ifdef STDFLOAT_DOUBLE + LMatrix4 matrix; + table->get_transform(i)->get_matrix(matrix); + matrices[i] = LCAST(float, matrix); +#else + table->get_transform(i)->get_matrix(matrices[i]); +#endif + } + } + for (; i < _transform_table_size; ++i) { + matrices[i] = LMatrix4f::ident_mat(); + } + + cgGLSetMatrixParameterArrayfc(_transform_table_param, 0, + _transform_table_size, (float *)matrices); +} + +//////////////////////////////////////////////////////////////////// +// Function: CgGLShaderContext::update_slider_table +// Access: Public +// Description: Changes the active slider table, used for hardware +// skinning. +//////////////////////////////////////////////////////////////////// +void CLP(CgShaderContext):: +update_slider_table(const SliderTable *table) { + float *sliders = (float *)alloca(_slider_table_size * 4); + memset(sliders, 0, _slider_table_size * 4); + + if (table != NULL) { + int num_sliders = min(_slider_table_size, (long)table->get_num_sliders()); + for (int i = 0; i < num_sliders; ++i) { + sliders[i] = table->get_slider(i)->get_slider(); + } + } + + cgGLSetParameterArray4f(_slider_table_param, 0, _slider_table_size, sliders); +} + //////////////////////////////////////////////////////////////////// // Function: GLCgShaderContext::disable_shader_vertex_arrays // Access: Public @@ -396,27 +676,37 @@ disable_shader_vertex_arrays() { return; } - for (int i=0; i<(int)_shader->_var_spec.size(); i++) { - CGparameter p = _cg_parameter_map[_shader->_var_spec[i]._id._seqno]; - if (p == 0) continue; + for (int i = 0; i < (int)_shader->_var_spec.size(); ++i) { + GLint p = _shader->_var_spec[i]._id._seqno; - if (cgGetParameterBaseResource(p) == CG_ATTR0) { - int index = cgGetParameterResourceIndex(p); - if (index >= 8) { - _glgsg->_glClientActiveTexture(GL_TEXTURE0 + (index - 8)); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - - } else if (index == 0) { - glDisableClientState(GL_VERTEX_ARRAY); - - } else if (index == 2) { - glDisableClientState(GL_NORMAL_ARRAY); - - } else if (index == 3) { - glDisableClientState(GL_COLOR_ARRAY); + if (p >= 0) { + _glgsg->_glDisableVertexAttribArray(p); + if (_has_divisor) { + _glgsg->_glVertexAttribDivisor(p, 0); } } else { - cgGLDisableClientState(p); +#ifdef SUPPORT_FIXED_FUNCTION + switch (p) { + case CA_unknown: + break; + case CA_vertex: + glDisableClientState(GL_VERTEX_ARRAY); + break; + case CA_normal: + glDisableClientState(GL_NORMAL_ARRAY); + break; + case CA_color: + glDisableClientState(GL_COLOR_ARRAY); + break; + case CA_secondary_color: + glDisableClientState(GL_SECONDARY_COLOR_ARRAY); + break; + default: + _glgsg->_glClientActiveTexture(GL_TEXTURE0 + (p - CA_texcoord)); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + break; + } +#endif // SUPPORT_FIXED_FUNCTION } } @@ -458,12 +748,9 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { int start, stride, num_values; int nvarying = _shader->_var_spec.size(); for (int i = 0; i < nvarying; ++i) { - if (_cg_parameter_map[_shader->_var_spec[i]._id._seqno] == 0) { - continue; - } - - InternalName *name = _shader->_var_spec[i]._name; - int texslot = _shader->_var_spec[i]._append_uv; + const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; + InternalName *name = bind._name; + int texslot = bind._append_uv; if (texslot >= 0 && texslot < _glgsg->_state_texture->get_num_on_stages()) { TextureStage *stage = _glgsg->_state_texture->get_on_stage(texslot); InternalName *texname = stage->get_texcoord_name(); @@ -474,84 +761,157 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { name = name->append(texname->get_basename()); } } - if (_glgsg->_data_reader->get_array_info(name, - array_reader, num_values, numeric_type, - start, stride)) { + GLint p = bind._id._seqno; + + // Don't apply vertex colors if they are disabled with a ColorAttrib. + int num_elements, element_stride, divisor; + bool normalized; + if ((p != _color_attrib_index || _glgsg->_vertex_colors_enabled) && + _glgsg->_data_reader->get_array_info(name, array_reader, + num_values, numeric_type, + normalized, start, stride, divisor, + num_elements, element_stride)) { const unsigned char *client_pointer; if (!_glgsg->setup_array_data(client_pointer, array_reader, force)) { return false; } + client_pointer += start; - CGparameter p = _cg_parameter_map[_shader->_var_spec[i]._id._seqno]; + // We don't use cgGLSetParameterPointer because it is very buggy and + // limited in the options we can set.start + GLenum type = _glgsg->get_numeric_type(numeric_type); + if (p >= 0) { + _glgsg->_glEnableVertexAttribArray(p); - if (numeric_type == GeomEnums::NT_packed_dabc) { - // Yes, this is a thing. - num_values = GL_BGRA; - } + if (bind._integer) { + _glgsg->_glVertexAttribIPointer(p, num_values, type, + stride, client_pointer); + } else if (numeric_type == GeomEnums::NT_packed_dabc) { + // GL_BGRA is a special accepted value available since OpenGL 3.2. + // It requires us to pass GL_TRUE for normalized. + _glgsg->_glVertexAttribPointer(p, GL_BGRA, GL_UNSIGNED_BYTE, + GL_TRUE, stride, client_pointer); + } else { + _glgsg->_glVertexAttribPointer(p, num_values, type, + normalized, stride, client_pointer); + } - // cgGLSetParameterPointer is just stupidly bugged on every level. - // Sigh. This seems to work on both NVIDIA and AMD cards now. - if (cgGetParameterBaseResource(p) == CG_ATTR0) { - int index = cgGetParameterResourceIndex(p); - switch (index) { - case 0: // gl_Vertex - glVertexPointer(num_values, _glgsg->get_numeric_type(numeric_type), - stride, client_pointer + start); + if (_glgsg->_supports_vertex_attrib_divisor) { + _glgsg->_glVertexAttribDivisor(p, divisor); + _has_divisor = true; + } + + } else { + // It's a conventional vertex attribute. Ugh. +#ifdef SUPPORT_FIXED_FUNCTION + switch (p) { + case CA_unknown: + break; + + case CA_vertex: + glVertexPointer(num_values, type, stride, client_pointer); glEnableClientState(GL_VERTEX_ARRAY); break; - case 2: // gl_Normal - glNormalPointer(_glgsg->get_numeric_type(numeric_type), - stride, client_pointer + start); + case CA_normal: + glNormalPointer(type, stride, client_pointer); glEnableClientState(GL_NORMAL_ARRAY); break; - case 3: // gl_Color - glColorPointer(num_values, _glgsg->get_numeric_type(numeric_type), - stride, client_pointer + start); + case CA_color: + if (numeric_type == GeomEnums::NT_packed_dabc) { + glColorPointer(GL_BGRA, GL_UNSIGNED_BYTE, stride, client_pointer); + } else { + glColorPointer(num_values, type, stride, client_pointer); + } glEnableClientState(GL_COLOR_ARRAY); break; - case 4: // gl_SecondaryColor - //glSecondaryColorPointer(num_values, _glgsg->get_numeric_type(numeric_type), - // stride, client_pointer + start); - //glEnableClientState(GL_SECONDARY_COLOR_ARRAY); - //break; - case 5: // gl_FogCoord - case 6: // PSIZE? - case 7: // BLENDINDICES? - case 1: // glWeightPointerARB? - GLCAT.error() - << "Unable to bind " << *name << " to " - << cgGetParameterResourceName(p) << "\n"; + case CA_secondary_color: + _glgsg->_glSecondaryColorPointer(num_values, type, + stride, client_pointer); + glEnableClientState(GL_SECONDARY_COLOR_ARRAY); break; default: - _glgsg->_glClientActiveTexture(GL_TEXTURE0 + (index - 8)); - glTexCoordPointer(num_values, _glgsg->get_numeric_type(numeric_type), - stride, client_pointer + start); + _glgsg->_glClientActiveTexture(GL_TEXTURE0 + (p - CA_texcoord)); + glTexCoordPointer(num_values, type, stride, client_pointer); glEnableClientState(GL_TEXTURE_COORD_ARRAY); break; } - } else { - if (name == InternalName::get_normal() && num_values == 4) { - // In some cases, the normals are aligned to 4 values. We tell - // it to use three values exactly, otherwise we get the error: - // An unsupported GL extension was required to perform this operation. - num_values = 3; - } - cgGLSetParameterPointer(p, num_values, - _glgsg->get_numeric_type(numeric_type), - stride, client_pointer + start); - cgGLEnableClientState(p); +#endif // SUPPORT_FIXED_FUNCTION } } else { - CGparameter p = _cg_parameter_map[_shader->_var_spec[i]._id._seqno]; - cgGLDisableClientState(p); + // There is no vertex column with this name; disable the attribute array. +#ifdef SUPPORT_FIXED_FUNCTION + if (p == 0) { + //NOTE: if we disable attribute 0 in compatibility profile, the object + // will disappear. In GLSL we fix this by forcing the vertex column + // to be at 0, but we don't have control over that with Cg. So, we + // work around this by just binding something silly to 0. + // This breaks flat colors, but it's better than invisible objects? + _glgsg->_glEnableVertexAttribArray(0); + if (bind._integer) { + _glgsg->_glVertexAttribIPointer(0, 4, GL_INT, 0, 0); + } else { + _glgsg->_glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); + } + + } else +#endif // SUPPORT_FIXED_FUNCTION + if (p >= 0) { + _glgsg->_glDisableVertexAttribArray(p); + + if (p == _color_attrib_index) { +#ifdef STDFLOAT_DOUBLE + _glgsg->_glVertexAttrib4dv(p, _glgsg->_scene_graph_color.get_data()); +#else + _glgsg->_glVertexAttrib4fv(p, _glgsg->_scene_graph_color.get_data()); +#endif + } + } else { +#ifdef SUPPORT_FIXED_FUNCTION + switch (p) { + case CA_unknown: + break; + case CA_vertex: + glDisableClientState(GL_VERTEX_ARRAY); + break; + case CA_normal: + glDisableClientState(GL_NORMAL_ARRAY); + break; + case CA_color: + glDisableClientState(GL_COLOR_ARRAY); +#ifdef STDFLOAT_DOUBLE + glColor4dv(_glgsg->_scene_graph_color.get_data()); +#else + glColor4fv(_glgsg->_scene_graph_color.get_data()); +#endif + break; + case CA_secondary_color: + glDisableClientState(GL_SECONDARY_COLOR_ARRAY); + break; + default: + _glgsg->_glClientActiveTexture(GL_TEXTURE0 + (p - CA_texcoord)); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + break; + } +#endif // SUPPORT_FIXED_FUNCTION + } } } } + if (_transform_table_param) { + const TransformTable *table = _glgsg->_data_reader->get_transform_table(); + update_transform_table(table); + } + + if (_slider_table_param) { + const SliderTable *table = _glgsg->_data_reader->get_slider_table(); + update_slider_table(table); + } + cg_report_errors(); _glgsg->report_my_gl_errors(); @@ -569,35 +929,27 @@ disable_shader_texture_bindings() { return; } -#ifndef OPENGLES_2 - for (int i=0; i<(int)_shader->_tex_spec.size(); i++) { + for (int i = 0; i < (int)_shader->_tex_spec.size(); ++i) { CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._seqno]; if (p == 0) continue; int texunit = cgGetParameterResourceIndex(p); _glgsg->_glActiveTexture(GL_TEXTURE0 + texunit); -#ifndef OPENGLES glBindTexture(GL_TEXTURE_1D, 0); -#endif // OPENGLES glBindTexture(GL_TEXTURE_2D, 0); -#ifndef OPENGLES_1 if (_glgsg->_supports_3d_texture) { glBindTexture(GL_TEXTURE_3D, 0); } -#endif // OPENGLES_1 -#ifndef OPENGLES if (_glgsg->_supports_2d_texture_array) { glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, 0); } -#endif if (_glgsg->_supports_cube_map) { glBindTexture(GL_TEXTURE_CUBE_MAP, 0); } // This is probably faster - but maybe not as safe? //cgGLDisableTextureParameter(p); } -#endif // OPENGLES_2 cg_report_errors(); _glgsg->report_my_gl_errors(); @@ -630,9 +982,10 @@ update_shader_texture_bindings(ShaderContext *prev) { nassertv(texattrib != (TextureAttrib *)NULL); for (int i = 0; i < (int)_shader->_tex_spec.size(); ++i) { - InternalName *id = _shader->_tex_spec[i]._name; + Shader::ShaderTexSpec &spec = _shader->_tex_spec[i]; + const InternalName *id = spec._name; - CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._seqno]; + CGparameter p = _cg_parameter_map[spec._id._seqno]; if (p == 0) { continue; } @@ -643,28 +996,30 @@ update_shader_texture_bindings(ShaderContext *prev) { SamplerState sampler; if (id != NULL) { - const ShaderInput *input = _glgsg->_target_shader->get_shader_input(id); - tex = input->get_texture(); - sampler = input->get_sampler(); + tex = _glgsg->_target_shader->get_shader_input_texture(id, &sampler); } else { - if (_shader->_tex_spec[i]._stage >= texattrib->get_num_on_stages()) { + if (spec._stage >= texattrib->get_num_on_stages()) { + // Apply a white texture in order to make it easier to use a shader + // that takes a texture on a model that doesn't have a texture applied. + _glgsg->_glActiveTexture(GL_TEXTURE0 + texunit); + _glgsg->apply_white_texture(); continue; } - TextureStage *stage = texattrib->get_on_stage(_shader->_tex_spec[i]._stage); + TextureStage *stage = texattrib->get_on_stage(spec._stage); tex = texattrib->get_on_texture(stage); sampler = texattrib->get_on_sampler(stage); view += stage->get_tex_view_offset(); } - if (_shader->_tex_spec[i]._suffix != 0) { + if (spec._suffix != 0) { // The suffix feature is inefficient. It is a temporary hack. if (tex == 0) { continue; } - tex = tex->load_related(_shader->_tex_spec[i]._suffix); + tex = tex->load_related(spec._suffix); } - if ((tex == 0) || (tex->get_texture_type() != _shader->_tex_spec[i]._desired_type)) { + if ((tex == 0) || (tex->get_texture_type() != spec._desired_type)) { continue; } @@ -686,11 +1041,11 @@ update_shader_texture_bindings(ShaderContext *prev) { } _glgsg->apply_texture(tc); - _glgsg->apply_sampler(i, sampler, tc); + _glgsg->apply_sampler(texunit, sampler, tc); } cg_report_errors(); _glgsg->report_my_gl_errors(); } -#endif // OPENGLES_1 +#endif // !OPENGLES diff --git a/panda/src/glstuff/glCgShaderContext_src.h b/panda/src/glstuff/glCgShaderContext_src.h index 16dd9bcdb2..da1f0bea78 100644 --- a/panda/src/glstuff/glCgShaderContext_src.h +++ b/panda/src/glstuff/glCgShaderContext_src.h @@ -41,6 +41,8 @@ public: void bind(bool reissue_parameters = true); void unbind(); void issue_parameters(int altered); + void update_transform_table(const TransformTable *table); + void update_slider_table(const SliderTable *table); void disable_shader_vertex_arrays(); bool update_shader_vertex_arrays(ShaderContext *prev, bool force); void disable_shader_texture_bindings(); @@ -50,13 +52,32 @@ public: INLINE bool uses_custom_vertex_arrays(void); INLINE bool uses_custom_texture_bindings(void); + // Special values for location to indicate conventional attrib slots. + enum ConventionalAttrib { + CA_unknown = -1, + CA_vertex = -2, + CA_normal = -3, + CA_color = -4, + CA_secondary_color = -5, + CA_texcoord = -32, + }; + private: CGprogram _cg_program; + GLuint _glsl_program; + + GLint _color_attrib_index; + CGparameter _transform_table_param; + CGparameter _slider_table_param; + long _transform_table_size; + long _slider_table_size; pvector _cg_parameter_map; CLP(GraphicsStateGuardian) *_glgsg; + bool _has_divisor; + void release_resources(); public: diff --git a/panda/src/glstuff/glGeomContext_src.cxx b/panda/src/glstuff/glGeomContext_src.cxx index 272d9727bf..d9e6578bf8 100644 --- a/panda/src/glstuff/glGeomContext_src.cxx +++ b/panda/src/glstuff/glGeomContext_src.cxx @@ -37,7 +37,7 @@ CLP(GeomContext):: bool CLP(GeomContext):: get_display_list(GLuint &index, const CLP(GeomMunger) *munger, UpdateSeq modified) { -#ifdef OPENGLES +#if defined(OPENGLES) || !defined(SUPPORT_FIXED_FUNCTION) // Display lists not supported by OpenGL ES. nassertr(false, false); return false; @@ -68,7 +68,7 @@ get_display_list(GLuint &index, const CLP(GeomMunger) *munger, //////////////////////////////////////////////////////////////////// void CLP(GeomContext):: release_display_lists() { -#ifdef OPENGLES +#if defined(OPENGLES) || !defined(SUPPORT_FIXED_FUNCTION) // Display lists not supported by OpenGL ES. nassertv(_display_lists.empty()); @@ -103,6 +103,7 @@ release_display_lists() { //////////////////////////////////////////////////////////////////// void CLP(GeomContext):: remove_munger(CLP(GeomMunger) *munger) { +#if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) DisplayLists::iterator dli = _display_lists.find(munger); nassertv(dli != _display_lists.end()); @@ -116,4 +117,5 @@ remove_munger(CLP(GeomMunger) *munger) { // running in any thread. Instead, enqueue the display list index // and let it get deleted at the end of the current or next frame. glgsg->record_deleted_display_list(index); +#endif } diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index fd98cbab1f..778fb71d95 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -158,7 +158,7 @@ munge_format_impl(const GeomVertexFormat *orig, if (animation.get_num_transforms() > 1) { PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; new_array_format->add_column - (InternalName::get_transform_weight(), animation.get_num_transforms() - 1, + (InternalName::get_transform_weight(), animation.get_num_transforms(), NT_stdfloat, C_other); if (animation.get_indexed_transforms()) { diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index ced71cdddd..cb1451ebe7 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -32,7 +32,8 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, _generate_mipmap_pcollector(_draw_window_pcollector, "Generate mipmaps"), _resolve_multisample_pcollector(_draw_window_pcollector, "Resolve multisamples"), _requested_multisamples(0), - _requested_coverage_samples(0) + _requested_coverage_samples(0), + _rb_context(NULL) { // A FBO doesn't have a back buffer. _draw_buffer_type = RenderBuffer::T_front; @@ -50,6 +51,7 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, _rb[i] = 0; _rbm[i] = 0; } + _rb_data_size_bytes = 0; _shared_depth_buffer = 0; _bound_tex_page = -1; @@ -246,6 +248,7 @@ rebuild_bitplanes() { } else { glgsg->bind_fbo(0); } + _rb_context->set_active(true); return; } @@ -273,6 +276,7 @@ rebuild_bitplanes() { rb_resize = true; } _rb_size_z = 1; + _rb_data_size_bytes = 0; int num_fbos = 1; @@ -381,6 +385,10 @@ rebuild_bitplanes() { // buffer was requested. _use_depth_stencil = true; } + } else if (attach[RTP_depth_stencil] != NULL && attach[RTP_depth] == NULL) { + // The depth stencil slot was assigned a texture, but we don't support it. + // Downgrade to a regular depth texture. + swap(attach[RTP_depth], attach[RTP_depth_stencil]); } // Knowing this, we can already be a tiny bit more accurate about the @@ -522,6 +530,9 @@ rebuild_bitplanes() { _fb_properties.set_rgba_bits(0, 0, 0, 0); } + _rb_context->set_active(true); + _rb_context->update_data_size_bytes(_rb_data_size_bytes); + _initial_clear = false; report_my_gl_errors(); @@ -824,6 +835,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_STENCIL_SIZE_EXT, &stencil_size); _fb_properties.set_depth_bits(depth_size); _fb_properties.set_stencil_bits(stencil_size); + _rb_data_size_bytes += _rb_size_x * _rb_size_y * ((depth_size + stencil_size) / 8); glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); @@ -847,6 +859,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, gl_format, _rb_size_x, _rb_size_y); glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_DEPTH_SIZE_EXT, &depth_size); _fb_properties.set_depth_bits(depth_size); + _rb_data_size_bytes += _rb_size_x * _rb_size_y * (depth_size / 8); glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); @@ -864,14 +877,17 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, GLCAT.debug() << "Creating color renderbuffer.\n"; glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, gl_format, _rb_size_x, _rb_size_y); + GLint red_size = 0, green_size = 0, blue_size = 0, alpha_size = 0; + glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_RED_SIZE_EXT, &red_size); + glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_GREEN_SIZE_EXT, &green_size); + glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_BLUE_SIZE_EXT, &blue_size); + glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_ALPHA_SIZE_EXT, &alpha_size); + if (attachpoint == GL_COLOR_ATTACHMENT0_EXT) { - GLint red_size = 0, green_size = 0, blue_size = 0, alpha_size = 0; - glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_RED_SIZE_EXT, &red_size); - glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_GREEN_SIZE_EXT, &green_size); - glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_BLUE_SIZE_EXT, &blue_size); - glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_ALPHA_SIZE_EXT, &alpha_size); _fb_properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size); } + _rb_data_size_bytes += _rb_size_x * _rb_size_y * ((red_size + green_size + blue_size + alpha_size) / 8); + glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); glgsg->_glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, attachpoint, GL_RENDERBUFFER_EXT, _rb[slot]); @@ -1038,7 +1054,7 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) { // to a framebuffer attachment. glgsg->apply_texture(gtc); -#ifndef OPENGLES +#if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) GLclampf priority = 1.0f; glPrioritizeTextures(1, >c->_index, &priority); #endif @@ -1232,6 +1248,10 @@ open_buffer() { return false; } + if (_rb_context == NULL) { + _rb_context = new BufferContext(&(glgsg->_renderbuffer_residency)); + } + // Describe the framebuffer properties of the FBO. // // Unfortunately, we can't currently predict which formats @@ -1403,6 +1423,13 @@ open_buffer() { //////////////////////////////////////////////////////////////////// void CLP(GraphicsBuffer):: close_buffer() { + _rb_data_size_bytes = 0; + if (_rb_context != NULL) { + _rb_context->update_data_size_bytes(0); + delete _rb_context; + _rb_context = NULL; + } + check_host_valid(); if (_gsg == 0) { @@ -1421,13 +1448,14 @@ close_buffer() { _rb[i] = 0; } } - // Delete the renderbuffers. + // Delete the multisample renderbuffers. for (int i=0; i_glDeleteRenderbuffers(1, &(_rbm[i])); _rb[i] = 0; } } + _rb_size_x = 0; _rb_size_y = 0; report_my_gl_errors(); diff --git a/panda/src/glstuff/glGraphicsBuffer_src.h b/panda/src/glstuff/glGraphicsBuffer_src.h index 653e5dc8b2..03e429a422 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.h +++ b/panda/src/glstuff/glGraphicsBuffer_src.h @@ -57,7 +57,6 @@ // the buffer will render as if multisamples is 0. // //////////////////////////////////////////////////////////////////// - class EXPCL_GL CLP(GraphicsBuffer) : public GraphicsBuffer { public: CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -125,6 +124,10 @@ private: GLuint _rb[RTP_COUNT]; GLuint _rbm[RTP_COUNT]; + // For memory tracking of renderbuffers. + BufferContext *_rb_context; + size_t _rb_data_size_bytes; + // List of textures for which we might have to generate mipmaps // after rendering one frame. typedef pvector TextureContexts; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.I b/panda/src/glstuff/glGraphicsStateGuardian_src.I index d973269700..5b5a7a81e9 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.I +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.I @@ -354,7 +354,7 @@ enable_line_smooth(bool val) { //////////////////////////////////////////////////////////////////// INLINE void CLP(GraphicsStateGuardian):: enable_point_smooth(bool val) { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION if (_point_smooth_enabled != val) { _state_mask.clear_bit(TransparencyAttrib::get_class_slot()); _point_smooth_enabled = val; @@ -532,7 +532,7 @@ enable_depth_test(bool val) { } } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::enable_fog // Access: @@ -559,7 +559,7 @@ enable_fog(bool val) { } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::enable_alpha_test // Access: @@ -644,7 +644,7 @@ clear_color_write_mask() { } } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::call_glFogfv // Access: Public @@ -662,7 +662,7 @@ call_glFogfv(GLenum pname, const LColor &color) { } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::call_glMaterialfv // Access: Public @@ -680,7 +680,7 @@ call_glMaterialfv(GLenum face, GLenum pname, const LColor &color) { } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::call_glLightfv // Access: Public @@ -698,7 +698,7 @@ call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value) { } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::call_glLightfv // Access: Public @@ -716,7 +716,7 @@ call_glLightfv(GLenum light, GLenum pname, const LVecBase3 &value) { } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::call_glLightModelfv // Access: Public @@ -734,7 +734,7 @@ call_glLightModelfv(GLenum pname, const LVecBase4 &value) { } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::call_glTexEnvfv // Access: Public @@ -768,7 +768,7 @@ call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value) { #endif // STDFLOAT_DOUBLE } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::get_light_id // Access: Public @@ -780,7 +780,7 @@ get_light_id(int index) const { } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::get_clip_plane_id // Access: Public diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 62c25d5795..e594579d4c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -83,7 +83,7 @@ PStatCollector CLP(GraphicsStateGuardian)::_texture_update_pcollector("Draw:Upda PStatCollector CLP(GraphicsStateGuardian)::_fbo_bind_pcollector("Draw:Bind FBO"); PStatCollector CLP(GraphicsStateGuardian)::_check_error_pcollector("Draw:Check errors"); -#ifdef OPENGLES_2 +#ifndef OPENGLES_1 PT(Shader) CLP(GraphicsStateGuardian)::_default_shader = NULL; #endif @@ -126,22 +126,54 @@ static void APIENTRY null_glBlendColor(GLclampf, GLclampf, GLclampf, GLclampf) { } -#ifdef OPENGLES_2 -// We have a default shader that will be applied when there -// isn't any shader applied (e.g. if it failed to compile). -// We need this because OpenGL ES 2.x does not have -// a fixed-function pipeline. -// This default shader just outputs a red color, telling -// the user that something went wrong. +#ifndef OPENGLES_1 +// We have a default shader that will be applied when there isn't any +// shader applied (e.g. if it failed to compile). We need this because +// OpenGL ES 2.x and OpenGL 3.2+ core don't have a fixed-function pipeline. +// This default shader just applies a single texture, which is good enough +// for drawing GUIs and such. static const string default_vshader = - "uniform mediump mat4 p3d_ModelViewProjectionMatrix;\n" - "attribute highp vec4 p3d_Vertex;\n" +#ifndef OPENGLES + "#version 130\n" + "in vec4 p3d_Vertex;\n" + "in vec4 p3d_Color;\n" + "in vec2 p3d_MultiTexCoord0;\n" + "out vec2 texcoord;\n" + "out vec4 color;\n" +#else + "precision mediump float;\n" + "attribute vec4 p3d_Vertex;\n" + "attribute vec4 p3d_Color;\n" + "attribute vec2 p3d_MultiTexCoord0;\n" + "varying vec2 texcoord;\n" + "varying vec4 color;\n" +#endif + "uniform mat4 p3d_ModelViewProjectionMatrix;\n" + "uniform vec4 p3d_ColorScale;\n" "void main(void) {\n" " gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n" + " texcoord = p3d_MultiTexCoord0;\n" + " color = p3d_Color * p3d_ColorScale;\n" "}\n"; + static const string default_fshader = +#ifndef OPENGLES + "#version 130\n" + "in vec2 texcoord;\n" + "in vec4 color;\n" +#else + "precision mediump float;\n" + "varying vec2 texcoord;\n" + "varying vec4 color;\n" +#endif + "uniform sampler2D p3d_Texture0;\n" "void main(void) {\n" - " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" +#ifndef OPENGLES + " gl_FragColor = texture(p3d_Texture0, texcoord);\n" +#else + " gl_FragColor = texture2D(p3d_Texture0, texcoord).bgra;\n" +#endif + " gl_FragColor *= color;\n" "}\n"; #endif @@ -304,9 +336,12 @@ int CLP(GraphicsStateGuardian)::get_driver_shader_version_minor() { return _gl_s //////////////////////////////////////////////////////////////////// CLP(GraphicsStateGuardian):: CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe) : - GraphicsStateGuardian(CS_yup_right, engine, pipe) + GraphicsStateGuardian(gl_coordinate_system, engine, pipe), + _renderbuffer_residency(get_prepared_objects()->get_name(), "renderbuffer") { _error_count = 0; + _gl_shadlang_ver_major = 0; + _gl_shadlang_ver_minor = 0; // Hack. Turn on the flag that we turned off at a higher level, // since we know this works properly in OpenGL, and we want the @@ -324,6 +359,8 @@ CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe) : _scissor_enabled = false; _scissor_attrib_active = false; + _white_texture = 0; + #ifdef HAVE_CG _cg_context = 0; #endif @@ -446,8 +483,55 @@ reset() { // Save the extensions tokens. _extensions.clear(); - save_extensions((const char *)glGetString(GL_EXTENSIONS)); + + // In OpenGL 3.0 and later, glGetString(GL_EXTENSIONS) is deprecated. +#ifndef OPENGLES + if (is_at_least_gl_version(3, 0)) { + PFNGLGETSTRINGIPROC _glGetStringi = + (PFNGLGETSTRINGIPROC)get_extension_func("glGetStringi"); + + if (_glGetStringi != NULL) { + GLint n = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &n); + for (GLint i = 0; i < n; ++i) { + const char *extension = (const char *)_glGetStringi(GL_EXTENSIONS, i); + _extensions.insert(string(extension)); + } + } else { + GLCAT.error() << "glGetStringi is not available!\n"; + save_extensions((const char *)glGetString(GL_EXTENSIONS)); + } + } else +#endif + { + save_extensions((const char *)glGetString(GL_EXTENSIONS)); + } + get_extra_extensions(); + + // This needs access to the extensions, so put this after save_extensions. + query_glsl_version(); + +#ifndef OPENGLES + bool core_profile; + if (_gl_version_major < 3 || has_extension("GL_ARB_compatibility")) { + core_profile = false; + } else { + core_profile = true; + } + + if (core_profile) { + GLCAT.debug() << "Using core profile\n"; + } else { + GLCAT.debug() << "Using compatibility profile\n"; + } +#elif defined(OPENGLES_1) + static const bool core_profile = false; +#else + static const bool core_profile = true; +#endif + + // Print out a list of all extensions. report_extensions(); // Initialize OpenGL debugging output first, if enabled and supported. @@ -598,115 +682,17 @@ reset() { } #endif -#ifdef OPENGLES_2 - _supports_vertex_blend = false; -#else - _supports_vertex_blend = has_extension("GL_ARB_vertex_blend"); +#if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) + if (is_at_least_gl_version(1, 4)) { + _glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC) + get_extension_func("glSecondaryColorPointer"); - if (_supports_vertex_blend) { - _glWeightPointer = (PFNGLWEIGHTPOINTERARBPROC) - get_extension_func("glWeightPointerARB"); - _glVertexBlend = (PFNGLVERTEXBLENDARBPROC) - get_extension_func("glVertexBlendARB"); - _glWeightfv = (PFNGLWEIGHTFVARBPROC) - get_extension_func("glWeightfvARB"); - _glWeightdv = (PFNGLWEIGHTDVARBPROC) - get_extension_func("glWeightdvARB"); - - if (_glWeightPointer == NULL || _glVertexBlend == NULL || - GLfv(_glWeight) == NULL) { - GLCAT.warning() - << "Vertex blending advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; - _supports_vertex_blend = false; - } + } else if (has_extension("GL_EXT_secondary_color")) { + _glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC) + get_extension_func("glSecondaryColorPointerEXT"); } #endif -#ifndef OPENGLES_2 - if (_supports_vertex_blend) { -#ifndef OPENGLES - glEnable(GL_WEIGHT_SUM_UNITY_ARB); -#endif - - GLint max_vertex_units = 0; - glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &max_vertex_units); - _max_vertex_transforms = max_vertex_units; - if (GLCAT.is_debug()) { - GLCAT.debug() - << "max vertex transforms = " << _max_vertex_transforms << "\n"; - } - } -#endif - - _supports_matrix_palette = false; -#ifndef OPENGLES - if (has_extension("GL_ARB_matrix_palette")) { - _supports_matrix_palette = true; - _glCurrentPaletteMatrix = (PFNGLCURRENTPALETTEMATRIXARBPROC) - get_extension_func("glCurrentPaletteMatrixARB"); - _glMatrixIndexPointer = (PFNGLMATRIXINDEXPOINTERARBPROC) - get_extension_func("glMatrixIndexPointerARB"); - _glMatrixIndexuiv = (PFNGLMATRIXINDEXUIVARBPROC) - get_extension_func("glMatrixIndexuivARB"); - - if (_glCurrentPaletteMatrix == NULL || - _glMatrixIndexPointer == NULL || - _glMatrixIndexuiv == NULL) { - GLCAT.warning() - << "Matrix palette advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; - _supports_matrix_palette = false; - } - } -#elif defined(OPENGLES_1) - if (has_extension("GL_OES_matrix_palette")) { - _supports_matrix_palette = true; - _glCurrentPaletteMatrix = (PFNGLCURRENTPALETTEMATRIXOESPROC) - get_extension_func("glCurrentPaletteMatrixOES"); - _glMatrixIndexPointer = (PFNGLMATRIXINDEXPOINTEROESPROC) - get_extension_func("glMatrixIndexPointerOES"); - - if (_glCurrentPaletteMatrix == NULL || - _glMatrixIndexPointer == NULL) { - GLCAT.warning() - << "Matrix palette advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; - _supports_matrix_palette = false; - } - } -#endif - - /* - The matrix_palette support in this module is completely untested - (because I don't happen to have a card handy whose driver supports - this extension), so I have this ConfigVariable set to - unconditionally set this flag off for now, to protect the unwary. - When we have shown that the code works, we should remove this bit. - In the meantime, you must put both "matrix-palette 1" and - "gl-matrix-palette 1" in your Config.prc to exercise the new - code. */ - if (!gl_matrix_palette) { - if (_supports_matrix_palette) { - if (GLCAT.is_debug()) { - GLCAT.debug() << "Forcing off matrix palette support.\n"; - } - } - _supports_matrix_palette = false; - } - - if (_supports_matrix_palette) { - GLint max_palette_matrices = 0; -#ifdef OPENGLES_1 - glGetIntegerv(GL_MAX_PALETTE_MATRICES_OES, &max_palette_matrices); -#endif -#ifndef OPENGLES - glGetIntegerv(GL_MAX_PALETTE_MATRICES_ARB, &max_palette_matrices); -#endif - _max_vertex_transform_indices = max_palette_matrices; - if (GLCAT.is_debug()) { - GLCAT.debug() - << "max vertex transform indices = " << _max_vertex_transform_indices << "\n"; - } - } - #ifndef OPENGLES _glDrawRangeElements = null_glDrawRangeElements; @@ -1002,11 +988,9 @@ reset() { has_extension("GL_EXT_bgra") || is_at_least_gl_version(1, 2); #endif -#ifdef OPENGLES_2 - _supports_rescale_normal = true; -#else +#ifdef SUPPORT_FIXED_FUNCTION _supports_rescale_normal = - gl_support_rescale_normal && + !core_profile && gl_support_rescale_normal && (has_extension("GL_EXT_rescale_normal") || is_at_least_gl_version(1, 2)); #endif @@ -1042,13 +1026,19 @@ reset() { #ifdef OPENGLES_2 _glActiveTexture = glActiveTexture; #else + bool supports_multitexture = false; if (is_at_least_gl_version(1, 3) || is_at_least_gles_version(1, 1)) { - _supports_multitexture = true; + supports_multitexture = true; _glActiveTexture = (PFNGLACTIVETEXTUREPROC) get_extension_func("glActiveTexture"); + +#ifdef SUPPORT_FIXED_FUNCTION _glClientActiveTexture = (PFNGLACTIVETEXTUREPROC) get_extension_func("glClientActiveTexture"); +#endif + +#ifdef SUPPORT_IMMEDIATE_MODE _glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC) get_extension_func("glMultiTexCoord1f"); _glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) @@ -1065,14 +1055,20 @@ reset() { get_extension_func("glMultiTexCoord3d"); _glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) get_extension_func("glMultiTexCoord4d"); +#endif } else if (has_extension("GL_ARB_multitexture")) { - _supports_multitexture = true; + supports_multitexture = true; _glActiveTexture = (PFNGLACTIVETEXTUREPROC) get_extension_func("glActiveTextureARB"); + +#ifdef SUPPORT_FIXED_FUNCTION _glClientActiveTexture = (PFNGLACTIVETEXTUREPROC) get_extension_func("glClientActiveTextureARB"); +#endif + +#ifdef SUPPORT_IMMEDIATE_MODE _glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC) get_extension_func("glMultiTexCoord1fARB"); _glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) @@ -1089,12 +1085,16 @@ reset() { get_extension_func("glMultiTexCoord3dARB"); _glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) get_extension_func("glMultiTexCoord4dARB"); +#endif } else { - _supports_multitexture = false; + supports_multitexture = false; } - if (_supports_multitexture) { - if (_glActiveTexture == NULL || _glClientActiveTexture == NULL + if (supports_multitexture) { + if (_glActiveTexture == NULL +#ifdef SUPPORT_FIXED_FUNCTION + || _glClientActiveTexture == NULL +#endif #ifdef SUPPORT_IMMEDIATE_MODE || GLf(_glMultiTexCoord1) == NULL || GLf(_glMultiTexCoord2) == NULL || GLf(_glMultiTexCoord3) == NULL || GLf(_glMultiTexCoord4) == NULL @@ -1102,16 +1102,21 @@ reset() { ) { GLCAT.warning() << "Multitexture advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; - _supports_multitexture = false; + supports_multitexture = false; } } - if (!_supports_multitexture) { + if (!supports_multitexture) { // Replace with dummy no-op functions. _glActiveTexture = null_glActiveTexture; + } + +#ifdef SUPPORT_FIXED_FUNCTION + if (!supports_multitexture || core_profile) { _glClientActiveTexture = null_glActiveTexture; } #endif +#endif // OPENGLES_2 #ifdef OPENGLES if (has_extension("GL_ANGLE_depth_texture")) { @@ -1129,6 +1134,9 @@ reset() { #else _supports_depth_texture = (is_at_least_gl_version(1, 4) || has_extension("GL_ARB_depth_texture")); + _supports_depth_stencil = (is_at_least_gl_version(3, 0) || + has_extension("GL_ARB_framebuffer_object") || + has_extension("GL_EXT_packed_depth_stencil")); #endif #ifdef OPENGLES_2 @@ -1152,17 +1160,19 @@ reset() { _supports_shadow_filter = false; }*/ -#ifdef OPENGLES_2 +#ifndef SUPPORT_FIXED_FUNCTION _supports_texture_combine = false; _supports_texture_saved_result = false; _supports_texture_dot3 = false; #else - _supports_texture_combine = - has_extension("GL_ARB_texture_env_combine") || is_at_least_gl_version(1, 3) || is_at_least_gles_version(1, 1); - _supports_texture_saved_result = - has_extension("GL_ARB_texture_env_crossbar") || has_extension("GL_OES_texture_env_crossbar") || is_at_least_gl_version(1, 4); - _supports_texture_dot3 = - has_extension("GL_ARB_texture_env_dot3") || is_at_least_gl_version(1, 3) || is_at_least_gles_version(1, 1); + if (!core_profile) { + _supports_texture_combine = + has_extension("GL_ARB_texture_env_combine") || is_at_least_gl_version(1, 3) || is_at_least_gles_version(1, 1); + _supports_texture_saved_result = + has_extension("GL_ARB_texture_env_crossbar") || has_extension("GL_OES_texture_env_crossbar") || is_at_least_gl_version(1, 4); + _supports_texture_dot3 = + has_extension("GL_ARB_texture_env_dot3") || is_at_least_gl_version(1, 3) || is_at_least_gles_version(1, 1); + } #endif #ifdef OPENGLES_2 @@ -1217,6 +1227,38 @@ reset() { } #endif + _supports_vao = false; + + if (is_at_least_gl_version(3, 0) || has_extension("GL_ARB_vertex_array_object")) { + _supports_vao = true; + + _glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) + get_extension_func("glBindVertexArray"); + _glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) + get_extension_func("glDeleteVertexArrays"); + _glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) + get_extension_func("glGenVertexArrays"); + + } else if (has_extension("GL_OES_vertex_array_object")) { + _supports_vao = true; + + _glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) + get_extension_func("glBindVertexArrayOES"); + _glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) + get_extension_func("glDeleteVertexArraysOES"); + _glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) + get_extension_func("glGenVertexArraysOES"); + } + + if (_supports_vao) { + if (_glBindVertexArray == NULL || _glDeleteVertexArrays == NULL || + _glGenVertexArrays == NULL) { + GLCAT.warning() + << "Vertex array objects advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; + _supports_vao = false; + } + } + #if defined(HAVE_CG) && !defined(OPENGLES) if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) && cgGLIsProfileSupported(CG_PROFILE_ARBVP1)) { @@ -1447,16 +1489,35 @@ reset() { _glVertexAttribPointer = glVertexAttribPointer; _glVertexAttribIPointer = NULL; _glVertexAttribLPointer = NULL; +#endif +#ifndef OPENGLES_1 // We need to have a default shader to apply in case // something didn't happen to have a shader applied, or // if it failed to compile. This default shader just outputs // a red color, indicating that something went wrong. - if (_default_shader == NULL) { + if (_default_shader == NULL && core_profile) { _default_shader = Shader::make(Shader::SL_GLSL, default_vshader, default_fshader); } #endif +#ifndef OPENGLES + // Check for uniform buffers. + if (is_at_least_gl_version(3, 1) || has_extension("GL_ARB_uniform_buffer_object")) { + _supports_uniform_buffers = true; + _glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) + get_extension_func("glGetActiveUniformsiv"); + _glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) + get_extension_func("glGetActiveUniformBlockiv"); + _glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) + get_extension_func("glGetActiveUniformBlockName"); + } else { + _supports_uniform_buffers = false; + } +#else + _supports_uniform_buffers = false; +#endif + // Check whether we support geometry instancing and instanced vertex attribs. #if defined(OPENGLES_1) _supports_vertex_attrib_divisor = false; @@ -2238,11 +2299,17 @@ reset() { report_my_gl_errors(); - if (support_stencil) { + if (core_profile) { + //TODO: better detection mechanism? + _supports_stencil = true; + } +#ifdef SUPPORT_FIXED_FUNCTION + else if (support_stencil) { GLint num_stencil_bits; glGetIntegerv(GL_STENCIL_BITS, &num_stencil_bits); _supports_stencil = (num_stencil_bits != 0); } +#endif _supports_stencil_wrap = has_extension("GL_EXT_stencil_wrap") || has_extension("GL_OES_stencil_wrap"); @@ -2259,8 +2326,6 @@ reset() { } #endif - _auto_rescale_normal = false; - // Ensure the initial state is what we say it should be (in some // cases, we don't want the GL default settings; in others, we have // to force the point with some drivers that aren't strictly @@ -2268,11 +2333,17 @@ reset() { glFrontFace(GL_CCW); #ifndef OPENGLES_2 glDisable(GL_LINE_SMOOTH); - glDisable(GL_POINT_SMOOTH); +#endif +#ifdef SUPPORT_FIXED_FUNCTION + if (!core_profile) { + glDisable(GL_POINT_SMOOTH); + } +#endif #ifndef OPENGLES glDisable(GL_POLYGON_SMOOTH); #endif // OPENGLES +#ifndef OPENGLES_2 if (_supports_multisample) { glDisable(GL_MULTISAMPLE); } @@ -2310,38 +2381,39 @@ reset() { _texture_binding_shader_context = (ShaderContext *)NULL; #endif -#ifdef OPENGLES_2 - _max_lights = 0; -#else // Count the max number of lights - GLint max_lights = 0; - glGetIntegerv(GL_MAX_LIGHTS, &max_lights); - _max_lights = max_lights; + _max_lights = 0; +#ifdef SUPPORT_FIXED_FUNCTION + if (!core_profile) { + GLint max_lights = 0; + glGetIntegerv(GL_MAX_LIGHTS, &max_lights); + _max_lights = max_lights; - if (GLCAT.is_debug()) { - GLCAT.debug() - << "max lights = " << _max_lights << "\n"; + if (GLCAT.is_debug()) { + GLCAT.debug() + << "max lights = " << _max_lights << "\n"; + } } #endif -#ifdef OPENGLES_2 - _max_clip_planes = 0; -#else // Count the max number of clipping planes - GLint max_clip_planes = 0; - glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes); - _max_clip_planes = max_clip_planes; + _max_clip_planes = 0; +#ifdef SUPPORT_FIXED_FUNCTION + if (!core_profile) { + GLint max_clip_planes = 0; + glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes); + _max_clip_planes = max_clip_planes; - if (GLCAT.is_debug()) { - GLCAT.debug() - << "max clip planes = " << _max_clip_planes << "\n"; + if (GLCAT.is_debug()) { + GLCAT.debug() + << "max clip planes = " << _max_clip_planes << "\n"; + } } #endif -#ifdef OPENGLES_2 - _max_texture_stages = 0; -#else - if (_supports_multitexture) { + _max_texture_stages = 1; +#ifdef SUPPORT_FIXED_FUNCTION + if (supports_multitexture && !core_profile) { GLint max_texture_stages = 0; glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_stages); _max_texture_stages = max_texture_stages; @@ -2355,38 +2427,43 @@ reset() { _current_vbuffer_index = 0; _current_ibuffer_index = 0; + _current_vao_index = 0; _current_fbo = 0; _auto_antialias_mode = false; _render_mode = RenderModeAttrib::M_filled; _point_size = 1.0f; _point_perspective = false; - _vertex_blending_enabled = false; - report_my_gl_errors(); -#ifndef OPENGLES_2 - if (gl_cheap_textures) { - GLCAT.info() - << "Setting glHint() for fastest textures.\n"; - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); - } +#ifdef SUPPORT_FIXED_FUNCTION + if (!core_profile) { + if (gl_cheap_textures) { + GLCAT.info() + << "Setting glHint() for fastest textures.\n"; + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + } - // Use per-vertex fog if per-pixel fog requires SW renderer - glHint(GL_FOG_HINT, GL_DONT_CARE); + // Use per-vertex fog if per-pixel fog requires SW renderer + glHint(GL_FOG_HINT, GL_DONT_CARE); + } #endif - GLint num_red_bits = 0; - glGetIntegerv(GL_RED_BITS, &num_red_bits); - if (num_red_bits < 8) { - glEnable(GL_DITHER); - _dithering_enabled = true; - if (GLCAT.is_debug()) { - GLCAT.debug() - << "frame buffer depth = " << num_red_bits - << " bits/channel, enabling dithering\n"; +#ifdef SUPPORT_FIXED_FUNCTION + if (!core_profile) { + GLint num_red_bits = 0; + glGetIntegerv(GL_RED_BITS, &num_red_bits); + if (num_red_bits < 8) { + glEnable(GL_DITHER); + _dithering_enabled = true; + if (GLCAT.is_debug()) { + GLCAT.debug() + << "frame buffer depth = " << num_red_bits + << " bits/channel, enabling dithering\n"; + } } } +#endif _error_count = 0; @@ -2495,6 +2572,20 @@ reset() { << "\n"; } +#endif + + // OpenGL core profile requires a VAO to be bound. It's a bit silly, + // because we can just bind a VAO and then forget about it. +#if !defined(OPENGLES) + if (core_profile) { + if (_supports_vao) { + _glGenVertexArrays(1, &_current_vao_index); + _glBindVertexArray(_current_vao_index); + } else { + GLCAT.error() + << "Core profile enabled, but vertex array objects not supported!\n"; + } + } #endif // Now that the GSG has been initialized, make it available for @@ -2826,7 +2917,7 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: clear_before_callback() { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION disable_standard_vertex_arrays(); #endif unbind_buffers(); @@ -2835,7 +2926,7 @@ clear_before_callback() { // texture stage is still set to stage 0. CEGUI, in particular, // makes this assumption. _glActiveTexture(GL_TEXTURE0); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION _glClientActiveTexture(GL_TEXTURE0); #endif @@ -2878,7 +2969,8 @@ calc_projection_mat(const Lens *lens) { // choice in the modelview matrix. LMatrix4 result = - LMatrix4::convert_mat(CS_yup_right, lens->get_coordinate_system()) * + LMatrix4::convert_mat(_internal_coordinate_system, + lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel); if (_scene_setup->get_inverted()) { @@ -2904,7 +2996,7 @@ calc_projection_mat(const Lens *lens) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: prepare_lens() { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION if (GLCAT.is_spam()) { GLCAT.spam() << "glMatrixMode(GL_PROJECTION): " << _projection_mat->get_mat() << endl; @@ -2917,6 +3009,12 @@ prepare_lens() { do_point_size(); #endif +#ifndef OPENGLES_1 + if (_current_shader_context) { + _current_shader_context->issue_parameters(Shader::SSD_transform); + } +#endif + return true; } @@ -2938,6 +3036,8 @@ begin_frame(Thread *current_thread) { if (!GraphicsStateGuardian::begin_frame(current_thread)) { return false; } + _renderbuffer_residency.begin_frame(current_thread); + report_my_gl_errors(); #ifdef DO_PSTATS @@ -3098,6 +3198,8 @@ end_frame(Thread *current_thread) { GraphicsStateGuardian::end_frame(current_thread); + _renderbuffer_residency.end_frame(current_thread); + // Flush any PCollectors specific to this kind of GSG. _primitive_batches_display_list_pcollector.flush_level(); _vertices_display_list_pcollector.flush_level(); @@ -3105,6 +3207,7 @@ end_frame(Thread *current_thread) { // Now is a good time to delete any pending display lists. #ifndef OPENGLES +#ifdef SUPPORT_FIXED_FUNCTION if (display_lists) { LightMutexHolder holder(_lock); if (!_deleted_display_lists.empty()) { @@ -3121,6 +3224,7 @@ end_frame(Thread *current_thread) { _deleted_display_lists.clear(); } } +#endif // And deleted queries, too, unless we're using query timers // in which case we'll need to reuse lots of them. @@ -3207,7 +3311,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } #endif // NDEBUG -#ifdef OPENGLES_2 +#ifndef SUPPORT_FIXED_FUNCTION // We can't draw without a shader bound in OpenGL ES 2. This shouldn't // happen anyway unless the default shader failed to compile somehow. if (_current_shader_context == NULL) { @@ -3251,95 +3355,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } } - const GeomVertexAnimationSpec &animation = - _data_reader->get_format()->get_animation(); - bool hardware_animation = (animation.get_animation_type() == Geom::AT_hardware); -#ifndef OPENGLES - if (hardware_animation) { - // Set up the transform matrices for vertex blending. - nassertr(_supports_vertex_blend, false); - glEnable(GL_VERTEX_BLEND_ARB); - _glVertexBlend(animation.get_num_transforms()); - - const TransformTable *table = _data_reader->get_transform_table(); - if (table != (TransformTable *)NULL) { - if (animation.get_indexed_transforms()) { - nassertr(_supports_matrix_palette, false); - // We are loading the indexed matrix palette. The ARB decided - // to change this interface from that for the list of - // nonindexed matrices, to make it easier to load an arbitrary - // number of matrices. - glEnable(GL_MATRIX_PALETTE_ARB); - - glMatrixMode(GL_MATRIX_PALETTE_ARB); - - for (int i = 0; i < table->get_num_transforms(); ++i) { - LMatrix4 mat; - table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); - _glCurrentPaletteMatrix(i); - GLPf(LoadMatrix)(mat.get_data()); - } - - // Presumably loading the matrix palette does not step on the - // GL_MODELVIEW matrix? - - } else { - // We are loading the list of nonindexed matrices. This is a - // little clumsier. - - if (_supports_matrix_palette) { - glDisable(GL_MATRIX_PALETTE_ARB); - } - - // GL_MODELVIEW0 and 1 are different than the rest. - int i = 0; - if (i < table->get_num_transforms()) { - LMatrix4 mat; - table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); - glMatrixMode(GL_MODELVIEW0_ARB); - GLPf(LoadMatrix)(mat.get_data()); - ++i; - } - if (i < table->get_num_transforms()) { - LMatrix4 mat; - table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); - glMatrixMode(GL_MODELVIEW1_ARB); - GLPf(LoadMatrix)(mat.get_data()); - ++i; - } - while (i < table->get_num_transforms()) { - LMatrix4 mat; - table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); - glMatrixMode(GL_MODELVIEW2_ARB + i - 2); - GLPf(LoadMatrix)(mat.get_data()); - ++i; - } - - // Setting the GL_MODELVIEW0 matrix steps on the world matrix, - // so we have to set a flag to reload the world matrix later. - _transform_stale = true; - } - } - _vertex_blending_enabled = true; - - } else { - // We're not using vertex blending. - if (_vertex_blending_enabled) { - glDisable(GL_VERTEX_BLEND_ARB); - if (_supports_matrix_palette) { - glDisable(GL_MATRIX_PALETTE_ARB); - } - _vertex_blending_enabled = false; - } - - if (_transform_stale) { - glMatrixMode(GL_MODELVIEW); - GLPf(LoadMatrix)(_internal_transform->get_mat().get_data()); - } - } -#endif - -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION if (_data_reader->is_vertex_transformed()) { // If the vertex data claims to be already transformed into clip // coordinates, wipe out the current projection and modelview @@ -3353,10 +3369,10 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } #endif -#ifndef OPENGLES // Display lists not supported by OpenGL ES. +#if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) // Display lists not supported by OpenGL ES. if (geom_reader->get_usage_hint() == Geom::UH_static && _data_reader->get_usage_hint() == Geom::UH_static && - display_lists && (!hardware_animation || display_list_animation)) { + display_lists) { // If the geom claims to be totally static, try to build it into // a display list. @@ -3435,13 +3451,13 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (_vertex_array_shader_context != 0) { _vertex_array_shader_context->disable_shader_vertex_arrays(); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION if (!update_standard_vertex_arrays(force)) { return false; } #endif } else { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION // Shader. if (_vertex_array_shader_context == 0 || _vertex_array_shader_context->uses_standard_vertex_arrays()) { // Previous shader used standard arrays. @@ -3455,7 +3471,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, disable_standard_vertex_arrays(); } } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION if (_current_shader_context->uses_custom_vertex_arrays()) { // The current shader also uses custom vertex arrays. if (!_current_shader_context-> @@ -3476,7 +3492,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, return true; } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::update_standard_vertex_arrays // Access: Protected @@ -3491,9 +3507,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: update_standard_vertex_arrays(bool force) { - const GeomVertexAnimationSpec &animation = - _data_reader->get_format()->get_animation(); - bool hardware_animation = (animation.get_animation_type() == Geom::AT_hardware); #ifdef SUPPORT_IMMEDIATE_MODE if (_use_sender) { // We must use immediate mode to render primitives. @@ -3551,20 +3564,6 @@ update_standard_vertex_arrays(bool force) { } _last_max_stage_index = max_stage_index; - if (_supports_vertex_blend) { - if (hardware_animation) { - // Issue the weights and/or transform indices for vertex blending. - _sender.add_vector_column(_data_reader, InternalName::get_transform_weight(), - GLfv(_glWeight)); - - if (animation.get_indexed_transforms()) { - // Issue the matrix palette indices. - _sender.add_vector_uint_column(_data_reader, InternalName::get_transform_index(), - _glMatrixIndexuiv); - } - } - } - // We must add vertex last, because glVertex3f() is the key // function call that actually issues the vertex. _sender.add_column(_data_reader, InternalName::get_vertex(), @@ -3666,48 +3665,6 @@ update_standard_vertex_arrays(bool force) { } _last_max_stage_index = max_stage_index; -#ifndef OPENGLES - if (_supports_vertex_blend) { - if (hardware_animation) { - // Issue the weights and/or transform indices for vertex blending. - if (_data_reader->get_array_info(InternalName::get_transform_weight(), - array_reader, num_values, numeric_type, - start, stride)) { - if (!setup_array_data(client_pointer, array_reader, force)) { - return false; - } - _glWeightPointer(num_values, get_numeric_type(numeric_type), - stride, client_pointer + start); - glEnableClientState(GL_WEIGHT_ARRAY_ARB); - } else { - glDisableClientState(GL_WEIGHT_ARRAY_ARB); - } - - if (animation.get_indexed_transforms()) { - // Issue the matrix palette indices. - if (_data_reader->get_array_info(InternalName::get_transform_index(), - array_reader, num_values, numeric_type, - start, stride)) { - if (!setup_array_data(client_pointer, array_reader, force)) { - return false; - } - _glMatrixIndexPointer(num_values, get_numeric_type(numeric_type), - stride, client_pointer + start); - glEnableClientState(GL_MATRIX_INDEX_ARRAY_ARB); - } else { - glDisableClientState(GL_MATRIX_INDEX_ARRAY_ARB); - } - } - - } else { - glDisableClientState(GL_WEIGHT_ARRAY_ARB); - if (_supports_matrix_palette) { - glDisableClientState(GL_MATRIX_INDEX_ARRAY_ARB); - } - } - } -#endif - // There's no requirement that we add vertices last, but we do // anyway. if (_data_reader->get_vertex_info(array_reader, num_values, numeric_type, @@ -3722,7 +3679,7 @@ update_standard_vertex_arrays(bool force) { } return true; } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::unbind_buffers @@ -3750,12 +3707,12 @@ unbind_buffers() { _current_ibuffer_index = 0; } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION disable_standard_vertex_arrays(); #endif } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::disable_standard_vertex_arrays // Access: Protected @@ -3782,19 +3739,10 @@ disable_standard_vertex_arrays() { } _last_max_stage_index = 0; -#ifndef OPENGLES - if (_supports_vertex_blend) { - glDisableClientState(GL_WEIGHT_ARRAY_ARB); - if (_supports_matrix_palette) { - glDisableClientState(GL_MATRIX_INDEX_ARRAY_ARB); - } - } -#endif - glDisableClientState(GL_VERTEX_ARRAY); report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::draw_triangles @@ -3803,7 +3751,7 @@ disable_standard_vertex_arrays() { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -3870,7 +3818,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); report_my_gl_errors(); @@ -3997,7 +3945,8 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() << "draw_trifans: " << *(reader->get_object()) << "\n"; @@ -4077,7 +4026,7 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_patches(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -4153,7 +4102,8 @@ draw_patches(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() << "draw_lines: " << *(reader->get_object()) << "\n"; @@ -4217,7 +4167,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); report_my_gl_errors(); @@ -4341,7 +4291,8 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_points(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() << "draw_points: " << *(reader->get_object()) << "\n"; @@ -4405,7 +4356,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: end_draw_primitives() { -#ifndef OPENGLES // Display lists not supported by OpenGL ES. +#if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) // Display lists not supported by OpenGL ES. if (_geom_display_list != 0) { // If we were building a display list, close it now. glEndList(); @@ -4417,18 +4368,9 @@ end_draw_primitives() { _primitive_batches_display_list_pcollector.add_level(1); } _geom_display_list = 0; - - // Clean up the vertex blending state. - if (_vertex_blending_enabled) { - glDisable(GL_VERTEX_BLEND_ARB); - if (_supports_matrix_palette) { - glDisable(GL_MATRIX_PALETTE_ARB); - } - _vertex_blending_enabled = false; - } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION if (_transform_stale) { glMatrixMode(GL_MODELVIEW); GLPf(LoadMatrix)(_internal_transform->get_mat().get_data()); @@ -5853,7 +5795,7 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z, return true; } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::apply_fog // Access: Public, Virtual @@ -5878,7 +5820,7 @@ apply_fog(Fog *fog) { call_glFogfv(GL_FOG_COLOR, fog->get_color()); report_my_gl_errors(); } -#endif // OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_transform @@ -5891,7 +5833,7 @@ apply_fog(Fog *fog) { //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: do_issue_transform() { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION // OpenGL ES 2 does not support glLoadMatrix. const TransformState *transform = _internal_transform; @@ -5903,10 +5845,6 @@ do_issue_transform() { DO_PSTATS_STUFF(_transform_state_pcollector.add_level(1)); glMatrixMode(GL_MODELVIEW); GLPf(LoadMatrix)(transform->get_mat().get_data()); - - if (_auto_rescale_normal) { - do_auto_rescale_normal(); - } #endif _transform_stale = false; @@ -5919,7 +5857,7 @@ do_issue_transform() { report_my_gl_errors(); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_shade_model // Access: Protected @@ -5942,8 +5880,9 @@ do_issue_shade_model() { break; } } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION +#ifndef OPENGLES_1 //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_shader // Access: Protected @@ -5951,24 +5890,25 @@ do_issue_shade_model() { //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: do_issue_shader(bool state_has_changed) { -#ifndef OPENGLES_1 ShaderContext *context = 0; Shader *shader = (Shader *)(_target_shader->get_shader()); -#ifdef OPENGLES_2 +#ifndef SUPPORT_FIXED_FUNCTION // If we don't have a shader, apply the default shader. if (!shader) { shader = _default_shader; + nassertv(shader != NULL); } #endif if (shader) { context = shader->prepare_now(get_prepared_objects(), this); } -#ifdef OPENGLES_2 +#ifndef SUPPORT_FIXED_FUNCTION // If it failed, try applying the default shader. if (shader != _default_shader && (context == 0 || !context->valid())) { shader = _default_shader; + nassertv(shader != NULL); context = shader->prepare_now(get_prepared_objects(), this); } #endif @@ -5999,8 +5939,8 @@ do_issue_shader(bool state_has_changed) { } report_my_gl_errors(); -#endif } +#endif // !OPENGLES_1 //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_render_mode @@ -6118,7 +6058,7 @@ do_issue_antialias() { report_my_gl_errors(); } -#ifndef OPENGLES_2 // OpenGL ES 2.0 doesn't support rescaling normals. +#ifdef SUPPORT_FIXED_FUNCTION // OpenGL ES 2.0 doesn't support rescaling normals. //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_rescale_normal // Access: Protected @@ -6126,12 +6066,12 @@ do_issue_antialias() { //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: do_issue_rescale_normal() { + RescaleNormalAttrib::Mode mode = RescaleNormalAttrib::M_none; + const RescaleNormalAttrib *target_rescale_normal; - _target_rs->get_attrib_def(target_rescale_normal); - - RescaleNormalAttrib::Mode mode = target_rescale_normal->get_mode(); - - _auto_rescale_normal = false; + if (_target_rs->get_attrib(target_rescale_normal)) { + mode = target_rescale_normal->get_mode(); + } switch (mode) { case RescaleNormalAttrib::M_none: @@ -6157,18 +6097,13 @@ do_issue_rescale_normal() { } break; - case RescaleNormalAttrib::M_auto: - _auto_rescale_normal = true; - do_auto_rescale_normal(); - break; - default: GLCAT.error() << "Unknown rescale_normal mode " << (int)mode << endl; } report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION // PandaCompareFunc - 1 + 0x200 === GL_NEVER, etc. order is sequential #define PANDA_TO_GL_COMPAREFUNC(PANDACMPFUNC) (PANDACMPFUNC-1 +0x200) @@ -6193,7 +6128,7 @@ do_issue_depth_test() { report_my_gl_errors(); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_alpha_test // Access: Protected @@ -6217,7 +6152,7 @@ do_issue_alpha_test() { } } } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_depth_write @@ -6278,7 +6213,7 @@ do_issue_cull_face() { report_my_gl_errors(); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_fog // Access: Protected @@ -6299,7 +6234,7 @@ do_issue_fog() { } report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_depth_offset @@ -6340,7 +6275,7 @@ do_issue_depth_offset() { report_my_gl_errors(); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_material // Access: Protected @@ -6446,7 +6381,7 @@ do_issue_material() { report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_blending @@ -6577,7 +6512,7 @@ do_issue_blending() { enable_blend(false); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::bind_light // Access: Public, Virtual @@ -6620,9 +6555,9 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::bind_light // Access: Public, Virtual @@ -6672,9 +6607,9 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::bind_light // Access: Public, Virtual @@ -6718,7 +6653,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_IMMEDIATE_MODE //////////////////////////////////////////////////////////////////// @@ -6927,8 +6862,7 @@ query_gl_version() { _gl_version_major = 0; _gl_version_minor = 0; - _gl_shadlang_ver_major = 0; - _gl_shadlang_ver_minor = 0; + const GLubyte *text = glGetString(GL_VERSION); if (text == (const GLubyte *)NULL) { @@ -6974,38 +6908,45 @@ query_gl_version() { << _gl_version_major << "." << _gl_version_minor << "\n"; } + } +} + +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::query_glsl_version +// Access: Protected +// Description: Queries the supported GLSL version. +//////////////////////////////////////////////////////////////////// +void CLP(GraphicsStateGuardian):: +query_glsl_version() { + _gl_shadlang_ver_major = 0; + _gl_shadlang_ver_minor = 0; #ifndef OPENGLES - if (_gl_version_major == 1) { - // We can't call has_extension at this point yet. - const char *extstr = (const char *) glGetString(GL_EXTENSIONS); - if (extstr != NULL) { - if (strstr(extstr, "GL_ARB_shading_language_100") != NULL) { - _gl_shadlang_ver_major = 1; - _gl_shadlang_ver_minor = 0; - } - } - } else if (_gl_version_major >= 2) { + if (_gl_version_major == 1) { + if (has_extension("GL_ARB_shading_language_100")) { _gl_shadlang_ver_major = 1; - _gl_shadlang_ver_minor = 1; - const char *verstr = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); - if (verstr == NULL || - sscanf(verstr, "%d.%d", &_gl_shadlang_ver_major, - &_gl_shadlang_ver_minor) != 2) { - GLCAT.warning() << "Invalid GL_SHADING_LANGUAGE_VERSION format.\n"; - } + _gl_shadlang_ver_minor = 0; } -#elif defined(OPENGLES_2) + } else if (_gl_version_major >= 2) { _gl_shadlang_ver_major = 1; - _gl_shadlang_ver_minor = 0; + _gl_shadlang_ver_minor = 1; const char *verstr = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); if (verstr == NULL || - sscanf(verstr, "OpenGL ES GLSL %d.%d", &_gl_shadlang_ver_major, - &_gl_shadlang_ver_minor) != 2) { + sscanf(verstr, "%d.%d", &_gl_shadlang_ver_major, + &_gl_shadlang_ver_minor) != 2) { GLCAT.warning() << "Invalid GL_SHADING_LANGUAGE_VERSION format.\n"; } -#endif } +#elif defined(OPENGLES_2) + _gl_shadlang_ver_major = 1; + _gl_shadlang_ver_minor = 0; + const char *verstr = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); + if (verstr == NULL || + sscanf(verstr, "OpenGL ES GLSL %d.%d", &_gl_shadlang_ver_major, + &_gl_shadlang_ver_minor) != 2) { + GLCAT.warning() << "Invalid GL_SHADING_LANGUAGE_VERSION format.\n"; + } +#endif } //////////////////////////////////////////////////////////////////// @@ -7101,6 +7042,7 @@ get_extension_func(const char *name) { #endif #ifdef EXPECT_GL_VERSION_1_4 { "glPointParameterfv", (void *)&glPointParameterfv }, + { "glSecondaryColorPointer", (void *)&glSecondaryColorPointer }, #endif #ifdef EXPECT_GL_VERSION_1_5 { "glBeginQuery", (void *)&glBeginQuery }, @@ -7388,7 +7330,11 @@ get_numeric_type(Geom::NumericType numeric_type) { return GL_SHORT; case Geom::NT_int32: +#ifndef OPENGLES_1 return GL_INT; +#else + break; +#endif case Geom::NT_packed_ufloat: #ifndef OPENGLES @@ -7821,8 +7767,14 @@ get_external_image_format(Texture *tex) const { case Texture::F_blue: return GL_BLUE; #endif + case Texture::F_alpha: +#ifdef SUPPORT_FIXED_FUNCTION return GL_ALPHA; +#else + return GL_RED; +#endif + #ifndef OPENGLES_1 case Texture::F_rg16: case Texture::F_rg32: @@ -7855,13 +7807,22 @@ get_external_image_format(Texture *tex) const { #else return _supports_bgr ? GL_BGRA : GL_RGBA; #endif + case Texture::F_luminance: case Texture::F_sluminance: +#ifdef SUPPORT_FIXED_FUNCTION return GL_LUMINANCE; +#else + return GL_RED; +#endif case Texture::F_luminance_alphamask: case Texture::F_luminance_alpha: case Texture::F_sluminance_alpha: +#ifdef SUPPORT_FIXED_FUNCTION return GL_LUMINANCE_ALPHA; +#else + return GL_RG; +#endif #ifndef OPENGLES case Texture::F_r8i: @@ -8369,7 +8330,11 @@ get_internal_image_format(Texture *tex, bool force_sized) const { #endif case Texture::F_alpha: +#ifdef SUPPORT_FIXED_FUNCTION return force_sized ? GL_ALPHA8 : GL_ALPHA; +#else + return force_sized ? GL_R8 : GL_RED; +#endif case Texture::F_luminance: #ifndef OPENGLES @@ -8485,7 +8450,7 @@ is_compressed_format(GLenum format) { //////////////////////////////////////////////////////////////////// GLint CLP(GraphicsStateGuardian):: get_texture_apply_mode_type(TextureStage::Mode am) { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION switch (am) { case TextureStage::M_modulate: return GL_MODULATE; case TextureStage::M_decal: return GL_DECAL; @@ -8517,7 +8482,7 @@ get_texture_apply_mode_type(TextureStage::Mode am) { //////////////////////////////////////////////////////////////////// GLint CLP(GraphicsStateGuardian):: get_texture_combine_type(TextureStage::CombineMode cm) { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION switch (cm) { case TextureStage::CM_undefined: // fall through case TextureStage::CM_replace: return GL_REPLACE; @@ -8545,7 +8510,7 @@ GLint CLP(GraphicsStateGuardian):: get_texture_src_type(TextureStage::CombineSource cs, int last_stage, int last_saved_result, int this_stage) const { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION switch (cs) { case TextureStage::CS_undefined: // fall through case TextureStage::CS_texture: return GL_TEXTURE; @@ -8607,6 +8572,7 @@ get_texture_operand_type(TextureStage::CombineOperand co) { return GL_SRC_COLOR; } +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::get_fog_mode_type // Access: Protected, Static @@ -8616,23 +8582,18 @@ GLenum CLP(GraphicsStateGuardian):: get_fog_mode_type(Fog::Mode m) { switch(m) { case Fog::M_linear: return GL_LINEAR; -#ifndef OPENGLES_2 case Fog::M_exponential: return GL_EXP; case Fog::M_exponential_squared: return GL_EXP2; -#endif /* case Fog::M_spline: return GL_FOG_FUNC_SGIS; */ default: GLCAT.error() << "Invalid Fog::Mode value" << endl; -#ifdef OPENGLES_2 - return GL_LINEAR; -#else return GL_EXP; -#endif } } +#endif //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::get_blend_equation_type @@ -8781,65 +8742,6 @@ get_usage(Geom::UsageHint usage_hint) { return GL_STATIC_DRAW; } - -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::print_gfx_visual -// Access: Public -// Description: Prints a description of the current visual selected. -//////////////////////////////////////////////////////////////////// -void CLP(GraphicsStateGuardian):: -print_gfx_visual() { - GLint i; - GLboolean j; - cout << "Graphics Visual Info (# bits of each):" << endl; - - cout << "RGBA: "; - glGetIntegerv( GL_RED_BITS, &i ); cout << i << " "; - glGetIntegerv( GL_GREEN_BITS, &i ); cout << i << " "; - glGetIntegerv( GL_BLUE_BITS, &i ); cout << i << " "; - glGetIntegerv( GL_ALPHA_BITS, &i ); cout << i << endl; - -#ifndef OPENGLES - cout << "Accum RGBA: "; - glGetIntegerv( GL_ACCUM_RED_BITS, &i ); cout << i << " "; - glGetIntegerv( GL_ACCUM_GREEN_BITS, &i ); cout << i << " "; - glGetIntegerv( GL_ACCUM_BLUE_BITS, &i ); cout << i << " "; - glGetIntegerv( GL_ACCUM_ALPHA_BITS, &i ); cout << i << endl; - - glGetIntegerv( GL_INDEX_BITS, &i ); cout << "Color Index: " << i << endl; -#endif - - glGetIntegerv( GL_DEPTH_BITS, &i ); cout << "Depth: " << i << endl; - glGetIntegerv( GL_ALPHA_BITS, &i ); cout << "Alpha: " << i << endl; - glGetIntegerv( GL_STENCIL_BITS, &i ); cout << "Stencil: " << i << endl; - -#ifndef OPENGLES - glGetBooleanv( GL_DOUBLEBUFFER, &j ); cout << "DoubleBuffer? " - << (int)j << endl; - - glGetBooleanv( GL_STEREO, &j ); cout << "Stereo? " << (int)j << endl; -#endif - - if (_supports_multisample) { -#ifndef OPENGLES_2 - glGetBooleanv( GL_MULTISAMPLE, &j ); cout << "Multisample? " << (int)j << endl; -#endif - glGetIntegerv( GL_SAMPLES, &i ); cout << "Samples: " << i << endl; - } - - glGetBooleanv( GL_BLEND, &j ); cout << "Blend? " << (int)j << endl; -#ifndef OPENGLES_2 - glGetBooleanv( GL_POINT_SMOOTH, &j ); cout << "Point Smooth? " - << (int)j << endl; - glGetBooleanv( GL_LINE_SMOOTH, &j ); cout << "Line Smooth? " - << (int)j << endl; -#endif - -#ifndef OPENGLES - glGetIntegerv( GL_AUX_BUFFERS, &i ); cout << "Aux Buffers: " << i << endl; -#endif -} - //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::get_light_color // Access: Public @@ -8882,7 +8784,7 @@ reissue_transforms() { do_issue_transform(); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::enable_lighting // Access: Protected, Virtual @@ -8902,9 +8804,9 @@ enable_lighting(bool enable) { glDisable(GL_LIGHTING); } } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::set_ambient_light // Access: Protected, Virtual @@ -8925,9 +8827,9 @@ set_ambient_light(const LColor &color) { c[3] * _light_color_scale[3]); call_glLightModelfv(GL_LIGHT_MODEL_AMBIENT, c); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::enable_light // Access: Protected, Virtual @@ -8946,9 +8848,9 @@ enable_light(int light_id, bool enable) { glDisable(get_light_id(light_id)); } } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::begin_bind_lights // Access: Protected, Virtual @@ -8980,9 +8882,9 @@ begin_bind_lights() { glPushMatrix(); GLPf(LoadMatrix)(render_transform->get_mat().get_data()); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::end_bind_lights // Access: Protected, Virtual @@ -9000,9 +8902,9 @@ end_bind_lights() { glMatrixMode(GL_MODELVIEW); glPopMatrix(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::enable_clip_plane // Access: Protected, Virtual @@ -9019,9 +8921,9 @@ enable_clip_plane(int plane_id, bool enable) { glDisable(get_clip_plane_id(plane_id)); } } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::begin_bind_clip_planes // Access: Protected, Virtual @@ -9050,9 +8952,9 @@ begin_bind_clip_planes() { glPushMatrix(); GLPf(LoadMatrix)(render_transform->get_mat().get_data()); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::bind_clip_plane // Access: Protected, Virtual @@ -9082,9 +8984,9 @@ bind_clip_plane(const NodePath &plane, int plane_id) { report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::end_bind_clip_planes // Access: Protected, Virtual @@ -9099,7 +9001,7 @@ end_bind_clip_planes() { glMatrixMode(GL_MODELVIEW); glPopMatrix(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::set_state_and_transform @@ -9150,7 +9052,7 @@ set_state_and_transform(const RenderState *target, _instance_count = _target_shader->get_instance_count(); #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION int alpha_test_slot = AlphaTestAttrib::get_class_slot(); if (_target_rs->get_attrib(alpha_test_slot) != _state_rs->get_attrib(alpha_test_slot) || !_state_mask.get_bit(alpha_test_slot) || @@ -9242,7 +9144,7 @@ set_state_and_transform(const RenderState *target, _state_mask.set_bit(render_mode_slot); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION int rescale_normal_slot = RescaleNormalAttrib::get_class_slot(); if (_target_rs->get_attrib(rescale_normal_slot) != _state_rs->get_attrib(rescale_normal_slot) || !_state_mask.get_bit(rescale_normal_slot)) { @@ -9252,7 +9154,7 @@ set_state_and_transform(const RenderState *target, } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION int shade_model_slot = ShadeModelAttrib::get_class_slot(); if (_target_rs->get_attrib(shade_model_slot) != _state_rs->get_attrib(shade_model_slot) || !_state_mask.get_bit(shade_model_slot)) { @@ -9288,7 +9190,7 @@ set_state_and_transform(const RenderState *target, _state_shader = _target_shader; _state_mask.clear_bit(TextureAttrib::get_class_slot()); } -#ifdef OPENGLES_2 +#ifndef SUPPORT_FIXED_FUNCTION else { // In the case of OpenGL ES 2.x, we need to glUseShader before we draw anything. do_issue_shader(false); } @@ -9315,7 +9217,7 @@ set_state_and_transform(const RenderState *target, // If one of the previously-loaded TexGen modes modified the texture // matrix, then if either state changed, we have to change both of // them now. -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION if (_tex_gen_modifies_mat) { int tex_gen_slot = TexGenAttrib::get_class_slot(); int tex_matrix_slot = TexMatrixAttrib::get_class_slot(); @@ -9337,7 +9239,7 @@ set_state_and_transform(const RenderState *target, } #endif -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION int tex_gen_slot = TexGenAttrib::get_class_slot(); if (_target_tex_gen != _state_tex_gen || !_state_mask.get_bit(tex_gen_slot)) { @@ -9352,7 +9254,7 @@ set_state_and_transform(const RenderState *target, if (_target_rs->get_attrib(material_slot) != _state_rs->get_attrib(material_slot) || !_state_mask.get_bit(material_slot)) { //PStatGPUTimer timer(this, _draw_set_state_material_pcollector); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION do_issue_material(); #endif _state_mask.set_bit(material_slot); @@ -9367,7 +9269,7 @@ set_state_and_transform(const RenderState *target, if (_target_rs->get_attrib(light_slot) != _state_rs->get_attrib(light_slot) || !_state_mask.get_bit(light_slot)) { //PStatGPUTimer timer(this, _draw_set_state_light_pcollector); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION do_issue_light(); #endif _state_mask.set_bit(light_slot); @@ -9390,7 +9292,7 @@ set_state_and_transform(const RenderState *target, if (_target_rs->get_attrib(fog_slot) != _state_rs->get_attrib(fog_slot) || !_state_mask.get_bit(fog_slot)) { //PStatGPUTimer timer(this, _draw_set_state_fog_pcollector); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION do_issue_fog(); #endif _state_mask.set_bit(fog_slot); @@ -9430,61 +9332,6 @@ free_pointers() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_auto_rescale_normal -// Access: Protected -// Description: Issues the appropriate GL commands to either rescale -// or normalize the normals according to the current -// transform. -//////////////////////////////////////////////////////////////////// -void CLP(GraphicsStateGuardian):: -do_auto_rescale_normal() { -#ifndef OPENGLES_2 - if (_internal_transform->has_identity_scale()) { - // If there's no scale at all, don't do anything. - glDisable(GL_NORMALIZE); - if (GLCAT.is_spam()) { - GLCAT.spam() << "glDisable(GL_NORMALIZE)\n"; - } - if (_supports_rescale_normal && support_rescale_normal) { - glDisable(GL_RESCALE_NORMAL); - if (GLCAT.is_spam()) { - GLCAT.spam() << "glDisable(GL_RESCALE_NORMAL)\n"; - } - } - - } else if (_internal_transform->has_uniform_scale()) { - // There's a uniform scale; use the rescale feature if available. - if (_supports_rescale_normal && support_rescale_normal) { - glEnable(GL_RESCALE_NORMAL); - glDisable(GL_NORMALIZE); - if (GLCAT.is_spam()) { - GLCAT.spam() << "glEnable(GL_RESCALE_NORMAL)\n"; - GLCAT.spam() << "glDisable(GL_NORMALIZE)\n"; - } - } else { - glEnable(GL_NORMALIZE); - if (GLCAT.is_spam()) { - GLCAT.spam() << "glEnable(GL_NORMALIZE)\n"; - } - } - - } else { - // If there's a non-uniform scale, normalize everything. - glEnable(GL_NORMALIZE); - if (GLCAT.is_spam()) { - GLCAT.spam() << "glEnable(GL_NORMALIZE)\n"; - } - if (_supports_rescale_normal && support_rescale_normal) { - glDisable(GL_RESCALE_NORMAL); - if (GLCAT.is_spam()) { - GLCAT.spam() << "glDisable(GL_RESCALE_NORMAL)\n"; - } - } - } -#endif -} - //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_texture // Access: Protected, Virtual @@ -9503,12 +9350,12 @@ do_issue_texture() { if (_texture_binding_shader_context != 0) { _texture_binding_shader_context->disable_shader_texture_bindings(); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION update_standard_texture_bindings(); #endif } else { if (_texture_binding_shader_context == 0) { -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION disable_standard_texture_bindings(); #endif _current_shader_context->update_shader_texture_bindings(NULL); @@ -9523,7 +9370,7 @@ do_issue_texture() { #endif } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::update_standard_texture_bindings // Access: Private @@ -9767,9 +9614,32 @@ update_standard_texture_bindings() { report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::apply_white_texture +// Access: Private +// Description: Applies a white dummy texture. This is useful to +// bind to a texture slot when a texture is missing. +//////////////////////////////////////////////////////////////////// +void CLP(GraphicsStateGuardian):: +apply_white_texture() { + if (_white_texture != 0) { + glBindTexture(GL_TEXTURE_2D, _white_texture); + return; + } + glGenTextures(1, &_white_texture); + glBindTexture(GL_TEXTURE_2D, _white_texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + unsigned char data[] = {0xff, 0xff, 0xff, 0xff}; + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, + GL_RGBA, GL_UNSIGNED_BYTE, data); +} #ifndef NDEBUG //////////////////////////////////////////////////////////////////// @@ -9812,7 +9682,7 @@ update_show_usage_texture_bindings(int show_stage_index) { tc->enqueue_lru(&_prepared_objects->_graphics_memory_lru); } -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION // Disable all texture stages. for (i = 0; i < _num_active_texture_stages; i++) { _glActiveTexture(GL_TEXTURE0 + i); @@ -9848,7 +9718,7 @@ update_show_usage_texture_bindings(int show_stage_index) { // Choose the corresponding usage texture and apply it. _glActiveTexture(GL_TEXTURE0 + i); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION glEnable(GL_TEXTURE_2D); #endif @@ -9949,7 +9819,7 @@ upload_usage_texture(int width, int height) { } #endif // NDEBUG -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::disable_standard_texture_bindings // Access: Private @@ -9978,9 +9848,9 @@ disable_standard_texture_bindings() { report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_tex_matrix // Access: Protected @@ -10015,9 +9885,9 @@ do_issue_tex_matrix() { } report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_tex_gen // Access: Protected @@ -10300,7 +10170,7 @@ do_issue_tex_gen() { report_my_gl_errors(); } -#endif // !OPENGLES_2 +#endif // SUPPORT_FIXED_FUNCTION //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::specify_texture @@ -10396,7 +10266,7 @@ specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) { tex->get_format() == Texture::F_depth_component16 || tex->get_format() == Texture::F_depth_component24 || tex->get_format() == Texture::F_depth_component32) { -#ifndef OPENGLES +#ifdef SUPPORT_FIXED_FUNCTION glTexParameteri(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY); #endif if (_supports_shadow_filter) { @@ -10830,6 +10700,36 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } #endif +#if !defined(SUPPORT_FIXED_FUNCTION) && !defined(OPENGLES_2) + // Do we need to apply a swizzle mask to emulate these deprecated + // texture formats? + switch (tex->get_format()) { + case Texture::F_alpha: + glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_ONE); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, GL_ONE); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_ONE); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, GL_RED); + break; + + case Texture::F_luminance: + glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_RED); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, GL_RED); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, GL_ONE); + break; + + case Texture::F_luminance_alpha: + glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_RED); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, GL_RED); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, GL_GREEN); + break; + + default: + break; + } +#endif + // Allocate immutable storage for the texture, after which we can subload it. // Pre-allocating storage using glTexStorage is more efficient than using glTexImage // to load all of the individual images one by one later, but we are not allowed to @@ -10960,9 +10860,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { gtc->_width = width; gtc->_height = height; gtc->_depth = depth; - } - if (!image.is_null()) { gtc->update_data_size_bytes(get_texture_memory_size(tex)); } @@ -11207,7 +11105,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, #ifndef OPENGLES case GL_TEXTURE_BUFFER: if (_supports_buffer_texture) { - _glBufferSubData(GL_TEXTURE_BUFFER, 0, width, image_ptr); + _glBufferSubData(GL_TEXTURE_BUFFER, 0, view_size, image_ptr); } else { report_my_gl_errors(); return false; @@ -11286,12 +11184,12 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, GLCAT.warning() << "No mipmap level " << n << " defined for " << tex->get_name() << "\n"; - #ifndef OPENGLES +#ifndef OPENGLES if (is_at_least_gl_version(1, 2)) { // Tell the GL we have no more mipmaps for it to use. glTexParameteri(texture_target, GL_TEXTURE_MAX_LEVEL, n - mipmap_bias); } - #endif +#endif break; } @@ -11391,7 +11289,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, #ifndef OPENGLES case GL_TEXTURE_BUFFER: if (_supports_buffer_texture) { - _glBufferData(GL_TEXTURE_BUFFER, width, image_ptr, + _glBufferData(GL_TEXTURE_BUFFER, view_size, image_ptr, get_usage(tex->get_usage_hint())); } else { report_my_gl_errors(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index f9eaa36ccb..71339e4b23 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -57,6 +57,7 @@ typedef double GLdouble; // functions are defined, and the system gl.h sometimes doesn't // declare these typedefs. #if !defined( __EDG__ ) || defined( __INTEL_COMPILER ) // Protect the following from the Tau instrumentor and expose it for the intel compiler. +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); @@ -103,6 +104,7 @@ typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); @@ -130,19 +132,15 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXOESPROC) (GLuint matrixpaletteindex); -typedef void (APIENTRYP PFNGLLOADPALETTEFROMMODELVIEWMATRIXOESPROC) (void); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); #ifndef OPENGLES_1 // GLSL shader functions @@ -347,7 +345,7 @@ public: virtual bool framebuffer_copy_to_ram (Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION void apply_fog(Fog *fog); virtual void bind_light(PointLight *light_obj, const NodePath &light, @@ -358,8 +356,6 @@ public: int light_id); #endif - void print_gfx_visual(); - LVecBase4 get_light_color(Light *light) const; #ifdef SUPPORT_IMMEDIATE_MODE @@ -392,23 +388,25 @@ protected: void do_issue_rescale_normal(); void do_issue_color_write(); void do_issue_depth_test(); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION void do_issue_alpha_test(); #endif void do_issue_depth_write(); void do_issue_cull_face(); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION void do_issue_fog(); #endif void do_issue_depth_offset(); void do_issue_shade_model(); +#ifndef OPENGLES_1 void do_issue_shader(bool state_has_changed = false); -#ifndef OPENGLES_2 +#endif +#ifdef SUPPORT_FIXED_FUNCTION void do_issue_material(); #endif void do_issue_texture(); void do_issue_blending(); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION void do_issue_tex_gen(); void do_issue_tex_matrix(); #endif @@ -424,10 +422,11 @@ protected: static string get_error_string(GLenum error_code); string show_gl_string(const string &name, GLenum id); virtual void query_gl_version(); + void query_glsl_version(); void save_extensions(const char *extensions); virtual void get_extra_extensions(); void report_extensions() const; - INLINE virtual bool has_extension(const string &extension) const FINAL; + INLINE virtual bool has_extension(const string &extension) const; INLINE bool is_at_least_gl_version(int major_version, int minor_version) const; INLINE bool is_at_least_gles_version(int major_version, int minor_version) const; void *get_extension_func(const char *name); @@ -435,7 +434,7 @@ protected: virtual void reissue_transforms(); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION virtual void enable_lighting(bool enable); virtual void set_ambient_light(const LColor &color); virtual void enable_light(int light_id, bool enable); @@ -470,7 +469,7 @@ protected: INLINE void set_color_write_mask(int mask); INLINE void clear_color_write_mask(); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION INLINE void call_glFogfv(GLenum pname, const LColor &color); INLINE void call_glMaterialfv(GLenum face, GLenum pname, const LColor &color); INLINE void call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value); @@ -481,7 +480,7 @@ protected: INLINE void call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION INLINE GLenum get_light_id(int index) const; INLINE GLenum get_clip_plane_id(int index) const; #endif @@ -513,19 +512,20 @@ protected: static GLenum get_usage(Geom::UsageHint usage_hint); void unbind_buffers(); -#ifndef OPENGLES_2 +#ifdef SUPPORT_FIXED_FUNCTION void disable_standard_vertex_arrays(); bool update_standard_vertex_arrays(bool force); void disable_standard_texture_bindings(); void update_standard_texture_bindings(); #endif + void apply_white_texture(); + #ifndef NDEBUG void update_show_usage_texture_bindings(int show_stage_index); void upload_usage_texture(int width, int height); #endif // NDEBUG - void do_auto_rescale_normal(); bool specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler); bool apply_texture(TextureContext *tc); bool apply_sampler(GLuint unit, const SamplerState &sampler, TextureContext *tc); @@ -586,7 +586,6 @@ protected: RenderModeAttrib::Mode _render_mode; PN_stdfloat _point_size; bool _point_perspective; - bool _vertex_blending_enabled; bool _scissor_enabled; bool _scissor_attrib_active; epvector _scissor_array; @@ -598,8 +597,7 @@ protected: ShaderContext *_vertex_array_shader_context; PT(Shader) _texture_binding_shader; ShaderContext *_texture_binding_shader_context; -#endif -#ifdef OPENGLES_2 + static PT(Shader) _default_shader; #endif @@ -625,7 +623,6 @@ protected: DirectionalLights _dlights; int _pass_number; - bool _auto_rescale_normal; GLuint _geom_display_list; GLuint _current_vbuffer_index; GLuint _current_ibuffer_index; @@ -636,6 +633,7 @@ protected: GLint _max_image_units; bool _supports_multi_bind; bool _supports_get_program_binary; + bool _supports_uniform_buffers; #ifdef OPENGLES bool _supports_depth24; @@ -663,21 +661,8 @@ public: bool _explicit_primitive_restart; #endif - bool _supports_vertex_blend; - PFNGLWEIGHTPOINTERARBPROC _glWeightPointer; - PFNGLVERTEXBLENDARBPROC _glVertexBlend; - PFNGLWEIGHTFVARBPROC _glWeightfv; - PFNGLWEIGHTDVARBPROC _glWeightdv; - - bool _supports_matrix_palette; -#ifdef OPENGLES_1 - PFNGLCURRENTPALETTEMATRIXOESPROC _glCurrentPaletteMatrix; - PFNGLMATRIXINDEXPOINTEROESPROC _glMatrixIndexPointer; -#endif -#ifndef OPENGLES - PFNGLCURRENTPALETTEMATRIXARBPROC _glCurrentPaletteMatrix; - PFNGLMATRIXINDEXPOINTERARBPROC _glMatrixIndexPointer; - PFNGLMATRIXINDEXUIVARBPROC _glMatrixIndexuiv; +#if defined(SUPPORT_FIXED_FUNCTION) && !defined(OPENGLES) + PFNGLSECONDARYCOLORPOINTERPROC _glSecondaryColorPointer; #endif #ifndef OPENGLES @@ -713,14 +698,18 @@ public: PFNGLGETCOMPRESSEDTEXIMAGEPROC _glGetCompressedTexImage; bool _supports_bgr; - bool _supports_rescale_normal; bool _supports_packed_dabc; bool _supports_packed_ufloat; +#ifdef SUPPORT_FIXED_FUNCTION + bool _supports_rescale_normal; +#endif + PFNGLACTIVETEXTUREPROC _glActiveTexture; -#ifndef OPENGLES_2 - bool _supports_multitexture; +#ifdef SUPPORT_FIXED_FUNCTION PFNGLCLIENTACTIVETEXTUREPROC _glClientActiveTexture; +#endif +#ifdef SUPPORT_IMMEDIATE_MODE PFNGLMULTITEXCOORD1FPROC _glMultiTexCoord1f; PFNGLMULTITEXCOORD2FPROC _glMultiTexCoord2f; PFNGLMULTITEXCOORD3FPROC _glMultiTexCoord3f; @@ -741,6 +730,12 @@ public: PFNGLBLENDEQUATIONPROC _glBlendEquation; PFNGLBLENDCOLORPROC _glBlendColor; + bool _supports_vao; + GLuint _current_vao_index; + PFNGLBINDVERTEXARRAYPROC _glBindVertexArray; + PFNGLDELETEVERTEXARRAYSPROC _glDeleteVertexArrays; + PFNGLGENVERTEXARRAYSPROC _glGenVertexArrays; + bool _supports_framebuffer_object; PFNGLISRENDERBUFFEREXTPROC _glIsRenderbuffer; PFNGLBINDRENDERBUFFEREXTPROC _glBindRenderbuffer; @@ -845,6 +840,9 @@ public: PFNGLDRAWELEMENTSINSTANCEDPROC _glDrawElementsInstanced; #endif // !OPENGLES_1 #ifndef OPENGLES + PFNGLGETACTIVEUNIFORMSIVPROC _glGetActiveUniformsiv; + PFNGLGETACTIVEUNIFORMBLOCKIVPROC _glGetActiveUniformBlockiv; + PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC _glGetActiveUniformBlockName; PFNGLGENSAMPLERSPROC _glGenSamplers; PFNGLDELETESAMPLERSPROC _glDeleteSamplers; PFNGLBINDSAMPLERPROC _glBindSampler; @@ -906,6 +904,8 @@ public: bool _use_object_labels; PFNGLOBJECTLABELPROC _glObjectLabel; + GLuint _white_texture; + #ifndef NDEBUG bool _show_texture_usage; int _show_texture_usage_max_size; @@ -923,6 +923,8 @@ public: UsageTextures _usage_textures; #endif // NDEBUG + BufferResidencyTracker _renderbuffer_residency; + static PStatCollector _load_display_list_pcollector; static PStatCollector _primitive_batches_display_list_pcollector; static PStatCollector _vertices_display_list_pcollector; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index a6818f85de..2fd3c25577 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -179,6 +179,19 @@ parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, Shader *objSha if (!objShader->cp_parse_eol(p, pieces, next)) { return false; } + + // clip == apiclip in OpenGL, and the apiclip matrices are cached. + if (bind._part[0] == Shader::SMO_view_to_clip) { + bind._part[0] = Shader::SMO_view_to_apiclip; + } else if (bind._part[0] == Shader::SMO_clip_to_view) { + bind._part[0] = Shader::SMO_apiclip_to_view; + } + if (bind._part[1] == Shader::SMO_view_to_clip) { + bind._part[1] = Shader::SMO_view_to_apiclip; + } else if (bind._part[1] == Shader::SMO_clip_to_view) { + bind._part[1] = Shader::SMO_apiclip_to_view; + } + objShader->cp_optimize_mat_spec(bind); objShader->_mat_spec.push_back(bind); return true; @@ -198,802 +211,1041 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext _uses_standard_vertex_arrays = false; _has_divisor = false; _color_attrib_index = -1; + _transform_table_index = -1; + _slider_table_index = -1; + _validated = !gl_validate_shaders; nassertv(s->get_language() == Shader::SL_GLSL); - // We compile and analyze the shader here, instead of in shader.cxx, to avoid gobj getting a dependency on GL stuff. + // We compile and analyze the shader here, instead of in shader.cxx, + // to avoid gobj getting a dependency on GL stuff. if (!glsl_compile_and_link()) { release_resources(); s->_error_flag = true; return; } - _glgsg->_glUseProgram(_glsl_program); - // Analyze the uniforms and put them in _glsl_parameter_map - if (_glsl_parameter_map.size() == 0) { - int seqno = 0, texunitno = 0, imgunitno = 0; - string noprefix; - GLint param_count, param_maxlength, param_size; - GLenum param_type; - _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORMS, ¶m_count); - _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, ¶m_maxlength); - char* param_name_cstr = (char *)alloca(param_maxlength); + // Create a buffer the size of the longest uniform name. + GLint name_buflen = 0; + _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &name_buflen); + char* name_buffer = (char *)alloca(max(64, name_buflen)); - for (int i = 0; i < param_count; ++i) { - param_name_cstr[0] = 0; - _glgsg->_glGetActiveUniform(_glsl_program, i, param_maxlength, NULL, ¶m_size, ¶m_type, param_name_cstr); - string param_name(param_name_cstr); - GLint p = _glgsg->_glGetUniformLocation(_glsl_program, param_name_cstr); - - if (GLCAT.is_debug()) { - GLCAT.debug() - << "Active uniform " << param_name << " with size " << param_size - << " and type " << param_type << " is bound to location " << p << "\n"; - } - - if (p > -1) { - // Strip off [0] suffix that some drivers append to arrays. - size_t size = param_name.size(); - if (size > 3 && param_name.substr(size - 3, 3) == "[0]") { - param_name = param_name.substr(0, size - 3); - } - - Shader::ShaderArgId arg_id; - arg_id._name = param_name; - arg_id._seqno = seqno++; - _glsl_parameter_map.push_back(p); - - // Check for inputs with p3d_ prefix. - if (param_name.substr(0, 4) == "p3d_") { - noprefix = param_name.substr(4); - - // Check for matrix inputs. - bool transpose = false; - bool inverse = false; - string matrix_name (noprefix); - - // Check for and chop off any "Transpose" or "Inverse" suffix. - if (size > 15 && matrix_name.compare(size - 9, 9, "Transpose") == 0) { - transpose = true; - matrix_name = matrix_name.substr(0, size - 9); - } - size = matrix_name.size(); - if (size > 13 && matrix_name.compare(size - 7, 7, "Inverse") == 0) { - inverse = true; - matrix_name = matrix_name.substr(0, size - 7); - } - size = matrix_name.size(); - - // Now if the suffix that is left over is "Matrix", - // we know that it is supposed to be a matrix input. - if (size > 6 && matrix_name.compare(size - 6, 6, "Matrix") == 0) { - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._func = Shader::SMF_compose; - if (transpose) { - bind._piece = Shader::SMP_transpose; - } else { - bind._piece = Shader::SMP_whole; - } - bind._arg[0] = NULL; - bind._arg[1] = NULL; - bind._dep[0] = Shader::SSD_general | Shader::SSD_transform; - bind._dep[1] = Shader::SSD_general | Shader::SSD_transform; - - if (matrix_name == "ModelViewProjectionMatrix") { - if (inverse) { - bind._part[0] = Shader::SMO_apiclip_to_view; - bind._part[1] = Shader::SMO_view_to_model; - } else { - bind._part[0] = Shader::SMO_model_to_view; - bind._part[1] = Shader::SMO_view_to_apiclip; - } - - } else if (matrix_name == "ModelViewMatrix") { - if (inverse) { - bind._part[0] = Shader::SMO_apiview_to_view; - bind._part[1] = Shader::SMO_view_to_model; - } else { - bind._part[0] = Shader::SMO_model_to_view; - bind._part[1] = Shader::SMO_view_to_apiview; - } - - } else if (matrix_name == "ProjectionMatrix") { - if (inverse) { - bind._part[0] = Shader::SMO_apiclip_to_view; - bind._part[1] = Shader::SMO_view_to_apiview; - } else { - bind._part[0] = Shader::SMO_apiview_to_view; - bind._part[1] = Shader::SMO_view_to_apiclip; - } - - } else if (matrix_name == "NormalMatrix") { - // This is really the upper 3x3 of the ModelViewMatrixInverseTranspose. - if (inverse) { - bind._part[0] = Shader::SMO_model_to_view; - bind._part[1] = Shader::SMO_view_to_apiview; - } else { - bind._part[0] = Shader::SMO_apiview_to_view; - bind._part[1] = Shader::SMO_view_to_model; - } - - if (param_type != GL_FLOAT_MAT3) { - GLCAT.error() << "p3d_NormalMatrix input should be mat3, not mat4!\n"; - } else { - if (transpose) { - bind._piece = Shader::SMP_upper3x3; - } else { - bind._piece = Shader::SMP_transpose3x3; - } - } - - } else if (matrix_name == "ModelMatrix") { - if (inverse) { - bind._part[0] = Shader::SMO_world_to_view; - bind._part[1] = Shader::SMO_view_to_model; - } else { - bind._part[0] = Shader::SMO_model_to_view; - bind._part[1] = Shader::SMO_view_to_world; - } - - } else if (matrix_name == "ViewMatrix") { - if (inverse) { - bind._part[0] = Shader::SMO_apiview_to_view; - bind._part[1] = Shader::SMO_view_to_world; - } else { - bind._part[0] = Shader::SMO_world_to_view; - bind._part[1] = Shader::SMO_view_to_apiview; - } - - } else if (matrix_name == "ViewProjectionMatrix") { - if (inverse) { - bind._part[0] = Shader::SMO_apiclip_to_view; - bind._part[1] = Shader::SMO_view_to_world; - } else { - bind._part[0] = Shader::SMO_world_to_view; - bind._part[1] = Shader::SMO_view_to_apiclip; - } - - } else { - GLCAT.error() << "Unrecognized uniform matrix name '" << matrix_name << "'!\n"; - continue; - } - s->_mat_spec.push_back(bind); - continue; - } - if (size > 7 && noprefix.substr(0, 7) == "Texture") { - Shader::ShaderTexSpec bind; - bind._id = arg_id; - bind._name = 0; - - string tail; - bind._stage = string_to_int(noprefix.substr(7), tail); - if (!tail.empty()) { - GLCAT.error() - << "Error parsing shader input name: unexpected '" - << tail << "' in '" << param_name << "'\n"; - continue; - } - - if (get_sampler_texture_type(bind._desired_type, param_type)) { - _glgsg->_glUniform1i(p, s->_tex_spec.size()); - s->_tex_spec.push_back(bind); - } else { - GLCAT.error() - << "Could not bind texture input " << param_name << "\n"; - } - continue; - } - if (size > 9 && noprefix.substr(0, 9) == "Material.") { - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_attr_material; - bind._arg[0] = NULL; - bind._dep[0] = Shader::SSD_general | Shader::SSD_material; - bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; - bind._dep[1] = Shader::SSD_NONE; - - if (noprefix == "Material.ambient") { - if (param_type != GL_FLOAT_VEC4) { - GLCAT.error() - << "p3d_Material.ambient should be vec4\n"; - } - bind._piece = Shader::SMP_row0; - s->_mat_spec.push_back(bind); - continue; - - } else if (noprefix == "Material.diffuse") { - if (param_type != GL_FLOAT_VEC4) { - GLCAT.error() - << "p3d_Material.diffuse should be vec4\n"; - } - bind._piece = Shader::SMP_row1; - s->_mat_spec.push_back(bind); - continue; - - } else if (noprefix == "Material.emission") { - if (param_type != GL_FLOAT_VEC4) { - GLCAT.error() - << "p3d_Material.emission should be vec4\n"; - } - bind._piece = Shader::SMP_row2; - s->_mat_spec.push_back(bind); - continue; - - } else if (noprefix == "Material.specular") { - if (param_type != GL_FLOAT_VEC3) { - GLCAT.error() - << "p3d_Material.specular should be vec3\n"; - } - bind._piece = Shader::SMP_row3x3; - s->_mat_spec.push_back(bind); - continue; - - } else if (noprefix == "Material.shininess") { - if (param_type != GL_FLOAT) { - GLCAT.error() - << "p3d_Material.shininess should be float\n"; - } - bind._piece = Shader::SMP_cell15; - s->_mat_spec.push_back(bind); - continue; - } - } - if (noprefix == "ColorScale") { - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_attr_colorscale; - bind._arg[0] = NULL; - bind._dep[0] = Shader::SSD_general | Shader::SSD_colorscale; - bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; - bind._dep[1] = Shader::SSD_NONE; - - if (param_type == GL_FLOAT_VEC3) { - bind._piece = Shader::SMP_row3x3; - } else if (param_type == GL_FLOAT_VEC4) { - bind._piece = Shader::SMP_row3; - } else { - GLCAT.error() - << "p3d_ColorScale should be vec3 or vec4\n"; - continue; - } - s->_mat_spec.push_back(bind); - continue; - } - if (noprefix == "Color") { - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_attr_color; - bind._arg[0] = NULL; - bind._dep[0] = Shader::SSD_general | Shader::SSD_color; - bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; - bind._dep[1] = Shader::SSD_NONE; - - if (param_type == GL_FLOAT_VEC3) { - bind._piece = Shader::SMP_row3x3; - } else if (param_type == GL_FLOAT_VEC4) { - bind._piece = Shader::SMP_row3; - } else { - GLCAT.error() - << "p3d_Color should be vec3 or vec4\n"; - continue; - } - s->_mat_spec.push_back(bind); - continue; - } - if (noprefix == "ClipPlane") { - if (param_type != GL_FLOAT_VEC4) { - GLCAT.error() - << "p3d_ClipPlane should be vec4 or vec4[]\n"; - continue; - } - for (int i = 0; i < param_size; ++i) { - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._id._seqno = seqno++; - bind._piece = Shader::SMP_row3; - bind._func = Shader::SMF_first; - bind._index = i; - bind._part[0] = Shader::SMO_apiview_clipplane_i; - bind._arg[0] = NULL; - bind._dep[0] = Shader::SSD_general | Shader::SSD_clip_planes; - bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; - bind._dep[1] = Shader::SSD_NONE; - s->_mat_spec.push_back(bind); - _glsl_parameter_map.push_back(p + i); - } - continue; - } - if (noprefix == "LightModel.ambient") { - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_light_ambient; - bind._arg[0] = NULL; - bind._dep[0] = Shader::SSD_general | Shader::SSD_light; - bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; - bind._dep[1] = Shader::SSD_NONE; - - if (param_type == GL_FLOAT_VEC3) { - bind._piece = Shader::SMP_row3x3; - } else if (param_type == GL_FLOAT_VEC4) { - bind._piece = Shader::SMP_row3; - } else { - GLCAT.error() - << "p3d_LightModel.ambient should be vec3 or vec4\n"; - continue; - } - s->_mat_spec.push_back(bind); - continue; - } - GLCAT.error() << "Unrecognized uniform name '" << param_name_cstr << "'!\n"; - continue; - - } else if (param_name.substr(0, 4) == "osg_") { - // These inputs are supported by OpenSceneGraph. We can support - // them as well, to increase compatibility. - // Other inputs we may support in the future: - // int osg_FrameNumber - - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._arg[0] = NULL; - bind._arg[1] = NULL; - - if (param_name == "osg_ViewMatrix") { - bind._piece = Shader::SMP_whole; - bind._func = Shader::SMF_compose; - bind._part[0] = Shader::SMO_world_to_view; - bind._part[1] = Shader::SMO_view_to_apiview; - bind._dep[0] = Shader::SSD_general | Shader::SSD_transform; - bind._dep[1] = Shader::SSD_general | Shader::SSD_transform; - s->_mat_spec.push_back(bind); - continue; - - } else if (param_name == "osg_InverseViewMatrix") { - bind._piece = Shader::SMP_whole; - bind._func = Shader::SMF_compose; - bind._part[0] = Shader::SMO_apiview_to_view; - bind._part[1] = Shader::SMO_view_to_world; - bind._dep[0] = Shader::SSD_general | Shader::SSD_transform; - bind._dep[1] = Shader::SSD_general | Shader::SSD_transform; - s->_mat_spec.push_back(bind); - continue; - - } else if (param_name == "osg_FrameTime") { - bind._piece = Shader::SMP_row3x1; - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_frame_time; - bind._part[1] = Shader::SMO_identity; - bind._dep[0] = Shader::SSD_general; - bind._dep[1] = Shader::SSD_NONE; - s->_mat_spec.push_back(bind); - continue; - - } else if (param_name == "osg_DeltaFrameTime") { - bind._piece = Shader::SMP_row3x1; - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_frame_delta; - bind._part[1] = Shader::SMO_identity; - bind._dep[0] = Shader::SSD_general; - bind._dep[1] = Shader::SSD_NONE; - s->_mat_spec.push_back(bind); - continue; - } - } - - //Tries to parse shorthand notations like mspos_XXX and trans_model_to_clip_of_XXX - if (parse_and_set_short_hand_shader_vars(arg_id, s)) { - continue; - } - - if (param_size == 1) { - switch (param_type) { #ifndef OPENGLES - case GL_INT_SAMPLER_1D: - case GL_INT_SAMPLER_2D: - case GL_INT_SAMPLER_3D: - case GL_INT_SAMPLER_2D_ARRAY: - case GL_INT_SAMPLER_CUBE: - case GL_INT_SAMPLER_BUFFER: - case GL_UNSIGNED_INT_SAMPLER_1D: - case GL_UNSIGNED_INT_SAMPLER_2D: - case GL_UNSIGNED_INT_SAMPLER_3D: - case GL_UNSIGNED_INT_SAMPLER_CUBE: - case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: - case GL_UNSIGNED_INT_SAMPLER_BUFFER: - case GL_SAMPLER_1D_SHADOW: - case GL_SAMPLER_1D: - case GL_SAMPLER_CUBE_SHADOW: - case GL_SAMPLER_2D_ARRAY: - case GL_SAMPLER_2D_ARRAY_SHADOW: - case GL_SAMPLER_BUFFER: -#endif // !OPENGLES - case GL_SAMPLER_2D: - case GL_SAMPLER_2D_SHADOW: - case GL_SAMPLER_3D: - case GL_SAMPLER_CUBE: { - Shader::ShaderTexSpec bind; - bind._id = arg_id; - bind._name = InternalName::make(param_name); - bind._desired_type = Texture::TT_2d_texture; - bind._stage = texunitno++; - if (get_sampler_texture_type(bind._desired_type, param_type)) { - _glgsg->_glUniform1i(p, s->_tex_spec.size()); - s->_tex_spec.push_back(bind); - } - continue; - } - case GL_FLOAT_MAT2: -#ifndef OPENGLES - case GL_FLOAT_MAT2x3: - case GL_FLOAT_MAT2x4: - case GL_FLOAT_MAT3x2: - case GL_FLOAT_MAT3x4: - case GL_FLOAT_MAT4x2: - case GL_FLOAT_MAT4x3: -#endif - GLCAT.warning() << "GLSL shader requested an unsupported matrix type\n"; - continue; - case GL_FLOAT_MAT3: { - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._piece = Shader::SMP_upper3x3; - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_mat_constant_x; - bind._arg[0] = InternalName::make(param_name); - bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; - bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; - bind._dep[1] = Shader::SSD_NONE; - s->_mat_spec.push_back(bind); - continue; - } - case GL_FLOAT_MAT4: { - Shader::ShaderMatSpec bind; - bind._id = arg_id; - bind._piece = Shader::SMP_whole; - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_mat_constant_x; - bind._arg[0] = InternalName::make(param_name); - bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; - bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; - bind._dep[1] = Shader::SSD_NONE; - s->_mat_spec.push_back(bind); - continue; - } - case GL_FLOAT: - case GL_FLOAT_VEC2: - case GL_FLOAT_VEC3: - case GL_FLOAT_VEC4: { - PT(InternalName) iname = InternalName::make(param_name); - if (iname->get_parent() != InternalName::get_root()) { - // It might be something like an attribute of a shader - // input, like a light parameter. It might also just be - // a custom struct parameter. We can't know yet, sadly. - Shader::ShaderMatSpec bind; - bind._id = arg_id; - switch (param_type) { - case GL_FLOAT: - bind._piece = Shader::SMP_row3x1; - break; - case GL_FLOAT_VEC2: - bind._piece = Shader::SMP_row3x2; - break; - case GL_FLOAT_VEC3: - bind._piece = Shader::SMP_row3x3; - break; - default: - bind._piece = Shader::SMP_row3; - } - bind._func = Shader::SMF_first; - bind._part[0] = Shader::SMO_vec_constant_x_attrib; - bind._arg[0] = iname; - bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; - bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; - bind._dep[1] = Shader::SSD_NONE; - s->_mat_spec.push_back(bind); - continue; - } // else fall through - } - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - case GL_INT: - case GL_INT_VEC2: - case GL_INT_VEC3: - case GL_INT_VEC4: { - Shader::ShaderPtrSpec bind; - bind._id = arg_id; - switch (param_type) { - case GL_BOOL: - case GL_INT: - case GL_FLOAT: bind._dim[1] = 1; break; - case GL_BOOL_VEC2: - case GL_INT_VEC2: - case GL_FLOAT_VEC2: bind._dim[1] = 2; break; - case GL_BOOL_VEC3: - case GL_INT_VEC3: - case GL_FLOAT_VEC3: bind._dim[1] = 3; break; - case GL_BOOL_VEC4: - case GL_INT_VEC4: - case GL_FLOAT_VEC4: bind._dim[1] = 4; break; - case GL_FLOAT_MAT3: bind._dim[1] = 9; break; - case GL_FLOAT_MAT4: bind._dim[1] = 16; break; - } - switch (param_type) { - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - case GL_INT: - case GL_INT_VEC2: - case GL_INT_VEC3: - case GL_INT_VEC4: - bind._type = Shader::SPT_int; - break; - case GL_FLOAT: - case GL_FLOAT_VEC2: - case GL_FLOAT_VEC3: - case GL_FLOAT_VEC4: - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT4: - bind._type = Shader::SPT_float; - break; - } - bind._arg = InternalName::make(param_name); - bind._dim[0] = 1; - bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; - bind._dep[1] = Shader::SSD_NONE; - s->_ptr_spec.push_back(bind); - continue; - } -#ifndef OPENGLES - case GL_IMAGE_1D_EXT: - case GL_IMAGE_2D_EXT: - case GL_IMAGE_3D_EXT: - case GL_IMAGE_CUBE_EXT: - case GL_IMAGE_2D_ARRAY_EXT: - case GL_IMAGE_BUFFER_EXT: - case GL_INT_IMAGE_1D_EXT: - case GL_INT_IMAGE_2D_EXT: - case GL_INT_IMAGE_3D_EXT: - case GL_INT_IMAGE_CUBE_EXT: - case GL_INT_IMAGE_2D_ARRAY_EXT: - case GL_INT_IMAGE_BUFFER_EXT: - case GL_UNSIGNED_INT_IMAGE_1D_EXT: - case GL_UNSIGNED_INT_IMAGE_2D_EXT: - case GL_UNSIGNED_INT_IMAGE_3D_EXT: - case GL_UNSIGNED_INT_IMAGE_CUBE_EXT: - case GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT: - case GL_UNSIGNED_INT_IMAGE_BUFFER_EXT: - // This won't really change at runtime, so we might as well - // bind once and then forget about it. - _glgsg->_glUniform1i(p, imgunitno++); - _glsl_img_inputs.push_back(InternalName::make(param_name)); - _glsl_img_textures.push_back(NULL); - continue; -#endif - default: - GLCAT.warning() << "Ignoring unrecognized GLSL parameter type!\n"; - } - } else { - switch (param_type) { - case GL_FLOAT_MAT2: -#ifndef OPENGLES - case GL_FLOAT_MAT2x3: - case GL_FLOAT_MAT2x4: - case GL_FLOAT_MAT3x2: - case GL_FLOAT_MAT3x4: - case GL_FLOAT_MAT4x2: - case GL_FLOAT_MAT4x3: -#endif - GLCAT.warning() << "GLSL shader requested an unrecognized matrix array type\n"; - continue; - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - case GL_INT: - case GL_INT_VEC2: - case GL_INT_VEC3: - case GL_INT_VEC4: - case GL_FLOAT: - case GL_FLOAT_VEC2: - case GL_FLOAT_VEC3: - case GL_FLOAT_VEC4: - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT4: { - Shader::ShaderPtrSpec bind; - bind._id = arg_id; - switch (param_type) { - case GL_BOOL: - case GL_INT: - case GL_FLOAT: bind._dim[1] = 1; break; - case GL_BOOL_VEC2: - case GL_INT_VEC2: - case GL_FLOAT_VEC2: bind._dim[1] = 2; break; - case GL_BOOL_VEC3: - case GL_INT_VEC3: - case GL_FLOAT_VEC3: bind._dim[1] = 3; break; - case GL_BOOL_VEC4: - case GL_INT_VEC4: - case GL_FLOAT_VEC4: bind._dim[1] = 4; break; - case GL_FLOAT_MAT3: bind._dim[1] = 9; break; - case GL_FLOAT_MAT4: bind._dim[1] = 16; break; - } - switch (param_type) { - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - case GL_INT: - case GL_INT_VEC2: - case GL_INT_VEC3: - case GL_INT_VEC4: - bind._type = Shader::SPT_int; - break; - case GL_FLOAT: - case GL_FLOAT_VEC2: - case GL_FLOAT_VEC3: - case GL_FLOAT_VEC4: - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT4: - bind._type = Shader::SPT_float; - break; - } - bind._arg = InternalName::make(param_name); - bind._dim[0] = param_size; - bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; - bind._dep[1] = Shader::SSD_NONE; - s->_ptr_spec.push_back(bind); - continue; - } - default: - GLCAT.warning() << "Ignoring unrecognized GLSL parameter array type!\n"; - } - } - } - } + // Get the used uniform blocks. + if (_glgsg->_supports_uniform_buffers) { + GLint block_count, block_maxlength; + _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORM_BLOCKS, &block_count); + _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &block_maxlength); + char *block_name_cstr = (char *)alloca(max(64, block_maxlength)); - // Now we've processed the uniforms, we'll process the attribs. - _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_ATTRIBUTES, ¶m_count); - _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, ¶m_maxlength); - param_name_cstr = (char *)alloca(param_maxlength); + for (int i = 0; i < block_count; ++i) { + block_name_cstr[0] = 0; + _glgsg->_glGetActiveUniformBlockName(_glsl_program, i, block_maxlength, NULL, block_name_cstr); - for (int i = 0; i < param_count; ++i) { - param_name_cstr[0] = 0; - _glgsg->_glGetActiveAttrib(_glsl_program, i, param_maxlength, NULL, ¶m_size, ¶m_type, param_name_cstr); - string param_name(param_name_cstr); - - // Get the attrib location. - GLint p = _glgsg->_glGetAttribLocation(_glsl_program, param_name_cstr); - - GLCAT.debug() << - "Active attribute " << param_name << " is bound to location " << p << "\n"; - - if (p == -1) { - // A gl_ attribute such as gl_Vertex requires us to pass the - // standard vertex arrays as we would do without shader. - // This is not always the case, though -- see below. - _uses_standard_vertex_arrays = true; - continue; - } - - Shader::ShaderArgId arg_id; - arg_id._name = param_name; - arg_id._seqno = seqno++; - _glsl_parameter_map.push_back(p); - - Shader::ShaderVarSpec bind; - bind._id = arg_id; - bind._name = NULL; - bind._append_uv = -1; - bind._elements = 1; - - if (param_name.substr(0, 3) == "gl_") { - // Not all drivers return -1 in glGetAttribLocation - // for gl_ prefixed attributes. - _uses_standard_vertex_arrays = true; - continue; - } else if (param_name.substr(0, 4) == "p3d_") { - noprefix = param_name.substr(4); - } else { - noprefix = ""; - } - - bind._integer = (param_type == GL_BOOL || - param_type == GL_BOOL_VEC2 || - param_type == GL_BOOL_VEC3 || - param_type == GL_BOOL_VEC4 || - param_type == GL_INT || - param_type == GL_INT_VEC2 || - param_type == GL_INT_VEC3 || - param_type == GL_INT_VEC4 || -#ifndef OPENGLES - param_type == GL_UNSIGNED_INT_VEC2 || - param_type == GL_UNSIGNED_INT_VEC3 || - param_type == GL_UNSIGNED_INT_VEC4 || -#endif - param_type == GL_UNSIGNED_INT); - - if (noprefix.empty()) { - // Arbitrarily named attribute. - bind._name = InternalName::make(param_name); - - } else if (noprefix == "Vertex") { - bind._name = InternalName::get_vertex(); - - } else if (noprefix == "Normal") { - bind._name = InternalName::get_normal(); - - } else if (noprefix == "Color") { - bind._name = InternalName::get_color(); - - // Save the index, so we can apply special handling to this attrib. - _color_attrib_index = p; - - } else if (noprefix.substr(0, 7) == "Tangent") { - bind._name = InternalName::get_tangent(); - if (noprefix.size() > 7) { - bind._append_uv = atoi(noprefix.substr(7).c_str()); - } - - } else if (noprefix.substr(0, 8) == "Binormal") { - bind._name = InternalName::get_binormal(); - if (noprefix.size() > 8) { - bind._append_uv = atoi(noprefix.substr(8).c_str()); - } - - } else if (noprefix.substr(0, 13) == "MultiTexCoord") { - bind._name = InternalName::get_texcoord(); - bind._append_uv = atoi(noprefix.substr(13).c_str()); - - } else { - GLCAT.error() << "Unrecognized vertex attrib '" << param_name << "'!\n"; - continue; - } - - // Get the number of bind points. - switch (param_type) { - case GL_FLOAT_MAT3: -#ifndef OPENGLES - case GL_DOUBLE_MAT3: -#endif - bind._elements = 3 * param_size; - break; - - case GL_FLOAT_MAT4: -#ifndef OPENGLES - case GL_DOUBLE_MAT4: -#endif - bind._elements = 4 * param_size; - break; - - default: - bind._elements = param_size; - break; - } - - s->_var_spec.push_back(bind); + reflect_uniform_block(i, block_name_cstr, name_buffer, name_buflen); } } - _glgsg->_glUseProgram(0); +#endif // !OPENGLES + // Bind the program, so that we can call glUniform1i for the textures. + _glgsg->_glUseProgram(_glsl_program); + + // Analyze the uniforms. + GLint param_count = 0; + _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORMS, ¶m_count); + + _shader->_ptr_spec.clear(); + _shader->_mat_spec.clear(); + _shader->_tex_spec.clear(); + for (int i = 0; i < param_count; ++i) { + reflect_uniform(i, name_buffer, name_buflen); + } + + // Now we've processed the uniforms, we'll process the attribs. + _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_ATTRIBUTES, ¶m_count); + _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &name_buflen); + name_buffer = (char *)alloca(max(64, name_buflen)); + + _shader->_var_spec.clear(); + for (int i = 0; i < param_count; ++i) { + reflect_attribute(i, name_buffer, name_buflen); + } + + _glgsg->_glUseProgram(0); _glgsg->report_my_gl_errors(); } +//////////////////////////////////////////////////////////////////// +// Function: GLShaderContext::reflect_attribute +// Access: Public +// Description: Analyzes the vertex attribute and stores the +// information it needs to remember. +//////////////////////////////////////////////////////////////////// +void CLP(ShaderContext):: +reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { + GLint param_size; + GLenum param_type; + + // Get the name, size, and type of this attribute. + name_buffer[0] = 0; + _glgsg->_glGetActiveAttrib(_glsl_program, i, name_buflen, NULL, + ¶m_size, ¶m_type, name_buffer); + + // Get the attrib location. + GLint p = _glgsg->_glGetAttribLocation(_glsl_program, name_buffer); + + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Active attribute " << name_buffer << " with size " << param_size + << " and type 0x" << hex << param_type << dec + << " is bound to location " << p << "\n"; + } + + if (p == -1 || strncmp(name_buffer, "gl_", 3) == 0) { + // A gl_ attribute such as gl_Vertex requires us to pass the standard + // vertex arrays as we would do without shader. Not all drivers return + // -1 in glGetAttribLocation for gl_ prefixed attributes, so we check the + // prefix of the input ourselves, just to be sure. + _uses_standard_vertex_arrays = true; + return; + } + + Shader::ShaderArgId arg_id; + arg_id._name = name_buffer; + arg_id._seqno = p; + + Shader::ShaderVarSpec bind; + bind._id = arg_id; + bind._name = NULL; + bind._append_uv = -1; + bind._elements = 1; + + // Check if this is an integer input- if so, we have to bind it differently. + bind._integer = (param_type == GL_BOOL || + param_type == GL_BOOL_VEC2 || + param_type == GL_BOOL_VEC3 || + param_type == GL_BOOL_VEC4 || + param_type == GL_INT || + param_type == GL_INT_VEC2 || + param_type == GL_INT_VEC3 || + param_type == GL_INT_VEC4 || +#ifndef OPENGLES + param_type == GL_UNSIGNED_INT_VEC2 || + param_type == GL_UNSIGNED_INT_VEC3 || + param_type == GL_UNSIGNED_INT_VEC4 || +#endif + param_type == GL_UNSIGNED_INT); + + // Check if it has a p3d_ prefix - if so, assign special meaning. + if (strncmp(name_buffer, "p3d_", 4) == 0) { + string noprefix(name_buffer + 4); + + if (noprefix == "Vertex") { + bind._name = InternalName::get_vertex(); + + } else if (noprefix == "Normal") { + bind._name = InternalName::get_normal(); + + } else if (noprefix == "Color") { + bind._name = InternalName::get_color(); + + // Save the index, so we can apply special handling to this attrib. + _color_attrib_index = p; + + } else if (noprefix.substr(0, 7) == "Tangent") { + bind._name = InternalName::get_tangent(); + if (noprefix.size() > 7) { + bind._append_uv = atoi(noprefix.substr(7).c_str()); + } + + } else if (noprefix.substr(0, 8) == "Binormal") { + bind._name = InternalName::get_binormal(); + if (noprefix.size() > 8) { + bind._append_uv = atoi(noprefix.substr(8).c_str()); + } + + } else if (noprefix.substr(0, 13) == "MultiTexCoord") { + bind._name = InternalName::get_texcoord(); + bind._append_uv = atoi(noprefix.substr(13).c_str()); + + } else { + GLCAT.error() << "Unrecognized vertex attrib '" << name_buffer << "'!\n"; + return; + } + } else { + // Arbitrarily named attribute. + bind._name = InternalName::make(name_buffer); + } + + // Get the number of bind points for arrays and matrices. + switch (param_type) { + case GL_FLOAT_MAT3: +#ifndef OPENGLES + case GL_DOUBLE_MAT3: +#endif + bind._elements = 3 * param_size; + break; + + case GL_FLOAT_MAT4: +#ifndef OPENGLES + case GL_DOUBLE_MAT4: +#endif + bind._elements = 4 * param_size; + break; + + default: + bind._elements = param_size; + break; + } + + _shader->_var_spec.push_back(bind); +} + +#ifndef OPENGLES +//////////////////////////////////////////////////////////////////// +// Function: GLShaderContext::reflect_uniform_block +// Access: Public +// Description: Analyzes the uniform block and stores its format. +//////////////////////////////////////////////////////////////////// +void CLP(ShaderContext):: +reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_buflen) { + //GLint offset = 0; + + GLint data_size = 0; + GLint param_count = 0; + GLsizei param_size; + _glgsg->_glGetActiveUniformBlockiv(_glsl_program, i, GL_UNIFORM_BLOCK_DATA_SIZE, &data_size); + _glgsg->_glGetActiveUniformBlockiv(_glsl_program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, ¶m_count); + + if (param_count <= 0) { + return; + } + + // We use a GeomVertexArrayFormat to describe the uniform buffer layout. + //GeomVertexArrayFormat block_format; + //block_format.set_pad_to(data_size); + + // Get an array containing the indices of all the uniforms in this block. + GLuint *indices = (GLuint *)alloca(param_count * sizeof(GLint)); + _glgsg->_glGetActiveUniformBlockiv(_glsl_program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, (GLint *)indices); + + // Acquire information about the way the uniforms in this block are packed. + GLint *offsets = (GLint *)alloca(param_count * sizeof(GLint)); + GLint *mstrides = (GLint *)alloca(param_count * sizeof(GLint)); + GLint *astrides = (GLint *)alloca(param_count * sizeof(GLint)); + _glgsg->_glGetActiveUniformsiv(_glsl_program, param_count, indices, GL_UNIFORM_OFFSET, offsets); + _glgsg->_glGetActiveUniformsiv(_glsl_program, param_count, indices, GL_UNIFORM_MATRIX_STRIDE, mstrides); + _glgsg->_glGetActiveUniformsiv(_glsl_program, param_count, indices, GL_UNIFORM_ARRAY_STRIDE, astrides); + + for (int ui = 0; ui < param_count; ++ui) { + name_buffer[0] = 0; + GLint param_size; + GLenum param_type; + _glgsg->_glGetActiveUniform(_glsl_program, indices[ui], name_buflen, NULL, ¶m_size, ¶m_type, name_buffer); + + // Strip off [0] suffix that some drivers append to arrays. + size_t size = strlen(name_buffer); + if (size > 3 && strncmp(name_buffer + (size - 3), "[0]", 3) == 0) { + name_buffer[size - 3] = 0; + } + + GeomEnums::NumericType numeric_type; + GeomEnums::Contents contents = GeomEnums::C_other; + int num_components = 1; + + switch (param_type) { + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + numeric_type = GeomEnums::NT_int32; + break; + + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + numeric_type = GeomEnums::NT_uint32; + break; + + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + numeric_type = GeomEnums::NT_float32; + break; + + case GL_DOUBLE: + case GL_DOUBLE_VEC2: + case GL_DOUBLE_VEC3: + case GL_DOUBLE_VEC4: + case GL_DOUBLE_MAT2: + case GL_DOUBLE_MAT3: + case GL_DOUBLE_MAT4: + numeric_type = GeomEnums::NT_float64; + break; + + default: + GLCAT.warning() << "Ignoring uniform '" << name_buffer + << "' with unsupported type 0x" << hex << param_type << dec << "\n"; + continue; + } + + switch (param_type) { + case GL_INT_VEC2: + case GL_BOOL_VEC2: + case GL_UNSIGNED_INT_VEC2: + case GL_FLOAT_VEC2: + case GL_DOUBLE_VEC2: + num_components = 2; + break; + + case GL_INT_VEC3: + case GL_BOOL_VEC3: + case GL_UNSIGNED_INT_VEC3: + case GL_FLOAT_VEC3: + case GL_DOUBLE_VEC3: + num_components = 3; + break; + + case GL_INT_VEC4: + case GL_BOOL_VEC4: + case GL_UNSIGNED_INT_VEC4: + case GL_FLOAT_VEC4: + case GL_DOUBLE_VEC4: + num_components = 4; + break; + + case GL_FLOAT_MAT3: + case GL_DOUBLE_MAT3: + num_components = 3; + contents = GeomEnums::C_matrix; + nassertd(param_size <= 1 || astrides[ui] == mstrides[ui] * 3) continue; + param_size *= 3; + break; + + case GL_FLOAT_MAT4: + case GL_DOUBLE_MAT4: + num_components = 4; + contents = GeomEnums::C_matrix; + nassertd(param_size <= 1 || astrides[ui] == mstrides[ui] * 4) continue; + param_size *= 4; + break; + } + + //GeomVertexColumn column(InternalName::make(name_buffer), + // num_components, numeric_type, contents, + // offsets[ui], 4, param_size, astrides[ui]); + //block_format.add_column(column); + } + + //if (GLCAT.is_debug()) { + // GLCAT.debug() << "Active uniform block " << name << " has format:\n"; + // block_format.write(GLCAT.debug(false), 2); + //} + + //UniformBlock block; + //block._name = InternalName::make(name); + //block._format = GeomVertexArrayFormat::register_format(&block_format); + //block._buffer = 0; + + //_uniform_blocks.push_back(block); +} +#endif // !OPENGLES + +//////////////////////////////////////////////////////////////////// +// Function: GLShaderContext::reflect_uniform +// Access: Public +// Description: Analyzes a single uniform variable and considers +// how it should be handled and bound. +//////////////////////////////////////////////////////////////////// +void CLP(ShaderContext):: +reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { + GLint param_size; + GLenum param_type; + + // Get the name, location, type and size of this uniform. + name_buffer[0] = 0; + _glgsg->_glGetActiveUniform(_glsl_program, i, name_buflen, NULL, ¶m_size, ¶m_type, name_buffer); + GLint p = _glgsg->_glGetUniformLocation(_glsl_program, name_buffer); + + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Active uniform " << name_buffer << " with size " << param_size + << " and type 0x" << hex << param_type << dec + << " is bound to location " << p << "\n"; + } + + if (p < 0) { + // Special meaning, or it's in a uniform block. Let it go. + return; + } + + // Strip off [0] suffix that some drivers append to arrays. + size_t size = strlen(name_buffer); + if (size > 3 && strncmp(name_buffer + (size - 3), "[0]", 3) == 0) { + size -= 3; + name_buffer[size] = 0; + } + + string param_name(name_buffer); + + Shader::ShaderArgId arg_id; + arg_id._name = param_name; + arg_id._seqno = p; + + // Check if it has a p3d_ prefix - if so, assign special meaning. + if (strncmp(name_buffer, "p3d_", 4) == 0) { + string noprefix(name_buffer + 4); + + // Check for matrix inputs. + bool transpose = false; + bool inverse = false; + string matrix_name(noprefix); + size = matrix_name.size(); + + // Check for and chop off any "Transpose" or "Inverse" suffix. + if (size > 15 && matrix_name.compare(size - 9, 9, "Transpose") == 0) { + transpose = true; + matrix_name = matrix_name.substr(0, size - 9); + } + size = matrix_name.size(); + if (size > 13 && matrix_name.compare(size - 7, 7, "Inverse") == 0) { + inverse = true; + matrix_name = matrix_name.substr(0, size - 7); + } + size = matrix_name.size(); + + // Now if the suffix that is left over is "Matrix", + // we know that it is supposed to be a matrix input. + if (size > 6 && matrix_name.compare(size - 6, 6, "Matrix") == 0) { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._func = Shader::SMF_compose; + if (param_type == GL_FLOAT_MAT3) { + if (transpose) { + bind._piece = Shader::SMP_upper3x3; + } else { + bind._piece = Shader::SMP_transpose3x3; + } + } else { + if (transpose) { + bind._piece = Shader::SMP_transpose; + } else { + bind._piece = Shader::SMP_whole; + } + } + bind._arg[0] = NULL; + bind._arg[1] = NULL; + bind._dep[0] = Shader::SSD_general | Shader::SSD_transform; + bind._dep[1] = Shader::SSD_general | Shader::SSD_transform; + + if (matrix_name == "ModelViewProjectionMatrix") { + if (inverse) { + bind._part[0] = Shader::SMO_apiclip_to_apiview; + bind._part[1] = Shader::SMO_apiview_to_model; + } else { + bind._part[0] = Shader::SMO_model_to_apiview; + bind._part[1] = Shader::SMO_apiview_to_apiclip; + } + + } else if (matrix_name == "ModelViewMatrix") { + bind._func = Shader::SMF_first; + bind._part[0] = inverse ? Shader::SMO_apiview_to_model + : Shader::SMO_model_to_apiview; + bind._part[1] = Shader::SMO_identity; + + } else if (matrix_name == "ProjectionMatrix") { + bind._func = Shader::SMF_first; + bind._part[0] = inverse ? Shader::SMO_apiclip_to_apiview + : Shader::SMO_apiview_to_apiclip; + bind._part[1] = Shader::SMO_identity; + + } else if (matrix_name == "NormalMatrix") { + // This is really the upper 3x3 of the ModelViewMatrixInverseTranspose. + bind._func = Shader::SMF_first; + bind._part[0] = inverse ? Shader::SMO_model_to_apiview + : Shader::SMO_apiview_to_model; + bind._part[1] = Shader::SMO_identity; + + if (param_type != GL_FLOAT_MAT3) { + GLCAT.error() << "p3d_NormalMatrix input should be mat3, not mat4!\n"; + } + + } else if (matrix_name == "ModelMatrix") { + if (inverse) { + bind._part[0] = Shader::SMO_world_to_view; + bind._part[1] = Shader::SMO_view_to_model; + } else { + bind._part[0] = Shader::SMO_model_to_view; + bind._part[1] = Shader::SMO_view_to_world; + } + + } else if (matrix_name == "ViewMatrix") { + if (inverse) { + bind._part[0] = Shader::SMO_apiview_to_view; + bind._part[1] = Shader::SMO_view_to_world; + } else { + bind._part[0] = Shader::SMO_world_to_view; + bind._part[1] = Shader::SMO_view_to_apiview; + } + + } else if (matrix_name == "ViewProjectionMatrix") { + if (inverse) { + bind._part[0] = Shader::SMO_apiclip_to_view; + bind._part[1] = Shader::SMO_view_to_world; + } else { + bind._part[0] = Shader::SMO_world_to_view; + bind._part[1] = Shader::SMO_view_to_apiclip; + } + + } else { + GLCAT.error() << "Unrecognized uniform matrix name '" << matrix_name << "'!\n"; + return; + } + _shader->_mat_spec.push_back(bind); + return; + } + if (size > 7 && noprefix.substr(0, 7) == "Texture") { + Shader::ShaderTexSpec bind; + bind._id = arg_id; + bind._name = 0; + + string tail; + bind._stage = string_to_int(noprefix.substr(7), tail); + if (!tail.empty()) { + GLCAT.error() + << "Error parsing shader input name: unexpected '" + << tail << "' in '" << param_name << "'\n"; + return; + } + + if (get_sampler_texture_type(bind._desired_type, param_type)) { + _glgsg->_glUniform1i(p, _shader->_tex_spec.size()); + _shader->_tex_spec.push_back(bind); + } else { + GLCAT.error() + << "Could not bind texture input " << param_name << "\n"; + } + return; + } + if (size > 9 && noprefix.substr(0, 9) == "Material.") { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_attr_material; + bind._arg[0] = NULL; + bind._dep[0] = Shader::SSD_general | Shader::SSD_material; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + + if (noprefix == "Material.ambient") { + if (param_type != GL_FLOAT_VEC4) { + GLCAT.error() + << "p3d_Material.ambient should be vec4\n"; + } + bind._piece = Shader::SMP_row0; + _shader->_mat_spec.push_back(bind); + return; + + } else if (noprefix == "Material.diffuse") { + if (param_type != GL_FLOAT_VEC4) { + GLCAT.error() + << "p3d_Material.diffuse should be vec4\n"; + } + bind._piece = Shader::SMP_row1; + _shader->_mat_spec.push_back(bind); + return; + + } else if (noprefix == "Material.emission") { + if (param_type != GL_FLOAT_VEC4) { + GLCAT.error() + << "p3d_Material.emission should be vec4\n"; + } + bind._piece = Shader::SMP_row2; + _shader->_mat_spec.push_back(bind); + return; + + } else if (noprefix == "Material.specular") { + if (param_type != GL_FLOAT_VEC3) { + GLCAT.error() + << "p3d_Material.specular should be vec3\n"; + } + bind._piece = Shader::SMP_row3x3; + _shader->_mat_spec.push_back(bind); + return; + + } else if (noprefix == "Material.shininess") { + if (param_type != GL_FLOAT) { + GLCAT.error() + << "p3d_Material.shininess should be float\n"; + } + bind._piece = Shader::SMP_cell15; + _shader->_mat_spec.push_back(bind); + return; + } + } + if (noprefix == "ColorScale") { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_attr_colorscale; + bind._arg[0] = NULL; + bind._dep[0] = Shader::SSD_general | Shader::SSD_colorscale; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + + if (param_type == GL_FLOAT_VEC3) { + bind._piece = Shader::SMP_row3x3; + } else if (param_type == GL_FLOAT_VEC4) { + bind._piece = Shader::SMP_row3; + } else { + GLCAT.error() + << "p3d_ColorScale should be vec3 or vec4\n"; + return; + } + _shader->_mat_spec.push_back(bind); + return; + } + if (noprefix == "Color") { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_attr_color; + bind._arg[0] = NULL; + bind._dep[0] = Shader::SSD_general | Shader::SSD_color; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + + if (param_type == GL_FLOAT_VEC3) { + bind._piece = Shader::SMP_row3x3; + } else if (param_type == GL_FLOAT_VEC4) { + bind._piece = Shader::SMP_row3; + } else { + GLCAT.error() + << "p3d_Color should be vec3 or vec4\n"; + return; + } + _shader->_mat_spec.push_back(bind); + return; + } + if (noprefix == "ClipPlane") { + if (param_type != GL_FLOAT_VEC4) { + GLCAT.error() + << "p3d_ClipPlane should be vec4 or vec4[]\n"; + return; + } + for (int i = 0; i < param_size; ++i) { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._id._seqno = p + i; + bind._piece = Shader::SMP_row3; + bind._func = Shader::SMF_first; + bind._index = i; + bind._part[0] = Shader::SMO_apiview_clipplane_i; + bind._arg[0] = NULL; + bind._dep[0] = Shader::SSD_general | Shader::SSD_clip_planes; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + _shader->_mat_spec.push_back(bind); + } + return; + } + if (noprefix == "LightModel.ambient") { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_light_ambient; + bind._arg[0] = NULL; + bind._dep[0] = Shader::SSD_general | Shader::SSD_light; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + + if (param_type == GL_FLOAT_VEC3) { + bind._piece = Shader::SMP_row3x3; + } else if (param_type == GL_FLOAT_VEC4) { + bind._piece = Shader::SMP_row3; + } else { + GLCAT.error() + << "p3d_LightModel.ambient should be vec3 or vec4\n"; + return; + } + _shader->_mat_spec.push_back(bind); + return; + } + if (noprefix == "TransformTable") { + if (param_type != GL_FLOAT_MAT4) { + GLCAT.error() + << "p3d_TransformTable should be uniform mat4\n"; + return; + } + _transform_table_index = p; + _transform_table_size = param_size; + return; + } + if (noprefix == "SliderTable") { + if (param_type != GL_FLOAT) { + GLCAT.error() + << "p3d_SliderTable should be uniform float\n"; + return; + } + _slider_table_index = p; + _slider_table_size = param_size; + return; + } + GLCAT.error() << "Unrecognized uniform name '" << param_name << "'!\n"; + return; + + } else if (strncmp(name_buffer, "osg_", 4) == 0) { + string noprefix(name_buffer + 4); + // These inputs are supported by OpenSceneGraph. We can support + // them as well, to increase compatibility. + // Other inputs we may support in the future: + // int osg_FrameNumber + + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._arg[0] = NULL; + bind._arg[1] = NULL; + + if (noprefix == "ViewMatrix") { + bind._piece = Shader::SMP_whole; + bind._func = Shader::SMF_compose; + bind._part[0] = Shader::SMO_world_to_view; + bind._part[1] = Shader::SMO_view_to_apiview; + bind._dep[0] = Shader::SSD_general | Shader::SSD_transform; + bind._dep[1] = Shader::SSD_general | Shader::SSD_transform; + _shader->_mat_spec.push_back(bind); + return; + + } else if (noprefix == "InverseViewMatrix") { + bind._piece = Shader::SMP_whole; + bind._func = Shader::SMF_compose; + bind._part[0] = Shader::SMO_apiview_to_view; + bind._part[1] = Shader::SMO_view_to_world; + bind._dep[0] = Shader::SSD_general | Shader::SSD_transform; + bind._dep[1] = Shader::SSD_general | Shader::SSD_transform; + _shader->_mat_spec.push_back(bind); + return; + + } else if (noprefix == "FrameTime") { + bind._piece = Shader::SMP_row3x1; + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_frame_time; + bind._part[1] = Shader::SMO_identity; + bind._dep[0] = Shader::SSD_general; + bind._dep[1] = Shader::SSD_NONE; + _shader->_mat_spec.push_back(bind); + return; + + } else if (noprefix == "DeltaFrameTime") { + bind._piece = Shader::SMP_row3x1; + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_frame_delta; + bind._part[1] = Shader::SMO_identity; + bind._dep[0] = Shader::SSD_general; + bind._dep[1] = Shader::SSD_NONE; + _shader->_mat_spec.push_back(bind); + return; + } + + } else { + // Tries to parse shorthand notations like mspos_XXX and trans_model_to_clip_of_XXX + if (parse_and_set_short_hand_shader_vars(arg_id, _shader)) { + return; + } + } + + if (param_size == 1) { + // A single uniform (not an array, or an array of size 1). + switch (param_type) { +#ifndef OPENGLES + case GL_INT_SAMPLER_1D: + case GL_INT_SAMPLER_2D: + case GL_INT_SAMPLER_3D: + case GL_INT_SAMPLER_2D_ARRAY: + case GL_INT_SAMPLER_CUBE: + case GL_INT_SAMPLER_BUFFER: + case GL_UNSIGNED_INT_SAMPLER_1D: + case GL_UNSIGNED_INT_SAMPLER_2D: + case GL_UNSIGNED_INT_SAMPLER_3D: + case GL_UNSIGNED_INT_SAMPLER_CUBE: + case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: + case GL_UNSIGNED_INT_SAMPLER_BUFFER: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_1D: + case GL_SAMPLER_CUBE_SHADOW: + case GL_SAMPLER_2D_ARRAY: + case GL_SAMPLER_2D_ARRAY_SHADOW: + case GL_SAMPLER_BUFFER: +#endif // !OPENGLES + case GL_SAMPLER_2D: + case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: { + Shader::ShaderTexSpec bind; + bind._id = arg_id; + bind._name = InternalName::make(param_name); + bind._desired_type = Texture::TT_2d_texture; + bind._stage = 0; + if (get_sampler_texture_type(bind._desired_type, param_type)) { + _glgsg->_glUniform1i(p, _shader->_tex_spec.size()); + _shader->_tex_spec.push_back(bind); + } + return; + } + case GL_FLOAT_MAT2: +#ifndef OPENGLES + case GL_FLOAT_MAT2x3: + case GL_FLOAT_MAT2x4: + case GL_FLOAT_MAT3x2: + case GL_FLOAT_MAT3x4: + case GL_FLOAT_MAT4x2: + case GL_FLOAT_MAT4x3: +#endif + GLCAT.warning() << "GLSL shader requested an unsupported matrix type\n"; + return; + case GL_FLOAT_MAT3: { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._piece = Shader::SMP_upper3x3; + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_mat_constant_x; + bind._arg[0] = InternalName::make(param_name); + bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + _shader->_mat_spec.push_back(bind); + return; + } + case GL_FLOAT_MAT4: { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._piece = Shader::SMP_whole; + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_mat_constant_x; + bind._arg[0] = InternalName::make(param_name); + bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + _shader->_mat_spec.push_back(bind); + return; + } + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: { + PT(InternalName) iname = InternalName::make(param_name); + if (iname->get_parent() != InternalName::get_root()) { + // It might be something like an attribute of a shader + // input, like a light parameter. It might also just be + // a custom struct parameter. We can't know yet, sadly. + Shader::ShaderMatSpec bind; + bind._id = arg_id; + switch (param_type) { + case GL_FLOAT: + bind._piece = Shader::SMP_row3x1; + break; + case GL_FLOAT_VEC2: + bind._piece = Shader::SMP_row3x2; + break; + case GL_FLOAT_VEC3: + bind._piece = Shader::SMP_row3x3; + break; + default: + bind._piece = Shader::SMP_row3; + } + bind._func = Shader::SMF_first; + bind._part[0] = Shader::SMO_vec_constant_x_attrib; + bind._arg[0] = iname; + bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + _shader->_mat_spec.push_back(bind); + return; + } // else fall through + } + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: { + Shader::ShaderPtrSpec bind; + bind._id = arg_id; + switch (param_type) { + case GL_BOOL: + case GL_INT: + case GL_FLOAT: bind._dim[1] = 1; break; + case GL_BOOL_VEC2: + case GL_INT_VEC2: + case GL_FLOAT_VEC2: bind._dim[1] = 2; break; + case GL_BOOL_VEC3: + case GL_INT_VEC3: + case GL_FLOAT_VEC3: bind._dim[1] = 3; break; + case GL_BOOL_VEC4: + case GL_INT_VEC4: + case GL_FLOAT_VEC4: bind._dim[1] = 4; break; + case GL_FLOAT_MAT3: bind._dim[1] = 9; break; + case GL_FLOAT_MAT4: bind._dim[1] = 16; break; + } + switch (param_type) { + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + bind._type = Shader::SPT_int; + break; + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + bind._type = Shader::SPT_float; + break; + } + bind._arg = InternalName::make(param_name); + bind._dim[0] = 1; + bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; + bind._dep[1] = Shader::SSD_NONE; + _shader->_ptr_spec.push_back(bind); + return; + } +#ifndef OPENGLES + case GL_IMAGE_1D_EXT: + case GL_IMAGE_2D_EXT: + case GL_IMAGE_3D_EXT: + case GL_IMAGE_CUBE_EXT: + case GL_IMAGE_2D_ARRAY_EXT: + case GL_IMAGE_BUFFER_EXT: + case GL_INT_IMAGE_1D_EXT: + case GL_INT_IMAGE_2D_EXT: + case GL_INT_IMAGE_3D_EXT: + case GL_INT_IMAGE_CUBE_EXT: + case GL_INT_IMAGE_2D_ARRAY_EXT: + case GL_INT_IMAGE_BUFFER_EXT: + case GL_UNSIGNED_INT_IMAGE_1D_EXT: + case GL_UNSIGNED_INT_IMAGE_2D_EXT: + case GL_UNSIGNED_INT_IMAGE_3D_EXT: + case GL_UNSIGNED_INT_IMAGE_CUBE_EXT: + case GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT: + case GL_UNSIGNED_INT_IMAGE_BUFFER_EXT: + // This won't really change at runtime, so we might as well + // bind once and then forget about it. + _glgsg->_glUniform1i(p, _glsl_img_inputs.size()); + { + ImageInput input; + input._name = InternalName::make(param_name); + input._writable = false; + input._gtc = NULL; + _glsl_img_inputs.push_back(input); + } + return; +#endif + default: + GLCAT.warning() << "Ignoring unrecognized GLSL parameter type!\n"; + } + } else { + // A uniform array. + switch (param_type) { + case GL_FLOAT_MAT2: +#ifndef OPENGLES + case GL_FLOAT_MAT2x3: + case GL_FLOAT_MAT2x4: + case GL_FLOAT_MAT3x2: + case GL_FLOAT_MAT3x4: + case GL_FLOAT_MAT4x2: + case GL_FLOAT_MAT4x3: +#endif + GLCAT.warning() << "GLSL shader requested an unrecognized matrix array type\n"; + return; + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: { + Shader::ShaderPtrSpec bind; + bind._id = arg_id; + switch (param_type) { + case GL_BOOL: + case GL_INT: + case GL_FLOAT: bind._dim[1] = 1; break; + case GL_BOOL_VEC2: + case GL_INT_VEC2: + case GL_FLOAT_VEC2: bind._dim[1] = 2; break; + case GL_BOOL_VEC3: + case GL_INT_VEC3: + case GL_FLOAT_VEC3: bind._dim[1] = 3; break; + case GL_BOOL_VEC4: + case GL_INT_VEC4: + case GL_FLOAT_VEC4: bind._dim[1] = 4; break; + case GL_FLOAT_MAT3: bind._dim[1] = 9; break; + case GL_FLOAT_MAT4: bind._dim[1] = 16; break; + } + switch (param_type) { + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + bind._type = Shader::SPT_int; + break; + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + bind._type = Shader::SPT_float; + break; + } + bind._arg = InternalName::make(param_name); + bind._dim[0] = param_size; + bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs; + bind._dep[1] = Shader::SSD_NONE; + _shader->_ptr_spec.push_back(bind); + return; + } + default: + GLCAT.warning() << "Ignoring unrecognized GLSL parameter array type!\n"; + } + } +} + //////////////////////////////////////////////////////////////////// // Function: GLShaderContext::get_sampler_texture_type // Access: Public @@ -1166,6 +1418,12 @@ bind(bool reissue_parameters) { issue_parameters(Shader::SSD_general); } + if (!_validated) { + _glgsg->_glValidateProgram(_glsl_program); + glsl_report_program_errors(_glsl_program, false); + _validated = true; + } + _glgsg->report_my_gl_errors(); } @@ -1214,7 +1472,7 @@ issue_parameters(int altered) { return; } - GLint p = _glsl_parameter_map[spec._id._seqno]; + GLint p = spec._id._seqno; switch (spec._type) { case Shader::SPT_float: { @@ -1305,7 +1563,7 @@ issue_parameters(int altered) { const PN_float32 *data = valf.get_data(); #endif - GLint p = _glsl_parameter_map[spec._id._seqno]; + GLint p = spec._id._seqno; switch (spec._piece) { case Shader::SMP_whole: _glgsg->_glUniformMatrix4fv(p, 1, GL_FALSE, data); continue; case Shader::SMP_transpose: _glgsg->_glUniformMatrix4fv(p, 1, GL_TRUE, data); continue; @@ -1350,6 +1608,58 @@ issue_parameters(int altered) { _glgsg->report_my_gl_errors(); } +//////////////////////////////////////////////////////////////////// +// Function: GLShaderContext::update_transform_table +// Access: Public +// Description: Changes the active transform table, used for hardware +// skinning. +//////////////////////////////////////////////////////////////////// +void CLP(ShaderContext):: +update_transform_table(const TransformTable *table) { + LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); + + int i = 0; + if (table != NULL) { + int num_transforms = min(_transform_table_size, table->get_num_transforms()); + for (; i < num_transforms; ++i) { +#ifdef STDFLOAT_DOUBLE + LMatrix4 matrix; + table->get_transform(i)->get_matrix(matrix); + matrices[i] = LCAST(float, matrix); +#else + table->get_transform(i)->get_matrix(matrices[i]); +#endif + } + } + for (; i < _transform_table_size; ++i) { + matrices[i] = LMatrix4f::ident_mat(); + } + + _glgsg->_glUniformMatrix4fv(_transform_table_index, _transform_table_size, + GL_FALSE, (float *)matrices); +} + +//////////////////////////////////////////////////////////////////// +// Function: GLShaderContext::update_slider_table +// Access: Public +// Description: Changes the active slider table, used for hardware +// skinning. +//////////////////////////////////////////////////////////////////// +void CLP(ShaderContext):: +update_slider_table(const SliderTable *table) { + float *sliders = (float *)alloca(_slider_table_size * 4); + memset(sliders, 0, _slider_table_size * 4); + + if (table != NULL) { + int num_sliders = min(_slider_table_size, table->get_num_sliders()); + for (int i = 0; i < num_sliders; ++i) { + sliders[i] = table->get_slider(i)->get_slider(); + } + } + + _glgsg->_glUniform1fv(_slider_table_index, _slider_table_size, sliders); +} + //////////////////////////////////////////////////////////////////// // Function: GLShaderContext::disable_shader_vertex_arrays // Access: Public @@ -1363,7 +1673,7 @@ disable_shader_vertex_arrays() { for (int i=0; i<(int)_shader->_var_spec.size(); i++) { const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; - const GLint p = _glsl_parameter_map[bind._id._seqno]; + GLint p = bind._id._seqno; if (_has_divisor) { _glgsg->_glVertexAttribDivisor(p, 0); } @@ -1421,7 +1731,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { name = name->append(texname->get_basename()); } } - GLint p = _glsl_parameter_map[bind._id._seqno]; + GLint p = bind._id._seqno; // Don't apply vertex colors if they are disabled with a ColorAttrib. int num_elements, element_stride, divisor; @@ -1481,6 +1791,16 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { } } + if (_transform_table_index >= 0) { + const TransformTable *table = _glgsg->_data_reader->get_transform_table(); + update_transform_table(table); + } + + if (_slider_table_index >= 0) { + const SliderTable *table = _glgsg->_data_reader->get_slider_table(); + update_slider_table(table); + } + _glgsg->report_my_gl_errors(); return true; @@ -1501,7 +1821,7 @@ disable_shader_texture_bindings() { #ifndef OPENGLES // Check if bindless was used, if so, there's nothing to unbind. if (_glgsg->_supports_bindless_texture) { - GLint p = _glsl_parameter_map[_shader->_tex_spec[i]._id._seqno]; + GLint p = _shader->_tex_spec[i]._id._seqno; if (_glsl_uniform_handles.count(p) > 0) { continue; @@ -1570,15 +1890,12 @@ disable_shader_texture_bindings() { if (gl_enable_memory_barriers) { for (int i = 0; i < num_image_units; ++i) { - const InternalName *name = _glsl_img_inputs[i]; - const ShaderInput *input = _glgsg->_target_shader->get_shader_input(name); + ImageInput &input = _glsl_img_inputs[i]; - if ((input->_access & ShaderInput::A_write) != 0) { - _glsl_img_textures[i]->mark_incoherent(true); - } else { - _glsl_img_textures[i]->mark_incoherent(false); + if (input._gtc != NULL) { + input._gtc->mark_incoherent(input._writable); + input._gtc = NULL; } - _glsl_img_textures[i] = NULL; } } } @@ -1616,9 +1933,24 @@ update_shader_texture_bindings(ShaderContext *prev) { if (num_image_units > 0) { for (int i = 0; i < num_image_units; ++i) { - const InternalName *name = _glsl_img_inputs[i]; - const ShaderInput *input = _glgsg->_target_shader->get_shader_input(name); - Texture *tex = input->get_texture(); + ImageInput &input = _glsl_img_inputs[i]; + const ParamTextureImage *param = NULL; + Texture *tex; + + const ShaderInput *sinp = _glgsg->_target_shader->get_shader_input(input._name); + if (sinp->get_value_type() == ShaderInput::M_texture_image) { + param = (const ParamTextureImage *)sinp->get_param(); + tex = param->get_texture(); + + } else if (sinp->get_value_type() == ShaderInput::M_texture) { + // People find it convenient to be able to pass a texture without further ado. + tex = sinp->get_texture(); + + } else { + GLCAT.error() + << "Mismatching type for parameter " << *input._name << ", expected texture image binding\n"; + continue; + } GLuint gl_tex = 0; CLP(TextureContext) *gtc; @@ -1628,7 +1960,7 @@ update_shader_texture_bindings(ShaderContext *prev) { gtc = DCAST(CLP(TextureContext), tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg)); if (gtc != (TextureContext*)NULL) { - _glsl_img_textures[i] = gtc; + input._gtc = gtc; gl_tex = gtc->_index; _glgsg->update_texture(gtc, true); @@ -1638,9 +1970,11 @@ update_shader_texture_bindings(ShaderContext *prev) { } } } + input._writable = false; if (gl_tex == 0) { _glgsg->_glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R8); + } else { //TODO: automatically convert to sized type instead of plain GL_RGBA // If a base type is used, it will crash. @@ -1654,25 +1988,36 @@ update_shader_texture_bindings(ShaderContext *prev) { internal_format = _glgsg->get_internal_image_format(tex, true); } - GLenum access = GL_READ_ONLY; - GLboolean layered = (input->_access & ShaderInput::A_layered) != 0; + GLenum access = GL_READ_WRITE; + GLint bind_level = 0; + GLint bind_layer = 0; + GLboolean layered = GL_TRUE; - if ((input->_access & ShaderInput::A_read) != 0 && - (input->_access & ShaderInput::A_write) != 0) { - access = GL_READ_WRITE; + if (param != NULL) { + layered = param->get_bind_layered(); + bind_level = param->get_bind_level(); + bind_layer = param->get_bind_layer(); - } else if ((input->_access & ShaderInput::A_read) != 0) { - access = GL_READ_ONLY; + bool has_read = param->has_read_access(); + bool has_write = param->has_write_access(); + input._writable = has_write; - } else if ((input->_access & ShaderInput::A_write) != 0) { - access = GL_WRITE_ONLY; + if (has_read && has_write) { + access = GL_READ_WRITE; - } else { - access = GL_READ_ONLY; - gl_tex = 0; + } else if (has_read) { + access = GL_READ_ONLY; + + } else if (has_write) { + access = GL_WRITE_ONLY; + + } else { + access = GL_READ_ONLY; + gl_tex = 0; + } } - _glgsg->_glBindImageTexture(i, gl_tex, input->_bind_level, layered, - input->_bind_layer, access, gtc->_internal_format); + _glgsg->_glBindImageTexture(i, gl_tex, bind_level, layered, bind_layer, + access, gtc->_internal_format); } } } @@ -1686,22 +2031,30 @@ update_shader_texture_bindings(ShaderContext *prev) { for (int i = 0; i < (int)_shader->_tex_spec.size(); ++i) { Shader::ShaderTexSpec &spec = _shader->_tex_spec[i]; const InternalName *id = spec._name; - int texunit = spec._stage; Texture *tex = NULL; int view = _glgsg->get_current_tex_view_offset(); SamplerState sampler; if (id != NULL) { - const ShaderInput *input = _glgsg->_target_shader->get_shader_input(id); - tex = input->get_texture(); - sampler = input->get_sampler(); - - } else { - if (texunit >= texattrib->get_num_on_stages()) { + // Named texture input. + if (!_glgsg->_target_shader->has_shader_input(id)) { + // This used to be legal for some reason, so don't trigger the assert. + GLCAT.error() + << "Shader input " << *id << " is not present.\n"; continue; } - TextureStage *stage = texattrib->get_on_stage(texunit); + tex = _glgsg->_target_shader->get_shader_input_texture(id, &sampler); + + } else { + if (spec._stage >= texattrib->get_num_on_stages()) { + // Apply a white texture in order to make it easier to use a shader + // that takes a texture on a model that doesn't have a texture applied. + _glgsg->_glActiveTexture(GL_TEXTURE0 + i); + _glgsg->apply_white_texture(); + continue; + } + TextureStage *stage = texattrib->get_on_stage(spec._stage); tex = texattrib->get_on_texture(stage); sampler = texattrib->get_on_sampler(stage); view += stage->get_tex_view_offset(); @@ -1718,7 +2071,7 @@ update_shader_texture_bindings(ShaderContext *prev) { "match type of texture " << *tex << ".\n"; } else { GLCAT.error() - << "Sampler type of GLSL shader input p3d_Texture" << texunit + << "Sampler type of GLSL shader input p3d_Texture" << spec._stage << " does not match type of texture " << *tex << ".\n"; } //TODO: also check whether shadow sampler textures have shadow filter enabled. @@ -1729,7 +2082,7 @@ update_shader_texture_bindings(ShaderContext *prev) { continue; } - GLint p = _glsl_parameter_map[spec._id._seqno]; + GLint p = spec._id._seqno; #ifndef OPENGLES // If it was recently written to, we will have to issue a memory barrier soon. @@ -1827,7 +2180,7 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { << "ERROR: " << fn << ":" << lineno << ": " << (line.c_str() + prefixlen) << "\n"; } else if (sscanf(line.c_str(), "WARNING: %d:%d: %n", &fileno, &lineno, &prefixlen) == 2 - && prefixlen > 0) { + && prefixlen > 0) { Filename fn = _shader->get_filename_from_index(fileno, type); GLCAT.warning(false) @@ -1867,9 +2220,13 @@ glsl_report_program_errors(GLuint program, bool fatal) { info_log = (char *) alloca(length); _glgsg->_glGetProgramInfoLog(program, length, &num_chars, info_log); - if (strcmp(info_log, "Success.\n") != 0 && strcmp(info_log, "No errors.\n") != 0) { + if (strcmp(info_log, "Success.\n") != 0 && + strcmp(info_log, "No errors.\n") != 0 && + strcmp(info_log, "Validation successful.\n") != 0) { if (!fatal) { - GLCAT.warning(false) << info_log << "\n"; + GLCAT.warning() + << "Shader " << _shader->get_filename() << " produced the " + << "following warnings:\n" << info_log << "\n"; } else { GLCAT.error(false) << info_log << "\n"; } diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index f9ca285572..fd4b56def4 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -20,6 +20,7 @@ #include "shader.h" #include "shaderContext.h" #include "deletedChain.h" +#include "paramTexture.h" class CLP(GraphicsStateGuardian); @@ -35,12 +36,20 @@ public: ~CLP(ShaderContext)(); ALLOC_DELETED_CHAIN(CLP(ShaderContext)); + void reflect_attribute(int i, char *name_buf, GLsizei name_buflen); +#ifndef OPENGLES + void reflect_uniform_block(int i, const char *block_name, + char *name_buffer, GLsizei name_buflen); +#endif + void reflect_uniform(int i, char *name_buffer, GLsizei name_buflen); bool get_sampler_texture_type(int &out, GLenum param_type); INLINE bool valid(void); void bind(bool reissue_parameters = true); void unbind(); void issue_parameters(int altered); + void update_transform_table(const TransformTable *table); + void update_slider_table(const SliderTable *table); void disable_shader_vertex_arrays(); bool update_shader_vertex_arrays(ShaderContext *prev, bool force); void disable_shader_texture_bindings(); @@ -51,6 +60,7 @@ public: INLINE bool uses_custom_texture_bindings(void); private: + bool _validated; GLuint _glsl_program; typedef pvector GLSLShaders; GLSLShaders _glsl_shaders; @@ -66,11 +76,18 @@ private: //ParamContexts _params; GLint _color_attrib_index; - pvector _glsl_parameter_map; + GLint _transform_table_index; + GLint _slider_table_index; + GLsizei _transform_table_size; + GLsizei _slider_table_size; pmap _glsl_uniform_handles; - pvector _glsl_img_inputs; - pvector _glsl_img_textures; + struct ImageInput { + CPT(InternalName) _name; + CLP(TextureContext) *_gtc; + bool _writable; + }; + pvector _glsl_img_inputs; CLP(GraphicsStateGuardian) *_glgsg; diff --git a/panda/src/glstuff/glmisc_src.cxx b/panda/src/glstuff/glmisc_src.cxx index 23e9c700ad..743b9ca0ea 100644 --- a/panda/src/glstuff/glmisc_src.cxx +++ b/panda/src/glstuff/glmisc_src.cxx @@ -14,6 +14,10 @@ #include "pandaSystem.h" +ConfigVariableInt gl_version + ("gl-version", "", + PRC_DESC("Set this to get an OpenGL context with a specific version.")); + ConfigVariableBool gl_support_fbo ("gl-support-fbo", true, PRC_DESC("Configure this false if your GL's implementation of " @@ -183,10 +187,6 @@ ConfigVariableBool gl_force_depth_stencil ("gl-force-depth-stencil", false, PRC_DESC("Temporary hack variable 7x00 vs 8x00 nVidia bug. See glGraphicsStateGuardian_src.cxx.")); -ConfigVariableBool gl_matrix_palette - ("gl-matrix-palette", false, - PRC_DESC("Temporary hack variable protecting untested code. See glGraphicsStateGuardian_src.cxx.")); - ConfigVariableBool gl_check_errors ("gl-check-errors", false, PRC_DESC("Regularly call glGetError() to check for OpenGL errors. " @@ -222,6 +222,12 @@ ConfigVariableBool gl_dump_compiled_shaders "programs to disk with a filename like glsl_program0.dump " "into the current directory.")); +ConfigVariableBool gl_validate_shaders + ("gl-validate-shaders", true, + PRC_DESC("Set this to true to enable glValidateShader the first time " + "a shader is bound. This may cause helpful information about " + "shaders to be printed.")); + ConfigVariableBool gl_immutable_texture_storage ("gl-immutable-texture-storage", false, PRC_DESC("This configures Panda to pre-allocate immutable storage " @@ -278,6 +284,15 @@ ConfigVariableBool gl_support_shadow_filter "cards suffered from a broken implementation of the " "shadow map filtering features.")); +ConfigVariableEnum gl_coordinate_system + ("gl-coordinate-system", CS_yup_right, + PRC_DESC("Which coordinate system to use as the internal " + "coordinate system for OpenGL operations. If you are " + "using features like fixed-function sphere mapping, it is " + "best to leave this to yup-right. However, if you are " + "creating a shader-only application, it may be easier and " + "more efficient to set this to default.")); + extern ConfigVariableBool gl_parallel_arrays; void CLP(init_classes)() { diff --git a/panda/src/glstuff/glmisc_src.h b/panda/src/glstuff/glmisc_src.h index 98e5bc8121..78a19a5a8f 100644 --- a/panda/src/glstuff/glmisc_src.h +++ b/panda/src/glstuff/glmisc_src.h @@ -17,6 +17,7 @@ #include "configVariableInt.h" #include "configVariableEnum.h" #include "geomEnums.h" +#include "coordinateSystem.h" // Define some macros to transparently map to the double or float // versions of the OpenGL function names. @@ -40,6 +41,7 @@ //#define GSG_VERBOSE 1 +extern ConfigVariableInt gl_version; extern EXPCL_PANDAGL ConfigVariableBool gl_support_fbo; extern ConfigVariableBool gl_cheap_textures; extern ConfigVariableBool gl_ignore_clamp; @@ -63,12 +65,12 @@ extern ConfigVariableBool gl_debug_object_labels; extern ConfigVariableBool gl_debug_buffers; extern ConfigVariableBool gl_finish; extern ConfigVariableBool gl_force_depth_stencil; -extern ConfigVariableBool gl_matrix_palette; extern ConfigVariableBool gl_check_errors; extern ConfigVariableBool gl_force_flush; extern ConfigVariableBool gl_separate_specular_color; extern ConfigVariableBool gl_cube_map_seamless; extern ConfigVariableBool gl_dump_compiled_shaders; +extern ConfigVariableBool gl_validate_shaders; extern ConfigVariableBool gl_immutable_texture_storage; extern ConfigVariableBool gl_use_bindless_texture; extern ConfigVariableBool gl_enable_memory_barriers; @@ -76,6 +78,7 @@ extern ConfigVariableBool gl_vertex_array_objects; extern ConfigVariableBool gl_support_primitive_restart_index; extern ConfigVariableBool gl_support_sampler_objects; extern ConfigVariableBool gl_support_shadow_filter; +extern ConfigVariableEnum gl_coordinate_system; extern EXPCL_GL void CLP(init_classes)(); diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index e9c44e9e8d..4964385912 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -355,6 +355,14 @@ choose_pixel_format(const FrameBufferProperties &properties, n = 0; attrib_list[n++] = GLX_RENDER_TYPE; attrib_list[n++] = render_type; + if (gl_version.get_num_words() > 0) { + attrib_list[n++] = GLX_CONTEXT_MAJOR_VERSION_ARB; + attrib_list[n++] = gl_version[0]; + if (gl_version.get_num_words() > 1) { + attrib_list[n++] = GLX_CONTEXT_MINOR_VERSION_ARB; + attrib_list[n++] = gl_version[1]; + } + } if (gl_debug) { attrib_list[n++] = GLX_CONTEXT_FLAGS_ARB; attrib_list[n++] = GLX_CONTEXT_DEBUG_BIT_ARB; diff --git a/panda/src/gobj/Sources.pp b/panda/src/gobj/Sources.pp index 7ac03ff431..5c74dac9d3 100644 --- a/panda/src/gobj/Sources.pp +++ b/panda/src/gobj/Sources.pp @@ -50,9 +50,11 @@ matrixLens.I matrixLens.h \ occlusionQueryContext.I occlusionQueryContext.h \ orthographicLens.I orthographicLens.h perspectiveLens.I \ + paramTexture.I paramTexture.h \ perspectiveLens.h \ preparedGraphicsObjects.I preparedGraphicsObjects.h \ queryContext.I queryContext.h \ + samplerState.I samplerState.h \ savedContext.I savedContext.h \ shader.I shader.h \ shaderContext.h shaderContext.I \ @@ -61,6 +63,7 @@ sliderTable.I sliderTable.h \ texture.I texture.h \ textureCollection.I textureCollection.h \ + textureCollection_ext.h \ textureContext.I textureContext.h \ texturePeeker.I texturePeeker.h \ texturePool.I texturePool.h \ @@ -123,9 +126,11 @@ materialPool.cxx matrixLens.cxx \ occlusionQueryContext.cxx \ orthographicLens.cxx \ + paramTexture.cxx \ perspectiveLens.cxx \ preparedGraphicsObjects.cxx \ queryContext.cxx \ + samplerState.cxx \ savedContext.cxx \ shader.cxx \ shaderContext.cxx \ @@ -196,10 +201,12 @@ material.I material.h \ materialPool.I materialPool.h matrixLens.I matrixLens.h \ occlusionQueryContext.I occlusionQueryContext.h \ - orthographicLens.I orthographicLens.h perspectiveLens.I \ - perspectiveLens.h \ + orthographicLens.I orthographicLens.h \ + paramTexture.I paramTexture.h \ + perspectiveLens.I perspectiveLens.h \ preparedGraphicsObjects.I preparedGraphicsObjects.h \ queryContext.I queryContext.h \ + samplerState.I samplerState.h \ savedContext.I savedContext.h \ shader.I shader.h \ shaderContext.h shaderContext.I \ diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index a1d3c43d03..7723d6b10b 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -255,6 +255,11 @@ ConfigVariableBool dump_generated_shaders "to disk. This is useful for debugging broken shader " "generators.")); +ConfigVariableBool cache_generated_shaders +("cache-generated-shaders", true, + PRC_DESC("Set this true to cause all generated shaders to be cached in " + "memory. This is useful to prevent unnecessary recompilation.")); + ConfigVariableBool enforce_attrib_lock ("enforce-attrib-lock", true, PRC_DESC("When a MaterialAttrib, TextureAttrib, or LightAttrib is " diff --git a/panda/src/gobj/config_gobj.h b/panda/src/gobj/config_gobj.h index df8824b68b..b7634f0480 100644 --- a/panda/src/gobj/config_gobj.h +++ b/panda/src/gobj/config_gobj.h @@ -64,6 +64,7 @@ extern EXPCL_PANDA_GOBJ ConfigVariableBool display_list_animation; extern EXPCL_PANDA_GOBJ ConfigVariableBool connect_triangle_strips; extern EXPCL_PANDA_GOBJ ConfigVariableBool preserve_triangle_strips; extern EXPCL_PANDA_GOBJ ConfigVariableBool dump_generated_shaders; +extern EXPCL_PANDA_GOBJ ConfigVariableBool cache_generated_shaders; extern EXPCL_PANDA_GOBJ ConfigVariableBool enforce_attrib_lock; extern EXPCL_PANDA_GOBJ ConfigVariableBool vertices_float64; extern EXPCL_PANDA_GOBJ ConfigVariableInt vertex_column_alignment; diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index 35337bbfcc..5e5b269f10 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -60,7 +60,7 @@ protected: virtual PT(CopyOnWriteObject) make_cow_copy(); PUBLISHED: - Geom(const GeomVertexData *data); + explicit Geom(const GeomVertexData *data); protected: Geom(const Geom ©); diff --git a/panda/src/gobj/geomEnums.cxx b/panda/src/gobj/geomEnums.cxx index 4158560ea5..839d468113 100644 --- a/panda/src/gobj/geomEnums.cxx +++ b/panda/src/gobj/geomEnums.cxx @@ -151,6 +151,9 @@ operator << (ostream &out, GeomEnums::Contents contents) { case GeomEnums::C_matrix: return out << "matrix"; + + case GeomEnums::C_normal: + return out << "normal"; } return out << "**invalid contents (" << (int)contents << ")**"; diff --git a/panda/src/gobj/geomEnums.h b/panda/src/gobj/geomEnums.h index f0e4482512..97883733db 100644 --- a/panda/src/gobj/geomEnums.h +++ b/panda/src/gobj/geomEnums.h @@ -196,7 +196,7 @@ PUBLISHED: C_other, // Arbitrary meaning, leave it alone C_point, // A point in 3-space or 4-space C_clip_point, // A point pre-transformed into clip coordinates - C_vector, // A surface normal, tangent, or binormal + C_vector, // A surface tangent or binormal (see C_normal for normals) C_texcoord, // A texture coordinate C_color, // 3- or 4-component color, ordered R, G, B, [A] C_index, // An index value into some other table @@ -205,6 +205,10 @@ PUBLISHED: // A transformation matrix. This is typically three or four // columns, but we pretend it's only one for convenience. C_matrix, + + // A special version of C_vector that should be used for normal + // vectors, which are scaled differently from other vectors. + C_normal, }; // The type of animation data that is represented by a particular diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index e0aebb95e5..58ffbb6b46 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -68,8 +68,8 @@ protected: virtual PT(CopyOnWriteObject) make_cow_copy(); PUBLISHED: - GeomVertexArrayData(const GeomVertexArrayFormat *array_format, - UsageHint usage_hint); + explicit GeomVertexArrayData(const GeomVertexArrayFormat *array_format, + UsageHint usage_hint); GeomVertexArrayData(const GeomVertexArrayData ©); void operator = (const GeomVertexArrayData ©); virtual ~GeomVertexArrayData(); diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index 2c06afca7a..4406d7f82c 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -394,8 +394,11 @@ align_columns_for_animation() { Columns::const_iterator ci; for (ci = orig_columns.begin(); ci != orig_columns.end(); ++ci) { GeomVertexColumn *column = (*ci); - if ((column->get_contents() == C_point || column->get_contents() == C_vector) && - (column->get_numeric_type() == NT_float32 || column->get_numeric_type() == NT_float64) && + if ((column->get_contents() == C_point || + column->get_contents() == C_vector || + column->get_contents() == C_normal) && + (column->get_numeric_type() == NT_float32 || + column->get_numeric_type() == NT_float64) && column->get_num_components() >= 3) { add_column(column->get_name(), 4, column->get_numeric_type(), column->get_contents(), -1, 16); } else { diff --git a/panda/src/gobj/geomVertexColumn.I b/panda/src/gobj/geomVertexColumn.I index f9a33bfaf6..50268cd3f2 100644 --- a/panda/src/gobj/geomVertexColumn.I +++ b/panda/src/gobj/geomVertexColumn.I @@ -33,13 +33,16 @@ GeomVertexColumn() : INLINE GeomVertexColumn:: GeomVertexColumn(CPT_InternalName name, int num_components, NumericType numeric_type, Contents contents, - int start, int column_alignment) : + int start, int column_alignment, int num_elements, + int element_stride) : _name(MOVE(name)), _num_components(num_components), _numeric_type(numeric_type), _contents(contents), _start(start), _column_alignment(column_alignment), + _num_elements(num_elements), + _element_stride(element_stride), _packer(NULL) { setup(); @@ -58,6 +61,8 @@ GeomVertexColumn(const GeomVertexColumn ©) : _contents(copy._contents), _start(copy._start), _column_alignment(copy._column_alignment), + _num_elements(copy._num_elements), + _element_stride(copy._element_stride), _packer(NULL) { setup(); @@ -317,6 +322,12 @@ compare_to(const GeomVertexColumn &other) const { if (_column_alignment != other._column_alignment) { return _column_alignment - other._column_alignment; } + if (_num_elements != other._num_elements) { + return _num_elements - other._num_elements; + } + if (_element_stride != other._element_stride) { + return _element_stride - other._element_stride; + } return 0; } diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index e5cbe29e27..b803f3e1ac 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -30,6 +30,8 @@ operator = (const GeomVertexColumn ©) { _contents = copy._contents; _start = copy._start; _column_alignment = copy._column_alignment; + _num_elements = copy._num_elements; + _element_stride = copy._element_stride; setup(); } @@ -159,6 +161,10 @@ output(ostream &out) const { } out << ")"; + + if (_num_elements > 1) { + out << "[" << _num_elements << "]"; + } } //////////////////////////////////////////////////////////////////// @@ -172,7 +178,6 @@ setup() { nassertv(_num_components > 0 && _start >= 0); _num_values = _num_components; - _num_elements = 1; if (_numeric_type == NT_stdfloat) { if (vertices_float64) { @@ -222,8 +227,13 @@ setup() { break; } - if (_contents == C_matrix) { - _num_elements = _num_components; + if (_num_elements == 0) { + // Matrices are assumed to be square. + if (_contents == C_matrix) { + _num_elements = _num_components; + } else { + _num_elements = 1; + } } if (_column_alignment < 1) { @@ -236,7 +246,9 @@ setup() { // Enforce the column alignment requirements on the _start byte. _start = ((_start + _column_alignment - 1) / _column_alignment) * _column_alignment; - _element_stride = _component_bytes * _num_components; + if (_element_stride < 1) { + _element_stride = _component_bytes * _num_components; + } _total_bytes = _element_stride * _num_elements; if (_packer != NULL) { @@ -340,6 +352,12 @@ make_packer() const { } return new Packer_color; + case C_normal: + if (get_num_values() != 3 && get_num_values() != 4) { + gobj_cat.error() + << "GeomVertexColumn with contents C_normal must have 3 or 4 components!\n"; + } + default: // Otherwise, we just read it as a generic value. switch (get_numeric_type()) { @@ -433,6 +451,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _column_alignment = scan.get_uint8(); } + _num_elements = 0; + _element_stride = 0; + setup(); } @@ -3598,6 +3619,8 @@ get_data3f(const unsigned char *pointer) { _v3.set(v4[0], v4[1], v4[2]); return _v3; } + + return _v3; } //////////////////////////////////////////////////////////////////// @@ -3682,6 +3705,8 @@ get_data4f(const unsigned char *pointer) { return _v4; } } + + return _v4; } //////////////////////////////////////////////////////////////////// @@ -3817,6 +3842,8 @@ get_data3d(const unsigned char *pointer) { _v3d.set(v4[0], v4[1], v4[2]); return _v3d; } + + return _v3d; } //////////////////////////////////////////////////////////////////// @@ -3901,6 +3928,8 @@ get_data4d(const unsigned char *pointer) { return _v4d; } } + + return _v4d; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/geomVertexColumn.h b/panda/src/gobj/geomVertexColumn.h index 8629c786d5..8fab9952aa 100644 --- a/panda/src/gobj/geomVertexColumn.h +++ b/panda/src/gobj/geomVertexColumn.h @@ -43,7 +43,8 @@ private: PUBLISHED: INLINE GeomVertexColumn(CPT_InternalName name, int num_components, NumericType numeric_type, Contents contents, - int start, int column_alignment = 0); + int start, int column_alignment = 0, + int num_elements = 0, int element_stride = 0); INLINE GeomVertexColumn(const GeomVertexColumn ©); void operator = (const GeomVertexColumn ©); INLINE ~GeomVertexColumn(); @@ -346,7 +347,7 @@ private: } }; - class Packer_nativedouble_3 : public Packer_float64_3 { + class Packer_nativedouble_3 FINAL : public Packer_float64_3 { public: virtual const LVecBase3d &get_data3d(const unsigned char *pointer); @@ -355,7 +356,7 @@ private: } }; - class Packer_point_nativedouble_2 : public Packer_point_float64_2 { + class Packer_point_nativedouble_2 FINAL : public Packer_point_float64_2 { public: virtual const LVecBase2d &get_data2d(const unsigned char *pointer); @@ -364,7 +365,7 @@ private: } }; - class Packer_point_nativedouble_3 : public Packer_point_float64_3 { + class Packer_point_nativedouble_3 FINAL : public Packer_point_float64_3 { public: virtual const LVecBase3d &get_data3d(const unsigned char *pointer); @@ -382,7 +383,7 @@ private: } }; - class Packer_argb_packed : public Packer_color { + class Packer_argb_packed FINAL : public Packer_color { public: virtual const LVecBase4f &get_data4f(const unsigned char *pointer); virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value); @@ -392,7 +393,7 @@ private: } }; - class Packer_rgba_uint8_4 : public Packer_color { + class Packer_rgba_uint8_4 FINAL : public Packer_color { public: virtual const LVecBase4f &get_data4f(const unsigned char *pointer); virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value); @@ -412,7 +413,7 @@ private: } }; - class Packer_rgba_nativefloat_4 : public Packer_rgba_float32_4 { + class Packer_rgba_nativefloat_4 FINAL : public Packer_rgba_float32_4 { public: virtual const LVecBase4f &get_data4f(const unsigned char *pointer); @@ -421,7 +422,7 @@ private: } }; - class Packer_uint16_1 : public Packer { + class Packer_uint16_1 FINAL : public Packer { public: virtual int get_data1i(const unsigned char *pointer); virtual void set_data1i(unsigned char *pointer, int value); diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 29273254e1..d2202e1831 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -1915,10 +1915,37 @@ do_transform_point_column(const GeomVertexFormat *format, GeomVertexRewriter &da //////////////////////////////////////////////////////////////////// void GeomVertexData:: do_transform_vector_column(const GeomVertexFormat *format, GeomVertexRewriter &data, - const LMatrix4 &mat, int begin_row, int end_row) { + const LMatrix4 &mat, int begin_row, int end_row) { const GeomVertexColumn *data_column = data.get_column(); int num_values = data_column->get_num_values(); + LMatrix4 xform; + bool normalize = false; + if (data_column->get_contents() == C_normal) { + // This is to preserve perpendicularity to the surface. + LVecBase3 scale, shear, hpr; + if (decompose_matrix(mat.get_upper_3(), scale, shear, hpr) && + IS_NEARLY_EQUAL(scale[0], scale[1]) && + IS_NEARLY_EQUAL(scale[0], scale[2])) { + if (scale[0] == 1) { + // No scale to worry about. + xform = mat; + } else { + // Simply take the uniform scale out of the transformation. + // Not sure if it might be better to just normalize? + compose_matrix(xform, LVecBase3(1, 1, 1), shear, hpr, LVecBase3::zero()); + } + } else { + // There is a non-uniform scale, so we need to do all this to + // preserve orthogonality to the surface. + xform.invert_from(mat); + xform.transpose_in_place(); + normalize = true; + } + } else { + xform = mat; + } + if ((num_values == 3 || num_values == 4) && data_column->get_numeric_type() == NT_float32) { // The table of vectors is a table of LVector3f's or LVector4f's. @@ -1929,9 +1956,11 @@ do_transform_vector_column(const GeomVertexFormat *format, GeomVertexRewriter &d size_t num_rows = end_row - begin_row; unsigned char *datat = data_handle->get_write_pointer(); datat += data_column->get_start() + begin_row * stride; - LMatrix4f matf = LCAST(float, mat); + LMatrix4f matf = LCAST(float, xform); - if (num_values == 3) { + if (normalize) { + table_xform_normal3f(datat, num_rows, stride, matf); + } else if (num_values == 3) { table_xform_vector3f(datat, num_rows, stride, matf); } else { table_xform_vecbase4f(datat, num_rows, stride, matf); @@ -1939,11 +1968,20 @@ do_transform_vector_column(const GeomVertexFormat *format, GeomVertexRewriter &d } else { // Use the GeomVertexRewriter to transform the vectors. - data.set_row_unsafe(begin_row); - for (int j = begin_row; j < end_row; ++j) { - LVector3 vertex = data.get_data3(); - data.set_data3(vertex * mat); + + if (normalize) { + for (int j = begin_row; j < end_row; ++j) { + LVector3 vector = data.get_data3(); + vector *= xform; + vector.normalize(); + data.set_data3(vector); + } + } else { + for (int j = begin_row; j < end_row; ++j) { + LVector3 vector = data.get_data3(); + data.set_data3(vector * xform); + } } } } @@ -1965,6 +2003,25 @@ table_xform_point3f(unsigned char *datat, size_t num_rows, size_t stride, } } +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexData::table_xform_normal3f +// Access: Private, Static +// Description: Transforms each of the LVector3f objects in the +// indicated table by the indicated matrix, and also +// normalizes them. +//////////////////////////////////////////////////////////////////// +void GeomVertexData:: +table_xform_normal3f(unsigned char *datat, size_t num_rows, size_t stride, + const LMatrix4f &matf) { + // We don't bother checking for the unaligned case here, because in + // practice it doesn't matter with a 3-component vector. + for (size_t i = 0; i < num_rows; ++i) { + LNormalf &vertex = *(LNormalf *)(&datat[i * stride]); + vertex *= matf; + vertex.normalize(); + } +} + //////////////////////////////////////////////////////////////////// // Function: GeomVertexData::table_xform_vector3f // Access: Private, Static diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 034018430a..de1b3d23d1 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -80,12 +80,12 @@ protected: virtual PT(CopyOnWriteObject) make_cow_copy(); PUBLISHED: - GeomVertexData(const string &name, - const GeomVertexFormat *format, - UsageHint usage_hint); + explicit GeomVertexData(const string &name, + const GeomVertexFormat *format, + UsageHint usage_hint); GeomVertexData(const GeomVertexData ©); - GeomVertexData(const GeomVertexData ©, - const GeomVertexFormat *format); + explicit GeomVertexData(const GeomVertexData ©, + const GeomVertexFormat *format); void operator = (const GeomVertexData ©); virtual ~GeomVertexData(); ALLOC_DELETED_CHAIN(GeomVertexData); @@ -339,6 +339,8 @@ private: const LMatrix4 &mat, int begin_row, int end_row); static void table_xform_point3f(unsigned char *datat, size_t num_rows, size_t stride, const LMatrix4f &matf); + static void table_xform_normal3f(unsigned char *datat, size_t num_rows, + size_t stride, const LMatrix4f &matf); static void table_xform_vector3f(unsigned char *datat, size_t num_rows, size_t stride, const LMatrix4f &matf); static void table_xform_vecbase4f(unsigned char *datat, size_t num_rows, diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index b0fd53515c..ec5a29436e 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -825,6 +825,7 @@ do_register() { break; case C_vector: + case C_normal: // It's a vector. _vectors.push_back(column->get_name()); break; @@ -1017,7 +1018,7 @@ make_standard_formats() { (InternalName::get_vertex(), 3, NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_stdfloat, C_vector)); + NT_stdfloat, C_normal)); _v3t2 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, @@ -1029,7 +1030,7 @@ make_standard_formats() { (InternalName::get_vertex(), 3, NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_stdfloat, C_vector, + NT_stdfloat, C_normal, InternalName::get_texcoord(), 2, NT_stdfloat, C_texcoord)); @@ -1044,7 +1045,7 @@ make_standard_formats() { (InternalName::get_vertex(), 3, NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_stdfloat, C_vector, + NT_stdfloat, C_normal, InternalName::get_color(), 1, NT_packed_dabc, C_color)); @@ -1060,7 +1061,7 @@ make_standard_formats() { (InternalName::get_vertex(), 3, NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_stdfloat, C_vector, + NT_stdfloat, C_normal, InternalName::get_color(), 1, NT_packed_dabc, C_color, InternalName::get_texcoord(), 2, @@ -1079,7 +1080,7 @@ make_standard_formats() { (InternalName::get_vertex(), 3, NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_stdfloat, C_vector, + NT_stdfloat, C_normal, InternalName::get_color(), 4, NT_uint8, C_color)); @@ -1095,7 +1096,7 @@ make_standard_formats() { (InternalName::get_vertex(), 3, NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_stdfloat, C_vector, + NT_stdfloat, C_normal, InternalName::get_color(), 4, NT_uint8, C_color, InternalName::get_texcoord(), 2, diff --git a/panda/src/gobj/perspectiveLens.cxx b/panda/src/gobj/perspectiveLens.cxx index b1fdb0ab6e..fcc8868662 100644 --- a/panda/src/gobj/perspectiveLens.cxx +++ b/panda/src/gobj/perspectiveLens.cxx @@ -82,12 +82,18 @@ do_compute_projection_mat(Lens::CData *lens_cdata) { PN_stdfloat fl = do_get_focal_length(lens_cdata); PN_stdfloat fFar = do_get_far(lens_cdata); PN_stdfloat fNear = do_get_near(lens_cdata); - PN_stdfloat far_minus_near = fFar-fNear; - PN_stdfloat a = (fFar + fNear); - PN_stdfloat b = -2.0f * fFar * fNear; + PN_stdfloat a, b; - a /= far_minus_near; - b /= far_minus_near; + if (cinf(fFar)) { + a = 1; + b = -2 * fNear; + } else { + PN_stdfloat far_minus_near = fFar-fNear; + a = (fFar + fNear); + b = -2 * fFar * fNear; + a /= far_minus_near; + b /= far_minus_near; + } LMatrix4 canonical; switch (cs) { diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index e101a07dfc..eccb05d79f 100644 --- a/panda/src/gobj/shader.I +++ b/panda/src/gobj/shader.I @@ -49,7 +49,7 @@ get_filename(const ShaderType &type) const { } else { // Um, better than nothing? - return _filename._vertex; + return _filename._fragment; } } @@ -865,7 +865,7 @@ get_filename_from_index(int index, ShaderType type) const { if (!fn.empty()) { return fn; } - } else if (glsl_preprocess && index > 2048 && + } else if (glsl_preprocess && index >= 2048 && (index - 2048) < (int)_included_files.size()) { return _included_files[index - 2048]; } diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index ced776921d..8f1cc70d33 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -413,8 +413,10 @@ cp_dependency(ShaderMatInput inp) { if (inp == SMO_attr_fog || inp == SMO_attr_fogcolor) { dep |= SSD_fog; } - if ((inp == SMO_model_to_view)|| - (inp == SMO_view_to_model)) { + if ((inp == SMO_model_to_view) || + (inp == SMO_view_to_model) || + (inp == SMO_model_to_apiview) || + (inp == SMO_apiview_to_model)) { dep |= SSD_transform; } if ((inp == SMO_texpad_x) || @@ -483,6 +485,43 @@ cp_optimize_mat_spec(ShaderMatSpec &spec) { spec._part[0] = spec._part[1]; spec._arg[0] = spec._arg[1]; } + + // More optimal combinations for common matrices. + + if (spec._part[0] == SMO_model_to_view && + spec._part[1] == SMO_view_to_apiclip) { + spec._part[0] = SMO_model_to_apiview; + spec._part[1] = SMO_apiview_to_apiclip; + + } else if (spec._part[0] == SMO_apiclip_to_view && + spec._part[1] == SMO_view_to_model) { + spec._part[0] = SMO_apiclip_to_apiview; + spec._part[1] = SMO_apiview_to_model; + + } else if (spec._part[0] == SMO_apiview_to_view && + spec._part[1] == SMO_view_to_apiclip) { + spec._func = SMF_first; + spec._part[0] = SMO_apiview_to_apiclip; + spec._part[1] = SMO_identity; + + } else if (spec._part[0] == SMO_apiclip_to_view && + spec._part[1] == SMO_view_to_apiview) { + spec._func = SMF_first; + spec._part[0] = SMO_apiclip_to_apiview; + spec._part[1] = SMO_identity; + + } else if (spec._part[0] == SMO_apiview_to_view && + spec._part[1] == SMO_view_to_model) { + spec._func = SMF_first; + spec._part[0] = SMO_apiview_to_model; + spec._part[1] = SMO_identity; + + } else if (spec._part[0] == SMO_model_to_view && + spec._part[1] == SMO_view_to_apiview) { + spec._func = SMF_first; + spec._part[0] = SMO_model_to_apiview; + spec._part[1] = SMO_identity; + } } // Calculate state and transform dependencies. @@ -514,6 +553,7 @@ cg_recurse_parameters(CGparameter parameter, const ShaderType &type, ShaderArgClass arg_subclass = arg_class; CGenum vbl = cgGetParameterVariability(parameter); + CGtype base_type = cgGetParameterBaseType(parameter); if ((vbl==CG_VARYING)||(vbl==CG_UNIFORM)) { switch (cgGetParameterType(parameter)) { @@ -528,16 +568,28 @@ cg_recurse_parameters(CGparameter parameter, const ShaderType &type, arg_dim[0] = cgGetArraySize(parameter, 0); + // Fall through default: { arg_dim[1] = cgGetParameterRows(parameter); arg_dim[2] = cgGetParameterColumns(parameter); - ShaderArgId id; - id._name = cgGetParameterName(parameter); - id._type = type; - id._seqno = -1; - success &= compile_parameter(id, arg_class, arg_subclass, arg_type, - arg_dir, (vbl == CG_VARYING), arg_dim, shader_cat.get_safe_ptr()); break; + ShaderArgInfo p; + p._id._name = cgGetParameterName(parameter); + p._id._type = type; + p._id._seqno = -1; + p._class = arg_class; + p._subclass = arg_subclass; + p._type = arg_type; + p._direction = arg_dir; + p._varying = (vbl == CG_VARYING); + p._integer = (base_type == CG_UINT || base_type == CG_INT || + base_type == CG_ULONG || base_type == CG_LONG || + base_type == CG_USHORT || base_type == CG_SHORT || + base_type == CG_UCHAR || base_type == CG_CHAR); + p._cat = shader_cat.get_safe_ptr(); + + success &= compile_parameter(p, arg_dim); + break; } } } @@ -562,24 +614,7 @@ cg_recurse_parameters(CGparameter parameter, const ShaderType &type, // an error message onto the error messages. //////////////////////////////////////////////////////////////////// bool Shader:: -compile_parameter(const ShaderArgId &arg_id, - const ShaderArgClass &arg_class, - const ShaderArgClass &arg_subclass, - const ShaderArgType &arg_type, - const ShaderArgDir &arg_direction, - bool arg_varying, - int *arg_dim, - NotifyCategory *arg_cat) -{ - ShaderArgInfo p; - p._id = arg_id; - p._class = arg_class; - p._subclass = arg_subclass; - p._type = arg_type; - p._direction = arg_direction; - p._varying = arg_varying; - p._cat = arg_cat; - +compile_parameter(ShaderArgInfo &p, int *arg_dim) { if (p._id._name.size() == 0) return true; if (p._id._name[0] == '$') return true; @@ -611,9 +646,9 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderVarSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._append_uv = -1; - bind._integer = false; + bind._integer = p._integer; if (pieces.size() == 2) { if (pieces[1] == "position") { @@ -646,6 +681,24 @@ compile_parameter(const ShaderArgId &arg_id, _var_spec.push_back(bind); return true; } + } else if (pieces.size() == 3) { + if (pieces[1] == "transform") { + if (pieces[2] == "blend") { + bind._name = InternalName::get_transform_blend(); + _var_spec.push_back(bind); + return true; + } + if (pieces[2] == "index") { + bind._name = InternalName::get_transform_index(); + _var_spec.push_back(bind); + return true; + } + if (pieces[2] == "weight") { + bind._name = InternalName::get_transform_weight(); + _var_spec.push_back(bind); + return true; + } + } } bind._name = InternalName::get_root(); @@ -754,7 +807,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._func = SMF_compose; int next = 1; @@ -817,7 +870,7 @@ compile_parameter(const ShaderArgId &arg_id, if (!cp_errchk_parameter_float(p,16,16)) { return false; } - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_transpose; bind._func = SMF_first; bind._part[0] = SMO_attr_material; @@ -828,7 +881,7 @@ compile_parameter(const ShaderArgId &arg_id, if (!cp_errchk_parameter_float(p,3,4)) { return false; } - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_color; @@ -839,7 +892,7 @@ compile_parameter(const ShaderArgId &arg_id, if (!cp_errchk_parameter_float(p,3,4)) { return false; } - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_colorscale; @@ -850,7 +903,7 @@ compile_parameter(const ShaderArgId &arg_id, if (!cp_errchk_parameter_float(p,3,4)) { return false; } - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_fog; @@ -861,7 +914,7 @@ compile_parameter(const ShaderArgId &arg_id, if (!cp_errchk_parameter_float(p,3,4)) { return false; } - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_fogcolor; @@ -901,7 +954,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_alight_x; @@ -922,7 +975,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_satten_x; @@ -942,7 +995,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_transpose; int next = 1; pieces.push_back(""); @@ -984,7 +1037,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_whole; bind._func = SMF_first; bind._part[0] = SMO_texmat_x; @@ -1005,7 +1058,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_plane_x; @@ -1026,7 +1079,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_clipplane_x; @@ -1048,7 +1101,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[1] = SMO_identity; @@ -1097,7 +1150,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderTexSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._name = 0; bind._stage = atoi(pieces[1].c_str()); switch (p._type) { @@ -1129,7 +1182,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_texpad_x; @@ -1149,7 +1202,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; } ShaderMatSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_texpix_x; @@ -1161,6 +1214,11 @@ compile_parameter(const ShaderArgId &arg_id, return true; } + if (pieces[0] == "tbl") { + // Handled elsewhere. + return true; + } + if (pieces[0] == "l") { // IMPLEMENT THE ERROR CHECKING return true; // Cg handles this automatically. @@ -1196,7 +1254,7 @@ compile_parameter(const ShaderArgId &arg_id, return false; ShaderPtrSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._arg = kinputname; bind._info = p; bind._dep[0] = SSD_general | SSD_shaderinputs; @@ -1214,7 +1272,7 @@ compile_parameter(const ShaderArgId &arg_id, switch (p._type) { case SAT_sampler1d: { ShaderTexSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._name = kinputname; bind._desired_type = Texture::TT_1d_texture; _tex_spec.push_back(bind); @@ -1222,7 +1280,7 @@ compile_parameter(const ShaderArgId &arg_id, } case SAT_sampler2d: { ShaderTexSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._name = kinputname; bind._desired_type = Texture::TT_2d_texture; _tex_spec.push_back(bind); @@ -1230,7 +1288,7 @@ compile_parameter(const ShaderArgId &arg_id, } case SAT_sampler3d: { ShaderTexSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._name = kinputname; bind._desired_type = Texture::TT_3d_texture; _tex_spec.push_back(bind); @@ -1238,7 +1296,7 @@ compile_parameter(const ShaderArgId &arg_id, } case SAT_sampler2dArray: { ShaderTexSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._name = kinputname; bind._desired_type = Texture::TT_2d_texture_array; _tex_spec.push_back(bind); @@ -1246,7 +1304,7 @@ compile_parameter(const ShaderArgId &arg_id, } case SAT_samplercube: { ShaderTexSpec bind; - bind._id = arg_id; + bind._id = p._id; bind._name = kinputname; bind._desired_type = Texture::TT_cube_map; _tex_spec.push_back(bind); @@ -1346,7 +1404,8 @@ cg_parameter_type(CGparameter p) { default: return SAT_unknown; } case CG_PARAMETERCLASS_ARRAY: return SAT_unknown; - default: return SAT_unknown; + default: + return SAT_unknown; } } @@ -1446,15 +1505,14 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, ultimate = CG_PROFILE_UNKNOWN; }; - cgGetError(); - if (type == ST_fragment && caps._bug_list.count(SBUG_ati_draw_buffers)) { compiler_args[nargs++] = "-po"; compiler_args[nargs++] = "ATI_draw_buffers"; } char version_arg[16]; - if (!cg_glsl_version.empty() && cgGetProfileProperty((CGprofile) active, CG_IS_GLSL_PROFILE)) { + if (!cg_glsl_version.empty() && active != CG_PROFILE_UNKNOWN && + cgGetProfileProperty((CGprofile) active, CG_IS_GLSL_PROFILE)) { snprintf(version_arg, 16, "version=%s", cg_glsl_version.c_str()); compiler_args[nargs++] = "-po"; compiler_args[nargs++] = version_arg; @@ -1462,6 +1520,8 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, compiler_args[nargs] = 0; + cgGetError(); + if ((active != (int)CG_PROFILE_UNKNOWN) && (active != ultimate)) { // Print out some debug information about what we're doing. if (shader_cat.is_debug()) { @@ -1491,6 +1551,12 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, if (shader_cat.is_debug()) { shader_cat.debug() << "Compilation with active profile failed: " << cgGetErrorString(err) << "\n"; + if (err == CG_COMPILER_ERROR) { + const char *listing = cgGetLastListing(context); + if (listing != NULL) { + shader_cat.debug(false) << listing; + } + } } } @@ -1527,6 +1593,11 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, return prog; } + if (shader_cat.is_debug()) { + shader_cat.debug() + << "Compilation with ultimate profile failed: " << cgGetErrorString(err) << "\n"; + } + if (prog != 0) { cgDestroyProgram(prog); } @@ -1587,19 +1658,19 @@ cg_compile_shader(const ShaderCaps &caps, CGcontext context) { shader_cat.debug() << "Cg vertex profile: " << cgGetProfileString((CGprofile)_cg_vprofile) << "\n"; vertex_program = cgGetProgramString(_cg_vprogram, CG_COMPILED_PROGRAM); - shader_cat.debug() << vertex_program << "\n"; + shader_cat.spam() << vertex_program << "\n"; } if (_cg_fprogram != 0) { shader_cat.debug() << "Cg fragment profile: " << cgGetProfileString((CGprofile)_cg_fprofile) << "\n"; fragment_program = cgGetProgramString(_cg_fprogram, CG_COMPILED_PROGRAM); - shader_cat.debug() << fragment_program << "\n"; + shader_cat.spam() << fragment_program << "\n"; } if (_cg_gprogram != 0) { shader_cat.debug() << "Cg geometry profile: " << cgGetProfileString((CGprofile)_cg_gprofile) << "\n"; geometry_program = cgGetProgramString(_cg_gprogram, CG_COMPILED_PROGRAM); - shader_cat.debug() << geometry_program << "\n"; + shader_cat.spam() << geometry_program << "\n"; } } @@ -1700,17 +1771,18 @@ cg_analyze_shader(const ShaderCaps &caps) { } } - // Assign sequence numbers to all parameters. + // Assign sequence numbers to all parameters. GLCgShaderContext relies + // on the fact that the varyings start at seqno 0. int seqno = 0; + for (int i=0; i<(int)_var_spec.size(); i++) { + _var_spec[i]._id._seqno = seqno++; + } for (int i=0; i<(int)_mat_spec.size(); i++) { _mat_spec[i]._id._seqno = seqno++; } for (int i=0; i<(int)_tex_spec.size(); i++) { _tex_spec[i]._id._seqno = seqno++; } - for (int i=0; i<(int)_var_spec.size(); i++) { - _var_spec[i]._id._seqno = seqno++; - } for (int i=0; i<(int)_ptr_spec.size(); i++) { _ptr_spec[i]._id._seqno = seqno++; @@ -1790,6 +1862,7 @@ cg_analyze_shader(const ShaderCaps &caps) { // } // } + cg_release_resources(); return true; } @@ -1909,7 +1982,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, const char *resource = cgGetParameterResourceName(p); if (resource != NULL) { shader_cat.debug() << "Texture parameter " << id._name - << " is bound to resource " << resource << "\n"; + << " is bound to resource " << resource << "\n"; } } map[id._seqno] = p; @@ -1921,48 +1994,18 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, const char *resource = cgGetParameterResourceName(p); if (shader_cat.is_debug() && resource != NULL) { - shader_cat.debug() - << "Varying parameter " << id._name << " is bound to resource " - << cgGetParameterResourceName(p) << "\n"; + if (cgGetParameterResource(p) == CG_GLSL_ATTRIB) { + shader_cat.debug() + << "Varying parameter " << id._name << " is bound to GLSL attribute " + << resource << "\n"; + } else { + shader_cat.debug() + << "Varying parameter " << id._name << " is bound to resource " + << resource << " (" << cgGetParameterResource(p) + << ", index " << cgGetParameterResourceIndex(p) << ")\n"; + } } - if (cgGetParameterBaseResource(p) == CG_UNDEFINED) { - // I really don't know what this means, but it happens when I - // use the NORMAL0 semantic instead of NORMAL, or POSITION0 - // instead of POSITION, etc. Not catching this results in a - // continuous stream of errors at the renderer side. - shader_cat.error() - << "Varying parameter " << id._name; - - const char *semantic = cgGetParameterSemantic(p); - if (semantic != NULL) { - shader_cat.error(false) << " : " << semantic; - } - if (resource != NULL) { - shader_cat.error(false) << " (bound to resource " << resource << ")"; - } - shader_cat.error(false) << " is invalid!\n"; - -#ifndef NDEBUG - // Let's try to give the developer a hint... - if (semantic != NULL) { - if (strcmp(semantic, "POSITION0") == 0) { - shader_cat.error() << "Try using the semantic POSITION instead of POSITION0.\n"; - } else if (strcmp(semantic, "NORMAL0") == 0) { - shader_cat.error() << "Try using the semantic NORMAL instead of NORMAL0.\n"; - } else if (strcmp(semantic, "DIFFUSE0") == 0) { - shader_cat.error() << "Try using the semantic DIFFUSE instead of DIFFUSE0.\n"; - } else if (strcmp(semantic, "SPECULAR0") == 0) { - shader_cat.error() << "Try using the semantic SPECULAR instead of SPECULAR0.\n"; - } else if (strcmp(semantic, "FOGCOORD0") == 0) { - shader_cat.error() << "Try using the semantic FOGCOORD instead of FOGCOORD0.\n"; - } else if (strcmp(semantic, "PSIZE0") == 0) { - shader_cat.error() << "Try using the semantic PSIZE instead of PSIZE0.\n"; - } - } -#endif // NDEBUG - p = 0; - } map[id._seqno] = p; } @@ -2013,9 +2056,9 @@ Shader(ShaderLanguage lang) : _cg_fprofile = CG_PROFILE_UNKNOWN; _cg_gprofile = CG_PROFILE_UNKNOWN; if (_default_caps._ultimate_vprofile == 0 || _default_caps._ultimate_vprofile == CG_PROFILE_UNKNOWN) { - _default_caps._active_vprofile = CG_PROFILE_UNKNOWN; - _default_caps._active_fprofile = CG_PROFILE_UNKNOWN; - _default_caps._active_gprofile = CG_PROFILE_UNKNOWN; + _default_caps._active_vprofile = CG_PROFILE_GENERIC; + _default_caps._active_fprofile = CG_PROFILE_GENERIC; + _default_caps._active_gprofile = CG_PROFILE_GENERIC; _default_caps._ultimate_vprofile = cgGetProfile("glslv"); _default_caps._ultimate_fprofile = cgGetProfile("glslf"); _default_caps._ultimate_gprofile = cgGetProfile("glslg"); @@ -2618,9 +2661,12 @@ make(const string &body, ShaderLanguage lang) { #endif ShaderFile sbody(body); - ShaderTable::const_iterator i = _make_table.find(sbody); - if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { - return i->second; + + if (cache_generated_shaders) { + ShaderTable::const_iterator i = _make_table.find(sbody); + if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { + return i->second; + } } PT(Shader) shader = new Shader(lang); @@ -2639,7 +2685,9 @@ make(const string &body, ShaderLanguage lang) { } #endif - _make_table[sbody] = shader; + if (cache_generated_shaders) { + _make_table[sbody] = shader; + } if (dump_generated_shaders) { ostringstream fns; @@ -2679,9 +2727,11 @@ make(ShaderLanguage lang, const string &vertex, const string &fragment, ShaderFile sbody(vertex, fragment, geometry, tess_control, tess_evaluation); - ShaderTable::const_iterator i = _make_table.find(sbody); - if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { - return i->second; + if (cache_generated_shaders) { + ShaderTable::const_iterator i = _make_table.find(sbody); + if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { + return i->second; + } } PT(Shader) shader = new Shader(lang); @@ -2698,8 +2748,10 @@ make(ShaderLanguage lang, const string &vertex, const string &fragment, } #endif + if (cache_generated_shaders) { + _make_table[sbody] = shader; + } - _make_table[sbody] = shader; return shader; } @@ -2720,16 +2772,22 @@ make_compute(ShaderLanguage lang, const string &body) { sbody._separate = true; sbody._compute = body; - ShaderTable::const_iterator i = _make_table.find(sbody); - if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { - return i->second; + + if (cache_generated_shaders) { + ShaderTable::const_iterator i = _make_table.find(sbody); + if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { + return i->second; + } } PT(Shader) shader = new Shader(lang); shader->_filename = ShaderFile("created-shader"); shader->_text = sbody; - _make_table[sbody] = shader; + if (cache_generated_shaders) { + _make_table[sbody] = shader; + } + return shader; } diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 805e2ea4f6..e56960b1f5 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -186,6 +186,11 @@ public: // SMO_clipplane_x is world coords, GLSL needs eye coords SMO_apiview_clipplane_i, + SMO_model_to_apiview, + SMO_apiview_to_model, + SMO_apiview_to_apiclip, + SMO_apiclip_to_apiview, + SMO_INVALID }; @@ -292,6 +297,7 @@ public: ShaderArgType _type; ShaderArgDir _direction; bool _varying; + bool _integer; NotifyCategory *_cat; }; @@ -473,14 +479,7 @@ public: bool &success); #endif - bool compile_parameter(const ShaderArgId &arg_id, - const ShaderArgClass &arg_class, - const ShaderArgClass &arg_subclass, - const ShaderArgType &arg_type, - const ShaderArgDir &arg_direction, - bool arg_varying, - int *arg_dim, - NotifyCategory *arg_cat); + bool compile_parameter(ShaderArgInfo &p, int *arg_dim); void clear_parameters(); diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 4aeaf4b259..6c6b945d2f 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -1105,6 +1105,28 @@ get_default_sampler() const { return cdata->_default_sampler; } +//////////////////////////////////////////////////////////////////// +// Function: Texture::set_default_sampler +// Access: Published +// Description: This sets the default sampler state for this +// texture, containing the wrap and filter properties +// specified on the texture level; it may still be +// overridden by a sampler state specified at a higher +// level. This encompasses the settings for get_wrap_u, +// get_minfilter, get_anisotropic_degree, etc. +// +// This makes a copy of the SamplerState object, so +// future modifications of the same SamplerState will +// have no effect on this texture unless you call +// set_default_sampler again. +//////////////////////////////////////////////////////////////////// +INLINE void Texture:: +set_default_sampler(const SamplerState &sampler) { + CDWriter cdata(_cycler, true); + cdata->_default_sampler = sampler; + cdata->inc_properties_modified(); +} + //////////////////////////////////////////////////////////////////// // Function: Texture::get_wrap_u // Access: Published diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 13137221f0..66bbe6767e 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -2892,6 +2892,8 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa } image.copy_header_from(*image_reader); + AutoTextureScale auto_texture_scale = do_get_auto_texture_scale(cdata); + // If it's a floating-point image file, read it by default into a // floating-point texture. bool read_floating_point; @@ -2929,9 +2931,7 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa y_size = 1; } else { - consider_rescale(image, fullpath.get_basename(), do_get_auto_texture_scale(cdata)); - x_size = image.get_read_x_size(); - y_size = image.get_read_y_size(); + adjust_size(x_size, y_size, fullpath.get_basename(), false, auto_texture_scale); } if (read_floating_point) { @@ -2949,9 +2949,15 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa } else { if (z == 0 && n == 0) { - cdata->_orig_file_x_size = image.get_x_size(); - cdata->_orig_file_y_size = image.get_y_size(); - consider_rescale(image, fullpath.get_basename(), do_get_auto_texture_scale(cdata)); + int x_size = image.get_x_size(); + int y_size = image.get_y_size(); + + cdata->_orig_file_x_size = x_size; + cdata->_orig_file_y_size = y_size; + + if (adjust_size(x_size, y_size, fullpath.get_basename(), false, auto_texture_scale)) { + image.set_read_size(x_size, y_size); + } } else { image.set_read_size(do_get_expected_mipmap_x_size(cdata, n), do_get_expected_mipmap_y_size(cdata, n)); @@ -3080,10 +3086,16 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa if (alpha_file_channel == 4 || (alpha_file_channel == 2 && alpha_image.get_num_channels() == 2)) { - // Use the alpha channel. - for (int x = 0; x < image.get_x_size(); x++) { - for (int y = 0; y < image.get_y_size(); y++) { - image.set_alpha(x, y, alpha_image.get_alpha(x, y)); + + if (!alpha_image.has_alpha()) { + gobj_cat.error() + << alpha_fullpath.get_basename() << " has no channel " << alpha_file_channel << ".\n"; + } else { + // Use the alpha channel. + for (int x = 0; x < image.get_x_size(); x++) { + for (int y = 0; y < image.get_y_size(); y++) { + image.set_alpha(x, y, alpha_image.get_alpha(x, y)); + } } } cdata->_alpha_file_channel = alpha_image.get_num_channels(); diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index f19b1ef8fa..d3fc0c4bb8 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -43,6 +43,7 @@ #include "pnmImage.h" #include "colorSpace.h" #include "geomEnums.h" +#include "bamCacheRecord.h" class PNMImage; class PfmFile; @@ -51,7 +52,6 @@ class FactoryParams; class PreparedGraphicsObjects; class CullTraverser; class CullTraverserData; -class BamCacheRecord; class TexturePeeker; struct DDSHeader; @@ -321,6 +321,7 @@ PUBLISHED: INLINE void set_render_to_texture(bool render_to_texture); INLINE const SamplerState &get_default_sampler() const; + INLINE void set_default_sampler(const SamplerState &sampler); INLINE SamplerState::WrapMode get_wrap_u() const; INLINE SamplerState::WrapMode get_wrap_v() const; INLINE SamplerState::WrapMode get_wrap_w() const; diff --git a/panda/src/gobj/textureStage.h b/panda/src/gobj/textureStage.h index 9831124864..9623f141a8 100644 --- a/panda/src/gobj/textureStage.h +++ b/panda/src/gobj/textureStage.h @@ -37,7 +37,7 @@ class FactoryParams; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_GOBJ TextureStage : public TypedWritableReferenceCount { PUBLISHED: - TextureStage(const string &name); + explicit TextureStage(const string &name); INLINE TextureStage(TextureStage ©); void operator = (const TextureStage ©); diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index 58457c01a7..cbd0beb187 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -180,6 +180,10 @@ clear_window() { //////////////////////////////////////////////////////////////////// bool FrameRateMeter:: cull_callback(CullTraverser *trav, CullTraverserData &data) { + // This triggers when you try to parent a frame rate meter into + // the scene graph yourself. Instead, use setup_window(). + nassertr(_display_region != NULL, false); + Thread *current_thread = trav->get_current_thread(); // Statistics diff --git a/panda/src/grutil/geoMipTerrain.I b/panda/src/grutil/geoMipTerrain.I index 3d972cb7bf..a80703c9e3 100644 --- a/panda/src/grutil/geoMipTerrain.I +++ b/panda/src/grutil/geoMipTerrain.I @@ -385,8 +385,11 @@ get_flatten_mode() { //////////////////////////////////////////////////////////////////// INLINE const NodePath GeoMipTerrain:: get_block_node_path(unsigned short mx, unsigned short my) { + nassertr(mx < _blocks.size(), NodePath::fail()); + nassertr(my < _blocks[mx].size(), NodePath::fail()); return _blocks[mx][my]; } + //////////////////////////////////////////////////////////////////// // Function: GeoMipTerrain::get_block_from_pos // Access: Published diff --git a/panda/src/grutil/geoMipTerrain.cxx b/panda/src/grutil/geoMipTerrain.cxx index 145ba37131..c236564172 100644 --- a/panda/src/grutil/geoMipTerrain.cxx +++ b/panda/src/grutil/geoMipTerrain.cxx @@ -63,7 +63,7 @@ generate_block(unsigned short mx, array->add_column(InternalName::get_texcoord(), 2, Geom::NT_stdfloat, Geom::C_texcoord); array->add_column(InternalName::get_normal(), 3, - Geom::NT_stdfloat, Geom::C_vector); + Geom::NT_stdfloat, Geom::C_normal); PT(GeomVertexFormat) format = new GeomVertexFormat(); format->add_array(array); diff --git a/panda/src/grutil/pfmVizzer.cxx b/panda/src/grutil/pfmVizzer.cxx index 1304d59bea..1d84cd6331 100644 --- a/panda/src/grutil/pfmVizzer.cxx +++ b/panda/src/grutil/pfmVizzer.cxx @@ -1062,7 +1062,7 @@ make_array_format(const VisColumns &vis_columns) const { case CT_normal3: num_components = 3; numeric_type = GeomEnums::NT_float32; - contents = GeomEnums::C_vector; + contents = GeomEnums::C_normal; break; case CT_blend1: @@ -1072,7 +1072,7 @@ make_array_format(const VisColumns &vis_columns) const { break; } nassertr(num_components != 0, NULL); - + array_format->add_column(name, num_components, numeric_type, contents); } diff --git a/panda/src/linmath/Sources.pp b/panda/src/linmath/Sources.pp index e4134e688e..286d812509 100644 --- a/panda/src/linmath/Sources.pp +++ b/panda/src/linmath/Sources.pp @@ -11,33 +11,19 @@ #define SOURCES \ aa_luse.h \ compose_matrix.h compose_matrix_src.I \ - compose_matrix_src.cxx compose_matrix_src.h config_linmath.h \ + config_linmath.h \ configVariableColor.h configVariableColor.I \ coordinateSystem.h dbl2fltnames.h dblnames.h \ deg_2_rad.h deg_2_rad.I \ - flt2dblnames.h fltnames.h intnames.h lcast_to.h lcast_to_src.h \ - lcast_to_src.I lmatrix.h lmatrix_ext.h lmatrix3_src.I \ - lmatrix3_src.cxx lmatrix3_src.h lmatrix4_src.I \ - lmatrix4_src.cxx lmatrix4_src.h lorientation.h \ - lorientation_src.I lorientation_src.cxx lorientation_src.h \ - lpoint2.h lpoint2_src.I lpoint2_src.cxx lpoint2_src.h \ - lpoint3.h lpoint3_src.I lpoint3_src.cxx lpoint3_src.h \ - lpoint4.h lpoint4_src.I lpoint4_src.cxx lpoint4_src.h \ - lquaternion.h lquaternion_src.I lquaternion_src.cxx \ - lquaternion_src.h lrotation.h lrotation_src.I \ - lrotation_src.cxx lrotation_src.h \ + flt2dblnames.h fltnames.h intnames.h lcast_to.h \ + lmatrix.h lmatrix_ext.h lorientation.h \ + lpoint2.h lpoint3.h lpoint4.h \ + lquaternion.h lrotation.h \ lsimpleMatrix.h lsimpleMatrix.I \ luse.I luse.N luse.h \ - lvec2_ops.h lvec2_ops_src.I lvec2_ops_src.h lvec3_ops.h \ - lvec3_ops_src.I lvec3_ops_src.h lvec4_ops.h lvec4_ops_src.I \ - lvec4_ops_src.h \ - lvecBase2.h lvecBase2_src.I lvecBase2_src.cxx lvecBase2_src.h \ - lvecBase3.h lvecBase3_src.I lvecBase3_src.cxx lvecBase3_src.h \ - lvecBase4.h lvecBase4_src.I lvecBase4_src.cxx lvecBase4_src.h \ - lvector2.h lvector2_src.I lvector2_src.cxx lvector2_src.h \ - lvector3.h lvector3_src.I lvector3_src.cxx lvector3_src.h \ - lvector4.h lvector4_src.I lvector4_src.cxx lvector4_src.h \ - lvector4.h lvector4_src.I lvector4_src.cxx lvector4_src.h \ + lvec2_ops.h lvec3_ops.h lvec4_ops.h \ + lvecBase2.h lvecBase3.h lvecBase4.h \ + lvector2.h lvector3.h lvector4.h \ lvecBase2_ext.h lvecBase3_ext.h lvecBase4_ext.h \ lpoint2_ext.h lpoint3_ext.h lpoint4_ext.h \ lvector2_ext.h lvector3_ext.h lvector4_ext.h \ diff --git a/panda/src/linmath/lcast_to_src.I b/panda/src/linmath/lcast_to_src.I index acfcad19d5..b5253a111e 100644 --- a/panda/src/linmath/lcast_to_src.I +++ b/panda/src/linmath/lcast_to_src.I @@ -138,3 +138,48 @@ lcast_to(FLOATTYPE2 *, const FLOATNAME(LMatrix4) &source) { source(2, 0), source(2, 1), source(2, 2), source(2, 3), source(3, 0), source(3, 1), source(3, 2), source(3, 3)); } + +INLINE_LINMATH FLOATNAME2(LVecBase2) +lcast_to(FLOATTYPE2 *, const LVecBase2i &source) { + return FLOATNAME2(LVecBase2)(source[0], source[1]); +} + +INLINE_LINMATH FLOATNAME2(LVecBase3) +lcast_to(FLOATTYPE2 *, const LVecBase3i &source) { + return FLOATNAME2(LVecBase3)(source[0], source[1], source[2]); +} + +INLINE_LINMATH FLOATNAME2(LVecBase4) +lcast_to(FLOATTYPE2 *, const LVecBase4i &source) { + return FLOATNAME2(LVecBase4)(source[0], source[1], source[2], source[3]); +} + +INLINE_LINMATH FLOATNAME2(LVector2) +lcast_to(FLOATTYPE2 *, const LVector2i &source) { + return FLOATNAME2(LVector2)(source[0], source[1]); +} + +INLINE_LINMATH FLOATNAME2(LVector3) +lcast_to(FLOATTYPE2 *, const LVector3i &source) { + return FLOATNAME2(LVector3)(source[0], source[1], source[2]); +} + +INLINE_LINMATH FLOATNAME2(LVector4) +lcast_to(FLOATTYPE2 *, const LVector4i &source) { + return FLOATNAME2(LVector4)(source[0], source[1], source[2], source[3]); +} + +INLINE_LINMATH FLOATNAME2(LPoint2) +lcast_to(FLOATTYPE2 *, const LPoint2i &source) { + return FLOATNAME2(LPoint2)(source[0], source[1]); +} + +INLINE_LINMATH FLOATNAME2(LPoint3) +lcast_to(FLOATTYPE2 *, const LPoint3i &source) { + return FLOATNAME2(LPoint3)(source[0], source[1], source[2]); +} + +INLINE_LINMATH FLOATNAME2(LPoint4) +lcast_to(FLOATTYPE2 *, const LPoint4i &source) { + return FLOATNAME2(LPoint4)(source[0], source[1], source[2], source[3]); +} diff --git a/panda/src/linmath/lcast_to_src.h b/panda/src/linmath/lcast_to_src.h index 9fa5b9e0cd..c61044d2da 100644 --- a/panda/src/linmath/lcast_to_src.h +++ b/panda/src/linmath/lcast_to_src.h @@ -86,6 +86,33 @@ lcast_to(FLOATTYPE2 *, const FLOATNAME(LMatrix3) &source); INLINE_LINMATH FLOATNAME2(LMatrix4) lcast_to(FLOATTYPE2 *, const FLOATNAME(LMatrix4) &source); +INLINE_LINMATH FLOATNAME2(LVecBase2) +lcast_to(FLOATTYPE2 *, const LVecBase2i &source); + +INLINE_LINMATH FLOATNAME2(LVecBase3) +lcast_to(FLOATTYPE2 *, const LVecBase3i &source); + +INLINE_LINMATH FLOATNAME2(LVecBase4) +lcast_to(FLOATTYPE2 *, const LVecBase4i &source); + +INLINE_LINMATH FLOATNAME2(LVector2) +lcast_to(FLOATTYPE2 *, const LVector2i &source); + +INLINE_LINMATH FLOATNAME2(LVector3) +lcast_to(FLOATTYPE2 *, const LVector3i &source); + +INLINE_LINMATH FLOATNAME2(LVector4) +lcast_to(FLOATTYPE2 *, const LVector4i &source); + +INLINE_LINMATH FLOATNAME2(LPoint2) +lcast_to(FLOATTYPE2 *, const LPoint2i &source); + +INLINE_LINMATH FLOATNAME2(LPoint3) +lcast_to(FLOATTYPE2 *, const LPoint3i &source); + +INLINE_LINMATH FLOATNAME2(LPoint4) +lcast_to(FLOATTYPE2 *, const LPoint4i &source); + #include "lcast_to_src.I" #endif // CPPPARSER diff --git a/panda/src/linmath/lpoint2_ext_src.I b/panda/src/linmath/lpoint2_ext_src.I index ba9eb8e1ca..aa7f88c281 100644 --- a/panda/src/linmath/lpoint2_ext_src.I +++ b/panda/src/linmath/lpoint2_ext_src.I @@ -42,7 +42,7 @@ __repr__() const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); @@ -52,7 +52,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -83,7 +83,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/linmath/lpoint2_ext_src.h b/panda/src/linmath/lpoint2_ext_src.h index 2bf9a6c8f9..0a9c790324 100644 --- a/panda/src/linmath/lpoint2_ext_src.h +++ b/panda/src/linmath/lpoint2_ext_src.h @@ -22,7 +22,7 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; }; diff --git a/panda/src/linmath/lpoint2_src.h b/panda/src/linmath/lpoint2_src.h index 03b264ffdc..5347325800 100644 --- a/panda/src/linmath/lpoint2_src.h +++ b/panda/src/linmath/lpoint2_src.h @@ -26,7 +26,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE x, FLOATTYPE y); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LPoint2) &zero(); diff --git a/panda/src/linmath/lpoint3_ext_src.I b/panda/src/linmath/lpoint3_ext_src.I index 79215517a5..2e758bfa01 100644 --- a/panda/src/linmath/lpoint3_ext_src.I +++ b/panda/src/linmath/lpoint3_ext_src.I @@ -43,7 +43,7 @@ __repr__() const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); @@ -53,7 +53,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -84,7 +84,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/linmath/lpoint3_ext_src.h b/panda/src/linmath/lpoint3_ext_src.h index e9131b891d..8e8339fc40 100644 --- a/panda/src/linmath/lpoint3_ext_src.h +++ b/panda/src/linmath/lpoint3_ext_src.h @@ -22,7 +22,7 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; }; diff --git a/panda/src/linmath/lpoint3_src.h b/panda/src/linmath/lpoint3_src.h index 76e06982d4..e8645529ff 100644 --- a/panda/src/linmath/lpoint3_src.h +++ b/panda/src/linmath/lpoint3_src.h @@ -32,7 +32,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); INLINE_LINMATH FLOATNAME(LPoint3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LPoint3) &zero(); diff --git a/panda/src/linmath/lpoint4_ext_src.I b/panda/src/linmath/lpoint4_ext_src.I index 88a83d20d5..48c40e3dc5 100644 --- a/panda/src/linmath/lpoint4_ext_src.I +++ b/panda/src/linmath/lpoint4_ext_src.I @@ -44,7 +44,7 @@ __repr__() const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); @@ -54,7 +54,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -89,7 +89,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/linmath/lpoint4_ext_src.h b/panda/src/linmath/lpoint4_ext_src.h index 05d1e4b3c2..1c5fe49779 100644 --- a/panda/src/linmath/lpoint4_ext_src.h +++ b/panda/src/linmath/lpoint4_ext_src.h @@ -22,7 +22,7 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; }; diff --git a/panda/src/linmath/lpoint4_src.h b/panda/src/linmath/lpoint4_src.h index b71e328c62..50eeb1ce5d 100644 --- a/panda/src/linmath/lpoint4_src.h +++ b/panda/src/linmath/lpoint4_src.h @@ -26,7 +26,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); INLINE_LINMATH FLOATNAME(LPoint4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LPoint4) &zero(); diff --git a/panda/src/linmath/lvecBase2_ext_src.I b/panda/src/linmath/lvecBase2_ext_src.I index 8a2c8221b4..00b8fdf616 100644 --- a/panda/src/linmath/lvecBase2_ext_src.I +++ b/panda/src/linmath/lvecBase2_ext_src.I @@ -80,7 +80,7 @@ __reduce__(PyObject *self) const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); @@ -90,7 +90,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -121,7 +121,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// @@ -135,10 +135,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { - PyTypeObject *tp = self->ob_type; - PyErr_Format(PyExc_AttributeError, - "'%.100s' object has no attribute '%.200s'", - tp->tp_name, attr_name.c_str()); + Dtool_Raise_AttributeError(self, attr_name.c_str()); return -1; } } diff --git a/panda/src/linmath/lvecBase2_ext_src.h b/panda/src/linmath/lvecBase2_ext_src.h index c19c8a49d4..d72a6da3e2 100644 --- a/panda/src/linmath/lvecBase2_ext_src.h +++ b/panda/src/linmath/lvecBase2_ext_src.h @@ -23,7 +23,7 @@ template<> class Extension : public ExtensionBase { public: INLINE_LINMATH PyObject *__reduce__(PyObject *self) const; - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; diff --git a/panda/src/linmath/lvecBase2_src.h b/panda/src/linmath/lvecBase2_src.h index 5cb049429e..f1f6d125e0 100644 --- a/panda/src/linmath/lvecBase2_src.h +++ b/panda/src/linmath/lvecBase2_src.h @@ -49,7 +49,7 @@ PUBLISHED: INLINE_LINMATH ~FLOATNAME(LVecBase2)(); EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH FLOATTYPE operator [](int i) const; diff --git a/panda/src/linmath/lvecBase3_ext_src.I b/panda/src/linmath/lvecBase3_ext_src.I index 6ecd5eefe0..56ac6cc176 100644 --- a/panda/src/linmath/lvecBase3_ext_src.I +++ b/panda/src/linmath/lvecBase3_ext_src.I @@ -81,7 +81,7 @@ __reduce__(PyObject *self) const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); @@ -91,7 +91,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -122,7 +122,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// @@ -136,10 +136,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { - PyTypeObject *tp = self->ob_type; - PyErr_Format(PyExc_AttributeError, - "'%.100s' object has no attribute '%.200s'", - tp->tp_name, attr_name.c_str()); + Dtool_Raise_AttributeError(self, attr_name.c_str()); return -1; } } diff --git a/panda/src/linmath/lvecBase3_ext_src.h b/panda/src/linmath/lvecBase3_ext_src.h index cf9f60a0d7..6b12ac69f3 100644 --- a/panda/src/linmath/lvecBase3_ext_src.h +++ b/panda/src/linmath/lvecBase3_ext_src.h @@ -23,7 +23,7 @@ template<> class Extension : public ExtensionBase { public: INLINE_LINMATH PyObject *__reduce__(PyObject *self) const; - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; diff --git a/panda/src/linmath/lvecBase3_src.h b/panda/src/linmath/lvecBase3_src.h index c126e0fb6c..1a4ec5ce97 100644 --- a/panda/src/linmath/lvecBase3_src.h +++ b/panda/src/linmath/lvecBase3_src.h @@ -51,7 +51,7 @@ PUBLISHED: INLINE_LINMATH ~FLOATNAME(LVecBase3)(); EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH FLOATTYPE operator [](int i) const; diff --git a/panda/src/linmath/lvecBase4_ext_src.I b/panda/src/linmath/lvecBase4_ext_src.I index a0400690a5..dd06bdc0dc 100644 --- a/panda/src/linmath/lvecBase4_ext_src.I +++ b/panda/src/linmath/lvecBase4_ext_src.I @@ -82,7 +82,7 @@ __reduce__(PyObject *self) const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); @@ -92,7 +92,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -127,7 +127,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// @@ -141,10 +141,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { - PyTypeObject *tp = self->ob_type; - PyErr_Format(PyExc_AttributeError, - "'%.100s' object has no attribute '%.200s'", - tp->tp_name, attr_name.c_str()); + Dtool_Raise_AttributeError(self, attr_name.c_str()); return -1; } } diff --git a/panda/src/linmath/lvecBase4_ext_src.h b/panda/src/linmath/lvecBase4_ext_src.h index 97924376ba..5d582bbe64 100644 --- a/panda/src/linmath/lvecBase4_ext_src.h +++ b/panda/src/linmath/lvecBase4_ext_src.h @@ -23,7 +23,7 @@ template<> class Extension : public ExtensionBase { public: INLINE_LINMATH PyObject *__reduce__(PyObject *self) const; - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; diff --git a/panda/src/linmath/lvecBase4_src.h b/panda/src/linmath/lvecBase4_src.h index 4abd48ed98..988d31b859 100644 --- a/panda/src/linmath/lvecBase4_src.h +++ b/panda/src/linmath/lvecBase4_src.h @@ -61,7 +61,7 @@ PUBLISHED: INLINE_LINMATH ~FLOATNAME(LVecBase4)(); EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH FLOATTYPE operator [](int i) const; diff --git a/panda/src/linmath/lvector2_ext_src.I b/panda/src/linmath/lvector2_ext_src.I index e0ae2bea6d..4e52774d3c 100644 --- a/panda/src/linmath/lvector2_ext_src.I +++ b/panda/src/linmath/lvector2_ext_src.I @@ -42,7 +42,7 @@ __repr__() const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); @@ -52,7 +52,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -83,7 +83,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/linmath/lvector2_ext_src.h b/panda/src/linmath/lvector2_ext_src.h index 56a48aeaa3..4a2888e7d4 100644 --- a/panda/src/linmath/lvector2_ext_src.h +++ b/panda/src/linmath/lvector2_ext_src.h @@ -22,7 +22,7 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; }; diff --git a/panda/src/linmath/lvector2_src.h b/panda/src/linmath/lvector2_src.h index 81b2475af6..2ee50d34ab 100644 --- a/panda/src/linmath/lvector2_src.h +++ b/panda/src/linmath/lvector2_src.h @@ -25,7 +25,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE x, FLOATTYPE y); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LVector2) &zero(); diff --git a/panda/src/linmath/lvector3_ext_src.I b/panda/src/linmath/lvector3_ext_src.I index 451b713dee..f7fc436f55 100644 --- a/panda/src/linmath/lvector3_ext_src.I +++ b/panda/src/linmath/lvector3_ext_src.I @@ -43,7 +43,7 @@ __repr__() const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); @@ -53,7 +53,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -84,7 +84,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/linmath/lvector3_ext_src.h b/panda/src/linmath/lvector3_ext_src.h index 33ab4ab140..a4c45fbe9a 100644 --- a/panda/src/linmath/lvector3_ext_src.h +++ b/panda/src/linmath/lvector3_ext_src.h @@ -22,7 +22,7 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; }; diff --git a/panda/src/linmath/lvector3_src.h b/panda/src/linmath/lvector3_src.h index 7fc0316b06..7e0dd196bb 100644 --- a/panda/src/linmath/lvector3_src.h +++ b/panda/src/linmath/lvector3_src.h @@ -32,7 +32,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); INLINE_LINMATH FLOATNAME(LVector3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LVector3) &zero(); diff --git a/panda/src/linmath/lvector4_ext_src.I b/panda/src/linmath/lvector4_ext_src.I index 04edba6a06..78a651a99e 100644 --- a/panda/src/linmath/lvector4_ext_src.I +++ b/panda/src/linmath/lvector4_ext_src.I @@ -44,7 +44,7 @@ __repr__() const { // Description: This is used to implement swizzle masks. //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: -__getattr__(const string &attr_name) const { +__getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); @@ -54,7 +54,7 @@ __getattr__(const string &attr_name) const { // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } } @@ -89,7 +89,7 @@ __getattr__(const string &attr_name) const { } } - return NULL; + return Dtool_Raise_AttributeError(self, attr_name.c_str()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/linmath/lvector4_ext_src.h b/panda/src/linmath/lvector4_ext_src.h index 5bc319ad13..c313e89848 100644 --- a/panda/src/linmath/lvector4_ext_src.h +++ b/panda/src/linmath/lvector4_ext_src.h @@ -22,7 +22,7 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); INLINE_LINMATH string __repr__() const; }; diff --git a/panda/src/linmath/lvector4_src.h b/panda/src/linmath/lvector4_src.h index 1cce8f0db5..ebf87429f6 100644 --- a/panda/src/linmath/lvector4_src.h +++ b/panda/src/linmath/lvector4_src.h @@ -26,7 +26,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); INLINE_LINMATH FLOATNAME(LVector4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(const string &attr_name) const); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LVector4) &zero(); diff --git a/panda/src/linmath/vector_LPoint2f.cxx b/panda/src/linmath/vector_LPoint2f.cxx deleted file mode 100644 index 2641b4b26e..0000000000 --- a/panda/src/linmath/vector_LPoint2f.cxx +++ /dev/null @@ -1,27 +0,0 @@ -// Filename: vector_LPoint2f.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#include "vector_LPoint2f.h" - -#define EXPCL EXPCL_PANDA_LINMATH -#define EXPTP EXPTP_PANDA_LINMATH -#define TYPE LPoint2f -#define NAME vector_LPoint2f - -#include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/linmath/vector_LPoint2f.h b/panda/src/linmath/vector_LPoint2f.h deleted file mode 100644 index 58dabbc828..0000000000 --- a/panda/src/linmath/vector_LPoint2f.h +++ /dev/null @@ -1,43 +0,0 @@ -// Filename: vector_LPoint2f.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#ifndef VECTOR_LPOINT2F_H -#define VECTOR_LPOINT2F_H - -#include "pandabase.h" -#include "luse.h" -#include "pvector.h" - -//////////////////////////////////////////////////////////////////// -// Class : vector_LPoint2f -// Description : A vector of LPoint2fs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// - -#define EXPCL EXPCL_PANDA_LINMATH -#define EXPTP EXPTP_PANDA_LINMATH -#define TYPE LPoint2f -#define NAME vector_LPoint2f - -#include "vector_src.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/mathutil/Sources.pp b/panda/src/mathutil/Sources.pp index 2c9b169a00..4a1b4de454 100644 --- a/panda/src/mathutil/Sources.pp +++ b/panda/src/mathutil/Sources.pp @@ -18,25 +18,23 @@ boundingSphere.I boundingSphere.h \ boundingVolume.I boundingVolume.h config_mathutil.h \ fftCompressor.h finiteBoundingVolume.h frustum.h \ - frustum_src.I frustum_src.h geometricBoundingVolume.I \ - geometricBoundingVolume.h \ + geometricBoundingVolume.I geometricBoundingVolume.h \ intersectionBoundingVolume.h intersectionBoundingVolume.I \ linmath_events.h \ - look_at.h look_at_src.I \ - look_at_src.cxx look_at_src.h \ + look_at.h \ linmath_events.h \ mersenne.h \ omniBoundingVolume.I \ omniBoundingVolume.h \ - parabola.h parabola_src.I parabola_src.cxx parabola_src.h \ + parabola.h \ perlinNoise.h perlinNoise.I \ perlinNoise2.h perlinNoise2.I \ perlinNoise3.h perlinNoise3.I \ - plane.h plane_src.I plane_src.cxx plane_src.h \ + plane.h \ pta_LMatrix4.h pta_LMatrix3.h pta_LVecBase3.h \ pta_LVecBase4.h pta_LVecBase2.h \ randomizer.h randomizer.I \ - rotate_to.h rotate_to_src.cxx \ + rotate_to.h \ stackedPerlinNoise2.h stackedPerlinNoise2.I \ stackedPerlinNoise3.h stackedPerlinNoise3.I \ triangulator.h triangulator.I \ diff --git a/panda/src/nativenet/socket_fdset.h b/panda/src/nativenet/socket_fdset.h index 2c848ae582..33e688a207 100644 --- a/panda/src/nativenet/socket_fdset.h +++ b/panda/src/nativenet/socket_fdset.h @@ -1,5 +1,5 @@ #ifndef __SOCKET_FDSET_H__ -#define __SOCKET_FDSET_H__ +#define __SOCKET_FDSET_H__ //////////////////////////////////////////////////// // @@ -16,27 +16,29 @@ #include "time_base.h" #include "socket_ip.h" -class Socket_fdset -{ +class Socket_fdset { PUBLISHED: - - inline Socket_fdset(); - inline void setForSocket(const Socket_IP &incon); - inline bool IsSetFor(const Socket_IP & incon) const; - inline int WaitForRead(bool zeroFds, PN_uint32 sleep_time = 0xffffffff); - inline int WaitForWrite(bool zeroFds, PN_uint32 sleep_time = 0xffffffff); - inline int WaitForError(bool zeroFds, PN_uint32 sleep_time = 0xffffffff); - - - inline int WaitForRead(bool zeroFds, const Time_Span & timeout); - inline void clear(); + inline Socket_fdset(); + inline void setForSocket(const Socket_IP &incon); + inline bool IsSetFor(const Socket_IP &incon) const; + inline int WaitForRead(bool zeroFds, PN_uint32 sleep_time = 0xffffffff); + inline int WaitForWrite(bool zeroFds, PN_uint32 sleep_time = 0xffffffff); + inline int WaitForError(bool zeroFds, PN_uint32 sleep_time = 0xffffffff); + + inline int WaitForRead(bool zeroFds, const Time_Span & timeout); + inline void clear(); + private: - inline void setForSocketNative(const SOCKET inid); - inline bool isSetForNative(const SOCKET inid) const; - - friend struct Socket_Selector; - SOCKET _maxid; - mutable fd_set _the_set; + inline void setForSocketNative(const SOCKET inid); + inline bool isSetForNative(const SOCKET inid) const; + + friend struct Socket_Selector; + + SOCKET _maxid; + +#ifndef CPPPARSER + mutable fd_set _the_set; +#endif }; //////////////////////////////////////////////////////////////////// diff --git a/panda/src/ode/odeGeom_ext.I b/panda/src/ode/odeGeom_ext.I index 6d1cf2bebd..e7508da018 100644 --- a/panda/src/ode/odeGeom_ext.I +++ b/panda/src/ode/odeGeom_ext.I @@ -15,10 +15,6 @@ #include "odeSpace_ext.h" #include "lpoint3.h" -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint3f; -#endif - //////////////////////////////////////////////////////////////////// // Function: OdeGeom::get_AA_bounds // Access: Published @@ -30,8 +26,8 @@ get_AA_bounds() const { LPoint3f *max_point = new LPoint3f; _this->get_AABB(*min_point, *max_point); - PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3f, true, false); - PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3f, true, false); + PyObject *min_inst = DTool_CreatePyInstance(min_point, true); + PyObject *max_inst = DTool_CreatePyInstance(max_point, true); return Py_BuildValue("NN", min_inst, max_inst); } diff --git a/panda/src/ode/odeSpace_ext.I b/panda/src/ode/odeSpace_ext.I index 78e9aeb7c3..8cbccc773e 100644 --- a/panda/src/ode/odeSpace_ext.I +++ b/panda/src/ode/odeSpace_ext.I @@ -15,10 +15,6 @@ /* okcircular */ #include "odeGeom_ext.h" -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint3f; -#endif - //////////////////////////////////////////////////////////////////// // Function: OdeSpace::get_AA_bounds // Access: Published @@ -30,8 +26,8 @@ get_AA_bounds() const { LPoint3f *max_point = new LPoint3f; _this->get_AABB(*min_point, *max_point); - PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3f, true, false); - PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3f, true, false); + PyObject *min_inst = DTool_CreatePyInstance(min_point, true); + PyObject *max_inst = DTool_CreatePyInstance(max_point, true); return Py_BuildValue("NN", min_inst, max_inst); } diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index 670ae662df..235b8b95b5 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -22,367 +22,262 @@ C++-style comments, since this file is occasionally included by a C file. */ -#if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) - #ifdef BUILDING_CFTALK - #define EXPCL_CFTALK __declspec(dllexport) - #define EXPTP_CFTALK + #define EXPCL_CFTALK EXPORT_CLASS + #define EXPTP_CFTALK EXPORT_TEMPL #else - #define EXPCL_CFTALK __declspec(dllimport) - #define EXPTP_CFTALK extern + #define EXPCL_CFTALK IMPORT_CLASS + #define EXPTP_CFTALK IMPORT_TEMPL #endif #ifdef BUILDING_COLLADA - #define EXPCL_COLLADA __declspec(dllexport) - #define EXPTP_COLLADA + #define EXPCL_COLLADA EXPORT_CLASS + #define EXPTP_COLLADA EXPORT_TEMPL #else - #define EXPCL_COLLADA __declspec(dllimport) - #define EXPTP_COLLADA extern + #define EXPCL_COLLADA IMPORT_CLASS + #define EXPTP_COLLADA IMPORT_TEMPL #endif #ifdef BUILDING_FFMPEG - #define EXPCL_FFMPEG __declspec(dllexport) - #define EXPTP_FFMPEG + #define EXPCL_FFMPEG EXPORT_CLASS + #define EXPTP_FFMPEG EXPORT_TEMPL #else - #define EXPCL_FFMPEG __declspec(dllimport) - #define EXPTP_FFMPEG extern + #define EXPCL_FFMPEG IMPORT_CLASS + #define EXPTP_FFMPEG IMPORT_TEMPL #endif #ifdef BUILDING_FRAMEWORK - #define EXPCL_FRAMEWORK __declspec(dllexport) - #define EXPTP_FRAMEWORK + #define EXPCL_FRAMEWORK EXPORT_CLASS + #define EXPTP_FRAMEWORK EXPORT_TEMPL #else - #define EXPCL_FRAMEWORK __declspec(dllimport) - #define EXPTP_FRAMEWORK extern + #define EXPCL_FRAMEWORK IMPORT_CLASS + #define EXPTP_FRAMEWORK IMPORT_TEMPL #endif #ifdef BUILDING_LINUX_AUDIO - #define EXPCL_LINUX_AUDIO __declspec(dllexport) - #define EXPTP_LINUX_AUDIO + #define EXPCL_LINUX_AUDIO EXPORT_CLASS + #define EXPTP_LINUX_AUDIO EXPORT_TEMPL #else - #define EXPCL_LINUX_AUDIO __declspec(dllimport) - #define EXPTP_LINUX_AUDIO extern + #define EXPCL_LINUX_AUDIO IMPORT_CLASS + #define EXPTP_LINUX_AUDIO IMPORT_TEMPL #endif #ifdef BUILDING_MILES_AUDIO - #define EXPCL_MILES_AUDIO __declspec(dllexport) - #define EXPTP_MILES_AUDIO + #define EXPCL_MILES_AUDIO EXPORT_CLASS + #define EXPTP_MILES_AUDIO EXPORT_TEMPL #else - #define EXPCL_MILES_AUDIO __declspec(dllimport) - #define EXPTP_MILES_AUDIO extern + #define EXPCL_MILES_AUDIO IMPORT_CLASS + #define EXPTP_MILES_AUDIO IMPORT_TEMPL #endif #ifdef BUILDING_FMOD_AUDIO - #define EXPCL_FMOD_AUDIO __declspec(dllexport) - #define EXPTP_FMOD_AUDIO + #define EXPCL_FMOD_AUDIO EXPORT_CLASS + #define EXPTP_FMOD_AUDIO EXPORT_TEMPL #else - #define EXPCL_FMOD_AUDIO __declspec(dllimport) - #define EXPTP_FMOD_AUDIO extern + #define EXPCL_FMOD_AUDIO IMPORT_CLASS + #define EXPTP_FMOD_AUDIO IMPORT_TEMPL #endif #ifdef BUILDING_OCULUSVR - #define EXPCL_OCULUSVR __declspec(dllexport) - #define EXPTP_OCULUSVR + #define EXPCL_OCULUSVR EXPORT_CLASS + #define EXPTP_OCULUSVR EXPORT_TEMPL #else - #define EXPCL_OCULUSVR __declspec(dllimport) - #define EXPTP_OCULUSVR extern + #define EXPCL_OCULUSVR IMPORT_CLASS + #define EXPTP_OCULUSVR IMPORT_TEMPL #endif #ifdef BUILDING_OPENAL_AUDIO - #define EXPCL_OPENAL_AUDIO __declspec(dllexport) - #define EXPTP_OPENAL_AUDIO + #define EXPCL_OPENAL_AUDIO EXPORT_CLASS + #define EXPTP_OPENAL_AUDIO EXPORT_TEMPL #else - #define EXPCL_OPENAL_AUDIO __declspec(dllimport) - #define EXPTP_OPENAL_AUDIO extern + #define EXPCL_OPENAL_AUDIO IMPORT_CLASS + #define EXPTP_OPENAL_AUDIO IMPORT_TEMPL #endif #ifdef BUILDING_PANDA - #define EXPCL_PANDA __declspec(dllexport) - #define EXPTP_PANDA + #define EXPCL_PANDA EXPORT_CLASS + #define EXPTP_PANDA EXPORT_TEMPL #else - #define EXPCL_PANDA __declspec(dllimport) - #define EXPTP_PANDA extern + #define EXPCL_PANDA IMPORT_CLASS + #define EXPTP_PANDA IMPORT_TEMPL #endif #ifdef BUILDING_PANDAAWESOMIUM - #define EXPCL_PANDAAWESOMIUM __declspec(dllexport) - #define EXPTP_PANDAAWESOMIUM + #define EXPCL_PANDAAWESOMIUM EXPORT_CLASS + #define EXPTP_PANDAAWESOMIUM EXPORT_TEMPL #else - #define EXPCL_PANDAAWESOMIUM __declspec(dllimport) - #define EXPTP_PANDAAWESOMIUM extern + #define EXPCL_PANDAAWESOMIUM IMPORT_CLASS + #define EXPTP_PANDAAWESOMIUM IMPORT_TEMPL #endif #ifdef BUILDING_PANDABULLET - #define EXPCL_PANDABULLET __declspec(dllexport) - #define EXPTP_PANDABULLET + #define EXPCL_PANDABULLET EXPORT_CLASS + #define EXPTP_PANDABULLET EXPORT_TEMPL #else - #define EXPCL_PANDABULLET __declspec(dllimport) - #define EXPTP_PANDABULLET extern + #define EXPCL_PANDABULLET IMPORT_CLASS + #define EXPTP_PANDABULLET IMPORT_TEMPL #endif #ifdef BUILDING_PANDACR - #define EXPCL_PANDACR __declspec(dllexport) - #define EXPTP_PANDACR + #define EXPCL_PANDACR EXPORT_CLASS + #define EXPTP_PANDACR EXPORT_TEMPL #else - #define EXPCL_PANDACR __declspec(dllimport) - #define EXPTP_PANDACR extern + #define EXPCL_PANDACR IMPORT_CLASS + #define EXPTP_PANDACR IMPORT_TEMPL #endif #ifdef BUILDING_PANDADX - #define EXPCL_PANDADX __declspec(dllexport) - #define EXPTP_PANDADX + #define EXPCL_PANDADX EXPORT_CLASS + #define EXPTP_PANDADX EXPORT_TEMPL #else - #define EXPCL_PANDADX __declspec(dllimport) - #define EXPTP_PANDADX extern + #define EXPCL_PANDADX IMPORT_CLASS + #define EXPTP_PANDADX IMPORT_TEMPL #endif #ifdef BUILDING_PANDAEGG - #define EXPCL_PANDAEGG __declspec(dllexport) - #define EXPTP_PANDAEGG + #define EXPCL_PANDAEGG EXPORT_CLASS + #define EXPTP_PANDAEGG EXPORT_TEMPL #else - #define EXPCL_PANDAEGG __declspec(dllimport) - #define EXPTP_PANDAEGG extern + #define EXPCL_PANDAEGG IMPORT_CLASS + #define EXPTP_PANDAEGG IMPORT_TEMPL #endif #ifdef BUILDING_PANDAEXPRESS - #define EXPCL_PANDAEXPRESS __declspec(dllexport) - #define EXPTP_PANDAEXPRESS + #define EXPCL_PANDAEXPRESS EXPORT_CLASS + #define EXPTP_PANDAEXPRESS EXPORT_TEMPL #else - #define EXPCL_PANDAEXPRESS __declspec(dllimport) - #define EXPTP_PANDAEXPRESS extern + #define EXPCL_PANDAEXPRESS IMPORT_CLASS + #define EXPTP_PANDAEXPRESS IMPORT_TEMPL #endif #ifdef BUILDING_PANDAFX - #define EXPCL_PANDAFX __declspec(dllexport) - #define EXPTP_PANDAFX + #define EXPCL_PANDAFX EXPORT_CLASS + #define EXPTP_PANDAFX EXPORT_TEMPL #else - #define EXPCL_PANDAFX __declspec(dllimport) - #define EXPTP_PANDAFX extern + #define EXPCL_PANDAFX IMPORT_CLASS + #define EXPTP_PANDAFX IMPORT_TEMPL #endif #ifdef BUILDING_PANDAGL - #define EXPCL_PANDAGL __declspec(dllexport) - #define EXPTP_PANDAGL + #define EXPCL_PANDAGL EXPORT_CLASS + #define EXPTP_PANDAGL EXPORT_TEMPL #else - #define EXPCL_PANDAGL __declspec(dllimport) - #define EXPTP_PANDAGL extern + #define EXPCL_PANDAGL IMPORT_CLASS + #define EXPTP_PANDAGL IMPORT_TEMPL #endif #ifdef BUILDING_PANDAGLES - #define EXPCL_PANDAGLES __declspec(dllexport) - #define EXPTP_PANDAGLES + #define EXPCL_PANDAGLES EXPORT_CLASS + #define EXPTP_PANDAGLES EXPORT_TEMPL #else - #define EXPCL_PANDAGLES __declspec(dllimport) - #define EXPTP_PANDAGLES extern + #define EXPCL_PANDAGLES IMPORT_CLASS + #define EXPTP_PANDAGLES IMPORT_TEMPL #endif #ifdef BUILDING_PANDAGLES2 - #define EXPCL_PANDAGLES2 __declspec(dllexport) - #define EXPTP_PANDAGLES2 + #define EXPCL_PANDAGLES2 EXPORT_CLASS + #define EXPTP_PANDAGLES2 EXPORT_TEMPL #else - #define EXPCL_PANDAGLES2 __declspec(dllimport) - #define EXPTP_PANDAGLES2 extern + #define EXPCL_PANDAGLES2 IMPORT_CLASS + #define EXPTP_PANDAGLES2 IMPORT_TEMPL #endif #ifdef BUILDING_PANDAODE - #define EXPCL_PANDAODE __declspec(dllexport) - #define EXPTP_PANDAODE + #define EXPCL_PANDAODE EXPORT_CLASS + #define EXPTP_PANDAODE EXPORT_TEMPL #else - #define EXPCL_PANDAODE __declspec(dllimport) - #define EXPTP_PANDAODE extern + #define EXPCL_PANDAODE IMPORT_CLASS + #define EXPTP_PANDAODE IMPORT_TEMPL #endif #ifdef BUILDING_PANDAPHYSICS - #define EXPCL_PANDAPHYSICS __declspec(dllexport) - #define EXPTP_PANDAPHYSICS + #define EXPCL_PANDAPHYSICS EXPORT_CLASS + #define EXPTP_PANDAPHYSICS EXPORT_TEMPL #else - #define EXPCL_PANDAPHYSICS __declspec(dllimport) - #define EXPTP_PANDAPHYSICS extern + #define EXPCL_PANDAPHYSICS IMPORT_CLASS + #define EXPTP_PANDAPHYSICS IMPORT_TEMPL #endif #ifdef BUILDING_PANDAPHYSX - #define EXPCL_PANDAPHYSX __declspec(dllexport) - #define EXPTP_PANDAPHYSX + #define EXPCL_PANDAPHYSX EXPORT_CLASS + #define EXPTP_PANDAPHYSX EXPORT_TEMPL #else - #define EXPCL_PANDAPHYSX __declspec(dllimport) - #define EXPTP_PANDAPHYSX extern + #define EXPCL_PANDAPHYSX IMPORT_CLASS + #define EXPTP_PANDAPHYSX IMPORT_TEMPL #endif #ifdef BUILDING_PANDASPEEDTREE - #define EXPCL_PANDASPEEDTREE __declspec(dllexport) - #define EXPTP_PANDASPEEDTREE + #define EXPCL_PANDASPEEDTREE EXPORT_CLASS + #define EXPTP_PANDASPEEDTREE EXPORT_TEMPL #else - #define EXPCL_PANDASPEEDTREE __declspec(dllimport) - #define EXPTP_PANDASPEEDTREE extern + #define EXPCL_PANDASPEEDTREE IMPORT_CLASS + #define EXPTP_PANDASPEEDTREE IMPORT_TEMPL #endif #ifdef BUILDING_PANDASKEL - #define EXPCL_PANDASKEL __declspec(dllexport) - #define EXPTP_PANDASKEL + #define EXPCL_PANDASKEL EXPORT_CLASS + #define EXPTP_PANDASKEL EXPORT_TEMPL #else - #define EXPCL_PANDASKEL __declspec(dllimport) - #define EXPTP_PANDASKEL extern + #define EXPCL_PANDASKEL IMPORT_CLASS + #define EXPTP_PANDASKEL IMPORT_TEMPL #endif #ifdef BUILDING_PANDAWIN - #define EXPCL_PANDAWIN __declspec(dllexport) - #define EXPTP_PANDAWIN + #define EXPCL_PANDAWIN EXPORT_CLASS + #define EXPTP_PANDAWIN EXPORT_TEMPL #else - #define EXPCL_PANDAWIN __declspec(dllimport) - #define EXPTP_PANDAWIN extern + #define EXPCL_PANDAWIN IMPORT_CLASS + #define EXPTP_PANDAWIN IMPORT_TEMPL #endif #ifdef BUILDING_PANDAX11 - #define EXPCL_PANDAX11 __declspec(dllexport) - #define EXPTP_PANDAX11 + #define EXPCL_PANDAX11 EXPORT_CLASS + #define EXPTP_PANDAX11 EXPORT_TEMPL #else - #define EXPCL_PANDAX11 __declspec(dllimport) - #define EXPTP_PANDAX11 extern + #define EXPCL_PANDAX11 IMPORT_CLASS + #define EXPTP_PANDAX11 IMPORT_TEMPL #endif #ifdef BUILDING_ROCKET - #define EXPCL_ROCKET __declspec(dllexport) - #define EXPTP_ROCKET + #define EXPCL_ROCKET EXPORT_CLASS + #define EXPTP_ROCKET EXPORT_TEMPL #else - #define EXPCL_ROCKET __declspec(dllimport) - #define EXPTP_ROCKET extern + #define EXPCL_ROCKET IMPORT_CLASS + #define EXPTP_ROCKET IMPORT_TEMPL #endif #ifdef BUILDING_SHADER - #define EXPCL_SHADER __declspec(dllexport) - #define EXPTP_SHADER + #define EXPCL_SHADER EXPORT_CLASS + #define EXPTP_SHADER EXPORT_TEMPL #else - #define EXPCL_SHADER __declspec(dllimport) - #define EXPTP_SHADER extern + #define EXPCL_SHADER IMPORT_CLASS + #define EXPTP_SHADER IMPORT_TEMPL #endif #ifdef BUILDING_TINYDISPLAY - #define EXPCL_TINYDISPLAY __declspec(dllexport) - #define EXPTP_TINYDISPLAY + #define EXPCL_TINYDISPLAY EXPORT_CLASS + #define EXPTP_TINYDISPLAY EXPORT_TEMPL #else - #define EXPCL_TINYDISPLAY __declspec(dllimport) - #define EXPTP_TINYDISPLAY extern + #define EXPCL_TINYDISPLAY IMPORT_CLASS + #define EXPTP_TINYDISPLAY IMPORT_TEMPL #endif #ifdef BUILDING_VISION - #define EXPCL_VISION __declspec(dllexport) - #define EXPTP_VISION + #define EXPCL_VISION EXPORT_CLASS + #define EXPTP_VISION EXPORT_TEMPL #else - #define EXPCL_VISION __declspec(dllimport) - #define EXPTP_VISION extern + #define EXPCL_VISION IMPORT_CLASS + #define EXPTP_VISION IMPORT_TEMPL #endif #ifdef BUILDING_VRPN - #define EXPCL_VRPN __declspec(dllexport) - #define EXPTP_VRPN + #define EXPCL_VRPN EXPORT_CLASS + #define EXPTP_VRPN EXPORT_TEMPL #else - #define EXPCL_VRPN __declspec(dllimport) - #define EXPTP_VRPN extern + #define EXPCL_VRPN IMPORT_CLASS + #define EXPTP_VRPN IMPORT_TEMPL #endif -#else /* !WIN32_VC */ - -#define EXPCL_CFTALK -#define EXPTP_CFTALK - -#define EXPCL_COLLADA -#define EXPTP_COLLADA - -#define EXPCL_FFMPEG -#define EXPTP_FFMPEG - -#define EXPCL_FRAMEWORK -#define EXPTP_FRAMEWORK - -#define EXPCL_LINUX_AUDIO -#define EXPTP_LINUX_AUDIO - -#define EXPCL_MILES_AUDIO -#define EXPTP_MILES_AUDIO - -#define EXPCL_FMOD_AUDIO -#define EXPTP_FMOD_AUDIO - -#define EXPCL_OCULUSVR -#define EXPTP_OCULUSVR - -#define EXPCL_OPENAL_AUDIO -#define EXPTP_OPENAL_AUDIO - -#define EXPCL_PANDA -#define EXPTP_PANDA - -#define EXPCL_PANDAAWESOMIUM -#define EXPTP_PANDAAWESOMIUM - -#define EXPCL_PANDABULLET -#define EXPTP_PANDABULLET - -#define EXPCL_PANDACR -#define EXPTP_PANDACR - -#define EXPCL_PANDADX -#define EXPTP_PANDADX - -#define EXPCL_PANDAEGG -#define EXPTP_PANDAEGG - -#define EXPCL_PANDAEXPRESS -#define EXPTP_PANDAEXPRESS - -#define EXPCL_PANDAFX -#define EXPTP_PANDAFX - -#define EXPCL_PANDAGL -#define EXPTP_PANDAGL - -#define EXPCL_PANDAGLES -#define EXPTP_PANDAGLES - -#define EXPCL_PANDAGLES2 -#define EXPTP_PANDAGLES2 - -#define EXPCL_PANDAODE -#define EXPTP_PANDAODE - -#define EXPCL_PANDAPHYSICS -#define EXPTP_PANDAPHYSICS - -#define EXPCL_PANDAPHYSX -#define EXPTP_PANDAPHYSX - -#define EXPCL_PANDASPEEDTREE -#define EXPTP_PANDASPEEDTREE - -#define EXPCL_PANDARIB -#define EXPTP_PANDARIB - -#define EXPCL_PANDASKEL -#define EXPTP_PANDASKEL - -#define EXPCL_PANDAWIN -#define EXPTP_PANDAWIN - -#define EXPCL_PANDAX11 -#define EXPTP_PANDAX11 - -#define EXPCL_ROCKET -#define EXPTP_ROCKET - -#define EXPCL_SHADER -#define EXPTP_SHADER - -#define EXPCL_TINYDISPLAY -#define EXPTP_TINYDISPLAY - -#define EXPCL_VISION -#define EXPTP_VISION - -#define EXPCL_VRPN -#define EXPTP_VRPN - -#endif /* WIN32_VC */ - #if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(CPPPARSER) #define INLINE_LINMATH __forceinline #define INLINE_MATHUTIL __forceinline diff --git a/panda/src/parametrics/ropeNode.cxx b/panda/src/parametrics/ropeNode.cxx index eaf0ef48ed..871931cd1b 100644 --- a/panda/src/parametrics/ropeNode.cxx +++ b/panda/src/parametrics/ropeNode.cxx @@ -282,7 +282,7 @@ get_format(bool support_normals) const { if (support_normals && get_normal_mode() == NM_vertex) { array_format->add_column (InternalName::get_normal(), 3, Geom::NT_stdfloat, - Geom::C_vector); + Geom::C_normal); } if (get_use_vertex_color()) { array_format->add_column diff --git a/panda/src/pgraph/camera.h b/panda/src/pgraph/camera.h index 54c0eeb945..c02c60da00 100644 --- a/panda/src/pgraph/camera.h +++ b/panda/src/pgraph/camera.h @@ -36,7 +36,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PGRAPH Camera : public LensNode { PUBLISHED: - Camera(const string &name, Lens *lens = new PerspectiveLens()); + explicit Camera(const string &name, Lens *lens = new PerspectiveLens()); Camera(const Camera ©); public: diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index a7cab23a8b..67a80b4c43 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -24,6 +24,7 @@ #include "fogAttrib.h" #include "transparencyAttrib.h" #include "renderState.h" +#include "rescaleNormalAttrib.h" #include "clockObject.h" #include "config_pgraph.h" #include "depthOffsetAttrib.h" @@ -122,14 +123,30 @@ add_object(CullableObject *object, const CullTraverser *traverser) { Thread *current_thread = traverser->get_current_thread(); CullBinManager *bin_manager = CullBinManager::get_global_ptr(); - // Check to see if there's a special transparency setting. const RenderState *state = object->_state; nassertv(state != (const RenderState *)NULL); - const TransparencyAttrib *trans = (const TransparencyAttrib *) - state->get_attrib(TransparencyAttrib::get_class_slot()); + // This is probably a good time to check for an auto rescale setting. + const RescaleNormalAttrib *rescale; + state->get_attrib_def(rescale); + if (rescale->get_mode() == RescaleNormalAttrib::M_auto) { + RescaleNormalAttrib::Mode mode; - if (trans != (const TransparencyAttrib *)NULL) { + if (object->_internal_transform->has_identity_scale()) { + mode = RescaleNormalAttrib::M_none; + } else if (object->_internal_transform->has_uniform_scale()) { + mode = RescaleNormalAttrib::M_rescale; + } else { + mode = RescaleNormalAttrib::M_normalize; + } + + state = state->set_attrib(RescaleNormalAttrib::make(mode)); + object->_state = state; + } + + // Check to see if there's a special transparency setting. + const TransparencyAttrib *trans; + if (state->get_attrib(trans)) { switch (trans->get_mode()) { case TransparencyAttrib::M_alpha: // M_alpha implies an alpha-write test, so we don't waste time diff --git a/panda/src/pgraph/cullTraverserData.h b/panda/src/pgraph/cullTraverserData.h index 73c1b137c2..a8b3da130c 100644 --- a/panda/src/pgraph/cullTraverserData.h +++ b/panda/src/pgraph/cullTraverserData.h @@ -92,6 +92,7 @@ private: static CPT(RenderState) get_fake_view_frustum_cull_state(); }; +/* okcircular */ #include "cullTraverser.h" #include "cullTraverserData.I" diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index 14a6bad1d0..b842850db7 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -18,6 +18,7 @@ #include "colorAttrib.h" #include "texGenAttrib.h" #include "textureAttrib.h" +#include "shaderAttrib.h" #include "renderState.h" #include "clockObject.h" #include "cullTraverser.h" @@ -128,6 +129,17 @@ munge_geom(GraphicsStateGuardianBase *gsg, return false; } + // If we have prepared it for skinning via the shader generator, + // mark a flag on the state so that the shader generator will do this. + // We should probably find a cleaner way to do this. + const ShaderAttrib *sattr; + if (_state->get_attrib(sattr) && sattr->auto_shader()) { + GeomVertexDataPipelineReader data_reader(_munged_data, current_thread); + if (data_reader.get_format()->get_animation().get_animation_type() == Geom::AT_hardware) { + _state = _state->set_attrib(sattr->set_flag(ShaderAttrib::F_hardware_skinning, true)); + } + } + StateMunger *state_munger; DCAST_INTO_R(state_munger, munger, false); _state = state_munger->munge_state(_state); diff --git a/panda/src/pgraph/geomNode.h b/panda/src/pgraph/geomNode.h index 285783df99..cfdbd85e2c 100644 --- a/panda/src/pgraph/geomNode.h +++ b/panda/src/pgraph/geomNode.h @@ -36,7 +36,7 @@ class GraphicsStateGuardianBase; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PGRAPH GeomNode : public PandaNode { PUBLISHED: - GeomNode(const string &name); + explicit GeomNode(const string &name); protected: GeomNode(const GeomNode ©); diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 828179f603..20a2f90ab4 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -6191,20 +6191,32 @@ write_bounds(ostream &out) const { // than the bounding volume returned by get_bounds() // (but it is more expensive to compute). // +// The bounding box is computed relative to the parent +// node's coordinate system by default. You can +// optionally specify a different NodePath to compute +// the bounds relative to. Note that the box is always +// axis-aligned against the given NodePath's coordinate +// system, so you might get a differently sized box +// depending on which node you pass. +// // The return value is true if any points are within the // bounding volume, or false if none are. //////////////////////////////////////////////////////////////////// bool NodePath:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, - Thread *current_thread) const { + const NodePath &other, Thread *current_thread) const { min_point.set(0.0f, 0.0f, 0.0f); max_point.set(0.0f, 0.0f, 0.0f); nassertr_always(!is_empty(), false); + CPT(TransformState) transform = TransformState::make_identity(); + if (!other.is_empty()) { + transform = get_transform(other)->compose(get_transform()->get_inverse()); + } + bool found_any = false; node()->calc_tight_bounds(min_point, max_point, found_any, - TransformState::make_identity(), - current_thread); + MOVE(transform), current_thread); return found_any; } diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 74ce52c3a8..4e7a098601 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -177,8 +177,8 @@ PUBLISHED: INLINE explicit NodePath(const string &top_node_name, Thread *current_thread = Thread::get_current_thread()); INLINE explicit NodePath(PandaNode *node, Thread *current_thread = Thread::get_current_thread()); INLINE static NodePath any_path(PandaNode *node, Thread *current_thread = Thread::get_current_thread()); - NodePath(const NodePath &parent, PandaNode *child_node, - Thread *current_thread = Thread::get_current_thread()); + explicit NodePath(const NodePath &parent, PandaNode *child_node, + Thread *current_thread = Thread::get_current_thread()); INLINE NodePath(const NodePath ©); INLINE void operator = (const NodePath ©); @@ -876,9 +876,10 @@ PUBLISHED: void force_recompute_bounds(); void write_bounds(ostream &out) const; bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, + const NodePath &other = NodePath(), Thread *current_thread = Thread::get_current_thread()) const; - EXTENSION(PyObject *get_tight_bounds() const); + EXTENSION(PyObject *get_tight_bounds(const NodePath &other = NodePath()) const); // void analyze() const; diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx index b5cc7dbd51..d38164d3ba 100644 --- a/panda/src/pgraph/nodePath_ext.cxx +++ b/panda/src/pgraph/nodePath_ext.cxx @@ -240,14 +240,15 @@ py_decode_NodePath_from_bam_stream_persist(PyObject *unpickler, const string &da // objects. This is a convenience function for Python // users, among which the use of calc_tight_bounds // may be confusing. +// // Returns None if calc_tight_bounds returned false. //////////////////////////////////////////////////////////////////// PyObject *Extension:: -get_tight_bounds() const { +get_tight_bounds(const NodePath &other) const { LPoint3 *min_point = new LPoint3; LPoint3 *max_point = new LPoint3; - if (_this->calc_tight_bounds(*min_point, *max_point)) { + if (_this->calc_tight_bounds(*min_point, *max_point, other)) { #ifdef STDFLOAT_DOUBLE PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3d, true, false); PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3d, true, false); diff --git a/panda/src/pgraph/nodePath_ext.h b/panda/src/pgraph/nodePath_ext.h index 00983a9de1..67afe2a383 100644 --- a/panda/src/pgraph/nodePath_ext.h +++ b/panda/src/pgraph/nodePath_ext.h @@ -48,7 +48,7 @@ public: INLINE bool has_net_python_tag(const string &key) const; NodePath find_net_python_tag(const string &key) const; - PyObject *get_tight_bounds() const; + PyObject *get_tight_bounds(const NodePath &other = NodePath()) const; }; BEGIN_PUBLISH diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index c1719a7658..dda7244acb 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -72,7 +72,7 @@ class GraphicsStateGuardianBase; class EXPCL_PANDA_PGRAPH PandaNode : public TypedWritableReferenceCount, public Namable, public LinkedListNode { PUBLISHED: - PandaNode(const string &name); + explicit PandaNode(const string &name); virtual ~PandaNode(); //published so that characters can be combined. virtual PandaNode *combine_with(PandaNode *other); diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index e1bc57d632..4a59fb5302 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -271,8 +271,8 @@ private: // The code to manage this map lives in // GraphicsStateGuardian::get_geom_munger(). typedef pmap Mungers; - Mungers _mungers; - Mungers::const_iterator _last_mi; + mutable Mungers _mungers; + mutable Mungers::const_iterator _last_mi; // This is used to mark nodes as we visit them to detect cycles. UpdateSeq _cycle_detect; diff --git a/panda/src/pgraph/rescaleNormalAttrib.cxx b/panda/src/pgraph/rescaleNormalAttrib.cxx index 3f061975f8..7c20896810 100644 --- a/panda/src/pgraph/rescaleNormalAttrib.cxx +++ b/panda/src/pgraph/rescaleNormalAttrib.cxx @@ -114,6 +114,21 @@ get_hash_impl() const { return hash; } +//////////////////////////////////////////////////////////////////// +// Function: RescaleNormalAttrib::get_auto_shader_attrib_impl +// Access: Protected, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +CPT(RenderAttrib) RescaleNormalAttrib:: +get_auto_shader_attrib_impl(const RenderState *state) const { + // We currently only support M_normalize in the ShaderGenerator. + if (_mode == M_none || _mode == M_normalize) { + return this; + } else { + return RescaleNormalAttrib::make(M_normalize); + } +} + //////////////////////////////////////////////////////////////////// // Function: RescaleNormalAttrib::register_with_read_factory // Access: Public, Static diff --git a/panda/src/pgraph/rescaleNormalAttrib.h b/panda/src/pgraph/rescaleNormalAttrib.h index 4b165881ec..04f5575614 100644 --- a/panda/src/pgraph/rescaleNormalAttrib.h +++ b/panda/src/pgraph/rescaleNormalAttrib.h @@ -59,6 +59,7 @@ public: protected: virtual int compare_to_impl(const RenderAttrib *other) const; virtual size_t get_hash_impl() const; + virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const; private: Mode _mode; diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index ad9b1a6eef..82f05cfbad 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -429,9 +429,12 @@ get_shader_input_ptr(const InternalName *id) const { // Access: Published // Description: Returns the ShaderInput as a texture. Assertion // fails if there is none, or if it is not a texture. +// +// If sampler is not NULL, the sampler state to use +// for this texture is assigned to it. //////////////////////////////////////////////////////////////////// Texture *ShaderAttrib:: -get_shader_input_texture(const InternalName *id) const { +get_shader_input_texture(const InternalName *id, SamplerState *sampler) const { Inputs::const_iterator i = _inputs.find(id); if (i == _inputs.end()) { ostringstream strm; @@ -447,34 +450,10 @@ get_shader_input_texture(const InternalName *id) const { nassert_raise(strm.str()); return NULL; } - return p->get_texture(); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::get_shader_input_sampler -// Access: Published -// Description: Returns the ShaderInput as a sampler. Assertion -// fails if there is none, or if it is not a texture. -//////////////////////////////////////////////////////////////////// -const SamplerState &ShaderAttrib:: -get_shader_input_sampler(const InternalName *id) const { - Inputs::const_iterator i = _inputs.find(id); - if (i == _inputs.end()) { - ostringstream strm; - strm << "Shader input " << id->get_name() << " is not present.\n"; - nassert_raise(strm.str()); - return SamplerState::get_default(); - } else { - const ShaderInput *p = (*i).second; - if (p->get_value_type() != ShaderInput::M_texture && - p->get_value_type() != ShaderInput::M_texture_sampler) { - ostringstream strm; - strm << "Shader input " << id->get_name() << " is not a texture.\n"; - nassert_raise(strm.str()); - return SamplerState::get_default(); + if (sampler != NULL) { + *sampler = p->get_sampler(); } - return p->get_sampler(); + return p->get_texture(); } } @@ -723,6 +702,7 @@ get_auto_shader_attrib_impl(const RenderState *state) const { attrib->_auto_gloss_on = _auto_gloss_on; attrib->_auto_ramp_on = _auto_ramp_on; attrib->_auto_shadow_on = _auto_shadow_on; + attrib->_flags = _flags; return return_new(attrib); } diff --git a/panda/src/pgraph/shaderAttrib.h b/panda/src/pgraph/shaderAttrib.h index c6bb2eb583..d146e80bab 100644 --- a/panda/src/pgraph/shaderAttrib.h +++ b/panda/src/pgraph/shaderAttrib.h @@ -48,6 +48,7 @@ PUBLISHED: enum { F_disable_alpha_write = 0, // Suppress writes to color buffer alpha channel. F_subsume_alpha_test = 1, // Shader promises to subsume the alpha test using TEXKILL + F_hardware_skinning = 2, // Shader needs pre-animated vertices }; INLINE bool has_shader() const; @@ -106,8 +107,7 @@ PUBLISHED: const NodePath &get_shader_input_nodepath(const InternalName *id) const; LVecBase4 get_shader_input_vector(InternalName *id) const; - Texture *get_shader_input_texture(const InternalName *id) const; - const SamplerState &get_shader_input_sampler(const InternalName *id) const; + Texture *get_shader_input_texture(const InternalName *id, SamplerState *sampler=NULL) const; const Shader::ShaderPtrData *get_shader_input_ptr(const InternalName *id) const; const LMatrix4 &get_shader_input_matrix(const InternalName *id, LMatrix4 &matrix) const; diff --git a/panda/src/pgraph/shaderInput.I b/panda/src/pgraph/shaderInput.I index c7aed1de80..5a060bb0e6 100644 --- a/panda/src/pgraph/shaderInput.I +++ b/panda/src/pgraph/shaderInput.I @@ -31,10 +31,7 @@ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, int priority) : _name(MOVE(name)), _type(M_invalid), - _priority(priority), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _priority(priority) { } @@ -48,60 +45,10 @@ ShaderInput(CPT_InternalName name, Texture *tex, int priority) : _name(MOVE(name)), _type(M_texture), _priority(priority), - _value(tex), - _bind_layer(0), - _bind_level(0), - _access(A_read | A_write | A_layered) + _value(tex) { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE ShaderInput:: -ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) : - _name(MOVE(name)), - _type(M_texture_sampler), - _priority(priority), - _value(tex), - _sampler(sampler), - _bind_layer(0), - _bind_level(0), - _access(A_read | A_layered) -{ -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE ShaderInput:: -ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) : - _name(MOVE(name)), - _type(M_texture), - _priority(priority), - _value(tex), - _bind_layer(z), - _bind_level(n), - _access(0) -{ - if (read) { - _access |= A_read; - } - if (write) { - _access |= A_write; - } - if (z >= 0) { - _bind_layer = z; - } else { - _bind_layer = 0; - _access |= A_layered; - } -} - //////////////////////////////////////////////////////////////////// // Function: ShaderInput::Constructor // Access: Published @@ -112,10 +59,7 @@ ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority) : _name(MOVE(name)), _type(M_param), _priority(priority), - _value(param), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _value(param) { } @@ -129,10 +73,7 @@ ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -146,10 +87,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -163,10 +101,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3f &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -180,10 +115,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2f &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -198,10 +130,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4f &vec, int priority) : _type(M_vector), _priority(priority), _stored_ptr(vec), - _stored_vector(LCAST(PN_stdfloat, vec)), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector(LCAST(PN_stdfloat, vec)) { } @@ -216,10 +145,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3f &vec, int priority) : _type(M_vector), _priority(priority), _stored_ptr(vec), - _stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0) { } @@ -234,10 +160,7 @@ ShaderInput(CPT_InternalName name, const LVecBase2f &vec, int priority) : _type(M_vector), _priority(priority), _stored_ptr(vec), - _stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0) { } @@ -251,10 +174,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix4f &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -268,10 +188,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix3f &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -285,10 +202,7 @@ ShaderInput(CPT_InternalName name, const LMatrix4f &mat, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(mat), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(mat) { } @@ -302,10 +216,7 @@ ShaderInput(CPT_InternalName name, const LMatrix3f &mat, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(mat), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(mat) { } @@ -319,10 +230,7 @@ ShaderInput(CPT_InternalName name, const PTA_double &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -336,10 +244,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4d &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -353,10 +258,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3d &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -370,10 +272,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2d &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -388,10 +287,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4d &vec, int priority) : _type(M_numeric), _priority(priority), _stored_ptr(vec), - _stored_vector(LCAST(PN_stdfloat, vec)), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector(LCAST(PN_stdfloat, vec)) { } @@ -406,10 +302,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3d &vec, int priority) : _type(M_numeric), _priority(priority), _stored_ptr(vec), - _stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0) { } @@ -424,10 +317,7 @@ ShaderInput(CPT_InternalName name, const LVecBase2d &vec, int priority) : _type(M_numeric), _priority(priority), _stored_ptr(vec), - _stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0) { } @@ -441,10 +331,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix4d &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -458,10 +345,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix3d &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -475,10 +359,7 @@ ShaderInput(CPT_InternalName name, const LMatrix4d &mat, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(mat), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(mat) { } @@ -492,10 +373,7 @@ ShaderInput(CPT_InternalName name, const LMatrix3d &mat, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(mat), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(mat) { } @@ -509,10 +387,7 @@ ShaderInput(CPT_InternalName name, const PTA_int &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -526,10 +401,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4i &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -543,10 +415,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3i &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -560,10 +429,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2i &ptr, int priority) : _name(MOVE(name)), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_ptr(ptr) { } @@ -578,10 +444,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4i &vec, int priority) : _type(M_numeric), _priority(priority), _stored_ptr(vec), - _stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), (int)vec.get_w()), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), (int)vec.get_w()) { } @@ -596,10 +459,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3i &vec, int priority) : _type(M_numeric), _priority(priority), _stored_ptr(vec), - _stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), 0.0), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), 0.0) { } @@ -614,10 +474,7 @@ ShaderInput(CPT_InternalName name, const LVecBase2i &vec, int priority) : _type(M_numeric), _priority(priority), _stored_ptr(vec), - _stored_vector((int)vec.get_x(), (int)vec.get_y(), 0.0, 0.0), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _stored_vector((int)vec.get_x(), (int)vec.get_y(), 0.0, 0.0) { } @@ -651,16 +508,6 @@ get_priority() const { return _priority; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_texture -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE Texture *ShaderInput:: -get_texture() const { - return DCAST(Texture, _value); -} - //////////////////////////////////////////////////////////////////// // Function: ShaderInput::get_vector // Access: Published @@ -681,18 +528,6 @@ get_ptr() const { return _stored_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_sampler -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE const SamplerState &ShaderInput:: -get_sampler() const { - return (_type == M_texture) - ? get_texture()->get_default_sampler() - : _sampler; -} - //////////////////////////////////////////////////////////////////// // Function: ShaderInput::get_param // Access: Public diff --git a/panda/src/pgraph/shaderInput.cxx b/panda/src/pgraph/shaderInput.cxx index 8ab7ef3b1a..ecb281f6f3 100644 --- a/panda/src/pgraph/shaderInput.cxx +++ b/panda/src/pgraph/shaderInput.cxx @@ -14,6 +14,7 @@ #include "shaderInput.h" #include "paramNodePath.h" +#include "paramTexture.h" TypeHandle ShaderInput::_type_handle; @@ -43,10 +44,35 @@ ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : _name(MOVE(name)), _type(M_nodepath), _priority(priority), - _value(new ParamNodePath(np)), - _bind_layer(0), - _bind_level(0), - _access(A_read) + _value(new ParamNodePath(np)) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +ShaderInput:: +ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) : + _name(MOVE(name)), + _type(M_texture_image), + _priority(priority), + _value(new ParamTextureImage(tex, read, write, z, n)) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +ShaderInput:: +ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) : + _name(MOVE(name)), + _type(M_texture_sampler), + _priority(priority), + _value(new ParamTextureSampler(tex, sampler)) { } @@ -61,6 +87,40 @@ get_nodepath() const { return DCAST(ParamNodePath, _value)->get_value(); } +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::get_texture +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +Texture *ShaderInput:: +get_texture() const { + switch (_type) { + case M_texture_sampler: + return DCAST(ParamTextureSampler, _value)->get_texture(); + + case M_texture_image: + return DCAST(ParamTextureImage, _value)->get_texture(); + + case M_texture: + return DCAST(Texture, _value); + + default: + return NULL; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::get_sampler +// Access: Published +// Description: Warning: no error checking is done. +//////////////////////////////////////////////////////////////////// +const SamplerState &ShaderInput:: +get_sampler() const { + return (_type == M_texture_sampler) + ? DCAST(ParamTextureSampler, _value)->get_sampler() + : get_texture()->get_default_sampler(); +} + //////////////////////////////////////////////////////////////////// // Function: ShaderInput::register_with_read_factory // Access: Public, Static diff --git a/panda/src/pgraph/shaderInput.h b/panda/src/pgraph/shaderInput.h index 26c7e2e375..11b4630a53 100644 --- a/panda/src/pgraph/shaderInput.h +++ b/panda/src/pgraph/shaderInput.h @@ -53,8 +53,6 @@ PUBLISHED: static const ShaderInput *get_blank(); INLINE ShaderInput(CPT_InternalName name, int priority=0); INLINE ShaderInput(CPT_InternalName name, Texture *tex, int priority=0); - INLINE ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority=0); - INLINE ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z=-1, int n=0, int priority=0); INLINE ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority=0); INLINE ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority=0); INLINE ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority=0); @@ -89,6 +87,8 @@ PUBLISHED: INLINE ShaderInput(CPT_InternalName name, const LVecBase2i &vec, int priority=0); ShaderInput(CPT_InternalName name, const NodePath &np, int priority=0); + ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z=-1, int n=0, int priority=0); + ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority=0); enum ShaderInputType { M_invalid = 0, @@ -97,19 +97,20 @@ PUBLISHED: M_vector, M_numeric, M_texture_sampler, - M_param + M_param, + M_texture_image }; INLINE const InternalName *get_name() const; INLINE int get_value_type() const; INLINE int get_priority() const; - INLINE Texture *get_texture() const; INLINE const LVecBase4 &get_vector() const; INLINE const Shader::ShaderPtrData &get_ptr() const; - INLINE const SamplerState &get_sampler() const; const NodePath &get_nodepath() const; + Texture *get_texture() const; + const SamplerState &get_sampler() const; public: INLINE ParamValueBase *get_param() const; @@ -117,25 +118,19 @@ public: static void register_with_read_factory(); private: - SamplerState _sampler; LVecBase4 _stored_vector; Shader::ShaderPtrData _stored_ptr; CPT_InternalName _name; PT(TypedWritableReferenceCount) _value; int _priority; - -public: - int _type : 8; - int _access : 8; - int _bind_level : 16; - int _bind_layer; + int _type; public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { - ReferenceCount::init_type(); + TypedWritableReferenceCount::init_type(); register_type(_type_handle, "ShaderInput", TypedWritableReferenceCount::get_class_type()); } diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index da3232692e..488fe84c95 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -37,6 +37,7 @@ #include "texture.h" #include "ambientLight.h" #include "directionalLight.h" +#include "rescaleNormalAttrib.h" #include "pointLight.h" #include "spotlight.h" #include "lightLensNode.h" @@ -91,19 +92,25 @@ reset_register_allocator() { //////////////////////////////////////////////////////////////////// const char *ShaderGenerator:: alloc_vreg() { + // The ATTR# input sseem to map to generic vertex attributes in + // both arbvp1 and glslv, which behave more consistently. switch (_vtregs_used) { - case 0: _vtregs_used += 1; return "TEXCOORD0"; - case 1: _vtregs_used += 1; return "TEXCOORD1"; - case 2: _vtregs_used += 1; return "TEXCOORD2"; - case 3: _vtregs_used += 1; return "TEXCOORD3"; - case 4: _vtregs_used += 1; return "TEXCOORD4"; - case 5: _vtregs_used += 1; return "TEXCOORD5"; - case 6: _vtregs_used += 1; return "TEXCOORD6"; - case 7: _vtregs_used += 1; return "TEXCOORD7"; + case 0: _vtregs_used += 1; return "ATTR8"; + case 1: _vtregs_used += 1; return "ATTR9"; + case 2: _vtregs_used += 1; return "ATTR10"; + case 3: _vtregs_used += 1; return "ATTR11"; + case 4: _vtregs_used += 1; return "ATTR12"; + case 5: _vtregs_used += 1; return "ATTR13"; + case 6: _vtregs_used += 1; return "ATTR14"; + case 7: _vtregs_used += 1; return "ATTR15"; } switch (_vcregs_used) { - case 0: _vcregs_used += 1; return "COLOR0"; - case 1: _vcregs_used += 1; return "COLOR1"; + case 0: _vcregs_used += 1; return "ATTR3"; + case 1: _vcregs_used += 1; return "ATTR4"; + case 2: _vcregs_used += 1; return "ATTR5"; + case 3: _vcregs_used += 1; return "ATTR6"; + case 4: _vcregs_used += 1; return "ATTR7"; + case 5: _vcregs_used += 1; return "ATTR1"; } // These don't exist in arbvp1, though they're reportedly // supported by other profiles. @@ -326,6 +333,12 @@ analyze_renderstate(const RenderState *rs) { _need_eye_normal = true; } + // Determine whether we should normalize the normals. + const RescaleNormalAttrib *rescale; + rs->get_attrib_def(rescale); + + _normalize_normals = (rescale->get_mode() != RescaleNormalAttrib::M_none); + // Find the material. const MaterialAttrib *material = DCAST(MaterialAttrib, rs->get_attrib_def(MaterialAttrib::get_class_slot())); @@ -487,6 +500,7 @@ clear_analysis() { _need_world_normal = false; _need_eye_position = false; _need_eye_normal = false; + _normalize_normals = false; _auto_normal_on = false; _auto_glow_on = false; _auto_gloss_on = false; @@ -607,6 +621,7 @@ update_shadow_buffer(NodePath light_np) { // - texmatrix // - 1D/2D/3D textures, cube textures, 2D tex arrays // - linear/exp/exp2 fog +// - animation // // Not yet supported: // - dot3_rgb and dot3_rgba combine modes @@ -616,7 +631,7 @@ update_shadow_buffer(NodePath light_np) { // //////////////////////////////////////////////////////////////////// CPT(ShaderAttrib) ShaderGenerator:: -synthesize_shader(const RenderState *rs) { +synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { analyze_renderstate(rs); reset_register_allocator(); @@ -652,7 +667,7 @@ synthesize_shader(const RenderState *rs) { text << "//Cg\n"; - text << "/* Generated shader for render state " << rs << ":\n"; + text << "/* Generated shader for render state:\n"; rs->write(text, 2); text << "*/\n"; @@ -698,7 +713,7 @@ synthesize_shader(const RenderState *rs) { } } if (_vertex_colors) { - text << "\t in float4 vtx_color : COLOR0,\n"; + text << "\t in float4 vtx_color : ATTR3,\n"; text << "\t out float4 l_color : COLOR0,\n"; } if (_need_world_position || _need_world_normal) { @@ -716,6 +731,8 @@ synthesize_shader(const RenderState *rs) { text << "\t uniform float4x4 trans_model_to_view,\n"; eye_position_freg = alloc_freg(); text << "\t out float4 l_eye_position : " << eye_position_freg << ",\n"; + } else if ((_lighting || _out_aux_normal) && (_map_index_normal >= 0 && _auto_normal_on)) { + text << "\t uniform float4x4 trans_model_to_view,\n"; } if (_need_eye_normal) { eye_normal_freg = alloc_freg(); @@ -723,7 +740,7 @@ synthesize_shader(const RenderState *rs) { text << "\t out float4 l_eye_normal : " << eye_normal_freg << ",\n"; } if (_map_index_height >= 0 || _need_world_normal || _need_eye_normal) { - text << "\t in float3 vtx_normal : NORMAL,\n"; + text << "\t in float3 vtx_normal : ATTR2,\n"; } if (_map_index_height >= 0) { text << "\t uniform float4 mspos_view,\n"; @@ -755,11 +772,50 @@ synthesize_shader(const RenderState *rs) { hpos_freg = alloc_freg(); text << "\t out float4 l_hpos : " << hpos_freg << ",\n"; } - text << "\t float4 vtx_position : POSITION,\n"; + if (anim.get_animation_type() == GeomEnums::AT_hardware && + anim.get_num_transforms() > 0) { + int num_transforms; + if (anim.get_indexed_transforms()) { + num_transforms = 120; + } else { + num_transforms = anim.get_num_transforms(); + } + text << "\t uniform float4x4 tbl_transforms[" << num_transforms << "],\n"; + text << "\t in float4 vtx_transform_weight : ATTR1,\n"; + if (anim.get_indexed_transforms()) { + text << "\t in uint4 vtx_transform_index : ATTR7,\n"; + } + } + text << "\t in float4 vtx_position : ATTR0,\n"; text << "\t out float4 l_position : POSITION,\n"; text << "\t uniform float4x4 mat_modelproj\n"; text << ") {\n"; + if (anim.get_animation_type() == GeomEnums::AT_hardware && + anim.get_num_transforms() > 0) { + + if (!anim.get_indexed_transforms()) { + text << "\t const uint4 vtx_transform_index = uint4(0, 1, 2, 3);\n"; + } + + text << "\t float4x4 matrix = tbl_transforms[vtx_transform_index.x] * vtx_transform_weight.x"; + if (anim.get_num_transforms() > 1) { + text << "\n\t + tbl_transforms[vtx_transform_index.y] * vtx_transform_weight.y"; + } + if (anim.get_num_transforms() > 2) { + text << "\n\t + tbl_transforms[vtx_transform_index.z] * vtx_transform_weight.z"; + } + if (anim.get_num_transforms() > 3) { + text << "\n\t + tbl_transforms[vtx_transform_index.w] * vtx_transform_weight.w"; + } + text << ";\n"; + + text << "\t vtx_position = mul(matrix, vtx_position);\n"; + if (_need_world_normal || _need_eye_normal) { + text << "\t vtx_normal = mul((float3x3)matrix, vtx_normal);\n"; + } + } + text << "\t l_position = mul(mat_modelproj, vtx_position);\n"; if (_fog) { text << "\t l_hpos = l_position;\n"; @@ -774,7 +830,11 @@ synthesize_shader(const RenderState *rs) { text << "\t l_eye_position = mul(trans_model_to_view, vtx_position);\n"; } if (_need_eye_normal) { - text << "\t l_eye_normal.xyz = mul((float3x3)tpose_view_to_model, vtx_normal);\n"; + if (_normalize_normals) { + text << "\t l_eye_normal.xyz = normalize(mul((float3x3)tpose_view_to_model, vtx_normal));\n"; + } else { + text << "\t l_eye_normal.xyz = mul((float3x3)tpose_view_to_model, vtx_normal);\n"; + } text << "\t l_eye_normal.w = 0;\n"; } pmap::const_iterator it; @@ -787,9 +847,9 @@ synthesize_shader(const RenderState *rs) { text << "\t l_color = vtx_color;\n"; } if ((_lighting || _out_aux_normal) && (_map_index_normal >= 0 && _auto_normal_on)) { - text << "\t l_tangent.xyz = mul((float3x3)tpose_view_to_model, vtx_" << tangent_input << ".xyz);\n"; + text << "\t l_tangent.xyz = normalize(mul((float3x3)trans_model_to_view, vtx_" << tangent_input << ".xyz));\n"; text << "\t l_tangent.w = 0;\n"; - text << "\t l_binormal.xyz = mul((float3x3)tpose_view_to_model, -vtx_" << binormal_input << ".xyz);\n"; + text << "\t l_binormal.xyz = normalize(mul((float3x3)trans_model_to_view, -vtx_" << binormal_input << ".xyz));\n"; text << "\t l_binormal.w = 0;\n"; } if (_shadows && _auto_shadow_on) { diff --git a/panda/src/pgraphnodes/shaderGenerator.h b/panda/src/pgraphnodes/shaderGenerator.h index 1e1daa581d..146f115d9a 100644 --- a/panda/src/pgraphnodes/shaderGenerator.h +++ b/panda/src/pgraphnodes/shaderGenerator.h @@ -33,6 +33,7 @@ class DirectionalLight; class PointLight; class Spotlight; class LightAttrib; +class GeomVertexAnimationSpec; //////////////////////////////////////////////////////////////////// // Class : ShaderGenerator @@ -71,7 +72,8 @@ class EXPCL_PANDA_PGRAPHNODES ShaderGenerator : public TypedReferenceCount { PUBLISHED: ShaderGenerator(GraphicsStateGuardianBase *gsg, GraphicsOutputBase *host); virtual ~ShaderGenerator(); - virtual CPT(ShaderAttrib) synthesize_shader(const RenderState *rs); + virtual CPT(ShaderAttrib) synthesize_shader(const RenderState *rs, + const GeomVertexAnimationSpec &anim); protected: CPT(RenderAttrib) create_shader_attrib(const string &txt); @@ -146,6 +148,7 @@ protected: bool _need_world_normal; bool _need_eye_position; bool _need_eye_normal; + bool _normalize_normals; bool _auto_normal_on; bool _auto_glow_on; bool _auto_gloss_on; diff --git a/panda/src/pnmimage/Sources.pp b/panda/src/pnmimage/Sources.pp index 8ab8efb55b..3b3863cb98 100644 --- a/panda/src/pnmimage/Sources.pp +++ b/panda/src/pnmimage/Sources.pp @@ -11,6 +11,8 @@ #define SOURCES \ config_pnmimage.h \ + convert_srgb.I convert_srgb.h \ + convert_srgb_sse2.cxx \ pfmFile.I pfmFile.h \ pfmFile_ext.cxx pfmFile_ext.h \ pnmbitio.h \ @@ -24,6 +26,7 @@ #define INCLUDED_SOURCES \ config_pnmimage.cxx \ + convert_srgb.cxx \ pfmFile.cxx \ pnm-image-filter.cxx \ pnmbitio.cxx \ @@ -36,6 +39,7 @@ #define INSTALL_HEADERS \ config_pnmimage.h \ + convert_srgb.I convert_srgb.h \ pfmFile.I pfmFile.h \ pfmFile_ext.cxx pfmFile_ext.h \ pnmBrush.h pnmBrush.I \ diff --git a/panda/src/pnmimage/convert_srgb.cxx b/panda/src/pnmimage/convert_srgb.cxx index 426e9818c5..184b3d679c 100644 --- a/panda/src/pnmimage/convert_srgb.cxx +++ b/panda/src/pnmimage/convert_srgb.cxx @@ -15,7 +15,7 @@ #include "convert_srgb.h" // Lookup tables for converting from unsigned char formats. -ALIGN_64BYTE const +const unsigned char to_srgb8_table[256] = { 0x00, 0x0d, 0x16, 0x1c, 0x22, 0x26, 0x2a, 0x2e, 0x32, 0x35, 0x38, 0x3b, 0x3d, 0x40, 0x42, 0x45, 0x47, 0x49, 0x4b, 0x4d, 0x4f, 0x51, 0x53, 0x55, 0x56, 0x58, 0x5a, 0x5c, 0x5d, 0x5f, 0x60, 0x62, 0x63, @@ -38,7 +38,7 @@ unsigned char to_srgb8_table[256] = { 0x00, 0x0d, 0x16, 0x1c, 0x22, 0x26, 0x2a, 0xf9, 0xf9, 0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfd, 0xfd, 0xfe, 0xfe, 0xff, 0xff}; -ALIGN_64BYTE const +const unsigned char to_linear_uchar_table[256] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, @@ -61,7 +61,6 @@ unsigned char to_linear_uchar_table[256] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe0, 0xe2, 0xe5, 0xe7, 0xe9, 0xeb, 0xed, 0xef, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfd, 0xff}; -ALIGN_64BYTE const float to_linear_float_table[256] = { 0, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, 0.002428f, 0.002732f, 0.003035f, 0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, 0.005182f, 0.005605f, diff --git a/panda/src/pnmimage/convert_srgb.h b/panda/src/pnmimage/convert_srgb.h index 33f362ef82..5eee26efd8 100644 --- a/panda/src/pnmimage/convert_srgb.h +++ b/panda/src/pnmimage/convert_srgb.h @@ -22,9 +22,9 @@ // The below functions can encode and decode sRGB colors in various // representations. Some of them are implemented using look-up tables, // some others using SSE2 intrinsics. -extern EXPCL_PANDA_PNMIMAGE ALIGN_64BYTE const unsigned char to_srgb8_table[256]; -extern EXPCL_PANDA_PNMIMAGE ALIGN_64BYTE const unsigned char to_linear_uchar_table[256]; -extern EXPCL_PANDA_PNMIMAGE ALIGN_64BYTE const float to_linear_float_table[256]; +extern EXPCL_PANDA_PNMIMAGE const unsigned char to_srgb8_table[256]; +extern EXPCL_PANDA_PNMIMAGE const unsigned char to_linear_uchar_table[256]; +extern EXPCL_PANDA_PNMIMAGE const float to_linear_float_table[256]; EXPCL_PANDA_PNMIMAGE INLINE float decode_sRGB_float(unsigned char val); EXPCL_PANDA_PNMIMAGE INLINE float decode_sRGB_float(float val); diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index b4b98ad6c8..57a3ff57ed 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -679,6 +679,63 @@ make_grayscale(float rc, float gc, float bc) { setup_rc(); } +//////////////////////////////////////////////////////////////////// +// Function: PNMImage::premultiply_alpha +// Access: Published +// Description: Converts an image in-place to its "premultiplied" +// form, where, for every pixel in the image, the +// red, green, and blue components are multiplied by +// that pixel's alpha value. +// +// This does not modify any alpha values. +//////////////////////////////////////////////////////////////////// +void PNMImage:: +premultiply_alpha() { + if (!has_alpha()) { + return; + } + + for (int y = 0; y < get_y_size(); y++) { + for (int x = 0; x < get_x_size(); x++) { + float alpha = get_alpha(x, y); + float r = get_red(x, y) * alpha; + float g = get_green(x, y) * alpha; + float b = get_blue(x, y) * alpha; + set_xel(x, y, r, g, b); + } + } +} + +//////////////////////////////////////////////////////////////////// +// Function: PNMImage::unpremultiply_alpha +// Access: Published +// Description: Converts an image in-place to its "straight alpha" +// form (presumably from a "premultiplied" form), +// where, for every pixel in the image, the red, +// green, and blue components are divided by that +// pixel's alpha value. +// +// This does not modify any alpha values. +//////////////////////////////////////////////////////////////////// +void PNMImage:: +unpremultiply_alpha() { + if (!has_alpha()) { + return; + } + + for (int y = 0; y < get_y_size(); y++) { + for (int x = 0; x < get_x_size(); x++) { + float alpha = get_alpha(x, y); + if (alpha > 0) { + float r = get_red(x, y) / alpha; + float g = get_green(x, y) / alpha; + float b = get_blue(x, y) / alpha; + set_xel(x, y, r, g, b); + } + } + } +} + //////////////////////////////////////////////////////////////////// // Function: PNMImage::reverse_rows // Access: Published diff --git a/panda/src/pnmimage/pnmImage.h b/panda/src/pnmimage/pnmImage.h index dd75fda118..10e3377635 100644 --- a/panda/src/pnmimage/pnmImage.h +++ b/panda/src/pnmimage/pnmImage.h @@ -68,10 +68,10 @@ class PNMFileType; class EXPCL_PANDA_PNMIMAGE PNMImage : public PNMImageHeader { PUBLISHED: INLINE PNMImage(); - PNMImage(const Filename &filename, PNMFileType *type = NULL); - INLINE PNMImage(int x_size, int y_size, int num_channels = 3, - xelval maxval = 255, PNMFileType *type = NULL, - ColorSpace color_space = CS_linear); + explicit PNMImage(const Filename &filename, PNMFileType *type = NULL); + INLINE explicit PNMImage(int x_size, int y_size, int num_channels = 3, + xelval maxval = 255, PNMFileType *type = NULL, + ColorSpace color_space = CS_linear); INLINE PNMImage(const PNMImage ©); INLINE void operator = (const PNMImage ©); @@ -134,6 +134,9 @@ PUBLISHED: void make_grayscale(float rc, float gc, float bc); INLINE void make_rgb(); + void premultiply_alpha(); + void unpremultiply_alpha(); + BLOCKING void reverse_rows(); BLOCKING void flip(bool flip_x, bool flip_y, bool transpose); diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index b75e6b0b74..ad5cf47555 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -42,8 +42,9 @@ typedef unsigned char gray; struct pixel { PUBLISHED: pixel() { } + pixel(gray fill) : r(fill), g(fill), b(fill) { } pixel(gray r, gray g, gray b) : r(r), g(g), b(b) { } - static int size() { return 3; } + gray operator [](int i) const { nassertr(i >= 0 && i < 3, 0); return *(&r + i); } gray &operator [](int i) { nassertr(i >= 0 && i < 3, r); return *(&r + i); } pixel operator + (const pixel &other) const @@ -60,6 +61,7 @@ PUBLISHED: { r *= mult; g *= mult; b *= mult; } #ifdef HAVE_PYTHON + static int size() { return 3; } void output(ostream &out) { out << "pixel(r=" << r << ", g=" << g << ", b=" << b << ")"; } diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index ff8cfa0052..27356576f9 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -129,6 +129,7 @@ static TimeCollectorProperties time_properties[] = { { 1, "Cull", { 0.21, 0.68, 0.37 }, 1.0 / 30.0 }, { 1, "Cull:Setup", { 0.7, 0.4, 0.5 } }, { 1, "Cull:Sort", { 0.3, 0.3, 0.6 } }, + { 1, "*", { 0.1, 0.1, 0.5 } }, { 1, "*:Show fps", { 0.5, 0.8, 1.0 } }, { 0, "*:Munge", { 0.3, 0.3, 0.9 } }, { 1, "*:Munge:Geom", { 0.4, 0.2, 0.8 } }, diff --git a/panda/src/pstatclient/pStatThread.h b/panda/src/pstatclient/pStatThread.h index df0435585b..36a091faeb 100644 --- a/panda/src/pstatclient/pStatThread.h +++ b/panda/src/pstatclient/pStatThread.h @@ -29,7 +29,7 @@ class Thread; // with Panda's Thread instance. //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PSTATCLIENT PStatThread { -private: +public: INLINE PStatThread(); PUBLISHED: diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index 9092bb4292..aea7e90733 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -29,7 +29,7 @@ callbackObject.h callbackObject.I \ callbackObject_ext.h callbackObject_ext.I \ clockObject.h clockObject.I \ - collideMask.h \ + colorSpace.h collideMask.h \ copyOnWriteObject.h copyOnWriteObject.I \ copyOnWritePointer.h copyOnWritePointer.I \ compareTo.I compareTo.h \ @@ -91,9 +91,10 @@ callbackData.cxx \ callbackObject.cxx \ clockObject.cxx \ + colorSpace.cxx \ + config_util.cxx configurable.cxx \ copyOnWriteObject.cxx \ copyOnWritePointer.cxx \ - config_util.cxx configurable.cxx \ cPointerCallbackObject.cxx \ datagramInputFile.cxx datagramOutputFile.cxx \ doubleBitMask.cxx \ @@ -141,7 +142,7 @@ callbackObject.h callbackObject.I \ callbackObject_ext.h callbackObject_ext.I \ clockObject.h clockObject.I \ - collideMask.h \ + colorSpace.h collideMask.h \ copyOnWriteObject.h copyOnWriteObject.I \ copyOnWritePointer.h copyOnWritePointer.I \ compareTo.I compareTo.h \ diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index 2c7ed67416..9ae84b5deb 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -1222,6 +1222,11 @@ p_read_object() { } return p_read_object(); + + default: + bam_cat.error() + << "Encountered invalid BamObjectCode 0x" << hex << (int)boc << dec << ".\n"; + return 0; } // An object definition in a Bam file consists of a TypeHandle diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index f7d91ee76f..ba519760f9 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/panda/src/rocket/rocketFileInterface.cxx @@ -41,8 +41,18 @@ Open(const Rocket::Core::String& path) { PT(VirtualFile) file = _vfs->get_file(fn); if (file == NULL) { - rocket_cat.error() << "Failed to find " << fn << "\n"; - return (Rocket::Core::FileHandle) NULL; + // failed? Try model-path as a Panda-friendly fallback. + if (!_vfs->resolve_filename(fn, get_model_path())) { + rocket_cat.error() << "Could not resolve " << fn + << " along the model-path (currently: " << get_model_path() << ")\n"; + return (Rocket::Core::FileHandle) NULL; + } + + file = _vfs->get_file(fn); + if (file == NULL) { + rocket_cat.error() << "Failed to get " << fn << ", found on model-path\n"; + return (Rocket::Core::FileHandle) NULL; + } } istream *str = file->open_read_file(true); diff --git a/panda/src/rocket/rocketInputHandler.cxx b/panda/src/rocket/rocketInputHandler.cxx index 58408ae08e..71ea099192 100644 --- a/panda/src/rocket/rocketInputHandler.cxx +++ b/panda/src/rocket/rocketInputHandler.cxx @@ -113,6 +113,22 @@ get_rocket_key(const ButtonHandle handle) { keymap[KeyboardButton::rshift().get_index()] = KI_RSHIFT; keymap[KeyboardButton::scroll_lock().get_index()] = KI_SCROLL; + // these "OEM" keys have standard mappings in Panda3D + keymap[KeyboardButton::ascii_key(';').get_index()] = KI_OEM_1; + keymap[KeyboardButton::ascii_key('=').get_index()] = KI_OEM_PLUS; + keymap[KeyboardButton::ascii_key(',').get_index()] = KI_OEM_COMMA; + keymap[KeyboardButton::ascii_key('-').get_index()] = KI_OEM_MINUS; + keymap[KeyboardButton::ascii_key('.').get_index()] = KI_OEM_PERIOD; + keymap[KeyboardButton::ascii_key('/').get_index()] = KI_OEM_2; + keymap[KeyboardButton::ascii_key('`').get_index()] = KI_OEM_3; + keymap[KeyboardButton::ascii_key('[').get_index()] = KI_OEM_4; + keymap[KeyboardButton::ascii_key('\\').get_index()] = KI_OEM_5; + keymap[KeyboardButton::ascii_key(']').get_index()] = KI_OEM_6; + + // comment says this may either be "<>" or "\|", but "\" (unshifted) is handled already, + // and "<" is only available "shifted" on 101-keyboards, so assume it's this one... + keymap[KeyboardButton::ascii_key('<').get_index()] = KI_OEM_102; + for (char c = 'a'; c <= 'z'; ++c) { keymap[KeyboardButton::ascii_key(c).get_index()] = (c - 'a') + KI_A; } diff --git a/panda/src/rocket/rocketRenderInterface.cxx b/panda/src/rocket/rocketRenderInterface.cxx index 2813b89d5c..c3d7af2ffa 100644 --- a/panda/src/rocket/rocketRenderInterface.cxx +++ b/panda/src/rocket/rocketRenderInterface.cxx @@ -66,7 +66,10 @@ render(Rocket::Core::Context* context, CullTraverser *trav) { // Description: Called internally to make a Geom from Rocket data. //////////////////////////////////////////////////////////////////// PT(Geom) RocketRenderInterface:: -make_geom(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, GeomEnums::UsageHint uh) { +make_geom(Rocket::Core::Vertex* vertices, + int num_vertices, int* indices, int num_indices, + GeomEnums::UsageHint uh, const LVecBase2 &tex_scale) { + PT(GeomVertexData) vdata = new GeomVertexData("", GeomVertexFormat::get_v3c4t2(), uh); vdata->unclean_set_num_rows(num_vertices); { @@ -81,7 +84,8 @@ make_geom(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int nu vwriter.add_data3f(LVector3f::right() * vertex.position.x + LVector3f::up() * vertex.position.y); cwriter.add_data4i(vertex.colour.red, vertex.colour.green, vertex.colour.blue, vertex.colour.alpha); - twriter.add_data2f(vertex.tex_coord.x, 1.0f - vertex.tex_coord.y); + twriter.add_data2f(vertex.tex_coord.x * tex_scale[0], + (1.0f - vertex.tex_coord.y) * tex_scale[1]); } } @@ -140,12 +144,24 @@ render_geom(const Geom* geom, const RenderState* state, const Rocket::Core::Vect // that the application does not wish to optimize. //////////////////////////////////////////////////////////////////// void RocketRenderInterface:: -RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation) { - PT(Geom) geom = make_geom(vertices, num_vertices, indices, num_indices, GeomEnums::UH_stream); +RenderGeometry(Rocket::Core::Vertex* vertices, + int num_vertices, int* indices, int num_indices, + Rocket::Core::TextureHandle thandle, + const Rocket::Core::Vector2f& translation) { + + Texture *texture = (Texture *)thandle; + + LVecBase2 tex_scale(1, 1); + if (texture != (Texture *)NULL) { + tex_scale = texture->get_tex_scale(); + } + + PT(Geom) geom = make_geom(vertices, num_vertices, indices, num_indices, + GeomEnums::UH_stream, tex_scale); CPT(RenderState) state; - if ((Texture*) texture != (Texture*) NULL) { - state = RenderState::make(TextureAttrib::make((Texture*) texture)); + if (texture != (Texture *)NULL) { + state = RenderState::make(TextureAttrib::make(texture)); } else { state = RenderState::make_empty(); } @@ -160,30 +176,40 @@ RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, i // it believes will be static for the forseeable future. //////////////////////////////////////////////////////////////////// Rocket::Core::CompiledGeometryHandle RocketRenderInterface:: -CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture) { +CompileGeometry(Rocket::Core::Vertex* vertices, + int num_vertices, int* indices, int num_indices, + Rocket::Core::TextureHandle thandle) { + + Texture *texture = (Texture *)thandle; CompiledGeometry *c = new CompiledGeometry; - c->_geom = make_geom(vertices, num_vertices, indices, num_indices, GeomEnums::UH_static); + LVecBase2 tex_scale(1, 1); + + if (texture != (Texture *)NULL) { + rocket_cat.debug() + << "Compiling geom " << c->_geom << " with texture '" + << texture->get_name() << "'\n"; + + tex_scale = texture->get_tex_scale(); - if ((Texture*) texture != (Texture*) NULL) { PT(TextureStage) stage = new TextureStage(""); stage->set_mode(TextureStage::M_modulate); CPT(TextureAttrib) attr = DCAST(TextureAttrib, TextureAttrib::make()); - attr = DCAST(TextureAttrib, attr->add_on_stage(stage, (Texture*) texture)); + attr = DCAST(TextureAttrib, attr->add_on_stage(stage, (Texture *)texture)); c->_state = RenderState::make(attr); - rocket_cat.debug() - << "Compiled geom " << c->_geom << " with texture '" - << ((Texture*) texture)->get_name() << "'\n"; } else { - c->_state = RenderState::make_empty(); - rocket_cat.debug() - << "Compiled geom " << c->_geom << " without texture\n"; + << "Compiling geom " << c->_geom << " without texture\n"; + + c->_state = RenderState::make_empty(); } + c->_geom = make_geom(vertices, num_vertices, indices, num_indices, + GeomEnums::UH_static, tex_scale); + return (Rocket::Core::CompiledGeometryHandle) c; } @@ -222,7 +248,16 @@ LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source) { - PT(Texture) tex = TexturePool::load_texture(Filename::from_os_specific(source.CString())); + // Prefer padding over scaling to avoid blurring people's pixel art. + LoaderOptions options; + if (Texture::get_textures_power_2() == ATS_none) { + options.set_auto_texture_scale(ATS_none); + } else { + options.set_auto_texture_scale(ATS_pad); + } + + Filename fn = Filename::from_os_specific(source.CString()); + PT(Texture) tex = TexturePool::load_texture(fn, 0, false, options); if (tex == NULL) { texture_handle = 0; texture_dimensions.x = 0; @@ -233,8 +268,20 @@ LoadTexture(Rocket::Core::TextureHandle& texture_handle, tex->set_minfilter(SamplerState::FT_nearest); tex->set_magfilter(SamplerState::FT_nearest); - texture_dimensions.x = tex->get_x_size(); - texture_dimensions.y = tex->get_y_size(); + // Since libRocket may make layout decisions based on the size of + // the image, it's important that we give it the original size of + // the image file in order to produce consistent results. + int width = tex->get_orig_file_x_size(); + int height = tex->get_orig_file_y_size(); + if (width == 0 && height == 0) { + // This shouldn't happen unless someone is playing very strange + // tricks with the TexturePool, but we might as well handle it. + width = tex->get_x_size(); + height = tex->get_y_size(); + } + texture_dimensions.x = width; + texture_dimensions.y = height; + tex->ref(); texture_handle = (Rocket::Core::TextureHandle) tex.p(); @@ -255,18 +302,26 @@ GenerateTexture(Rocket::Core::TextureHandle& texture_handle, PT(Texture) tex = new Texture; tex->setup_2d_texture(source_dimensions.x, source_dimensions.y, Texture::T_unsigned_byte, Texture::F_rgba); + + // Pad to nearest power of two if necessary. It may not be necessary + // as libRocket seems to give power-of-two sizes already, but can't hurt. + tex->set_size_padded(source_dimensions.x, source_dimensions.y); + PTA_uchar image = tex->modify_ram_image(); // Convert RGBA to BGRA - size_t row_size = source_dimensions.x * 4; - size_t y2 = image.size(); - for (size_t y = 0; y < image.size(); y += row_size) { - y2 -= row_size; - for (size_t i = 0; i < row_size; i += 4) { - image[y2 + i + 0] = source[y + i + 2]; - image[y2 + i + 1] = source[y + i + 1]; - image[y2 + i + 2] = source[y + i]; - image[y2 + i + 3] = source[y + i + 3]; + size_t src_stride = source_dimensions.x * 4; + size_t dst_stride = tex->get_x_size() * 4; + const unsigned char *src_ptr = source + (src_stride * source_dimensions.y); + unsigned char *dst_ptr = &image[0]; + + for (; src_ptr > source; dst_ptr += dst_stride) { + src_ptr -= src_stride; + for (size_t i = 0; i < src_stride; i += 4) { + dst_ptr[i + 0] = src_ptr[i + 2]; + dst_ptr[i + 1] = src_ptr[i + 1]; + dst_ptr[i + 2] = src_ptr[i]; + dst_ptr[i + 3] = src_ptr[i + 3]; } } @@ -289,9 +344,9 @@ GenerateTexture(Rocket::Core::TextureHandle& texture_handle, //////////////////////////////////////////////////////////////////// void RocketRenderInterface:: ReleaseTexture(Rocket::Core::TextureHandle texture_handle) { - Texture* tex = (Texture*) texture_handle; - if (tex != (Texture*) NULL) { - tex->unref(); + Texture *tex = (Texture *)texture_handle; + if (tex != (Texture *)NULL) { + unref_delete(tex); } } diff --git a/panda/src/rocket/rocketRenderInterface.h b/panda/src/rocket/rocketRenderInterface.h index bc1e64647e..fac486831e 100644 --- a/panda/src/rocket/rocketRenderInterface.h +++ b/panda/src/rocket/rocketRenderInterface.h @@ -39,7 +39,9 @@ protected: CPT(RenderState) _state; }; - PT(Geom) make_geom(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, GeomEnums::UsageHint uh); + PT(Geom) make_geom(Rocket::Core::Vertex* vertices, + int num_vertices, int* indices, int num_indices, + GeomEnums::UsageHint uh, const LVecBase2 &tex_scale); void render_geom(const Geom* geom, const RenderState* state, const Rocket::Core::Vector2f& translation); void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation); @@ -70,6 +72,7 @@ private: CPT(TransformState) _net_transform; CPT(RenderState) _net_state; Rocket::Core::Vector2i _dimensions; + }; #endif diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index 5d5b9ba113..e92df5d220 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -26,6 +26,7 @@ #include "virtualFileSystem.h" #include "panda_getopt.h" #include "preprocess_argv.h" +#include "graphicsPipeSelection.h" // By including checkPandaVersion.h, we guarantee that runtime // attempts to run pview will fail if it inadvertently links with the @@ -209,6 +210,15 @@ help() { " Delete the model files after loading them (presumably this option\n" " will only be used when loading a temporary model file).\n\n" + " -L\n" + " Enable lighting in the scene. This can also be achieved with\n" + " the 'l' hotkey at runtime.\n\n" + + " -P \n" + " Select the given graphics pipe for the window, rather than using\n" + " the platform default. The allowed values for are those\n" + " from the Config.prc variables 'load-display' and 'aux-display'.\n\n" + " -V\n" " Report the current version of Panda, and exit.\n\n" @@ -241,10 +251,12 @@ main(int argc, char **argv) { PartGroup::HMF_ok_anim_extra; Filename screenshotfn; bool delete_models = false; + bool apply_lighting = false; + PointerTo pipe = NULL; extern char *optarg; extern int optind; - static const char *optflags = "acls:DVhi"; + static const char *optflags = "acls:DVhiLP:"; int flag = getopt(argc, argv, optflags); while (flag != EOF) { @@ -275,6 +287,19 @@ main(int argc, char **argv) { delete_models = true; break; + case 'L': + apply_lighting = true; + break; + + case 'P': { + pipe = GraphicsPipeSelection::get_global_ptr()->make_module_pipe(optarg); + if (!pipe) { + cerr << "No such pipe '" << optarg << "' available." << endl; + return 1; + } + break; + } + case 'V': report_version(); return 1; @@ -296,7 +321,7 @@ main(int argc, char **argv) { argc -= (optind - 1); argv += (optind - 1); - WindowFramework *window = framework.open_window(); + WindowFramework *window = framework.open_window(pipe, NULL); if (window != (WindowFramework *)NULL) { // We've successfully opened a window. @@ -348,6 +373,10 @@ main(int argc, char **argv) { loading_np.remove_node(); + if (apply_lighting) { + window->set_lighting(true); + } + if (auto_center) { window->center_trackball(framework.get_models()); } diff --git a/panda/src/tform/Sources.pp b/panda/src/tform/Sources.pp index d57c054cc2..42894003fa 100644 --- a/panda/src/tform/Sources.pp +++ b/panda/src/tform/Sources.pp @@ -31,7 +31,7 @@ mouseWatcher.cxx \ mouseWatcherBase.cxx \ mouseWatcherGroup.cxx \ - mouseWatcherParameter.cxx + mouseWatcherParameter.cxx \ mouseWatcherRegion.cxx \ trackball.cxx \ transform2sg.cxx diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 3d8a0a0316..e477deae9c 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -2708,6 +2708,10 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { int t_bits = get_tex_shift(y_size); if (s_bits < 0 || t_bits < 0) { + tinydisplay_cat.error() + << "Texture size " << x_size << 'x' << y_size + << " unsupported: dimensions must be power of two" + << " and smaller than " << _max_texture_dimension << '\n'; return false; } diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 5195b8ac5d..46a3e03882 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -104,6 +104,7 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _awaiting_configure = false; _dga_mouse_enabled = false; + _override_redirect = False; _wm_delete_window = x11_pipe->_wm_delete_window; GraphicsWindowInputDevice device = @@ -946,9 +947,10 @@ open_window() { wa.border_pixel = 0; wa.colormap = _colormap; wa.event_mask = _event_mask; + wa.override_redirect = _override_redirect; unsigned long attrib_mask = - CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; _xwindow = XCreateWindow (_display, parent_window, @@ -1180,7 +1182,7 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { nassertv(next_set_data < max_set_data); // Add the process ID as a convenience for other applications. - Cardinal pid = getpid(); + PN_int32 pid = getpid(); XChangeProperty(_display, _xwindow, x11_pipe->_net_wm_pid, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); @@ -2146,7 +2148,6 @@ get_cursor(const Filename &filename) { } fi = _cursor_filenames.find(resolved); if (fi != _cursor_filenames.end()) { - _cursor_filenames[filename] = (*fi).second; return fi->second; } diff --git a/panda/src/x11display/x11GraphicsWindow.h b/panda/src/x11display/x11GraphicsWindow.h index 9fc7210f60..8f59a9534d 100644 --- a/panda/src/x11display/x11GraphicsWindow.h +++ b/panda/src/x11display/x11GraphicsWindow.h @@ -99,6 +99,7 @@ protected: long _event_mask; bool _awaiting_configure; bool _dga_mouse_enabled; + Bool _override_redirect; Atom _wm_delete_window; struct MouseDeviceInfo { diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index 2dcd3f36e8..7b87b574cb 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -25,7 +25,6 @@ #include "materialAttrib.h" #include "textureAttrib.h" #include "cullFaceAttrib.h" -#include "lightNode.h" #include "ambientLight.h" #include "directionalLight.h" #include "spotlight.h" @@ -36,7 +35,7 @@ #include "pandaIOSystem.h" #include "pandaLogger.h" -#include "aiPostProcess.h" +#include "assimp/postprocess.h" //////////////////////////////////////////////////////////////////// // Function: AssimpLoader::Constructor @@ -570,12 +569,13 @@ load_light(const aiLight &light) { aiColor3D col; aiVector3D vec; - PT(LightNode) lnode; - switch (light.mType) { case aiLightSource_DIRECTIONAL: { PT(DirectionalLight) dlight = new DirectionalLight(name); - lnode = DCAST(LightNode, dlight); + _root->add_child(dlight); + + col = light.mColorDiffuse; + dlight->set_color(LColor(col.r, col.g, col.b, 1)); col = light.mColorSpecular; dlight->set_specular_color(LColor(col.r, col.g, col.b, 1)); @@ -589,7 +589,10 @@ load_light(const aiLight &light) { case aiLightSource_POINT: { PT(PointLight) plight = new PointLight(name); - lnode = DCAST(LightNode, plight); + _root->add_child(plight); + + col = light.mColorDiffuse; + plight->set_color(LColor(col.r, col.g, col.b, 1)); col = light.mColorSpecular; plight->set_specular_color(LColor(col.r, col.g, col.b, 1)); @@ -604,7 +607,10 @@ load_light(const aiLight &light) { case aiLightSource_SPOT: { PT(Spotlight) plight = new Spotlight(name); - lnode = DCAST(LightNode, plight); + _root->add_child(plight); + + col = light.mColorDiffuse; + plight->set_color(LColor(col.r, col.g, col.b, 1)); col = light.mColorSpecular; plight->set_specular_color(LColor(col.r, col.g, col.b, 1)); @@ -624,21 +630,23 @@ load_light(const aiLight &light) { plight->set_transform(TransformState::make_pos_quat_scale(pos, quat, LVecBase3(1, 1, 1))); break; } + // This is a somewhat recent addition to Assimp, so let's be kind to + // those that don't have an up-to-date version of Assimp. + case 0x4: //aiLightSource_AMBIENT: + // This is handled below. + break; + default: assimp_cat.warning() << "Light '" << name << "' has an unknown type!\n"; return; } // If there's an ambient color, add it as ambient light. + col = light.mColorAmbient; LVecBase4 ambient (col.r, col.g, col.b, 0); if (ambient != LVecBase4::zero()) { PT(AmbientLight) alight = new AmbientLight(name); - col = light.mColorAmbient; alight->set_color(ambient); _root->add_child(alight); } - - _root->add_child(lnode); - col = light.mColorDiffuse; - lnode->set_color(LColor(col.r, col.g, col.b, 1)); } diff --git a/pandatool/src/assimp/assimpLoader.h b/pandatool/src/assimp/assimpLoader.h index 54597f9228..3c8391b324 100644 --- a/pandatool/src/assimp/assimpLoader.h +++ b/pandatool/src/assimp/assimpLoader.h @@ -20,7 +20,8 @@ #include "modelRoot.h" #include "texture.h" -#include "aiScene.h" +#include "assimp/scene.h" +#include "assimp/Importer.hpp" //////////////////////////////////////////////////////////////////// // Class : AssimpLoader diff --git a/pandatool/src/assimp/config_assimp.h b/pandatool/src/assimp/config_assimp.h index 43cd1ef87e..4c2da9d449 100644 --- a/pandatool/src/assimp/config_assimp.h +++ b/pandatool/src/assimp/config_assimp.h @@ -17,8 +17,6 @@ #include "pandatoolbase.h" -#include "assimp.hpp" - #include "dconfig.h" ConfigureDecl(config_assimp, EXPCL_ASSIMP, EXPTP_ASSIMP); diff --git a/pandatool/src/assimp/p3assimp_composite1.cxx b/pandatool/src/assimp/p3assimp_composite1.cxx new file mode 100644 index 0000000000..bc813b11ec --- /dev/null +++ b/pandatool/src/assimp/p3assimp_composite1.cxx @@ -0,0 +1,7 @@ + +#include "config_assimp.cxx" +#include "assimpLoader.cxx" +#include "loaderFileTypeAssimp.cxx" +#include "pandaIOStream.cxx" +#include "pandaIOSystem.cxx" +#include "pandaLogger.cxx" diff --git a/pandatool/src/assimp/pandaIOStream.cxx b/pandatool/src/assimp/pandaIOStream.cxx index 4dc634f319..647af59ccc 100644 --- a/pandatool/src/assimp/pandaIOStream.cxx +++ b/pandatool/src/assimp/pandaIOStream.cxx @@ -78,6 +78,11 @@ Seek(size_t offset, aiOrigin origin) { case aiOrigin_END: _istream.seekg(offset, ios::end); break; + + default: + // Keep compiler happy + nassertr(false, AI_FAILURE); + break; } if (_istream.good()) { @@ -105,4 +110,5 @@ Tell() const { size_t PandaIOStream:: Write(const void *buffer, size_t size, size_t count) { nassertr(false, 0); + return 0; } diff --git a/pandatool/src/assimp/pandaIOStream.h b/pandatool/src/assimp/pandaIOStream.h index be9b2d0548..c89f4a15bf 100644 --- a/pandatool/src/assimp/pandaIOStream.h +++ b/pandatool/src/assimp/pandaIOStream.h @@ -17,7 +17,7 @@ #include "config_assimp.h" -#include "IOStream.h" +#include "assimp/IOStream.hpp" class PandaIOSystem; diff --git a/pandatool/src/assimp/pandaIOSystem.cxx b/pandatool/src/assimp/pandaIOSystem.cxx index c28584ede5..abaadc76c8 100644 --- a/pandatool/src/assimp/pandaIOSystem.cxx +++ b/pandatool/src/assimp/pandaIOSystem.cxx @@ -95,5 +95,6 @@ Open(const char *file, const char *mode) { } else { nassertr(false, NULL); // Not implemented on purpose. + return NULL; } } diff --git a/pandatool/src/assimp/pandaIOSystem.h b/pandatool/src/assimp/pandaIOSystem.h index 04b2c1edaa..b86c1695a1 100644 --- a/pandatool/src/assimp/pandaIOSystem.h +++ b/pandatool/src/assimp/pandaIOSystem.h @@ -18,7 +18,7 @@ #include "config_assimp.h" #include "virtualFileSystem.h" -#include "IOSystem.h" +#include "assimp/IOSystem.hpp" //////////////////////////////////////////////////////////////////// // Class : PandaIOSystem diff --git a/pandatool/src/assimp/pandaLogger.cxx b/pandatool/src/assimp/pandaLogger.cxx index 138dae43b5..20de4497b7 100644 --- a/pandatool/src/assimp/pandaLogger.cxx +++ b/pandatool/src/assimp/pandaLogger.cxx @@ -14,7 +14,7 @@ #include "pandaLogger.h" -#include "DefaultLogger.h" +#include "assimp/DefaultLogger.hpp" PandaLogger *PandaLogger::_ptr = NULL; diff --git a/pandatool/src/assimp/pandaLogger.h b/pandatool/src/assimp/pandaLogger.h index 5930ef1248..7791153b8c 100644 --- a/pandatool/src/assimp/pandaLogger.h +++ b/pandatool/src/assimp/pandaLogger.h @@ -17,7 +17,7 @@ #include "config_assimp.h" -#include "Logger.h" +#include "assimp/Logger.hpp" //////////////////////////////////////////////////////////////////// // Class : PandaLogger @@ -30,7 +30,7 @@ public: protected: INLINE bool attachStream(Assimp::LogStream*, unsigned int) {}; - INLINE bool detatchStream(Assimp::LogStream*, unsigned int) {}; + INLINE bool detatchStream(Assimp::LogStream*, unsigned int) {}; // sic void OnDebug(const char *message); void OnError(const char *message); diff --git a/pandatool/src/imageprogs/imageFixHiddenColor.cxx b/pandatool/src/imageprogs/imageFixHiddenColor.cxx index 682cc8dd1b..bd291e9e57 100644 --- a/pandatool/src/imageprogs/imageFixHiddenColor.cxx +++ b/pandatool/src/imageprogs/imageFixHiddenColor.cxx @@ -111,7 +111,7 @@ run() { // First, get the average color of all the opaque pixels. int count = 0; - LRGBColord color(0.0, 0.0, 0.0); + LRGBColor color(0.0, 0.0, 0.0); int xi, yi; for (yi = 0; yi < _image.get_y_size(); ++yi) { for (xi = 0; xi < _image.get_x_size(); ++xi) { @@ -127,7 +127,7 @@ run() { } color /= (double)count; nout << " average color of " << count << " opaque pixels is " << color << "\n"; - + // Now, apply that wherever there are transparent pixels. count = 0; for (yi = 0; yi < _image.get_y_size(); ++yi) { @@ -143,7 +143,7 @@ run() { exit(1); } nout << " applied to " << count << " transparent pixels.\n"; - + write_image(_image); } diff --git a/pandatool/src/imageprogs/imageTransformColors.cxx b/pandatool/src/imageprogs/imageTransformColors.cxx index 118ef0f5c1..6ff358b9a6 100644 --- a/pandatool/src/imageprogs/imageTransformColors.cxx +++ b/pandatool/src/imageprogs/imageTransformColors.cxx @@ -477,19 +477,19 @@ process_image(PNMImage &image) { if (_hls) { for (int yi = 0; yi < image.get_y_size(); ++yi) { for (int xi = 0; xi < image.get_x_size(); ++xi) { - LRGBColord rgb = image.get_xel(xi, yi); + LRGBColord rgb = LCAST(double, image.get_xel(xi, yi)); rgb = hls2rgb(_mat.xform_point(rgb2hls(rgb))); - image.set_xel(xi, yi, rgb); + image.set_xel(xi, yi, LCAST(float, rgb)); } - } - } else { + } + } else { for (int yi = 0; yi < image.get_y_size(); ++yi) { for (int xi = 0; xi < image.get_x_size(); ++xi) { - LRGBColord rgb = image.get_xel(xi, yi); + LRGBColord rgb = LCAST(double, image.get_xel(xi, yi)); rgb = _mat.xform_point(rgb); - image.set_xel(xi, yi, rgb); + image.set_xel(xi, yi, LCAST(float, rgb)); } - } + } } } diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index a7eba240b2..dfeb68fc5c 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -101,6 +101,7 @@ struct MayaVerInfo maya_versions[] = { { "MAYA20135", "2013.5"}, { "MAYA2014", "2014"}, { "MAYA2015", "2015"}, + { "MAYA2016", "2016"}, { 0, 0 }, }; diff --git a/pandatool/src/pandatoolbase/pandatoolsymbols.h b/pandatool/src/pandatoolbase/pandatoolsymbols.h index 43863d54e9..431d72f7f8 100644 --- a/pandatool/src/pandatoolbase/pandatoolsymbols.h +++ b/pandatool/src/pandatoolbase/pandatoolsymbols.h @@ -17,32 +17,20 @@ /* See dtoolsymbols.h for a rant on the purpose of this file. */ -#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) - #ifdef BUILDING_ASSIMP - #define EXPCL_ASSIMP __declspec(dllexport) - #define EXPTP_ASSIMP + #define EXPCL_ASSIMP EXPORT_CLASS + #define EXPTP_ASSIMP EXPORT_TEMPL #else - #define EXPCL_ASSIMP __declspec(dllimport) - #define EXPTP_ASSIMP extern + #define EXPCL_ASSIMP IMPORT_CLASS + #define EXPTP_ASSIMP IMPORT_TEMPL #endif #ifdef BUILDING_PTLOADER - #define EXPCL_PTLOADER __declspec(dllexport) - #define EXPTP_PTLOADER + #define EXPCL_PTLOADER EXPORT_CLASS + #define EXPTP_PTLOADER EXPORT_TEMPL #else - #define EXPCL_PTLOADER __declspec(dllimport) - #define EXPTP_PTLOADER extern + #define EXPCL_PTLOADER IMPORT_CLASS + #define EXPTP_PTLOADER IMPORT_TEMPL #endif -#else /* !WIN32_VC */ - -#define EXPCL_ASSIMP -#define EXPTP_ASSIMP - -#define EXPCL_PTLOADER -#define EXPTP_PTLOADER - -#endif /* WIN32_VC */ - #endif